Repository navigation
Conversation
|
Codex review: needs maintainer review before merge. Reviewed June 5, 2026, 11:44 PM ET / 03:44 UTC. Summary PR surface: Source +386, Tests +891, Docs +2. Total +1279 across 31 files. Reproducibility: yes. source-level. Current main persists Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Mantis proof suggestion Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the shared command-metadata Do we have a high-confidence way to reproduce the issue? Yes, source-level. Current main persists Is this the best way to solve the issue? Yes, this appears to be the best fix shape. It threads a narrow typed metadata signal to the Gateway context that can broadcast, reuses a shared AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against 092075534e54. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +386, Tests +891, Docs +2. Total +1279 across 31 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
3623771 to
d1c02d6
Compare
d1c02d6 to
fff0305
Compare
fff0305 to
a249595
Compare
a249595 to
be2b9c2
Compare
be2b9c2 to
4b2c2f3
Compare
4b2c2f3 to
395128d
Compare
|
Cross-linking from #88581 / #88598: this shared command-metadata If this lands, #88581 should rebase onto it and use the same notification path for successful |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
b97bcf5 to
1205389
Compare
1205389 to
7145447
Compare
Constraint: Gateway subscribers depend on sessions.changed to refresh visible session rows after command-only metadata writes. Rejected: Reply-payload-only refresh | command-only turns can mutate store without a model reply, directive-only turns persist outside command handlers, mixed inline directive fast-lane writes happen before the persistence pass, and stop/abort writes target session metadata directly. Confidence: high Scope-risk: moderate Directive: Keep command metadata notifications tied to successful store writes or verified persisted goal/directive/abort changes, derive event agent scope from the changed session key, and never let command-only turns project themselves as the only active run. Tested: node scripts/docs-list.js; git diff --check origin/main; OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs src/auto-reply/reply/commands-goal.test.ts src/auto-reply/reply/directive-handling.model.test.ts src/auto-reply/reply/directive-handling.mixed-inline.test.ts src/auto-reply/reply/commands-stop-target.test.ts src/auto-reply/reply/commands-session-store.test.ts -t "metadata|mixed inline directives|directive-only handling mutates|fast-lane metadata|directive persistence mutates|passes session metadata|goal|command session metadata"; OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs src/gateway/session-message-events.test.ts src/gateway/server.sessions.list-changed.test.ts src/gateway/server.chat.gateway-server-chat.test.ts -t "broadcasts command metadata lifecycle changes|chat.send broadcasts sessions.changed when in-chat command metadata changes|sessions.changed command metadata excludes only the command run from active state" Not-tested: Full core typecheck due existing ui/src/ui/views/workboard-3d-game.ts missing three type resolution and implicit any errors; live browser Control UI with a real long-running /goal turn.
Constraint: chat.send active runs for selected global agents are tracked as agent:<id>:global.\nRejected: Passing caller-supplied hasActiveRun everywhere | duplicates session activity logic across command paths.\nConfidence: high\nScope-risk: narrow\nDirective: Keep sessions.changed active-state resolution centralized in emitSessionsChanged.\nTested: OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs src/gateway/server.sessions.list-changed.test.ts -t selected-global/command-metadata focus.\nNot-tested: Manual browser Control UI websocket session switching.
Constraint: openclaw#88598 requires in-chat command metadata to reach WebChat, Control UI, and embedded TUI consumers without waiting for a later list refresh. Rejected: relying on periodic sessions.list refresh | it leaves live chat and embedded history consumers with stale selected-session metadata. Confidence: high Scope-risk: narrow Directive: Keep session-row lifecycle events and chat event session-key aliasing aligned when adding new agent-scoped global aliases. Tested: OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs ui/src/ui/controllers/chat.test.ts src/tui/embedded-backend.test.ts src/gateway/server.sessions.list-changed.test.ts -t 'canonical global|history model catalog|live session setting metadata' (gateway shard rerun with local listen permission); OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs src/auto-reply/reply/commands-goal.test.ts src/auto-reply/reply/directive-handling.model.test.ts src/auto-reply/reply/directive-handling.mixed-inline.test.ts src/auto-reply/reply/commands-stop-target.test.ts src/auto-reply/reply/commands-session-store.test.ts -t 'metadata|mixed inline directives|directive-only handling mutates|fast-lane metadata|global-session|directive persistence mutates|passes session metadata|goal|command session metadata'; OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs src/gateway/session-message-events.test.ts src/gateway/server.sessions.list-changed.test.ts src/gateway/server.chat.gateway-server-chat.test.ts -t 'broadcasts command metadata lifecycle changes|chat.send broadcasts sessions.changed when in-chat command metadata changes|sessions.changed command metadata excludes only the command run from active state|sessions.changed command metadata marks selected global runs active|sessions.changed mutation events include live session setting metadata'; git diff --check origin/main Not-tested: full pnpm test suite and browser screenshot flow.
Constraint: upstream main removed the old session-model-catalog helper during rebase. Rejected: recreate session-model-catalog.js | duplicating the upstream optional-model-catalog helper would widen this PR. Confidence: high Scope-risk: narrow Directive: Keep future session metadata event changes aligned with the shared server-method catalog loader. Tested: env OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs ui/src/ui/controllers/chat.test.ts src/tui/embedded-backend.test.ts -t "canonical global|history model catalog"; env OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs src/auto-reply/reply/commands-goal.test.ts src/auto-reply/reply/directive-handling.model.test.ts src/auto-reply/reply/directive-handling.mixed-inline.test.ts src/auto-reply/reply/commands-stop-target.test.ts src/auto-reply/reply/commands-session-store.test.ts -t "metadata|mixed inline directives|directive-only handling mutates|fast-lane metadata|global-session|directive persistence mutates|passes session metadata|goal|command session metadata"; env OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs src/gateway/session-message-events.test.ts src/gateway/server.sessions.list-changed.test.ts src/gateway/server.chat.gateway-server-chat.test.ts -t "broadcasts command metadata lifecycle changes|chat.send broadcasts sessions.changed when in-chat command metadata changes|sessions.changed command metadata excludes only the command run from active state|sessions.changed command metadata marks selected global runs active|sessions.changed mutation events include live session setting metadata" Not-tested: full pnpm test suite
Constraint: Keep openclaw#88690 focused on Control UI/WebChat session update metadata and accepted review feedback. Rejected: Broadcasting command metadata for hidden/internal runs | it reintroduces stale Control UI running indicators. Confidence: high Scope-risk: moderate Directive: Treat literal global metadata as default-agent scoped unless the event carries an explicit agent id. Tested: git diff --check origin/main...HEAD; focused gateway sessions.changed command metadata Vitest; codex review --base origin/main. Not-tested: Broader auto-reply rerun stalled under the local no-output guard; full gateway suite not run.
Constraint: openclaw#88690 CI rejected an unsafe catch callback and a TUI mock spread with non-tuple args. Rejected: broad refactor of chat command refresh plumbing | existing branch already has behavior tests and only CI hygiene failed. Confidence: high Scope-risk: narrow Directive: Keep future CI-only followups restricted to failing lint/type surfaces unless behavior evidence changes. Tested: git diff --check origin/main...HEAD; ./node_modules/.bin/oxlint src/gateway/server-methods/chat.ts src/tui/embedded-backend.test.ts; CI=1 NODE_OPTIONS=--max-old-space-size=4096 node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core-test.tsbuildinfo; node scripts/run-vitest.mjs src/tui/embedded-backend.test.ts src/gateway/server.sessions.list-changed.test.ts src/gateway/server.chat.gateway-server-chat.test.ts; codex review --base origin/main. Not-tested: node scripts/run-oxlint-shards.mjs --threads=8 because this local checkout lacks the tsgolint executable required by the shard wrapper.
7145447 to
677e3d3
Compare
|
Closing this — superseded by That change already covers the core of this PR: a shared command-metadata seam ( For anyone following the cross-link from #88581 / #88598 (cc @BSG2000): the canonical seam to build on is now Thanks @vincentkoc — closing in favor of the merged version. |
Fixes #88598
User-facing bug
Control UI clients subscribed to session updates could miss metadata changes made by in-chat commands. A command-only turn such as
/goal complete,/goal pause, or/goal clearcan update the session store without starting a model run, but the Gateway did not emit asessions.changedevent for that mutation. The visible session row could keep stale goal/status metadata until a manual reload or another unrelated session event.Exact repro
Source-level reproduction:
sessions.changed./goalcommand that mutates the persisted session goal, for example/goal complete shipped.sessions.changedevent was broadcast for the store write, so subscribed clients did not get a scoped refresh for that session.Fix summary
onSessionMetadataChangedreply option for command handlers.persistSessionEntryhelper./goalstart, pause, resume, complete, blocked, clear, and status paths when they actually change the persisted goal metadata.sessions.changedemitter between session RPC handlers andchat.send, so command-only chat turns can broadcast a scoped session row update.hasActiveRun: trueif another run for the same session is active.chat.send, so raw channel dispatchers that use the same command-session store helper also refresh Gateway subscribers.globalupdates still refresh a selectedagent:<id>:globalControl UI/WebChat session, and normalize command lifecycle metadata fromagent:<id>:globalback tosessionKey: "global"plusagentId.thinkingLevels,thinkingOptions,thinkingDefault) on command-metadatasessions.changedevents when a read-only catalog is available, avoid overwriting richer UI metadata when catalog discovery is unavailable or slow, and reuse the TUI-loaded model catalog when rebuilding embedded session defaults.Targeted tests
/goalcommand unit coverage for metadata-change notifications on mutating goal actions and no-op clear paths./goalcommand unit coverage for the shared lifecycle fallback when no direct Gateway subscriber callback is installed.sessions.changedpayloads, active-run exclusion, catalog-backed thinking metadata, slow catalog fallback, hidden internal runs, selected global runs, and default-agent scoped literalglobalactive runs./goalturns broadcast scoped session updates and do not report their own command turn as active.sessionKey: "global"plus the parsed agent id.globaldeltas against selected agent-global aliases.Real behavior proof
Behavior addressed: In-chat command metadata writes now emit scoped
sessions.changedevents, so subscribed Control UI/WebChat clients can refresh visible session metadata after command-only turns.Real environment tested: Local OpenClaw checkout on branch
fix/sessions-changed-in-chat-commands, commit677e3d3c01d3df9943da18e7b4509dc618797606, rebased onto currentorigin/mainat9cbf18293b. The Gateway proof exercises thesessions.changedcommand-metadata path used by subscribed Control UI/WebChat clients.Exact steps or command run after this patch:
git diff --check origin/main...HEAD./node_modules/.bin/oxlint src/auto-reply/reply/commands-session-store.ts src/auto-reply/reply/commands-session-store.test.ts src/gateway/server-methods/session-change-events.ts src/gateway/server-methods/optional-model-catalog.ts src/gateway/session-utils.ts src/gateway/server-methods/sessions.ts src/gateway/server-methods/chat.ts src/gateway/server.sessions.list-changed.test.ts src/tui/embedded-backend.ts src/tui/embedded-backend.test.tsOPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree CI=1 NODE_OPTIONS=--max-old-space-size=4096 OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=120000 OPENCLAW_VITEST_NO_OUTPUT_HEARTBEAT_MS=10000 node scripts/run-vitest.mjs --run --maxWorkers 1 src/auto-reply/reply/commands-session-store.test.tsOPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree CI=1 NODE_OPTIONS=--max-old-space-size=4096 OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=120000 OPENCLAW_VITEST_NO_OUTPUT_HEARTBEAT_MS=10000 node scripts/run-vitest.mjs --run --maxWorkers 1 src/auto-reply/reply/commands-goal.test.ts src/auto-reply/reply/commands-session-store.test.ts src/auto-reply/reply/directive-handling.mixed-inline.test.ts src/gateway/server.sessions.list-changed.test.ts ui/src/ui/controllers/chat.test.ts src/tui/embedded-backend.test.tsCI=1 NODE_OPTIONS=--max-old-space-size=4096 node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core-test-88690-rebase.tsbuildinfonode --import tsx src/entry.ts --versionnode --import tsx .artifacts/pr-88690-fn-proof.mjs(function-level real-behavior proof on the current head; see below)node --import tsx .artifacts/pr-88690-sessions-changed-proof.mjs(full live-gateway subscriber proof; captured on a prior head — see the note below on why it cannot re-run in this no-build checkout)codex review --base origin/mainEvidence after fix:
git diff --check origin/main...HEADpassed.oxlinton the touched command/gateway/TUI files passed.Test Files 1 passed (1),Tests 4 passed (4). This includes the scoped-global proof thatagent:target:globalmetadata notifications becomesessionKey: "global"withagentId: "target".origin/main: 10 focused test files, 431 tests passed (auto-reply command + directive-handling suites,src/gateway/server.chat.gateway-server-chat.test.ts,src/gateway/server.sessions.list-changed.test.ts,src/gateway/session-message-events.test.ts,src/tui/embedded-backend.test.ts,ui/src/ui/controllers/chat.test.ts). Core + UItsgotypecheck both passed with exit 0;oxlintpassed on all changedsrc/andui/files.run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.jsonexited successfully.OpenClaw 2026.6.2 (677e3d3).OPENCLAW_HOME,OPENCLAW_STATE_DIR, andOPENCLAW_CONFIG_PATH, preloaded one session with an active goal, connected one operator client that only subscribed tosessions.changed, connected a second operator client that sent/goal complete redacted websocket proofthroughchat.send, and did not callchat.history.codex review --base origin/mainfound no discrete, actionable correctness issue after the scoped-global fix. Its sandboxed gateway socket shard was blocked bylisten EPERMon127.0.0.1, while the expanded Gateway-containing regression above passed outside that sandbox restriction.Copied redacted standalone subscriber proof:
{ "ok": true, "pr": 88690, "proof": "standalone websocket subscriber", "command": "/goal complete redacted websocket proof", "token": "<redacted-gateway-token>", "sessionKeySent": "main", "event": "sessions.changed", "reason": "command-metadata", "eventSessionKey": "agent:main:main", "sessionId": "sess-pr-88690-proof", "label": "PR 88690 sessions.changed proof", "goalStatus": "complete", "goalObjective": "redacted PR 88690 websocket subscriber proof objective", "hasActiveRun": false, "chatSendStatus": "started", "chatSendRunId": "<redacted-run-id>", "subscriberSawEventBeforeHistoryReload": true, "chatHistoryCallsSent": 0, "isolatedState": { "configPath": "<redacted-temp-openclaw.json>", "stateDir": "<redacted-temp-state-dir>", "storePath": "<redacted-temp-sessions-json>" }, "localStorePathExisted": true }Observed result after fix: Command-only
/goalmetadata mutations produce scopedsessions.changedbroadcasts with fresh session row metadata. A standalone WebSocket subscriber receives thecommand-metadataevent before any history reload, and the payload excludes the transient command-onlychat.sendactive run (hasActiveRun: false).chat.sendkeeps selected agent-global aliases receiving canonical global deltas, slow or failed model catalog discovery does not block the broadcast or TUI history, and non-chat.sendcommand paths get the shared lifecycle fallback instead of leaving subscribers stale.Note on the standalone subscriber proof above: that JSON was captured on a prior head. This refresh is a rebase onto current
origin/main(9cbf18293b). The only conflict on thesessions.changedpath was a one-line import union inchat.ts(kept main's newupdateSessionStoreEntryalongside this PR'sSessionMetadataChangedEventtype import); the patched event-emitting functiondispatchSessionMetadataChanged(src/auto-reply/reply/commands-session-store.ts) is byte-for-byte identical to the prior head, and the 431-test focused suite (including the scoped-global regression andui/src/ui/controllers/chat.test.ts) passes on this head. The full live-gateway subscriber script could not be re-run in this checkout because the gateway's provider-auth worker thread fails to resolvesrc/agents/auth-profiles.js(a tsx-worker/no-build limitation of running from source, unrelated to this PR). To prove the patched path on this exact head without that environment dependency, I ran the patched exported function directly:The script imports the real
dispatchSessionMetadataChanged(src/auto-reply/reply/commands-session-store.ts), passes a real subscriber callback, and prints the events the patched code actually emits on commit677e3d3c01:{ "ok": true, "pr": 88690, "proof": "function-level dispatchSessionMetadataChanged", "results": [ { "case": "agent-scoped key derives agentId from the key (not the caller agentId)", "input": { "sessionKey": "agent:target:telegram:direct:123", "agentId": "main", "reason": "command-metadata" }, "emittedToSubscriber": { "sessionKey": "agent:target:telegram:direct:123", "agentId": "target", "reason": "command-metadata" } }, { "case": "scoped-global key canonicalizes to global row + parsed agent", "input": { "sessionKey": "agent:target:global", "agentId": "main", "reason": "command-metadata" }, "emittedToSubscriber": { "sessionKey": "global", "agentId": "target", "reason": "command-metadata" } }, { "case": "plain global keeps fallback agentId", "input": { "sessionKey": "global", "agentId": "target", "reason": "command-metadata" }, "emittedToSubscriber": { "sessionKey": "global", "agentId": "target", "reason": "command-metadata" } } ] }This proves the patched dispatch on the current head: an agent-scoped session key derives its
agentIdfrom the key (target, not the caller'smain), a scopedagent:target:globalkey canonicalizes to theglobalrow with the parsed agent, and a plainglobalkey keeps its fallback agent — each delivered to a live subscriber callback as acommand-metadataevent.What was not tested: Full gateway/core suites and full
pnpm checkwere not run. I did not run a browser-rendered Control UI session; the added proof uses the same Gateway WebSocket subscription contract that Control UI/WebChat clients consume. The Gateway tests and standalone proof require local127.0.0.1listening; default sandboxed review attempts returnedlisten EPERM, so I reran the expanded Gateway-containing regression and standalone subscriber proof with elevated local-network permission. I did not implement or test/namebecause this checkout does not contain a/namehandler.Not tested / known gaps
chat.sendreply options and the shared command-session store helper.pnpm checkwere not run in this remediation pass.AI-assisted disclosure
This patch was prepared with AI assistance. I used source-level reproduction, targeted regression tests, and
codex review --base origin/mainto validate the behavior above.