fix(apiproxy): echo the resolved agent preset on create and session-added

session.create's reply named only the id, and the session-added frame's
agentPreset — which the server already derives via sessionListFields — was
stripped by the wire schema it never joined. A client therefore could not
label a session it just created (or learned live) until the next full list
refresh: the header's preset label rendered nothing for exactly the sessions
made in this tab. The create reply is the commit point that knows the
RESOLVED composition (a caller that named none gets the default the header
recorded), so both carriers now say it.
This commit is contained in:
Yichen Jiang
2026-08-08 20:16:50 +08:00
parent 46649858f6
commit 132debb5fe
5 changed files with 11 additions and 2 deletions
@@ -73,6 +73,7 @@ export const hostFrameSchema = z.discriminatedUnion('type', [
parentSessionId: sessionIdSchema.optional(),
origin: z.literal('subagent').optional(),
cwd: z.string().optional(),
agentPreset: z.string().optional(),
}),
z.object({ type: z.literal('host/session-removed'), sessionId: sessionIdSchema }),
z.object({ type: z.literal('host/session-status'), sessionId: sessionIdSchema, running: z.boolean() }),
+1
View File
@@ -116,6 +116,7 @@ export type HostFrame =
parentSessionId?: SessionId
origin?: 'subagent'
cwd?: string
agentPreset?: string
}
| { type: 'host/session-removed'; sessionId: SessionId }
| { type: 'host/session-status'; sessionId: SessionId; running: boolean }
@@ -109,6 +109,7 @@ export const sessionCreateRequestSchema = z.object({
/** session.create response value. */
export const sessionCreateValueSchema = z.object({
sessionId: sessionIdSchema,
agentPreset: z.string().optional(),
}) satisfies z.ZodType<Wire<ResponseValue<'session.create'>>>
/** session.rename request payload (raw title; host-side normalization decides acceptance). */
+1 -1
View File
@@ -217,7 +217,7 @@ export interface SessionsApi {
* cannot be mounted fails with `agent-preset-invalid`.
*/
create(request: RpcRequest<{ workspaceId?: WorkspaceId; cwd?: string; sessionId?: SessionId; agentPreset?: string }>):
Promise<RpcResponse<{ sessionId: SessionId }>>
Promise<RpcResponse<{ sessionId: SessionId; agentPreset?: string }>>
/**
* Reads a window of history events; page boundaries align to append-origin message