fix(sessions): fire command:new hook against parent session on sessions.create#76967
Closed
hclsys wants to merge 1 commit intoopenclaw:mainfrom
Closed
fix(sessions): fire command:new hook against parent session on sessions.create#76967hclsys wants to merge 1 commit intoopenclaw:mainfrom
hclsys wants to merge 1 commit intoopenclaw:mainfrom
Conversation
…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.
|
Closing this PR because the author has more than 20 active PRs in this repo. Please reduce the active PR queue and reopen or resubmit once it is back under the limit. You can close your own PRs to get back under the limit. |
BunsDev
added a commit
that referenced
this pull request
May 6, 2026
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
steipete
pushed a commit
that referenced
this pull request
May 6, 2026
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)
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
May 9, 2026
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Typing
/newin the Control UI no longer firescommand:newinternal hooks, breaking the bundledsession-memoryhook and any custom hooks listening oncommand:new.Root cause: Commit
37aebf612b(fix(control-ui): create sessions for typed /new, fixing #69599) rerouted the/newslash-command dispatch from:to:
sessions.createcreates the session entry but never emitscommand:new(orbefore_reset) hooks against the parent session. The gateway logs confirm:[ws] ⇄ res ✓ sessions.create 93mswith zero hook activity — compare with/resetwhich produces[hooks/session-memory] Hook triggered for reset/new command.TUI and CLI
/newpaths go throughperformGatewaySessionResetand are unaffected.Fix
In
sessions.create, when aparentSessionKeyis provided (this is the "new session from existing" =/newflow), emit thecommand:newinternal hook against the parent session before creating the new session:This mirrors the hook emission in
performGatewaySessionReset(which handles TUI/CLI/new). ThehasInternalHookListenersguard keeps this path zero-cost when no hooks are registered.Files changed:
src/gateway/server-methods/sessions.ts(1 import added, 17 lines added insessions.create)Fixes #76957.