Skip to content

[Bug]: Control UI typed /new no longer fires command:new hooks after 37aebf612b — session-memory and custom hooks broken #76957

@origfla

Description

@origfla

Issue Draft for openclaw/openclaw

Title

[Bug]: Control UI typed /new no longer fires command:new hooks after 37aebf6 — session-memory and custom hooks broken

Labels

bug, regression

Body

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

After v2026.5.2, typing /new in the Control UI (webchat) no longer fires command:new internal hooks because commit 37aebf612b rerouted it from sendChatMessageNow(host, "/new") (which went through Gateway command dispatch → hooks) to host.onSlashAction("new-session")createSessionAndRefresh()sessions.create (which fires zero hooks).

This breaks:

  • The bundled session-memory hook — no memory file is written on /new
  • Any custom managed/workspace hooks listening on command:new
  • The before_reset plugin hook chain

This is the Control UI equivalent of #49918 (TUI /new hooks regression). The TUI bug was introduced in v2026.3.7 by a different commit; this one was introduced in v2026.5.2 by 37aebf612b which fixed #69599.

Steps to reproduce

  1. Enable the bundled session-memory hook (openclaw hooks enable session-memory)
  2. Have a conversation in the Control UI webchat
  3. Type /new in the chat input
  4. Check <workspace>/memory/ — no new memory file is created
  5. Check gateway logs — no hooks/session-memory log entries after the /new
  6. For comparison: type /reset in a session — memory file IS created, hooks fire correctly

Expected behavior

Typing /new in the Control UI should fire command:new internal hooks (and before_reset plugin hooks) against the previous session before switching to the new one, consistent with documented behavior and the bundled hook contract.

From the hooks documentation:

| command:new | /new command issued |

From the bundled hooks table:

| session-memory | command:new, command:reset | Saves session context to <workspace>/memory/ |

Actual behavior

Control UI /new calls sessions.create via WebSocket, which creates a fresh session entry but does not:

  • Fire the command:new internal hook event
  • Fire the before_reset plugin hook
  • Fire the session_end plugin hook for the previous session
  • Trigger the bundled session-memory hook

The old session's transcript is never captured to memory.

Root cause

Commit 37aebf612b ("fix(control-ui): create sessions for typed /new", fixing #69599) changed the /new dispatch in ui/src/ui/app-chat.ts:

Before:

case "new":
  await sendChatMessageNow(host, "/new", { refreshSessions: true, ... });
  return;

After:

case "new":
  if (!host.onSlashAction) {
    host.lastError = "New Chat is unavailable.";
    return;
  }
  await host.onSlashAction("new-session");
  return;

onSlashAction("new-session")createChatSessionInternal()createSessionAndRefresh()sessions.create WebSocket RPC, which has no hook emission.

Meanwhile /reset was intentionally preserved on the old path: sendChatMessageNow(host, "/reset") → Gateway command dispatch → hooks fire.

Suggested fix direction

Similar to the approach in PR #49945 (TUI fix): when the Control UI creates a new session with a parentSessionKey, emit before_reset/session_end/command:new hooks against the parent session before completing the create. This preserves the fresh-session UX from #69599 while restoring the hook contract.

Alternatively, sessions.create could accept an optional flag to emit lifecycle hooks against the parent session when one is provided.

OpenClaw version

2026.5.2

Operating system

Ubuntu 24.04 LTS (Linux 6.17.0)

Install method

npm link (local fork), but the regression is in upstream ui/src/ui/app-chat.ts

Provider / routing chain

webchat / Control UI

Logs, screenshots, and evidence

Gateway logs around /new (17:20:39 EDT) show sessions.create with no hook activity:

May 03 17:20:39 node[1321657]: [ws] ⇄ res ✓ sessions.create 93ms

No hooks/session-memory log entries appear. Compare with /reset which produces:

[hooks/session-memory] Hook triggered for reset/new command
[hooks/session-memory] Session content loaded
[hooks/session-memory] Memory file written successfully

Confirmed: only one memory file exists for today (from an earlier /reset), none from the /new at 17:20.

Impact and severity

Affected: All Control UI/webchat users relying on session-memory or any command:new hooks.

Severity: Medium-High — the bundled session-memory hook shipped by OpenClaw itself is silently broken for the most common webchat session-start flow.

Workaround: Use /reset instead of /new. Both produce a fresh session; /reset resets in-place while /new creates a separate session entry. /reset correctly fires all hooks.

Additional information

Related issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions