fix(sessions): fire command:new hook against parent session on sessions.create (#76957)#77004
fix(sessions): fire command:new hook against parent session on sessions.create (#76957)#77004hclsys wants to merge 1 commit intoopenclaw:mainfrom
Conversation
|
Codex review: needs changes before merge. Summary Reproducibility: yes. source-level. Current main routes Control UI typed Next step before merge Security Review findings
Review detailsBest possible solution: Constrain the restored hook emission to the actual Control UI new-session transition, while leaving generic SDK/programmatic parent-session creation as normal session creation unless it explicitly opts into command/reset semantics. Do we have a high-confidence way to reproduce the issue? Yes, source-level. Current main routes Control UI typed Is this the best way to solve the issue? No, not as currently patched. Emitting the reset-style hooks from the gateway is the right boundary, but Full review comments:
Overall correctness: patch is incorrect Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against c59c20e9fd48. |
6fe2387 to
84ed87d
Compare
|
Fixed clawsweeper P2: Problem: The initial patch only emitted the internal Fix:
Tests added (3 new tests in
14/14 pass, oxfmt clean. |
…ns.create Control UI /new typed command was rerouted by 37aebf6 from sendChatMessageNow("/new") — which dispatched through the Gateway command handler and fired command:new internal hooks — to host.onSlashAction("new-session") → sessions.create, which only creates a session entry and fires no lifecycle hooks. This broke the bundled session-memory hook (and any custom command:new hook) for the Control UI /new path. The TUI and CLI paths were unaffected. Fix: in sessions.create, when a parentSessionKey is provided (meaning this is a "new session from existing" = /new flow), emit the command:new internal hook event against the parent session before creating the new session. This mirrors the hook emission in performGatewaySessionReset and restores hook delivery without altering the session creation logic. The guard on hasInternalHookListeners("command", "new") keeps this path free of any I/O when no hooks are registered. Fixes openclaw#76957.
84ed87d to
a5f868d
Compare
|
Rebased onto current main — pre-existing |
|
Superseded by #77376 which narrows hook emission to an explicit |
…am in sessions.create (openclaw#76957) Control UI /new typed command was rerouted by 37aebf6 from sendChatMessageNow("/new") to host.onSlashAction("new-session") → sessions.create, which fires no lifecycle hooks. This broke session-memory and other command:new hooks for the Control UI /new path. Previous fix (openclaw#77004) gated on parentSessionKey alone, which is too broad (SDK programmatic creates also supply parentSessionKey but must not fire webchat command:new hooks per the public docs). Fix: add emitCommandHooks: boolean to SessionsCreateParams. The Control UI /new flow sets emitCommandHooks: true; SDK callers do not. Gateway only emits command:new + before_reset + session lifecycle hooks when this flag is explicitly true. Tests: - sessions.create with emitCommandHooks=true fires command:new against parent - sessions.create with parentSessionKey but no emitCommandHooks fires nothing
…am in sessions.create (openclaw#76957) Control UI /new typed command was rerouted by 37aebf6 from sendChatMessageNow("/new") to host.onSlashAction("new-session") → sessions.create, which fires no lifecycle hooks. This broke session-memory and other command:new hooks for the Control UI /new path. Previous fix (openclaw#77004) gated on parentSessionKey alone, which is too broad (SDK programmatic creates also supply parentSessionKey but must not fire webchat command:new hooks per the public docs). Fix: add emitCommandHooks: boolean to SessionsCreateParams. The Control UI /new flow sets emitCommandHooks: true; SDK callers do not. Gateway only emits command:new + before_reset + session lifecycle hooks when this flag is explicitly true. Tests: - sessions.create with emitCommandHooks=true fires command:new against parent - sessions.create with parentSessionKey but no emitCommandHooks fires nothing
Fixes #76957. Restores the Control UI /new hook lifecycle through an explicit sessions.create emitCommandHooks opt-in, preserving hook-free defaults for programmatic parent-session creates. Validation: - pnpm protocol:check - pnpm test src/gateway/server.sessions.reset-hooks.test.ts ui/src/ui/app-render.helpers.node.test.ts - pnpm exec oxlint on touched TS files - pnpm exec oxfmt --check --threads=1 on touched files - git diff --check - OPENCLAW_LOCAL_CHECK=1 OPENCLAW_LOCAL_CHECK_MODE=throttled env NODE_OPTIONS=--max-old-space-size=4096 pnpm check:changed - GitHub PR checks green on 3a446ec - ClawSweeper re-review completed with no blocking findings and security cleared Duplicate triage: - #77376, #77004, and #76967 were superseded closed attempts for #76957 - #77562 is a closed duplicate issue - #77880 mentions #76957 but is not a duplicate of this hook fix
Fixes #76957. Restores the Control UI /new hook lifecycle through an explicit sessions.create emitCommandHooks opt-in, preserving hook-free defaults for programmatic parent-session creates. Validation: - pnpm protocol:check - pnpm test src/gateway/server.sessions.reset-hooks.test.ts ui/src/ui/app-render.helpers.node.test.ts - pnpm exec oxlint on touched TS files - pnpm exec oxfmt --check --threads=1 on touched files - git diff --check - OPENCLAW_LOCAL_CHECK=1 OPENCLAW_LOCAL_CHECK_MODE=throttled env NODE_OPTIONS=--max-old-space-size=4096 pnpm check:changed - GitHub PR checks green on 3a446ec - ClawSweeper re-review completed with no blocking findings and security cleared Duplicate triage: - #77376, #77004, and #76967 were superseded closed attempts for #76957 - #77562 is a closed duplicate issue - #77880 mentions #76957 but is not a duplicate of this hook fix (cherry picked from commit 49c4a13)
Fixes openclaw#76957. Restores the Control UI /new hook lifecycle through an explicit sessions.create emitCommandHooks opt-in, preserving hook-free defaults for programmatic parent-session creates. Validation: - pnpm protocol:check - pnpm test src/gateway/server.sessions.reset-hooks.test.ts ui/src/ui/app-render.helpers.node.test.ts - pnpm exec oxlint on touched TS files - pnpm exec oxfmt --check --threads=1 on touched files - git diff --check - OPENCLAW_LOCAL_CHECK=1 OPENCLAW_LOCAL_CHECK_MODE=throttled env NODE_OPTIONS=--max-old-space-size=4096 pnpm check:changed - GitHub PR checks green on 3a446ec - ClawSweeper re-review completed with no blocking findings and security cleared Duplicate triage: - openclaw#77376, openclaw#77004, and openclaw#76967 were superseded closed attempts for openclaw#76957 - openclaw#77562 is a closed duplicate issue - openclaw#77880 mentions openclaw#76957 but is not a duplicate of this hook fix
Summary
Commit
37aebf612brerouted the Control UI typed/newpath fromsendChatMessageNow(host, "/new")(which passed through Gateway command dispatch →command:newhooks) tohost.onSlashAction("new-session")→sessions.create, which creates a session entry but fires zero internal hooks. This broke:session-memoryhook (no memory file written on/new)command:newbefore_resetplugin hook chainFix
In
sessions.create, after a successful session creation, ifcanonicalParentSessionKeyis set (the Control UI/newflow always passes the current session asparentSessionKey), firecreateInternalHookEvent("command", "new", parentSessionKey, ...)→triggerInternalHook. This restorescommand:newhook delivery for the transition from the parent session.The guard
hasInternalHookListeners("command", "new")ensures zero overhead when no hooks are registered.Files changed
src/gateway/server-methods/sessions.ts— hook emission insessions.createCHANGELOG.md— fix entryTest
web-tree-sitterimport)pnpm exec oxfmt --checkpasses on changed files