Repository navigation
feat(profiles): carry markdown frontmatter visibility in project transfers (#16741 T2 P7) - #24405
Conversation
…sfers (#16741 T2 P7) Moving a project to another profile now carries its hidden-frontmatter overrides, rekeyed to the destination worktree's editor file ids, and removing a repo prunes the overrides that belonged to its open files. The owner-keyed session projection moves into profile-session-owner-transfer (extractSessionOwnersForTransfer, exported for later reuse), and extractSessionForTransfer becomes a thin repo-rekey projection over it. Terminal layouts of unified-only terminal tabs now travel with their tab. Ported by hunk from #16741 (a68b6f3). Client-hosted browser pages and sleeping agent sessions stay untransferred (see the field census).
|
| worktreeId: string, | ||
| runtimeEnvironmentId: string | null | undefined | ||
| ): ReadonlySet<string> { | ||
| return new Set([filePath, ownedEditorFileId(filePath, worktreeId, runtimeEnvironmentId)]) |
There was a problem hiding this comment.
Plain-path override has one owner When two worktrees open the same absolute path, only one file can have that path as its editor ID. This code treats the path as an ID for both files. Transferring one worktree can carry the other file’s hidden-frontmatter choice, while removing one repo can delete the retained file’s choice.
| const destinationId = ownedEditorFileId( | ||
| file.filePath, | ||
| destinationWorktreeId, | ||
| file.runtimeEnvironmentId | ||
| ) |
There was a problem hiding this comment.
Hidden override misses hydrated file If a local file has an owned editor ID only because another worktree opened the same path, moving it to a profile without that collision makes hydration use the plain path instead. This mapping keeps the override under a new owned ID, so the transferred file no longer restores its hidden-frontmatter choice.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 8 minutes. View limit detailsLimit details: You’ve used all 10 included reviews currently available. Review configuration: ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughWorkspace session transfer now uses shared owner-transfer utilities to remap eligible session records and selections. Markdown frontmatter visibility overrides are mapped to unambiguous destination file IDs, and explicit visible values are omitted. Session merging combines visibility maps, with incoming values taking precedence. Repo removal prunes visibility entries associated with the removed repo’s open files. Tests cover transfer mapping, ambiguous IDs, repo removal, and terminal layouts. Priority: ➖ Normal Merge Risk: 🔵 Low · up to Most transferred session state and Markdown visibility settings move correctly between profiles. For files in host-qualified worktrees, though, hidden-frontmatter preferences can be lost after transfer. This is a small fix, and the PR is otherwise mergeable. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The transfer preserves ownership checks and primarily carries local presentation preferences. However, newly transferred terminal history and layout metadata may outlive later project removal because cleanup does not recognize every transferred terminal identity. Retained concerns
Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 277ef1eb-14ba-466d-999c-be7c40e4f9ba
📒 Files selected for processing (7)
src/main/orca-profiles/profile-project-session-field-disposition.test.tssrc/main/orca-profiles/profile-project-session-field-disposition.tssrc/main/orca-profiles/profile-project-session-state.tssrc/main/orca-profiles/profile-project-session-transfer.tssrc/main/orca-profiles/profile-session-markdown-transfer.tssrc/main/orca-profiles/profile-session-owner-transfer.test.tssrc/main/orca-profiles/profile-session-owner-transfer.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
| const destinationWorktreeId = projection.mapWorktreeId(sourceOwnerKey) | ||
| const sourceWorktreeIds = [sourceOwnerKey] | ||
| const separator = sourceOwnerKey.indexOf('|') | ||
| if (separator > 0) { | ||
| sourceWorktreeIds.push(sourceOwnerKey.slice(separator + 1)) | ||
| } |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
fd -i 'hydrated-editor-file' src/renderer | xargs -I{} sh -c 'echo "== {}"; cat -n "{}" | head -120'
rg -nP "editor:\\$\\{|isWorktreeHostIdentity\s*\(" -C3 srcRepository: stablyai/orca
Length of output: 28274
🏁 Script executed:
#!/bin/bash
printf '%s\n' '== transfer implementation =='
cat -n src/main/orca-profiles/profile-session-markdown-transfer.ts | sed -n '1,180p'
printf '%s\n' '== project session state implementation =='
cat -n src/main/orca-profiles/profile-project-session-state.ts | sed -n '110,175p'
printf '%s\n' '== projection and identity helpers =='
cat -n src/main/orca-profiles/profile-project-worktree-identity.ts | sed -n '1,125p'
cat -n src/main/orca-profiles/profile-session-owner-transfer.test.ts | sed -n '1,260p'
printf '%s\n' '== relevant diff =='
git diff --unified=30 c9918931c8e6fa23e311814eda9ca63589fe45a8 25b30470d8b2f864086d9d92e2cdd4dc79072355 -- src/main/orca-profiles/profile-session-markdown-transfer.ts src/main/orca-profiles/profile-project-session-state.ts src/main/orca-profiles/profile-project-worktree-identity.ts src/main/orca-profiles/profile-session-owner-transfer.test.tsRepository: stablyai/orca
Length of output: 31720
🏁 Script executed:
#!/bin/bash
printf '%s\n' '== mapWorktreeId bindings =='
rg -n -C5 'mapWorktreeId' src/main src/shared src/renderer
printf '%s\n' '== transfer callers =='
cat -n src/main/orca-profiles/profile-session-owner-transfer.ts | sed -n '1,220p'
cat -n src/main/orca-profiles/profile-project-session-transfer.ts | sed -n '1,240p'
printf '%s\n' '== persisted worktreeId hydration =='
rg -n -C5 'worktreeId.*file|file.*worktreeId|openFilesByWorktree' src/renderer/src/store src/main | head -240Repository: stablyai/orca
Length of output: 41675
🏁 Script executed:
#!/bin/bash
printf '%s\n' '== hydration implementation =='
rg -n -C8 'hydrateEditorSession|buildOwnedEditorFileId|PersistedOpenFile' src/renderer/src/store/slices src/renderer/src/lib | head -320
printf '%s\n' '== persisted open-file type and session serialization =='
rg -n -C8 'export (type|interface) PersistedOpenFile|worktreeId:.*PersistedOpenFile|openFilesByWorktree' src/shared src/main/persistence src/renderer/src/store | head -260Repository: stablyai/orca
Length of output: 41950
🏁 Script executed:
#!/bin/bash
printf '%s\n' '== hydration call =='
cat -n src/renderer/src/store/slices/editor/actions/hydrate-editor-session.ts | sed -n '42,95p'
printf '%s\n' '== transfer owner-key mapping =='
cat -n src/main/orca-profiles/profile-session-owner-transfer.ts | sed -n '27,70p'
cat -n src/main/orca-profiles/profile-project-session-transfer.ts | sed -n '20,40p'Repository: stablyai/orca
Length of output: 6296
Use the destination owner key for the transferred Markdown editor ID.
The real projection maps mapWorktreeId with rekeyWorktreeId, which leaves a host-qualified source key unchanged. Hydration uses the destination openFilesByWorktree owner key when it builds the editor ID. The transferred visibility override can therefore retain the source owner key and be missed.
The repository-removal path is correct. Do not add an unqualified candidate there.
Suggested fix
- if (!projection.mapOwnerKey(sourceOwnerKey)) {
+ const destinationWorktreeId = projection.mapOwnerKey(sourceOwnerKey)
+ if (!destinationWorktreeId) {
continue
}
- const destinationWorktreeId = projection.mapWorktreeId(sourceOwnerKey)
const sourceWorktreeIds = [sourceOwnerKey]📍 Affects 2 files
src/main/orca-profiles/profile-session-markdown-transfer.ts#L43-L48(this comment)src/main/orca-profiles/profile-project-session-state.ts#L141-L151
There was a problem hiding this comment.
ℹ️ No critical issues — a few edge-case suggestions inline.
Reviewed changes
- Frontmatter visibility transfer/prune:
markdownFrontmatterVisiblenow rekeys with the open-file identity on transfer and is pruned on repo removal; the field census andmergeWorkspaceSessionswere updated. - Owner projection extraction:
extractSessionOwnersForTransferandhasTransferredSessionStatemoved intoprofile-session-owner-transfer.ts;extractSessionForTransferis now a thinrekeyOwnerKey/rekeyWorktreeIdwrapper. - Markdown id mapping: new
profile-session-markdown-transfer.tsmaps hidden (false) overrides from source ids to destination ids, dropping ids two transferred files both claim. - Unified-only terminal layouts:
terminalLayoutsByTabIdand pane metadata now follow terminal tabs that exist only inunifiedTabs. - Tests: ported field-disposition cases plus a new
profile-session-owner-transfer.test.tsfor the rekey/ambiguity/merge behavior.
I ran the three changed test files (50 pass) and pnpm tc:node (clean). I also verified ownedEditorFileId is equivalent to the renderer's buildOwnedEditorFileId for all inputs, and traced the old-vs-new transfer path — the refactor is behavior-preserving for the forms current producers emit.
ℹ️ Nitpicks
- The ambiguity/owner test at
profile-session-owner-transfer.test.ts:37-62passes a hand-writtenmapWorktreeIdthat handles host-qualified keys, so it does not exercise the real projection'srekeyWorktreeId(which does not). It still pins the intended contract, but it masks that divergence rather than testing it.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
| continue | ||
| } | ||
| for (const file of files) { | ||
| markdownFileIdCandidates(file.filePath, ownerKey, file.runtimeEnvironmentId).forEach((id) => |
There was a problem hiding this comment.
markdownFileIdCandidates returns both the owned id and the bare filePath, and the filter below removes any markdownFrontmatterVisible key in that set. Hydration assigns the raw path id to only one owner of a given absolute filePath, so if a removed owner and a retained owner share that path, this can delete the retained owner's hidden override.
Technical details
# Removal prunes a retained owner's raw-path override
## Affected sites
- src/main/orca-profiles/profile-project-session-state.ts:147 — `markdownFileIdCandidates` includes the bare `filePath` for every file of the removed repo.
- src/main/orca-profiles/profile-project-session-state.ts:181-186 — the visibility map is filtered by membership in `removedMarkdownFileIds` alone.
## Why it can over-prune
- Hydration gives the raw `filePath` id to the first owner of that path; any other owner of the same path gets an owned id (`src/renderer/src/store/slices/editor/actions/hydrate-editor-session.ts:59-68`).
- Two repo ids sharing one absolute worktree path is possible (e.g. copying the same project twice into one target profile). If the *retained* owner holds raw id `P` and a removed owner has a file at `P`, `P` lands in `removedMarkdownFileIds` and the retained owner's override is dropped.
- Order-dependent, and the PR's removal test (`profile-project-session-field-disposition.test.ts:116-145`) uses distinct paths, so it is not caught.
## Required outcome
- Prune only overrides that cannot belong to a retained owner.
## Suggested approach (optional)
- Collect the `filePath`s of all retained owners' open files and exclude those raw paths from `removedMarkdownFileIds` (the owned-id candidates stay, since they encode the removed owner key).
## Open questions for the human
- Is registering two repo ids for the same absolute worktree path in one profile a supported flow? If not, this is unreachable and can stay as-is.| runtimeEnvironmentId: string | null | undefined | ||
| ): string { | ||
| const runtimeKey = runtimeEnvironmentId?.trim() || 'local' | ||
| return `editor:${encodeURIComponent(worktreeId)}:${encodeURIComponent(runtimeKey)}:${encodeURIComponent(filePath)}` |
There was a problem hiding this comment.
ownedEditorFileId reimplements the renderer's buildOwnedEditorFileId (src/renderer/src/store/slices/editor/file-ids/editor-file-ids.ts:40). The id format is a cross-process contract — if either copy changes, transferred overrides silently stop matching the ids hydration assigns. A shared helper/constant would keep main and renderer in lockstep; worth a comment at minimum noting the coupling.
| } | ||
|
|
||
| function mapTerminalTab(tab: TerminalTab, projection: SessionOwnerProjection): TerminalTab { | ||
| const { pendingActivationSpawn: _pendingActivationSpawn, ...persisted } = tab |
There was a problem hiding this comment.
mapTerminalTab strips the transient pendingActivationSpawn but leaves recovery, whereas buildSanitizedTabsByWorktree (src/renderer/src/lib/workspace-session.ts:207-217) strips both for the same reason. Not a regression — the old code carried both — but since this helper now strips one, stripping recovery too would match persistence.
| Object.keys(session.tabGroups ?? {}).length > 0 || | ||
| Object.keys(session.terminalLayoutsByTabId ?? {}).length > 0 || | ||
| SESSION_FIELDS_COPIED_BY_OWNER_KEY.some( | ||
| (field) => Object.keys(session[field] ?? {}).length > 0 |
There was a problem hiding this comment.
Indexed access breaks typechecking The field list is typed as any key of
WorkspaceSessionState, so session[field] can be a string. Object.keys requires an object, making the node typecheck fail on this line.
| (field) => Object.keys(session[field] ?? {}).length > 0 | |
| (field) => Object.keys((session[field] as Record<string, unknown> | undefined) ?? {}).length > 0 |
* Revert "feat(orcad): source-side dormant export of a relay-hosted SSH target (#16741 T6-8) (#24519)" This reverts commit 783101b. * Revert "feat(ssh): update, roll back, recover and stop a managed orcad server (#16741 T6-5 follow-up) (#24463)" This reverts commit 38c2d1d. * Revert "feat(ssh): deploy and pair an empty managed orcad server over SSH (#16741 T6-5) (#24453)" This reverts commit 8b76683. * Revert "fix(ssh): orcad GC honors the activation journal; readiness requires proven daemon coverage (#16741 T6 follow-up) (#24451)" This reverts commit d3f8c50. * Revert "feat(ssh): remote orcad stop by request file and journaled decommission (#16741 T6-4) (#24449)" This reverts commit 43d9b43. * Revert "feat(orcad): supervisable server: stop requests, managed stop receipts and a lifetime that keeps its lock on failed teardown (#16741 T6-3) (#24433)" This reverts commit b093d3a. * Revert "feat(ssh): crash-safe orcad activation, rollback and recovery (#16741 T6-2) (#24423)" This reverts commit 1a9ac0e. * Revert "feat(runtime): SSH access links for paired servers in a downgrade-safe sidecar (#16741 T5-1+T5-2) (#24420)" This reverts commit 99db2bf. * Revert "feat(relay): capability-gated owner reset with a durable preparation journal (#16741 T3 R1) (#24418)" This reverts commit 34a582b. * Revert "feat(ssh): track connection-manager drains, test probes and provider continuations (#16741 T2 P3+P8a) (#24407)" This reverts commit d53063d. * Revert "feat(daemon): idle retirement, session census and recovery-only provider (#16741 T2 P4b) (#24409)" This reverts commit ff212db. * Revert "feat(ssh): add pty.resumeClient and split SSH PTY process listing (#16741 T2 P5+P6) (#24414)" This reverts commit 92cb717. * Revert "feat(relay): await owned watcher and agent children on shutdown (#16741 T2 P1) (#24400)" This reverts commit 6b36e4f. * Revert "feat(session): retry failed renderer session writes and verify local folder PTYs (#16741 T2 P9) (#24406)" This reverts commit d23ecef. * Revert "feat(ssh): remote orcad primitives on the pinned Node runtime (#16741 T6-1) (#24419)" This reverts commit dd87ae5. * Revert "fix(runtime): fence runtime-environment subscriptions and status probes by identity (#16741 T5-3) (#24421)" This reverts commit ece9e4d. * Revert "feat(orcad): migration manifest and dormant-state contracts (#16741 T6-7) (#24422)" This reverts commit 3fbdaba. * Revert "feat(ssh): wire SshConnection through the work and transport close ledgers (#16741 T2 P2) (#24401)" This reverts commit 4e8edc8. * Revert "feat(profiles): carry markdown frontmatter visibility in project transfers (#16741 T2 P7) (#24405)" This reverts commit 60c9326. * Revert "fix(runtime): project the PTY incarnation onto mobile session tabs (#24413)" This reverts commit 99e0303. * Revert "feat(daemon): tag daemon stream data with the PTY incarnation id (#16741 T2 P4a) (#24402)" This reverts commit 817af76. * Revert "feat(ssh): port the SSH connection work ledger and transport close ledger (#16741 T2) (#24210)" This reverts commit c991893. * Revert "feat(relay): fence and drain file and git response streams on shutdown (#24185)" This reverts commit dc08ffe. * Revert "refactor(runtime-rpc): extract the Node WebSocket lifecycle; opt-in pinned port (#24186)" This reverts commit a789233. * Revert "feat(relay): route relay handlers through work admission; producer publication drain (#24181)" This reverts commit 0b812bd. * Revert "feat(relay): land the #16741 T1 seam (work drain, publication drain, release gate) (#24156)" This reverts commit 3aa2d3a. --------- Co-authored-by: m4air <[email protected]>

ELI5
In Orca you can hide the frontmatter block (the metadata header) at the top of a markdown file. That choice was lost when you moved a project to another profile. It now moves with the project. Removing a project also cleans up the hidden-frontmatter choices that belonged to its files, instead of leaving them behind.
This is the T2 P7 slice of porting #16741 (profile project transfer of session owners).
What Changed
Before:
markdownFrontmatterVisible).After:
false) overrides travel. Visible is the default when a session loads.removeRepoFromWorkspaceSessiondrops the overrides that belonged to the removed repo's open files.mergeWorkspaceSessionsmerges the overrides into the destination profile's session.profile-session-owner-transfer.ts, exported asextractSessionOwnersForTransferfor later reuse.extractSessionForTransferis now a thin repo-rekey wrapper over it. Markdown id mapping lives inprofile-session-markdown-transfer.ts.markdownFrontmatterVisible.Why
This only changes how session data is reshaped in memory. Reading and writing still go through main's current profile store (
readProfileProjectTransferStateandwriteProfileProjectDomainChanges), not the old JSON files. Folder workspaces and git worktrees both go through the same owner-key rekeying that already exists (rekeyOwnerKey).Adapted from #16741 (a68b6f3), by hunk:
src/main/runtime/client-hosted-browser-page-persistence.ts, which is outside this slice. It should come with that change, not before it.activeRepoId/execution-host focus merge. On the branch, only the orcad source-session mirror (T6) produces these, through theprojectSleepingAgentSessionandprojectSessionFocushooks. A plain profile transfer never emits them. Those hooks are left out, and the census keeps sleeping sessions as not transferred.docLocationremap.WorkspaceKeytype assertion with the existingisWorkspaceKeyguard.Linked Issue
Part of the Node runtime plan (Phase 3), porting #16741.
Visual Proof
N/A. Nothing in the UI changes. The difference is whether a hidden-frontmatter choice survives a profile move.
Testing
Field-disposition tests (ported):
New
profile-session-owner-transfer.test.ts:Regression: every
src/main/orca-profiles/*.test.tsandsrc/main/persistence/profile-state/*.test.ts. 83 files: 80 passed, 1 skipped. 2 profile-state SQLite backup files time out at 30s on this machine, and they also time out on an unrelated worktree off main, so this change doesn't cause them.macOS locally.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.