fix(frontend): status快照模式字段按对话来源隔离,修复跨terminal广播污染
status_update 是用户级房间广播,工作区级/其他对话/其他标签页的 terminal 触发时都会携带各自的模式值;applyStatusSnapshot 此前对 work_mode/ permission_mode/execution_mode/network_permission 无条件覆盖,plan 锁对话的 UI 会被其他 terminal 的广播误解锁,用户点击切换被后端 plan 锁拒绝(500)。 现仅当快照 conversation.current_id 与当前查看对话匹配(含双空:/new 页面 ↔ 工作区级 terminal)时才应用模式字段;对话权威值仍由进入对话时的 fetchWorkMode 等对话级 fetch 保证。
This commit is contained in:
parent
944cef0587
commit
e5a988f00f
@ -161,41 +161,52 @@ export const resourceMethods = {
|
|||||||
this.modelSet(status.model_key);
|
this.modelSet(status.model_key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (status && typeof status.permission_mode === 'string') {
|
// 运行模式四件套(work_mode/permission_mode/execution_mode/network_permission)
|
||||||
this.currentPermissionMode = status.permission_mode;
|
// 来源隔离:status_update 是用户级房间广播,工作区级 / 其他对话 / 其他标签页
|
||||||
}
|
// 的 terminal 触发时都会携带它自己的模式值;不做隔离时别的 terminal 的快照会
|
||||||
// 运行模式(work_mode):terminal 快照权威。对话加载后 load.ts 会再调
|
// 覆盖当前对话的显示(plan 锁对话的 UI 会被误解锁,点击切换又被后端 500 拒绝)。
|
||||||
// fetchWorkMode 以对话 metadata 为准修正一次,两者一致,不会跳变。
|
// 仅当快照对应当前查看的对话(含双空:/new 页面 ↔ 工作区级 terminal)才应用;
|
||||||
if (status && typeof status.work_mode === 'string') {
|
// 对话权威值由 load.ts 进入对话时的对话级 fetch(fetchWorkMode 等)保证。
|
||||||
this.currentWorkMode = status.work_mode;
|
const statusConvIdRaw = status?.conversation?.current_id;
|
||||||
}
|
const statusConvId = typeof statusConvIdRaw === 'string' ? statusConvIdRaw : '';
|
||||||
const pendingModes = status?.pending_runtime_modes || {};
|
const modeSourceMatches = hasConversation ? statusConvId === convId : !statusConvId;
|
||||||
if (typeof pendingModes.permission_mode === 'string') {
|
if (modeSourceMatches) {
|
||||||
this.pendingPermissionMode = pendingModes.permission_mode;
|
if (status && typeof status.permission_mode === 'string') {
|
||||||
} else {
|
this.currentPermissionMode = status.permission_mode;
|
||||||
this.pendingPermissionMode = '';
|
}
|
||||||
}
|
if (status && typeof status.work_mode === 'string') {
|
||||||
if (status?.execution_mode && typeof status.execution_mode === 'object') {
|
this.currentWorkMode = status.work_mode;
|
||||||
if (typeof status.execution_mode.mode === 'string') {
|
}
|
||||||
this.currentExecutionMode = status.execution_mode.mode;
|
const pendingModes = status?.pending_runtime_modes || {};
|
||||||
|
if (typeof pendingModes.permission_mode === 'string') {
|
||||||
|
this.pendingPermissionMode = pendingModes.permission_mode;
|
||||||
|
} else {
|
||||||
|
this.pendingPermissionMode = '';
|
||||||
|
}
|
||||||
|
if (status?.execution_mode && typeof status.execution_mode === 'object') {
|
||||||
|
if (typeof status.execution_mode.mode === 'string') {
|
||||||
|
this.currentExecutionMode = status.execution_mode.mode;
|
||||||
|
}
|
||||||
|
this.executionModeEnabled =
|
||||||
|
typeof status.execution_mode_enabled === 'boolean' ? status.execution_mode_enabled : true;
|
||||||
|
}
|
||||||
|
if (typeof status.network_permission === 'string') {
|
||||||
|
this.currentNetworkPermission = status.network_permission;
|
||||||
|
}
|
||||||
|
this.networkPermissionEnabled =
|
||||||
|
typeof status.network_permission_enabled === 'boolean'
|
||||||
|
? status.network_permission_enabled
|
||||||
|
: false;
|
||||||
|
if (typeof pendingModes.network_permission === 'string') {
|
||||||
|
this.pendingNetworkPermission = pendingModes.network_permission;
|
||||||
|
} else {
|
||||||
|
this.pendingNetworkPermission = '';
|
||||||
|
}
|
||||||
|
if (typeof pendingModes.execution_mode === 'string') {
|
||||||
|
this.pendingExecutionMode = pendingModes.execution_mode;
|
||||||
|
} else {
|
||||||
|
this.pendingExecutionMode = '';
|
||||||
}
|
}
|
||||||
this.executionModeEnabled =
|
|
||||||
typeof status.execution_mode_enabled === 'boolean' ? status.execution_mode_enabled : true;
|
|
||||||
}
|
|
||||||
if (typeof status.network_permission === 'string') {
|
|
||||||
this.currentNetworkPermission = status.network_permission;
|
|
||||||
}
|
|
||||||
this.networkPermissionEnabled =
|
|
||||||
typeof status.network_permission_enabled === 'boolean' ? status.network_permission_enabled : false;
|
|
||||||
if (typeof pendingModes.network_permission === 'string') {
|
|
||||||
this.pendingNetworkPermission = pendingModes.network_permission;
|
|
||||||
} else {
|
|
||||||
this.pendingNetworkPermission = '';
|
|
||||||
}
|
|
||||||
if (typeof pendingModes.execution_mode === 'string') {
|
|
||||||
this.pendingExecutionMode = pendingModes.execution_mode;
|
|
||||||
} else {
|
|
||||||
this.pendingExecutionMode = '';
|
|
||||||
}
|
}
|
||||||
// has_images/has_videos 遵循与上面模型/运行模式相同的权威规则:
|
// has_images/has_videos 遵循与上面模型/运行模式相同的权威规则:
|
||||||
// 有打开对话时才从 status 同步;空对话/显式新建路由(/new)上 status 里的值
|
// 有打开对话时才从 status 同步;空对话/显式新建路由(/new)上 status 里的值
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user