Skip to content

feat(sidebar): snooze a workspace until a chosen time - #24956

Open
tvrmsmith wants to merge 3 commits into
stablyai:mainfrom
tvrmsmith:feat/workspace-snooze
Open

tvrmsmith wants to merge 3 commits into
stablyai:mainfrom
tvrmsmith:feat/workspace-snooze

Conversation

@tvrmsmith

@tvrmsmith tvrmsmith commented Oct 3, 2026 •

Copy link
Copy Markdown

ELI5

Sometimes a workspace is worth keeping but not worth looking at today. Snooze puts it to sleep, hides it from the sidebar, and brings it back as unread at the time you pick.

What Changed

Before: a workspace you wanted to set aside stayed in the sidebar. Sleep freed memory but the row kept its place in the list.

After:

  • Right-clicking a workspace (or a multi-selection) shows Snooze with 1 Hour, 5 Hours, Tomorrow Morning (9 AM), Next Week (Monday 9 AM) and Pick a Time…. Snoozing sleeps the workspace and hides it from the sidebar, the kanban board, the jump palette's default list and mobile. A typed palette search still finds it.
  • At the wake time it reappears marked unread, even if every window is closed.
  • Wake Now in the same menu wakes it early.
  • Workspace options gains a Hide snoozed switch, on by default. Turning it off shows snoozed rows with a "snoozed" badge whose tooltip gives the wake time. The setting resets on restart, so snoozes cannot be undone by accident.

Mechanism:

  • Workspace metadata (WorktreeMeta and FolderWorkspace) gains an optional snooze: { snoozedAt, wakeAt?, afterSession? }. Sending null clears it.
  • The wake conditions are flat optional fields rather than a tagged union. A reader that does not know a condition still treats the workspace as snoozed. afterSession is reserved for the follow-up that wakes a workspace when another session finishes. Nothing writes it yet.
  • A main-process service checks every 30 seconds, once at startup and again after the OS wakes from sleep. For each due workspace it clears the snooze, sets unread and bumps activity through the runtime, which notifies every client. It runs wherever the metadata lives, so headless and remote hosts wake their own workspaces.
  • worktree.set and folderWorkspace.update accept the field, and worktree.ps reports it.

Why

Snooze reuses the existing Sleep teardown instead of adding a second way to free a workspace. Snooze is Sleep plus a saved wake condition and hiding.

The timer lives in the main process, not the renderer. That way a snooze fires with no window open, on headless servers, and after the laptop wakes, when an in-renderer timer would have stalled.

Remote hosts check their parameters with a schema that silently strips unknown fields. An older host would drop snooze and still report success. The client therefore checks a new workspace.snooze.v1 runtime capability and shows "Update the remote runtime to snooze workspaces" when the host lacks it. Older clients ignore the new field and simply keep showing snoozed rows.

Linked Issue

Part of #24940. This PR covers timed snooze only. A orca worktree snooze CLI command and "wake when another session finishes" follow in separate PRs.

Visual Proof

Before: no Snooze item in the context menu.
0-before

After: screenshots below
1-snooze-menu
2-pick-time
3-hidden
4-peek
5-badge-tooltip

Testing

  • I manually tested these changes locally (macOS, background Electron launch driven over CDP)

  • Automated tests added/updated

  • Unit tests:

    • Snooze schema and parse
    • Presets, including DST-safe "tomorrow 9 AM" and the Monday edge
    • Wake service: startup catch-up, tick, resume after OS sleep, one failing wake not blocking the rest, a call during a pass queuing one more pass
    • Snooze and wake flow
    • Persistence across restart and null clearing, for git worktrees and folder workspaces
    • Visibility filter
  • E2E: tests/e2e/workspace-snooze.spec.ts

    • Snooze from the menu, the row hides, the filter peeks it, Wake Now
    • The main process waking a workspace on its own tick
  • pnpm tc, the mobile typecheck, pnpm run check:code-quality:changed and the pnpm lint steps pass. One exception: audit:code-quality:native reports five import(no-cycle) warnings in mobile/src/transport and mobile/src/terminal, files this PR does not touch.

  • Linux, Windows and SSH were not run by hand. The change has no platform-specific code. SSH and remote hosts go through the capability gate, and the wake runs on whichever host owns the metadata.

AI Disclosure

Written with Claude Code (Claude Opus 5.5), reviewed and directed by me.

Review

Cross-boundary contract (the snooze field on worktree.set, folderWorkspace.update and worktree.ps): contract approved by Trevor Smith, recorded on #24940 as "orca-runtime worktree.set + worktree.ps snooze field".

Agent skill upstream boundary

  • Not applicable

Notes

  • Known limitation: the wake service reads the legacy metadata projection. A workspace whose metadata is keyed only by a second host's identity might not auto-wake; Wake Now still works for it.
  • Mobile: snoozed workspaces are hidden but there is no wake action on mobile yet.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

🤖 Generated with Claude Code

Snooze sleeps a workspace, hides it from the sidebar, kanban board, jump
palette default list and mobile, and stores a wake condition on its
metadata. A main-process service wakes due workspaces every 30s and on
resume from OS sleep, marking them unread. The context menu offers
presets, a pick-a-time dialog and Wake Now; a "Hide snoozed" filter peeks
snoozed rows for the session.

worktree.set and folderWorkspace.update gain an optional snooze field,
gated by the workspace.snooze.v1 runtime capability so older hosts refuse
instead of dropping it.

Contract approved by Trevor Smith, recorded on stablyai#24940 as
"orca-runtime worktree.set + worktree.ps snooze field".

Refs stablyai#24940

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Important

The wake ticker is only installed on the Electron entry path, so a headless orcad host — including a paired remote environment — persists a snooze but never wakes it. That contradicts the stated mechanism and is the exact host class the main-process timer was added for.

Reviewed changes

  • Snooze model and wire contract — new WorkspaceSnooze (snoozedAt, optional wakeAt/afterSession) threaded through WorktreeMeta, FolderWorkspace, Worktree and RuntimeWorktreePsSummary; worktree.set/folderWorkspace.update accept it nullable, and null deletes the stored field.
  • Wake service — WorkspaceSnoozeWakeService ticks every 30s, once at startup, and on OS resume; each due workspace is woken through the runtime (snooze cleared, marked unread, activity bumped).
  • Renderer UX — context-menu Snooze submenu with presets, a Pick-a-Time dialog, Wake Now, a session-only Hide-snoozed peek, and a snoozed badge.
  • Visibility filtering — sidebar computeVisibleWorktrees, the lineage ancestor index, kanban ids, the jump-palette empty-query list and mobile all hide snoozed rows; a typed palette search still finds them.
  • Remote capability gate — workspace.snooze.v1 is asserted before writing to a paired environment so an older runtime fails loudly instead of stripping the field.

⚠️ Headless and paired-remote hosts never wake a due snooze

The wake ticker is started only from initializeReadyRuntimeServices, which is reached only from the Electron entry (src/main/index.ts). The headless server orcad builds its own runtime in src/main/orcad/orcad-entry.ts and starts no equivalent; a repo-wide search finds no snooze symbol anywhere under src/main/orcad/. Because a paired remote environment is orcad and owns its own metadata store, a snooze written there via worktree.set/folderWorkspace.update is persisted but never auto-woken, so the row stays hidden until a client sends an explicit Wake Now. This undercuts the reason the timer lives in the main process.

Technical details
# Headless/remote wake is never scheduled

## Affected sites
- src/main/startup/main-process-ready-runtime.ts:60-61 — the sole production start of `WorkspaceSnoozeWakeService`.
- src/main/index.ts:124 — the sole caller of `initializeMainProcessReady`.
- src/main/orcad/orcad-entry.ts:210,321 — `orcad` constructs `OrcaRuntimeService` and starts the RPC server; it starts no wake service and has no snooze reference.

## Required outcome
- Any host that owns snoozed metadata runs its own wake tick against its own store, including `orcad`.

## Suggested approach (optional)
- Start `createWorkspaceSnoozeWakeService(profileStore, runtime)` in `orcad-entry` alongside the other host-local services, and stop it on shutdown; or factor the desktop runtime-service wiring so both entries install it.

## Open questions for the human (optional)
- Is the paired-remote path expected to be the Electron `--serve` app rather than `orcad`? If so, direct `orcad` deployments still need the tick, since the PR body advertises both.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

Comment thread src/shared/workspace-snooze.ts Resolved
@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (1)
AGENTS.md — auto-discovered
📝 Walkthrough

Walkthrough

The change adds snooze metadata for worktrees and folder workspaces, persists and propagates it through runtime and IPC paths, and adds a service that wakes due workspaces. The sidebar adds snooze controls, a custom wake-time dialog, status badges, and a setting to show snoozed workspaces. Snoozed worktrees are excluded by default from supported sidebar, jump-palette, and mobile lists. Tests cover metadata, wake behavior, visibility, and end-to-end snooze and wake flows.

Priority: ⬇️ Low

Merge Risk: 🟡 Moderate · up to d443c

A workspace snoozed again on another host may wake earlier than requested. Check the snooze on the host being updated before merging.

Security Architecture Review

Security architecture risk: 🔵 Low · up to d443c

The inspected wake path changes workspace metadata without demonstrating new privileges or cross-user access. Concurrency safeguards reduce stale updates, but multi-host ownership, restart recovery, and compatibility with older remote hosts remain incompletely established.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • observed — The inspected automatic transition constructs updates only for snooze, unread status, and activity on workspace records obtained from the process's store. This bounds the visible mutation payload, but does not establish complete cross-host exposure or authorization coverage.

Trust Boundaries and Controls

  • observed — The changed runtime entrypoint forwards an optional local predicate. The inspected public RPC handler does not accept or pass that predicate, so the new callback mechanism is not exposed as remotely supplied executable behavior.

Resilience and Maintainability Implications

  • observed — A failed metadata precondition throws before persistence and notification. The wake adapter treats that refusal as stale-work suppression while allowing other errors to reach the scheduler's per-workspace failure handling.

Hardening Proposals

  • proposed — Consider carrying host and instance identity through wake selection and comparing the same owner-qualified snooze snapshot at mutation time. This would strengthen the transition contract beyond a locator and snoozedAt timestamp; it is not a verified vulnerability finding.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 49 functions across 60 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: timed workspace snoozing from the sidebar.
Description check ✅ Passed The description covers the user-facing change, mechanism, rationale, linked issue, visual proof, testing, AI disclosure, review, boundary checklist, known limitations, and compatibility considerations…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7375e5df-9697-4fe4-a08e-dec9a338a108
📥 Commits

Reviewing files that changed from the base of the PR and between 843607b and 3a35283.

📒 Files selected for processing (65)
  • mobile/src/worktree/workspace-list-sections.ts
  • mobile/src/worktree/workspace-list-types.ts
  • mobile/src/worktree/worktree-list-snapshot.ts
  • src/main/ipc/repos/repo-ipc-arg-schemas.ts
  • src/main/ipc/worktree-metadata-merge.ts
  • src/main/ipc/worktrees/folder-workspace-model.ts
  • src/main/ipc/worktrees/metadata/register-worktree-metadata-handlers.ts
  • src/main/persistence-worktree-meta-and-folder-workspaces.test.ts
  • src/main/persistence/loading-store/worktree-meta-write-normalization.test.ts
  • src/main/persistence/loading-store/worktree-meta-write-normalization.ts
  • src/main/persistence/restoring-sessions/folder-workspace-operations.ts
  • src/main/runtime/rpc/methods/worktree.ts
  • src/main/runtime/runtime-folder-workspace.ts
  • src/main/runtime/runtime-project-group-controller.ts
  • src/main/runtime/runtime-worktree-ps-summaries.ts
  • src/main/startup/main-process-quit.ts
  • src/main/startup/main-process-ready-runtime.ts
  • src/main/startup/main-process-state.ts
  • src/main/workspace-snooze/workspace-snooze-wake-runtime.ts
  • src/main/workspace-snooze/workspace-snooze-wake-service.test.ts
  • src/main/workspace-snooze/workspace-snooze-wake-service.ts
  • src/preload/api/worktree-api.ts
  • src/renderer/src/components/sidebar/SidebarFilter.tsx
  • src/renderer/src/components/sidebar/SidebarWorkspaceFilterSection.tsx
  • src/renderer/src/components/sidebar/SnoozeWorkspaceDialog.tsx
  • src/renderer/src/components/sidebar/WorkspaceSnoozeBadge.tsx
  • src/renderer/src/components/sidebar/WorkspaceSnoozeMenuItems.tsx
  • src/renderer/src/components/sidebar/WorktreeContextMenuView.tsx
  • src/renderer/src/components/sidebar/index.tsx
  • src/renderer/src/components/sidebar/use-visible-workspace-kanban-worktree-ids.ts
  • src/renderer/src/components/sidebar/use-worktree-context-menu-commands.ts
  • src/renderer/src/components/sidebar/visible-worktree-indexes.ts
  • src/renderer/src/components/sidebar/visible-worktree-options-from-state.ts
  • src/renderer/src/components/sidebar/visible-worktrees.ts
  • src/renderer/src/components/sidebar/workspace-snooze-flow.test.ts
  • src/renderer/src/components/sidebar/workspace-snooze-flow.ts
  • src/renderer/src/components/sidebar/workspace-snooze-presets.test.ts
  • src/renderer/src/components/sidebar/workspace-snooze-presets.ts
  • src/renderer/src/components/sidebar/worktree-card-header.tsx
  • src/renderer/src/components/sidebar/worktree-list/listing/use-filters.ts
  • src/renderer/src/components/sidebar/worktree-list/listing/use-visible-worktrees.test.tsx
  • src/renderer/src/components/sidebar/worktree-list/listing/use-visible-worktrees.ts
  • src/renderer/src/components/use-worktree-jump-palette-store-state.ts
  • src/renderer/src/components/use-worktree-jump-palette-worktrees.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/store/folder-workspaces/folder-workspace-mutations.ts
  • src/renderer/src/store/repos/repo-state.ts
  • src/renderer/src/store/slices/ui/ui-slice-contract-contextual.ts
  • src/renderer/src/store/slices/ui/ui-slice-contract-preferences.ts
  • src/renderer/src/store/slices/ui/ui-slice-preference-actions.ts
  • src/renderer/src/store/slices/worktrees/listing/detected-worktree-meta.ts
  • src/renderer/src/store/slices/worktrees/metadata/worktree-meta-persist.ts
  • src/shared/folder-workspace-types.ts
  • src/shared/folder-workspace-worktree.ts
  • src/shared/folder-workspaces.test.ts
  • src/shared/folder-workspaces.ts
  • src/shared/protocol-version.ts
  • src/shared/rpc-contract/folder-workspace-params.ts
  • src/shared/rpc-contract/worktree-params.ts
  • src/shared/runtime-worktree-contracts.ts
  • src/shared/workspace-snooze.test.ts
  • src/shared/workspace-snooze.ts
  • src/shared/worktree/meta-types.ts
  • src/shared/worktree/types.ts
  • tests/e2e/workspace-snooze.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

- orcad starts the wake service too, so headless and remote hosts wake snoozes
- wake pass logs listing failures instead of rejecting
- wake skips a workspace re-snoozed or woken after the pass listed it
- snooze actions skip already-snoozed rows in mixed selections
- lineage index keeps snoozed parents while the peek is on
- stored snooze parse keeps unknown keys so newer conditions survive re-persist

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

The follow-up commit 12542490bc addresses both prior findings and hardens the wake path.

  • Headless orcad host now wakes snoozes — orcad-entry starts createWorkspaceSnoozeWakeService(profileStore, runtime) after recovery and stops it first on shutdown, so a paired-remote host that owns snoozed metadata runs its own tick.
  • Stored parse preserves unknown wake conditions — parseStoredWorkspaceSnooze now parses with a .loose() schema, so a condition written by a newer build survives the folder-workspace load/save round-trip.
  • Wake skips a workspace the user changed mid-pass — the runtime adapter re-reads the stored snoozedAt with no await before writing and bails when it no longer matches, so a re-snooze or Wake Now is not clobbered.
  • Listing failure no longer aborts the service — a throwing listSnoozed() is warned and retried on the next pass instead of rejecting.
  • Snooze menu ignores already-snoozed rows — the context-menu snooze actions filter to non-snoozed rows so re-snoozing cannot overwrite an existing wake time.
  • Peek-aware lineage index — getLineageAncestorIndex now takes the peek flag, with a per-value WeakMap cache, so a snoozed parent resolves its children only while Hide snoozed is off.
  • Tests — new coverage for the headless startup wake, the re-snooze/wake race, listing-failure retry, persistence round-trip, and peek-aware nesting. All focused suites pass locally.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

Runtime worktree meta update takes an optional precondition, read
after its last await and before any write. Wake passes "snoozedAt
unchanged", so a re-snooze during selector resolution survives.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

The follow-up commit d443c87 closes the re-snooze race that the prior adapter check could not: the worktree path awaits resolution before it writes.

  • Precondition checked after every await — updateRuntimeManagedWorktreeMetadata gains an optional precondition and runs it after resolveWorktree and the parent resolve, immediately before the synchronous write. The parent resolve was hoisted above the check so the guard really sits after the last await.
  • Wake skip is not a failure — WorkspaceSnoozeWakeRuntime.updateManagedWorktreeMeta passes (meta) => unchanged(meta?.snooze) and the service swallows WorktreeMetaPreconditionError, so a workspace the user re-snoozed mid-resolution is left alone without a warn or retry. Folder workspaces keep the earlier pre-read check, which is sufficient because updateFolderWorkspace has no await for a snooze update.
  • Tests — a refusal test that proves no write/notify when the stored snoozedAt moved during resolution, and a wake-runtime test pinning the precondition verdicts plus the silent skip. The wake-service test was updated for the third argument.

The focused suites (runtime-managed-worktree-metadata, workspace-snooze-wake-runtime, workspace-snooze-wake-service) pass and pnpm tc:node is clean.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 54f9aac8-4143-49ed-9b42-ae90d58fe5cb
📥 Commits

Reviewing files that changed from the base of the PR and between 1254249 and d443c87.

📒 Files selected for processing (5)
  • src/main/runtime/orca-runtime-create-managed-remote-worktree.ts
  • src/main/runtime/runtime-managed-worktree-metadata.test.ts
  • src/main/runtime/runtime-managed-worktree-metadata.ts
  • src/main/workspace-snooze/workspace-snooze-wake-runtime.test.ts
  • src/main/workspace-snooze/workspace-snooze-wake-runtime.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/workspace-snooze/workspace-snooze-wake-runtime.test.ts
  • src/main/workspace-snooze/workspace-snooze-wake-runtime.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

? await args.ports.resolveWorktree(lineage.parentWorktree)
: null
// Why after every await: a check before one would let a concurrent write slip in before ours.
if (args.precondition && !args.precondition(args.store.getWorktreeMeta(worktree.id))) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
# Inspect the store's getter, host-specific setter, and their call sites.
rg -n -C 5 'getWorktreeMeta\s*[:=(]|setWorktreeMetaForHost\s*[:=(]|getWorktreeMetaForHost\s*[:=(]' src/main
rg -n -C 5 'updateManagedWorktreeMeta\s*\(|snoozedAt' src/main/workspace-snooze

Repository: stablyai/orca

Length of output: 45667


🏁 Script executed:

printf '%s\n' '--- managed worktree update ---'
sed -n '1,155p' src/main/runtime/runtime-managed-worktree-metadata.ts
printf '%s\n' '--- declarations / implementations in files binding host metadata methods ---'
rg -l 'getWorktreeMetaForHost|setWorktreeMetaForHost' src/main --glob '*.ts' | head -40
printf '%s\n' '--- method definitions ---'
rg -n 'getWorktreeMeta\s*\(|getWorktreeMetaForHost\s*\(|setWorktreeMetaForHost\s*\(' src/main --glob '*.ts' -g '!*.test.ts' | head -100
printf '%s\n' '--- snooze wake call chain ---'
sed -n '1,100p' src/main/workspace-snooze/workspace-snooze-wake-runtime.ts

Repository: stablyai/orca

Length of output: 17595


🏁 Script executed:

printf '%s\n' '--- store method implementations ---'
sed -n '1,115p' src/main/persistence/loading-store/metadata-lineage-operations.ts
printf '%s\n' '--- host-keyed metadata operations ---'
sed -n '135,245p' src/main/persistence/loading-store/worktree-identity-metadata.ts
printf '%s\n' '--- canonical alias projection ---'
sed -n '1,220p' src/main/persistence/loading-store/worktree-meta-alias-projection.ts
printf '%s\n' '--- host-specific operation references and generic getter wiring ---'
rg -n -C 3 'getWorktreeMetaForHost|setWorktreeMetaForHost|project.*WorktreeMeta|worktreeMetaById' src/main/persistence/loading-store --glob '*.ts' -g '!*.test.ts' | head -180

Repository: stablyai/orca

Length of output: 36084


🏁 Script executed:

printf '%s\n' '--- setter projection rule ---'
sed -n '208,285p' src/main/persistence/loading-store/worktree-identity-metadata.ts
printf '%s\n' '--- managed update callers and bindings ---'
rg -n -C 3 'updateRuntimeManagedWorktreeMetadata\s*\(|updateManagedWorktreeMeta\s*[:=]' src/main --glob '*.ts' -g '!*.test.ts' | head -180
printf '%s\n' '--- wake service construction / wake path ---'
rg -n -C 3 'createWorkspaceSnoozeWakeService|workspaceSnoozeWake|listSnoozed' src/main --glob '*.ts' -g '!*.test.ts' | head -120
printf '%s\n' '--- target-file changes from PR base ---'
git diff --unified=5 f7b1f9d8be14d12244957ee0b710a3482ec62383 d443c87521ee14f85963511e4d375da6709b1efc -- src/main/runtime/runtime-managed-worktree-metadata.ts | sed -n '1,180p'

Repository: stablyai/orca

Length of output: 14033


🏁 Script executed:

printf '%s\n' '--- managed update wrapper ---'
sed -n '110,190p' src/main/runtime/orca-runtime-create-managed-remote-worktree.ts
printf '%s\n' '--- selector resolution bindings in runtime source ---'
rg -n -C 4 'resolveWorktree\s*[:=]|resolveWorktree\(' src/main/runtime --glob '*.ts' -g '!*.test.ts' | head -200
printf '%s\n' '--- selector id resolution ---'
sed -n '150,220p' src/main/runtime/orca-runtime-resolve-worktree-selector.ts

Repository: stablyai/orca

Length of output: 20215


🏁 Script executed:

sed -n '1,155p' src/main/runtime/orca-runtime-resolve-worktree-selector.ts | cat -n

Repository: stablyai/orca

Length of output: 7945


🏁 Script executed:

rg -n -C 5 'resolveExplicitWorktreeIdScoped' src/main/runtime --glob '*.ts' -g '!*.test.ts'

Repository: stablyai/orca

Length of output: 6086


🏁 Script executed:

sed -n '105,195p' src/main/runtime/orca-runtime-list-known-resolved-worktrees-for-explicit-target.ts | cat -n

Repository: stablyai/orca

Length of output: 4767


🏁 Script executed:

rg -n -C 8 'resolveScopedWorktreeIdRow' src/main/runtime --glob '*.ts' -g '!*.test.ts'

Repository: stablyai/orca

Length of output: 6535


🏁 Script executed:

sed -n '175,265p' src/main/runtime/repo-worktree-row-resolution.ts | cat -n

Repository: stablyai/orca

Length of output: 2557


🏁 Script executed:

rg -n 'resolveRepoWorktreeRows|readWorktreeMetaForHost|getWorktreeMetaForHost' src/main/runtime/repo-worktree-row-resolution.ts
sed -n '1,175p' src/main/runtime/repo-worktree-row-resolution.ts | cat -n

Repository: stablyai/orca

Length of output: 9214


🏁 Script executed:

sed -n '1,180p' src/main/runtime/runtime-store-contract.ts | cat -n
rg -n -C 2 'getWorktreeMetaForHost' src/main/runtime/runtime-store-contract.ts src/main/runtime/orca-runtime-create-managed-remote-worktree.ts

Repository: stablyai/orca

Length of output: 8918


🏁 Script executed:

rg -n -C 8 'mergeWorktreeMetaForWrite' src/main/persistence/loading-store/worktree-meta-write-normalization.ts

Repository: stablyai/orca

Length of output: 724


🏁 Script executed:

sed -n '31,60p' src/main/persistence/loading-store/worktree-meta-write-normalization.ts | cat -n

Repository: stablyai/orca

Length of output: 1173


Check metadata for the host that the update will write.

getWorktreeMeta(worktree.id) reads the generic locator row, but an id: selector can resolve to a different host and write through setWorktreeMetaForHost. If the generic row still holds the snooze that the wake service listed, the precondition can pass even when the resolved host has a newer snooze. The snooze: null write can then clear that newer snooze. Read metadata for the resolved executionHostId before evaluating the precondition.

🐛 Suggested fix
--- a/src/main/runtime/runtime-store-contract.ts
+++ b/src/main/runtime/runtime-store-contract.ts
@@
   getWorktreeMeta: Store['getWorktreeMeta']
+  getWorktreeMetaForHost: Store['getWorktreeMetaForHost']
   setWorktreeMeta: Store['setWorktreeMeta']

--- a/src/main/runtime/runtime-managed-worktree-metadata.ts
+++ b/src/main/runtime/runtime-managed-worktree-metadata.ts
@@
   const parent = lineage?.parentWorktree
     ? await args.ports.resolveWorktree(lineage.parentWorktree)
     : null
+  const executionHostId = worktree.identity?.executionHostId ?? worktree.hostId
+  const currentMeta =
+    executionHostId && args.store.setWorktreeMetaForHost
+      ? args.store.getWorktreeMetaForHost(worktree.id, executionHostId)
+      : args.store.getWorktreeMeta(worktree.id)
   // Why after every await: a check before one would let a concurrent write slip in before ours.
-  if (args.precondition && !args.precondition(args.store.getWorktreeMeta(worktree.id))) {
+  if (args.precondition && !args.precondition(currentMeta)) {
@@
-  const executionHostId = worktree.identity?.executionHostId ?? worktree.hostId
   if (executionHostId && args.store.setWorktreeMetaForHost) {

This branch has not been deployed

No deployments
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.

1 participant