Implement DataModel name change removal in PatchSet and adjust session handling in App

- Added a new function to PatchSet to remove the DataModel name change from updates, preventing unwanted synchronization of the project name.
- Updated the App:startSession method to conditionally skip session lock acquisition and release based on one-shot mode settings.
- Enhanced the confirmation callback to utilize the new PatchSet function for filtering DataModel name changes from patches.
This commit is contained in:
Joe 2026-01-30 11:26:40 -06:00
parent 240c225be0
commit 77088eccd8
3 changed files with 62 additions and 42 deletions

View file

@ -571,22 +571,25 @@ function App:useRunningConnectionInfo()
end
function App:startSession()
local claimedLock, priorOwner = self:claimSyncLock()
if not claimedLock then
local msg = string.format("Could not sync because user '%s' is already syncing", tostring(priorOwner))
-- Skip session lock in one-shot mode since it's a quick sync-and-disconnect
if not Settings:get("oneShotSync") then
local claimedLock, priorOwner = self:claimSyncLock()
if not claimedLock then
local msg = string.format("Could not sync because user '%s' is already syncing", tostring(priorOwner))
Log.warn(msg)
self:addNotification({
text = msg,
timeout = 10,
})
self:setState({
appStatus = AppStatus.Error,
errorMessage = msg,
toolbarIcon = Assets.Images.PluginButtonWarning,
})
Log.warn(msg)
self:addNotification({
text = msg,
timeout = 10,
})
self:setState({
appStatus = AppStatus.Error,
errorMessage = msg,
toolbarIcon = Assets.Images.PluginButtonWarning,
})
return
return
end
end
local host, port = self:getHostAndPort()
@ -671,7 +674,10 @@ function App:startSession()
})
elseif status == ServeSession.Status.Disconnected then
self.serveSession = nil
self:releaseSyncLock()
-- Only release lock if we claimed it (not in one-shot mode)
if not Settings:get("oneShotSync") then
self:releaseSyncLock()
end
self:clearRunningConnectionInfo()
self:setState({
patchData = {
@ -709,6 +715,10 @@ function App:startSession()
end)
serveSession:setConfirmCallback(function(instanceMap, patch, serverInfo)
-- Filter out the DataModel name change from the patch
-- The project name (DataModel.Name) is managed by Studio independently
PatchSet.removeDataModelName(patch, instanceMap)
local isOneShotMode = Settings:get("oneShotSync")
-- ONE-SHOT MODE: Never auto-accept, always require explicit confirmation
@ -759,24 +769,6 @@ function App:startSession()
return "Accept"
end
end
-- The datamodel name gets overwritten by Studio, making confirmation of it intrusive
-- and unnecessary. This special case allows it to be accepted without confirmation.
if
PatchSet.hasAdditions(patch) == false
and PatchSet.hasRemoves(patch) == false
and PatchSet.containsOnlyInstance(patch, instanceMap, game)
then
local datamodelUpdates = PatchSet.getUpdateForInstance(patch, instanceMap, game)
if
datamodelUpdates ~= nil
and next(datamodelUpdates.changedProperties) == nil
and datamodelUpdates.changedClassName == nil
then
Log.trace("Accepting patch without confirmation because it only contains a datamodel name change")
return "Accept"
end
end
else
Log.info("One-shot mode: skipping all auto-accept paths, requiring explicit confirmation")
end