remove plugin-side session restore + warn if cmux native bridge missing - #12
Open
comp615 wants to merge 5 commits into
Open
remove plugin-side session restore + warn if cmux native bridge missing#12comp615 wants to merge 5 commits into
comp615 wants to merge 5 commits into
Conversation
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
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
…-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
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.
Why
manaflow-ai/cmux#3710 (shipped in cmux 0.64.5) adds native Amp session restore:
.ampis a built-inRestorableAgentKind— with its own sanitizer (preserves--mode/--effort/--mcp-config/--visibility/--log-*/--settings-file, stripsthreads continue <id>preambles, blocks--execute/--print/-x) and an env allowlist (AMP_LOG_*,AMP_SETTINGS_FILE,AMP_URL; explicitly dropsAMP_API_KEY).cmux hooks setup(orcmux hooks amp install) drops a bridge plugin at~/.config/amp/plugins/cmux-session.tsthat wires Amp'ssession.start/agent.start/agent.endinto cmux's standard session store viacmux hooks amp <subcommand>calls (with the fullCMUX_AGENT_LAUNCH_*envelope).That obsoletes the plugin-side restore added in #10. Keeping both means:
.custom("amp")vault entry duplicates the built-in.ampkind — cmux's process scanner can match both, risking duplicate restorable entries.~/.cmuxterm/amp-hook-sessions.jsonwrites are dead bytes on 0.64.5+ (and confusingly, native restore reuses the same path with a different schema).cmux-status.ts+cmux-session.ts) both fire onsession.startand record into competing stores.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_PATHconstants andVAULT_REGISTRATIONwriteHookSession,ensureVaultRegistration,stripJsonCommentshelperssession.startcmux: Register Amp for cmux session restorecommand (replaced — see below)Add a missing-bridge nudge. On
session.start, if running under cmux (CMUX_WORKSPACE_IDset) and~/.config/amp/plugins/cmux-session.tsis absent, the plugin emits two signals:cmux log --level warning— cheap, useful for diagnostics:cmux notify— visible enough to actually catch attention without being annoying. Rate-limit state lives at~/.cache/cmux-amp/bridge-warning.json: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 restorecommand palette action shells out tocmux hooks amp install -y, verifies the bridge plugin actually appeared at the expected path (older cmux without thehooks ampsubcommand can exit non-zero or print a stub error and still leave the file missing), and prompts the user to runplugins: reloadafterwards. Saves users from dropping into a terminal.README.mdreplaces 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 thecmux:command palette list.Untouched: status bar, workspace title tracking, handoff suffixing,
cmux_notifytool, the rename commands.Migration
Users on cmux 0.64.5+ should run the new
cmux: Install cmux session restorecommand (orcmux hooks setup/cmux hooks amp installfrom a shell) once. They can also clean up leftover state from the old plugin path:(Cmux's native restore writes a fresh
~/.cmuxterm/amp-hook-sessions.jsonwith its own schema on first session.start.)Verification
node --experimental-strip-types --check plugin/cmux-status.ts✅cmux hooks amp install+plugins: reload,~/.cmuxterm/amp-hook-sessions.jsonis rewritten in cmux's native schema (activeSessionsByWorkspace, sessions keyed bysessionId, withpid/capturedAt/launcher: "amp"/source: "environment"), and the active thread restores after a full cmux quit + relaunch.🤖 Drafted with assistance from Amp.