Skip to content

remove plugin-side session restore + warn if cmux native bridge missing - #12

Open
comp615 wants to merge 5 commits into
block:mainfrom
comp615:charlie/remove-session-restore
Open

remove plugin-side session restore + warn if cmux native bridge missing#12
comp615 wants to merge 5 commits into
block:mainfrom
comp615:charlie/remove-session-restore

Conversation

@comp615

@comp615 comp615 commented May 13, 2026

Copy link
Copy Markdown
Contributor

Why

manaflow-ai/cmux#3710 (shipped in cmux 0.64.5) adds native Amp session restore:

  1. .amp is a built-in RestorableAgentKind — with its own sanitizer (preserves --mode / --effort / --mcp-config / --visibility / --log-* / --settings-file, strips threads continue <id> preambles, blocks --execute / --print / -x) and an env allowlist (AMP_LOG_*, AMP_SETTINGS_FILE, AMP_URL; explicitly drops AMP_API_KEY).
  2. cmux hooks setup (or cmux hooks amp install) drops a bridge plugin at ~/.config/amp/plugins/cmux-session.ts that wires Amp's session.start / agent.start / agent.end into cmux's standard session store via cmux hooks amp <subcommand> calls (with the full CMUX_AGENT_LAUNCH_* envelope).

That obsoletes the plugin-side restore added in #10. Keeping both means:

  • The .custom("amp") vault entry duplicates the built-in .amp kind — cmux's process scanner can match both, risking duplicate restorable entries.
  • The legacy ~/.cmuxterm/amp-hook-sessions.json writes are dead bytes on 0.64.5+ (and confusingly, native restore reuses the same path with a different schema).
  • Two plugins (cmux-status.ts + cmux-session.ts) both fire on session.start and record into competing stores.
  • The native path captures full original argv via CMUX_AGENT_LAUNCH_ARGV_B64, so launches are restored at higher fidelity than our hardcoded ["amp"].

What changes

Remove plugin-side restore from plugin/cmux-status.ts:

  • HOOK_SESSIONS_PATH / CMUX_CONFIG_PATH constants and VAULT_REGISTRATION
  • writeHookSession, ensureVaultRegistration, stripJsonComments helpers
  • The two restore calls inside session.start
  • The cmux: Register Amp for cmux session restore command (replaced — see below)

Add a missing-bridge nudge. On session.start, if running under cmux (CMUX_WORKSPACE_ID set) and ~/.config/amp/plugins/cmux-session.ts is absent, the plugin emits two signals:

  1. Activity-feed warning every session via cmux log --level warning — cheap, useful for diagnostics:

    session restore disabled — run cmux: Install cmux session restore (requires cmux ≥ 0.64.5) to enable

  2. Native macOS notification at most once per 24h via cmux notify — visible enough to actually catch attention without being annoying. Rate-limit state lives at ~/.cache/cmux-amp/bridge-warning.json:
    • Title: "Amp session restore is off"
    • Body: "Run `cmux: Install cmux session restore` from the Amp command palette to enable."

The native failure mode is otherwise silent (panes just don't restore on relaunch), so this catches the "I upgraded cmux but forgot to install the bridge plugin" case.

Add a one-click installer command. New cmux: Install cmux session restore command palette action shells out to cmux hooks amp install -y, verifies the bridge plugin actually appeared at the expected path (older cmux without the hooks amp subcommand can exit non-zero or print a stub error and still leave the file missing), and prompts the user to run plugins: reload afterwards. Saves users from dropping into a terminal.

README.md replaces the old "Session restore" feature bullet with a note pointing at the new command and documenting both warning channels, and adds the new command to the cmux: command palette list.

Untouched: status bar, workspace title tracking, handoff suffixing, cmux_notify tool, the rename commands.

Migration

Users on cmux 0.64.5+ should run the new cmux: Install cmux session restore command (or cmux hooks setup / cmux hooks amp install from a shell) once. They can also clean up leftover state from the old plugin path:

rm -f ~/.cmuxterm/amp-hook-sessions.json
# Optional: edit ~/.config/cmux/cmux.json and remove the `vault.agents[].id == "amp"` entry

(Cmux's native restore writes a fresh ~/.cmuxterm/amp-hook-sessions.json with its own schema on first session.start.)

Verification

  • node --experimental-strip-types --check plugin/cmux-status.ts
  • Live-tested in cmux 0.64.5-nightly:
    • With the bridge plugin missing, the warning fires in the cmux activity feed.
    • After cmux hooks amp install + plugins: reload, ~/.cmuxterm/amp-hook-sessions.json is rewritten in cmux's native schema (activeSessionsByWorkspace, sessions keyed by sessionId, with pid / capturedAt / launcher: "amp" / source: "environment"), and the active thread restores after a full cmux quit + relaunch.

🤖 Drafted with assistance from Amp.

cmux 0.64.5 ships native Amp session restore via PR #3710:
  - `.amp` is a built-in RestorableAgentKind with its own sanitizer + env
    allowlist
  - `cmux hooks setup` (or `cmux hooks amp install`) drops a bridge plugin
    at ~/.config/amp/plugins/cmux-session.ts that wires Amp's session
    lifecycle into cmux's standard session store

That obsoletes the plugin-side restore added in block#10. Keeping both means:
  - the .custom("amp") vault entry duplicates the built-in .amp kind
    (cmux's process scanner can match both, risking duplicate restorable
    entries)
  - the legacy ~/.cmuxterm/amp-hook-sessions.json writes are dead bytes
    on 0.64.5+
  - two plugins (cmux-status.ts + cmux-session.ts) both fire on
    session.start and record into competing stores

Removes:
  - HOOK_SESSIONS_PATH / CMUX_CONFIG_PATH constants and VAULT_REGISTRATION
  - writeHookSession, ensureVaultRegistration, stripJsonComments helpers
  - the two restore calls inside session.start
  - the `cmux: Register Amp for cmux session restore` command
  - node:fs / node:os / node:path imports (no longer needed)

Status bar, workspace title tracking, handoff suffixing, cmux_notify, and
the rename commands are untouched.

Users on cmux 0.64.5+ should run `cmux hooks setup` once.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019e223e-687c-74f9-b41b-049f1ee86a85
Failure mode is silent today — if the user upgrades to cmux 0.64.5+ but
forgets `cmux hooks amp install`, panes just don't restore and there's
no obvious feedback. Adds a one-time `wsLog` warning per Amp session
(only when running under cmux, i.e. CMUX_WORKSPACE_ID is set) when
~/.config/amp/plugins/cmux-session.ts is missing:

  > session restore disabled — run `cmux hooks amp install` (requires
    cmux ≥ 0.64.5) to enable

Cheap to check (existsSync once on session.start) and cheap to ignore
once the file is present.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019e223e-687c-74f9-b41b-049f1ee86a85
@comp615 comp615 changed the title revert: remove plugin-side session restore (cmux 0.64.5 ships native) remove plugin-side session restore + warn if cmux native bridge missing May 13, 2026
comp615 and others added 2 commits May 13, 2026 13:18
The wsLog warning lands in the cmux activity feed, which is easy to miss.
Adds a native macOS notification on top, gated to at most once per 24h
via a tiny state file at ~/.cache/cmux-amp/bridge-warning.json:

  Title: "Amp session restore is off"
  Body:  "Run `cmux hooks amp install` to enable cmux native restore."

Once the bridge plugin exists, the existsSync check returns early and
neither the wsLog nor the popup fire. After a fresh `cmux hooks amp
install`, no further nag.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019e223e-687c-74f9-b41b-049f1ee86a85
Saves users from dropping into a terminal when they hit the missing-bridge
warning. Shells out to `cmux hooks amp install -y`, then verifies the
bridge plugin actually appeared at ~/.config/amp/plugins/cmux-session.ts
before reporting success (older cmux without the `hooks amp` subcommand
can exit non-zero or print a stub error and still leave the file missing).

Updates the wsLog warning + cmuxNotify body to point at the new command
instead of the raw shell invocation, since most users will see one of
those signals first.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019e223e-687c-74f9-b41b-049f1ee86a85
HamptonMakes
HamptonMakes previously approved these changes May 13, 2026

@HamptonMakes HamptonMakes left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LFG

…-clear

Without --surface, cmux drops the notification on whichever surface in
the workspace is currently "default", and any UI activity on that
surface fires notification.clear_requested → the popup vanishes within
seconds (verified in ~/.cmuxterm/events.jsonl: every set_status from
the cmux-status plugin's tool tracking was triggering a clear).

Pinning to $CMUX_PANEL_ID keeps the notification in cmux's inbox until
the user actually clicks into the Amp pane. Affects both the missing-
bridge popup and the agent-error popup.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019e223e-687c-74f9-b41b-049f1ee86a85
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants