fix(persistence): worktree meta and lineage writes take the row's host, not the id (R4-2b) (#30811)

* fix(persistence): worktree meta and lineage writes take the row's host, not the id (R4-2b)

* fix(persistence): review fixes for host-targeted worktree writes

* test: SAFETY notes on partial runtime store mocks

* test: drop imports duplicated by the rebase onto #30797
This commit is contained in:
Neil
2026-10-19 11:39:54 -07:00
committed by GitHub
parent 86ef00ad55
commit eedca5ee1c
142 changed files with 1625 additions and 772 deletions
@@ -46,6 +46,7 @@ import {
readLaunchedAgentForeground,
type LaunchedAgentForeground
} from '../launched-agent-foreground'
import { worktreeRowTarget } from '../../persistence/host-qualified-worktree-meta'
export abstract class OrcaRuntimeWithActivateManagedWorktree extends OrcaRuntimeWithListManagedWorktrees {
protected abstract toAgentSessionOptions(
@@ -82,10 +83,15 @@ export abstract class OrcaRuntimeWithActivateManagedWorktree extends OrcaRuntime
const targetsHost = navigationTargetsHost(navigation)
const targetsClients = navigationTargetsClients(navigation)
if (!targetsHost && this.store?.getWorktreeMeta(worktree.id)?.isUnread) {
const target = this.store ? worktreeRowTarget(this.store, worktree) : undefined
if (
!targetsHost &&
target &&
this.store?.getWorktreeMetaForHost?.(target.id, target.hostId)?.isUnread
) {
// Why: mobile/web session activation intentionally bypasses renderer
// selection, so the runtime must acknowledge the unread state itself.
this.store.setWorktreeMeta(worktree.id, { isUnread: false })
this.store.setWorktreeMeta(target, { isUnread: false })
this.notifyWorktreesChanged(repo.id)
}
@@ -460,6 +460,7 @@ describe('first-work rename lazy Store capabilities', () => {
branchPrefixCustom: ''
}),
getRepo: () => undefined,
getRepos: () => [],
getWorktreeMeta: () => undefined,
setWorktreeMeta: vi.fn()
}
@@ -42,6 +42,7 @@ import {
resolveAgentTerminalCreateOptions,
withHostAccountLaunchEnv
} from '../runtime-agent-terminal-startup'
import { removeWorktreeMetaRow } from '../../persistence/host-qualified-worktree-meta'
export abstract class OrcaRuntimeWithResolveWorktreeRemovalTarget extends OrcaRuntimeWithRemoveManagedWorktree {
protected abstract resolveExplicitWorktreeIdScoped(
@@ -158,11 +159,7 @@ export abstract class OrcaRuntimeWithResolveWorktreeRemovalTarget extends OrcaRu
)
const acceptedRendererSnapshot = this.acceptedRendererMobileSnapshotByWorktree.get(worktreeId)
const storedSnapshot = this.mobileSessionTabsByWorktree.get(worktreeId)
if (hostId) {
store.removeWorktreeMeta(worktreeId, hostId)
} else {
store.removeWorktreeMeta(worktreeId)
}
removeWorktreeMetaRow(store, worktreeId, hostId)
// Why outside the same-id gate: retirement is per host and per pane, so a surviving owner keeps its own.
this.dropAgentStatusForRemovedWorktreeFn?.(worktreeId, hostId ?? persistedHostId)
if (!preservesSameIdOwner) {