Skip to content

feat: workspace_switch ⌘K/voice action + CoS auto-save hook (#2035)#2059

Merged
atomantic merged 2 commits into
mainfrom
claim/issue-2035
Jul 2, 2026
Merged

feat: workspace_switch ⌘K/voice action + CoS auto-save hook (#2035)#2059
atomantic merged 2 commits into
mainfrom
claim/issue-2035

Conversation

@atomantic

Copy link
Copy Markdown
Owner

Closes #2035

Summary

Workspace Contexts (WorkspaceContexts.jsx, #902) was manual-only. This adds the two missing surfaces:

  1. workspace_switch voice/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 the workspaceContext service the page already drives (snapshotOnRepoSwitch + restoreContext); never checks out branches or spawns shells. Whitelisted in PALETTE_ACTIONS (section Workspace) so it appears in ⌘K; description/params hydrate from getToolSpecs() (no duplication). Wired into TOOL_GROUPS/GROUP_INTENT with a WORKSPACE_INTENT_RE for voice intent-gating.

  2. CoS auto-save hook — new snapshotOnRepoSwitch() in workspaceContext.js tracks the single "current workspace" and saves the previous app's context when work moves to a different repo. Called from agentLifecycle.spawnAgentForTask so 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

  • "Switch workspace to X" works from ⌘K and voice; the palette lists it.
  • CoS repo-switch produces an automatic context snapshot (visible on the Workspace Contexts page).
  • No auto-restore without explicit user action.

Test plan

  • server/routes/palette.test.jsworkspace_switch manifest hydration (section/label/description/params), dispatch (snapshot + restore), and unknown-workspace fallback; existing whitelist-enforcement tests unchanged.
  • server/services/workspaceContext.test.js — new snapshotOnRepoSwitch block: first-switch no-op, snapshots previous on repo change, no-op on same repo, null→PortOS normalization.
  • Ran: palette + voice tools (178 passed), workspaceContext + navManifest (57), agentLifecycle (40). All green.

https://claude.ai/code/session_01DKGYJ2LdM91DRvNKj8Y31B

atomantic added 2 commits July 2, 2026 07:20
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
@atomantic atomantic merged commit 2e3073b into main Jul 2, 2026
2 checks passed
@atomantic atomantic deleted the claim/issue-2035 branch July 2, 2026 16:19
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.

Workspace Contexts: add ⌘K/voice workspace_switch action and CoS auto-save hook

1 participant