|
|
@@ -523,6 +523,7 @@ export class SessionManager {
|
|
|
this.recordMutation({ kind: 'upsert', summary: {
|
|
|
sessionId: result.value.sessionId, updatedAt: Date.now(), running: false, blank: true,
|
|
|
...(opts.cwd !== undefined ? { cwd: opts.cwd } : {}),
|
|
|
+ ...(result.value.agentPreset !== undefined ? { agentPreset: result.value.agentPreset } : {}),
|
|
|
} })
|
|
|
} else {
|
|
|
const publishedSessionId = workspaceAttachSessionId(result.error)
|
|
|
@@ -588,6 +589,17 @@ export class SessionManager {
|
|
|
this.recordMutation({ kind: 'upsert', summary })
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Record a host-confirmed composition switch (see ISessions.noteAgentPreset).
|
|
|
+ * @param sessionId - the switched session.
|
|
|
+ * @param agentPreset - the preset id the host confirmed.
|
|
|
+ */
|
|
|
+ noteAgentPreset(sessionId: SessionId, agentPreset: string): void {
|
|
|
+ this.recordMutation({ kind: 'upsert', summary: {
|
|
|
+ sessionId, updatedAt: Date.now(), running: false, blank: true, agentPreset,
|
|
|
+ } })
|
|
|
+ }
|
|
|
+
|
|
|
/** Apply immediately and retain for replay when a list response is in flight. */
|
|
|
private recordMutation(mutation: SessionListMutation): void {
|
|
|
this.listMutations?.push(mutation)
|
|
|
@@ -743,6 +755,7 @@ export class SessionManager {
|
|
|
...(frame.parentSessionId !== undefined ? { parentSessionId: frame.parentSessionId } : {}),
|
|
|
...(frame.origin !== undefined ? { origin: frame.origin } : {}),
|
|
|
...(frame.cwd !== undefined ? { cwd: frame.cwd } : {}),
|
|
|
+ ...(frame.agentPreset !== undefined ? { agentPreset: frame.agentPreset } : {}),
|
|
|
})
|
|
|
this.sessions.get(frame.sessionId)?.handleBlank(frame.blank)
|
|
|
if (frame.origin === 'subagent' && frame.parentSessionId !== undefined) {
|
|
|
@@ -1027,9 +1040,15 @@ function applyMutation(summaries: readonly SessionSummary[], mutation: SessionLi
|
|
|
? { parentSessionId: mutation.summary.parentSessionId } : {}),
|
|
|
...(existing.origin === undefined && mutation.summary.origin !== undefined
|
|
|
? { origin: mutation.summary.origin } : {}),
|
|
|
+ // Newest wins, not fill-only: a blank-session preset switch replaces
|
|
|
+ // the creation-time value, and every producer of this field (the
|
|
|
+ // create echo, the select echo, a list row) reports the CURRENT one.
|
|
|
+ ...(mutation.summary.agentPreset !== undefined
|
|
|
+ ? { agentPreset: mutation.summary.agentPreset } : {}),
|
|
|
}
|
|
|
if (filled.cwd === existing.cwd && filled.parentSessionId === existing.parentSessionId
|
|
|
- && filled.origin === existing.origin && filled.blank === existing.blank) return [...summaries]
|
|
|
+ && filled.origin === existing.origin && filled.blank === existing.blank
|
|
|
+ && filled.agentPreset === existing.agentPreset) return [...summaries]
|
|
|
return summaries.map(summary => summary.sessionId === mutation.summary.sessionId ? filled : summary)
|
|
|
}
|
|
|
case 'remove':
|