feat: workspace_switch ⌘K/voice action + CoS auto-save hook (#2035)#2059
Merged
Conversation
Add a workspace_switch voice tool (server/services/voice/tools/workspace.js) that snapshots the workspace being left, then restores a named project's saved context (git branch, in-repo shell sessions, scoped tasks) via the existing workspaceContext service. Whitelisted in PALETTE_ACTIONS so it surfaces in ⌘K. Add snapshotOnRepoSwitch() to workspaceContext.js — a shared "current workspace" tracker that saves the previous app's context when work moves to a different repo. Wired into agentLifecycle.spawnAgentForTask so a CoS coding-agent dispatch against a different app auto-snapshots silently (snapshot-only, no restore, no LLM calls), defensively so a missing current context is a no-op. Covered by palette.test.js (manifest hydration + dispatch + unknown-workspace) and workspaceContext.test.js (switch/no-op/same-repo/null-normalization). Claude-Session: https://claude.ai/code/session_01DKGYJ2LdM91DRvNKj8Y31B
…ify tracker atomicity (#2035) Codex review: the description advertised "take me back to PortOS" which WORKSPACE_INTENT_RE (requires workspace/project/context) wouldn't surface to the voice LLM — reworded to "take me back to the PortOS workspace". Added a comment noting the tracker's read→update is synchronous (atomic per call), so concurrent spawns can't tear it. Claude-Session: https://claude.ai/code/session_01DKGYJ2LdM91DRvNKj8Y31B
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.
Closes #2035
Summary
Workspace Contexts (
WorkspaceContexts.jsx, #902) was manual-only. This adds the two missing surfaces:workspace_switchvoice/palette action (server/services/voice/tools/workspace.js) — "switch workspace to BookLoom" / "restore my PortOS context". Saves a snapshot of the workspace being left, then reconciles the named project's saved context (git branch, in-repo shell sessions, scoped tasks) and reports what's still live to re-attach. Reuses theworkspaceContextservice the page already drives (snapshotOnRepoSwitch+restoreContext); never checks out branches or spawns shells. Whitelisted inPALETTE_ACTIONS(sectionWorkspace) so it appears in ⌘K; description/params hydrate fromgetToolSpecs()(no duplication). Wired intoTOOL_GROUPS/GROUP_INTENTwith aWORKSPACE_INTENT_REfor voice intent-gating.CoS auto-save hook — new
snapshotOnRepoSwitch()inworkspaceContext.jstracks the single "current workspace" and saves the previous app's context when work moves to a different repo. Called fromagentLifecycle.spawnAgentForTaskso a coding-agent dispatch against a different app/repo auto-snapshots the workspace it's leaving. Snapshot-only — no auto-restore, no LLM calls; defensive so a missing/absent current context (first dispatch) or a same-repo dispatch is a no-op, not a throw. Null target normalizes to the PortOS app.Acceptance criteria
Test plan
server/routes/palette.test.js—workspace_switchmanifest hydration (section/label/description/params), dispatch (snapshot + restore), and unknown-workspace fallback; existing whitelist-enforcement tests unchanged.server/services/workspaceContext.test.js— newsnapshotOnRepoSwitchblock: first-switch no-op, snapshots previous on repo change, no-op on same repo, null→PortOS normalization.https://claude.ai/code/session_01DKGYJ2LdM91DRvNKj8Y31B