-
-
Notifications
You must be signed in to change notification settings - Fork 80.3k
Emit sessions.changed for store-mutating in-chat commands (/name, /goal) #88598
Copy link
Copy link
Closed
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.ClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Description
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.ClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Type
Fields
No fields configured for issues without a type.
Summary
Store-mutating in-chat slash commands that change session metadata do not broadcast a
sessions.changedevent. As a result, already-open session lists (web session picker, TUI, SDK subscribers) stay stale until the next reload/refresh.This was surfaced by the Codex review on #88581 (the new
/namecommand, P2). It is not specific to/name— the peer command/goalbehaves identically. Both write the session store directly through the auto-reply command pipeline, which has no gateway broadcast context.Current behavior
/name <topic>(and/goal …) updateSessionEntryfields in the store and persist them correctly.sessions.changedevent is emitted for command-driven metadata changes.sessions.patchRPC (used by the web admin/session-picker inline rename) does emitsessions.changedviaemitSessionsChanged.Why it isn't a one-line fix
There is currently no single call site that has both the command reply result and the gateway broadcast context:
getReplyFromConfig) runs deep in the auto-reply / infra layer. Its caller (src/infra/heartbeat-runner.ts, web wrappersrc/library.ts) has nobroadcastToConnIds/ session-subscriber registry in scope.broadcastToConnIds+ session-event subscribers) lives insrc/gateway/server-chat.tsclosures (the lifecyclesessions.changedbroadcasts around lines ~526 and ~1199), but those closures do not invoke the reply pipeline.emitSessionsChangedinsrc/gateway/server-methods/sessions.ts(~line 316) is module-private.Proposed approach (for discussion)
Thread a "session metadata changed" signal from the command handler up to a place that has broadcast context, then emit
sessions.changedfor all store-mutating commands uniformly:ReplyPayloadwith a metadata marker (e.g. a new optional field onReplyPayloadMetadata, set viasetReplyPayloadMetadata, carrying{ sessionKey, reason: "command-metadata" }).getReplyFromConfig's return to a caller that holds gateway broadcast context.getReplyPayloadMetadata(reply)and call a (newly exported/shared)emitSessionsChanged-equivalent.This is a cross-layer gateway change with non-trivial blast radius on core event semantics, so it deserves a dedicated design rather than being folded into the small
/namecommand PR (#88581).Acceptance criteria
/nameand/goal(and any future store-mutating chat command) emitsessions.changedso open web/TUI/SDK session lists update live, without reload.sessions.patchshape (includessessionKey+ updated row incl.label).src/gateway/server.sessions.list-changed.test.ts).docs/tools/slash-commands.mdupdated to state live refresh once implemented (currently documents refresh-on-reload).References
/namecommand) — documents the current refresh-on-reload limitation.commands-name.ts, nosessions.changedemit).src/gateway/server-methods/sessions.tsemitSessionsChanged;src/auto-reply/reply-payload.tsmetadata helpers.