Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
560a88a
feat(native-chat): show each interrupted chat's workspace as its read…
brennanb2025 Oct 5, 2026
b956288
test(native-chat): name the nesting helper for what it returns
brennanb2025 Oct 5, 2026
a27b59e
fix(native-chat): resume dialog cards show no status
brennanb2025 Oct 5, 2026
0163c9c
fix(sidebar): a read-only card is inert and shows no live state, what…
brennanb2025 Oct 5, 2026
fd3cbbe
fix(native-chat): nest and indent the resume dialog's child workspace…
brennanb2025 Oct 5, 2026
ead9ca8
fix(native-chat): the resume dialog places every workspace even if li…
brennanb2025 Oct 5, 2026
0736622
fix(native-chat): keep "Don't ask again" above the resume dialog's bu…
brennanb2025 Oct 5, 2026
b05eaab
test(sidebar): import the card statically in the read-only contract test
brennanb2025 Oct 5, 2026
756fa06
fix(sidebar): legacy lineage children step in as far without a status…
brennanb2025 Oct 5, 2026
50351c1
fix(native-chat): nest resume dialog children by the sidebar's own ro…
brennanb2025 Oct 5, 2026
186bbf2
test(sidebar): pin child-workspace indent with and without a status lane
brennanb2025 Oct 5, 2026
ff1b786
fix(sidebar): a read-only card's child workspaces step in as the side…
brennanb2025 Oct 5, 2026
7a92bde
Merge origin/main into brennanb2025/resume-modal-sidebar-cards
brennanb2025 Oct 5, 2026
5e73d7e
test(sidebar): a read-only card never carries main's multi-selected m…
brennanb2025 Oct 5, 2026
d92d318
fix(sidebar): preserve quiet read-only card geometry
brennanb2025 Oct 6, 2026
cf86c0b
fix(native-chat): match resume cards to sidebar rows
brennanb2025 Oct 6, 2026
f0004d0
fix(sidebar): preserve passive SSH identity on read-only cards
brennanb2025 Oct 6, 2026
404de10
fix(native-chat): keep resume focus and folder host identity
brennanb2025 Oct 6, 2026
1140cca
fix(native-chat): remove resume dialog list border
brennanb2025 Oct 6, 2026
07ad990
fix(sidebar): keep passive SSH pills static
brennanb2025 Oct 6, 2026
dc8cc8b
fix(native-chat): align resume card vertical spacing
brennanb2025 Oct 6, 2026
4b21e08
fix(native-chat): preserve cache-only card header spacing
brennanb2025 Oct 6, 2026
35d9d07
Merge remote-tracking branch 'origin/main' into brennanb2025/resume-m…
brennanb2025 Oct 7, 2026
c2e4d93
fix(native-chat): lay the resume dialog out as a checkbox-column list
brennanb2025 Oct 7, 2026
9e4f9b7
Merge remote-tracking branch 'origin/main' into brennanb2025/resume-m…
brennanb2025 Oct 7, 2026
2405257
fix(native-chat): name SSH hosts by their saved label in the resume d…
brennanb2025 Oct 7, 2026
f762e68
Merge remote-tracking branch 'origin/main' into brennanb2025/resume-m…
brennanb2025 Oct 7, 2026
b108fbb
fix(native-chat): group the resume list in bands and let a project se…
brennanb2025 Oct 7, 2026
4b92273
Merge remote-tracking branch 'origin/main' into brennanb2025/resume-m…
brennanb2025 Oct 7, 2026
73d1874
fix(native-chat): no project row for workspaces the resume list canno…
brennanb2025 Oct 7, 2026
8deb3a9
fix(native-chat): lay the resume list out as nested workspace boxes
brennanb2025 Oct 7, 2026
a560331
Merge remote-tracking branch 'origin/main' into brennanb2025/resume-m…
brennanb2025 Oct 7, 2026
ad09bff
feat(native-chat): resume interrupted chats on every machine: reconne…
brennanb2025 Oct 8, 2026
3445654
fix(native-chat): a resume dialog request always has something to dra…
brennanb2025 Oct 8, 2026
2aebf53
fix(native-chat): show the resume list as a tree
brennanb2025 Oct 8, 2026
6c316fe
Merge remote-tracking branch 'origin/main' into brennanb2025/resume-m…
brennanb2025 Oct 8, 2026
2bdcd7c
fix(native-chat): judge "the resume dialog is on screen" when asked, …
brennanb2025 Oct 8, 2026
0175ddf
refactor(native-chat): read each resume chat through one key helper
brennanb2025 Oct 8, 2026
25cefbc
fix(native-chat): make the resume tree's keys work from its Tab stop …
brennanb2025 Oct 8, 2026
10478ae
Merge #25652 6c316fe9c0c (the resume tree; carries main 7c88ab7dd55) …
brennanb2025 Oct 8, 2026
6bcab27
fix(native-chat): look up a machine node's host by the plain string i…
brennanb2025 Oct 8, 2026
ded5c15
Merge #25652 25cefbc5db1 (one key helper; tree keys from its Tab stop…
brennanb2025 Oct 8, 2026
996e884
fix(native-chat): a machine's opened/closed choice belongs to the lis…
brennanb2025 Oct 8, 2026
9b6b7f7
Merge origin/main a4854ac1e96 into brennanb2025/rsc-resume-reconnect …
brennanb2025 Oct 8, 2026
863e138
refactor(native-chat): keep the paired restart-offer capability besid…
brennanb2025 Oct 8, 2026
9bcde43
Merge origin/main e3639ef8d69 into brennanb2025/rsc-resume-reconnect
brennanb2025 Oct 8, 2026
530e41d
Merge origin/main cf5dda642d9 into brennanb2025/rsc-resume-reconnect
brennanb2025 Oct 10, 2026
5927e5d
Merge origin/main 5462b5bd7ac into brennanb2025/rsc-resume-reconnect
brennanb2025 Oct 10, 2026
d86e4ca
fix(native-chat): keep per-machine resume runs consistent with the di…
brennanb2025 Oct 10, 2026
60aa16f
fix(native-chat): name a resumed chat's origin from the row the dialo…
brennanb2025 Oct 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { AgentSessionResumeTrigger } from '../../../shared/agent-session-re
import { SUPERVISED_GRACEFUL_EXIT_MS } from '../../claude/claude-child-exit-proof-ladder'
import { PROVIDER_SUPERVISOR_MAX_STOP_MS } from '../../provider-process/provider-process-supervisor'
import { SNAPSHOT_DRAIN_TIMEOUT_MS } from './structured-agent-session-eviction'
import type { StructuredAgentSessionRestartResume } from './structured-agent-session-restart-resume-host'
import type { StructuredAgentSessionRestartResume } from './structured-agent-session-restart-resume-contract'
import {
evictOwnedStructuredAgentSessions,
type StructuredAgentSessionLifetimeContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export class TrackedTestRecoveryCapsule extends AgentSessionRecoveryCapsule {
return this.track(super.dismiss(...args))
}

override dismissListed(...args: Parameters<Capsule['dismissListed']>) {
return this.track(super.dismissListed(...args))
}

override forgetSuperseded(...args: Parameters<Capsule['forgetSuperseded']>) {
return this.track(super.forgetSuperseded(...args))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ import { StructuredAgentSessionEventRecovery } from './structured-agent-session-
import { StructuredAgentSessionBackgroundTaskChannel } from './structured-agent-session-background-task-channel'
import { StructuredAgentSessionClientDelivery } from './structured-agent-session-client-delivery'
import { StructuredAgentSessionConversations } from './structured-agent-session-conversations'
import {
createStructuredAgentSessionRestartResume,
type StructuredAgentSessionRestartResume
} from './structured-agent-session-restart-resume-host'
import { createStructuredAgentSessionRestartResume } from './structured-agent-session-restart-resume-host'
import type { StructuredAgentSessionRestartResume } from './structured-agent-session-restart-resume-contract'
import { structuredAgentSessionRestartResumeSurfaces } from './structured-agent-session-restart-resume-wiring'
import * as conversation from './structured-agent-session-host-delivery'
import { structuredAgentSessionConversationFence } from './structured-agent-session-provider-child'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ it('neither lists nor dismisses an offer the caller cannot show', async () => {
expect(await offersIn(root)).toEqual([])
})

it('does not dismiss an offer the caller cannot show, even listed with its interruption', async () => {
const { host, root } = await interruptedRestart()
const [offer] = await host.restartResume.list()
const listed = [{ sessionId: SESSION, recordedAt: offer!.recordedAt }]

expect(await host.restartResume.dismissListed(listed, cannotShowCodex)).toBe(0)
expect(await offersIn(root)).toHaveLength(1)
expect(await host.restartResume.dismissListed(listed, showsCodex)).toBe(1)
expect(await offersIn(root)).toEqual([])
})

it('neither continues nor reserves an offer the caller cannot show, named or not', async () => {
const { host, root, acquire, dispatch } = await interruptedRestart()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import type {
AgentSessionRecoveryCapsule,
AgentSessionResumeFailureInput,
AgentSessionResumeFailureRecord
AgentSessionResumeFailureRecord,
ListedRestartOffer
} from '../../runtime/agent-session-recovery-capsule'
import type { AgentSessionRecord } from '../../../shared/agent-session-record'
import type {
Expand All @@ -34,7 +35,13 @@ import type { StructuredAgentSessionLogger } from './structured-agent-session-lo

type FailureCapsule = Pick<
AgentSessionRecoveryCapsule,
'listFailed' | 'completeResume' | 'failResume' | 'rollbackResume' | 'dismiss' | 'clearAll'
| 'listFailed'
| 'completeResume'
| 'failResume'
| 'rollbackResume'
| 'dismiss'
| 'dismissListed'
| 'clearAll'
>

export type StructuredAgentSessionRestartFailureLedger = {
Expand Down Expand Up @@ -65,6 +72,12 @@ export type StructuredAgentSessionRestartFailureLedger = {
beforeClearAll: (audience?: StructuredAgentSessionRestartAudience) => void | Promise<void>,
audience?: StructuredAgentSessionRestartAudience
) => Promise<number>
/** Forgets offers exactly as a client listed them; see the capsule's `dismissListed`. With an
* audience, only records of agents it sees go. */
dismissListed: (
listed: readonly ListedRestartOffer[],
audience?: StructuredAgentSessionRestartAudience
) => Promise<number>
}

/** Which continuation outcomes count as the agent not carrying on, and how each is filed. */
Expand Down Expand Up @@ -252,6 +265,17 @@ export function createStructuredAgentSessionRestartFailureLedger(deps: {
// A newer Orca's offers and failures were never shown here, so "dismiss all" keeps them.
const keep = (marker: AgentSessionResumeMarker) => deps.savedByNewerOrca(marker.sessionId)
return (await deps.capsule?.clearAll(deps.now(), keep)) ?? 0
}),
dismissListed: (listed, audience) =>
deps.enqueue(async () => {
// Decided under the capsule lock, as `dismiss` does.
const hidden = audience
? (marker: AgentSessionResumeMarker) => {
const record = deps.getRecord(marker.sessionId)
return record === null || !audience(record.provider)
}
: undefined
return (await deps.capsule?.dismissListed(listed, deps.now(), hidden)) ?? 0
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -518,3 +518,24 @@ it('files a restart refused by a conflicted claim under its code, with its detai
])
)
})

it('continues a chat once when two desktops both resume it, and the second hears nothing failed', async () => {
const { host } = await interruptedRestart()
await host.restartResume.list()

const [first, second] = await Promise.all([
host.restartResume.continueAfterRestart([SESSION], 'desktop-a'),
host.restartResume.continueAfterRestart([SESSION], 'desktop-b')
])
const later = await host.restartResume.continueAfterRestart([SESSION], 'desktop-b')

expect([...first.continued, ...second.continued]).toMatchObject([{ outcome: 'continued' }])
// The loser reserved nothing, so it sent nothing and has no failure to file or report.
expect(later.continued).toEqual([])
expect([...first.failed!, ...second.failed!, ...later.failed!]).toEqual([])
expect(
(await statusNotes(host)).filter(
(note) => note.text === AGENT_SESSION_RESTART_CONTINUATION_NOTE
)
).toHaveLength(1)
})
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// What a host's restart-resume surface offers: teardown's offer recording, the offer list and its
// actions, and Continue on a cut reply.

import type { ListedRestartOffer } from '../../runtime/agent-session-recovery-capsule'
import type { AgentSessionResumeTrigger } from '../../../shared/agent-session-resume-marker'
import type { createInterruptedContinuation } from './structured-agent-session-interrupted-continuation'
import type { StructuredAgentSessionContinuationOutcome } from './structured-agent-session-restart-continuation'
Expand Down Expand Up @@ -44,6 +45,12 @@ export type StructuredAgentSessionRestartResume = {
sessionIds?: readonly string[],
audience?: StructuredAgentSessionRestartAudience
) => Promise<number>
/** Forgets offers exactly as a client listed them: a chat interrupted again since, or being
* resumed by another action right now, keeps its record. An audience limits it as `dismiss`. */
dismissListed: (
listed: readonly ListedRestartOffer[],
audience?: StructuredAgentSessionRestartAudience
) => Promise<number>
/** The chat's agent proved a start: its offer ends unless the start is a resume's own. */
onAgentStarted: (sessionId: string) => void
/** Continue on a reply an Orca stop cut off, offer or not; the send itself retires any offer. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ export function createStructuredAgentSessionRestartResume(
},
audience
),
dismissListed: failures.dismissListed,

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.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
# Inspect the listed-dismissal path and the teardown witness publication path.
ast-grep outline src/main/native-chat/agent-session-wire/structured-agent-session-restart-failure-ledger.ts --items all
rg -n -C 8 'dismissListed|witnesses\.clear|witnesses\.record|enqueueRecoveryOperation' \
  src/main/native-chat/agent-session-wire/structured-agent-session-restart-failure-ledger.ts \
  src/main/native-chat/agent-session-wire/structured-agent-session-restart-resume-host.ts

Repository: stablyai/orca

Length of output: 28142


🏁 Script executed:

set -e
printf '%s\n' '--- witness references ---'
rg -n -F --glob '*.ts' -- 'createStructuredAgentSessionRestartWitnesses' src/main/native-chat/agent-session-wire
rg -n -F --glob '*.ts' -- 'dismissListed' src/main/native-chat/agent-session-wire src/main/runtime
printf '%s\n' '--- witness and queue files ---'
rg --files src/main/native-chat/agent-session-wire src/main/runtime | rg 'restart-(witness|operation|resume|failure)|recovery-capsule'
printf '%s\n' '--- witness implementation ---'
w=$(rg -l -F --glob '*.ts' -- 'export function createStructuredAgentSessionRestartWitnesses' src/main/native-chat/agent-session-wire)
sed -n '1,280p' "$w"
printf '%s\n' '--- operation queue implementation ---'
q=$(rg -l -F --glob '*.ts' -- 'createStructuredAgentSessionRestartOperationQueue' src/main/native-chat/agent-session-wire)
sed -n '1,220p' "$q"
printf '%s\n' '--- recovery capsule definitions and listed dismissal ---'
rg -n -C 12 -F -- 'dismissListed' src/main/runtime src/main/shared src/main/native-chat/agent-session-wire

Repository: stablyai/orca

Length of output: 9646


🏁 Script executed:

set -e
printf '%s\n' '--- operation queue ---'
sed -n '1,220p' src/main/native-chat/agent-session-wire/structured-agent-session-restart-operation-queue.ts
printf '%s\n' '--- recovery capsule API and methods ---'
sed -n '1,340p' src/main/runtime/agent-session-recovery-capsule.ts
printf '%s\n' '--- related tests ---'
sed -n '1,360p' src/main/native-chat/agent-session-wire/structured-agent-session-restart-witnesses.test.ts
sed -n '240,315p' src/main/runtime/agent-session-recovery-capsule.test.ts

Repository: stablyai/orca

Length of output: 20722


Clear teardown witnesses during listed dismissal.

If dismissListed runs before a queued witness record, the witness remains in confirmed and can be recorded after the listed offer is removed. Clear the applicable witnesses before delegating the dismissal.

🐛 Suggested fix
--- "a/src/main/native-chat/agent-session-wire/structured-agent-session-restart-resume-host.ts"
+++ "b/src/main/native-chat/agent-session-wire/structured-agent-session-restart-resume-host.ts"
@@ -319,7 +319,10 @@
         },
         audience
       ),
-    dismissListed: failures.dismissListed,
+    dismissListed: (listed, audience) => {
+      witnesses.clear(audience)
+      return failures.dismissListed(listed, audience)
+    },
     continueAfterRestart,
     onAgentStarted: withdrawal.onAgentStarted,
     continueInterrupted: createInterruptedContinuation(continuationHost, readMarkers)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
dismissListed: failures.dismissListed,
dismissListed: (listed, audience) => {
witnesses.clear(audience)
return failures.dismissListed(listed, audience)
},

continueAfterRestart,
onAgentStarted: withdrawal.onAgentStarted,
continueInterrupted: createInterruptedContinuation(continuationHost, readMarkers)
Expand Down
80 changes: 77 additions & 3 deletions src/main/runtime/agent-session-recovery-capsule-entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,90 @@ export function shouldReplaceMarker(
/** Records "dismiss all" leaves as they were: this host does not list them (a newer Orca's chats). */
export type KeepRecord = (marker: AgentSessionResumeMarker) => boolean

/** What a "dismiss all" keeps, and how many pending offers it ends. */
/** What a "dismiss all" keeps, and how many pending offers it ends. A chat another action is
* resuming right now (another device's, on a shared host) stays with its earlier failure for that
* action to settle; the action lease ends a reservation whose action died. */
export function splitDismissedAll(
state: Pick<RecoveryCapsuleState, 'entries' | 'failed'>,
keep: KeepRecord
): { kept: Pick<RecoveryCapsuleState, 'entries' | 'failed'>; dismissedPending: number } {
const entries = state.entries.filter((entry) => keep(entry.marker))
const resuming = new Set(
state.entries
.filter((entry) => entry.state === 'in-progress')
.map((entry) => entry.marker.sessionId)
)
const kept = (marker: AgentSessionResumeMarker): boolean =>
resuming.has(marker.sessionId) || keep(marker)
return {
kept: { entries, failed: state.failed.filter((failure) => keep(failure.marker)) },
kept: {
entries: state.entries.filter((entry) => kept(entry.marker)),
failed: state.failed.filter((failure) => kept(failure.marker))
},
dismissedPending: state.entries.filter(
(entry) => entry.state === 'pending' && !keep(entry.marker)
).length
}
}

/** One offer as a client listed it: the chat and the interruption it was shown. */
export type ListedRestartOffer = { sessionId: string; recordedAt: number }

/** What dismissing listed offers keeps: a record no longer the one listed (a newer interruption),
* and every record of a chat another action is resuming right now. */
export function splitDismissedListed(
state: Pick<RecoveryCapsuleState, 'entries' | 'failed'>,
listed: readonly ListedRestartOffer[],
keepRecord: KeepRecord = () => false
): { kept: Pick<RecoveryCapsuleState, 'entries' | 'failed'>; dismissed: Set<string> } {
const shown = new Map(listed.map((offer) => [offer.sessionId, offer.recordedAt]))
const resuming = new Set(
state.entries
.filter((entry) => entry.state === 'in-progress')
.map((entry) => entry.marker.sessionId)
)
const dismissed = new Set<string>()
const keep = (marker: AgentSessionResumeMarker): boolean => {
if (
resuming.has(marker.sessionId) ||
shown.get(marker.sessionId) !== marker.recordedAt ||
keepRecord(marker)
) {
return true
}
dismissed.add(marker.sessionId)
return false
}
return {
kept: {
entries: state.entries.filter((entry) => keep(entry.marker)),
failed: state.failed.filter((failure) => keep(failure.marker))
},
dismissed
}
}

/** Records the chat itself has since superseded go; witness-keyed, so a newer record stays. */
export function withoutSuperseded(
state: Pick<RecoveryCapsuleState, 'entries' | 'failed'>,
superseded: readonly { sessionId: string; recordedAt: number; failedAt?: number }[]
): Pick<RecoveryCapsuleState, 'entries' | 'failed'> {
return {
entries: state.entries.filter(
(entry) =>
entry.state !== 'pending' ||
!superseded.some(
(gone) =>
gone.failedAt === undefined &&
gone.sessionId === entry.marker.sessionId &&
gone.recordedAt === entry.marker.recordedAt
)
),
failed: state.failed.filter(
(failure) =>
!superseded.some(
(gone) =>
gone.sessionId === failure.marker.sessionId && gone.failedAt === failure.failedAt
)
)
}
}
20 changes: 20 additions & 0 deletions src/main/runtime/agent-session-recovery-capsule-read.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { readNodeFileWithinLimit } from '../../shared/node-bounded-file-reader'
import { parseState, type RecoveryCapsuleState } from './agent-session-recovery-capsule-entries'

export const MAX_RECOVERY_CAPSULE_BYTES = 4 * 1024 * 1024

/** The capsule as stored; a missing file is an empty one. Callers hold the file's lock. */
export async function readRecoveryCapsuleState(filePath: string): Promise<RecoveryCapsuleState> {
let raw: string
try {
raw = (await readNodeFileWithinLimit(filePath, MAX_RECOVERY_CAPSULE_BYTES)).buffer.toString(
'utf8'
)
} catch (error) {
if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {
return { entries: [], failed: [] }
}
throw error
}
return parseState(raw)
}
62 changes: 58 additions & 4 deletions src/main/runtime/agent-session-recovery-capsule.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,33 @@ describe('durable restart offers', () => {
expect(await capsule.list(NOW)).toEqual([marker({ sessionId: 'third' }), marker()])
})

it('forgets listed records only while they are still the interruption the client listed', async () => {
await capsule.record(
[marker(), marker({ sessionId: 'second' }), marker({ sessionId: 'third' })],
NOW
)
// Interrupted again after the listing: the newer offer was never shown, so it stays.
await capsule.record([marker({ sessionId: 'second', recordedAt: NOW + 5 })], NOW + 5)

const listed = [SESSION, 'second', 'third'].map((sessionId) => ({ sessionId, recordedAt: NOW }))
expect(await capsule.dismissListed(listed, NOW + 6)).toBe(2)
expect(await capsule.list(NOW + 6)).toEqual([
marker({ sessionId: 'second', recordedAt: NOW + 5 })
])
})

it('leaves a listed chat another action is resuming, and its earlier failure, to that action', async () => {
await capsule.record([marker()], NOW)
await fileFailure()
// A retry on another desktop reserves the failed chat; this desktop listed it before that.
await capsule.beginResume([SESSION], 'operation-b', NOW)

expect(await capsule.dismissListed([{ sessionId: SESSION, recordedAt: NOW }], NOW)).toBe(0)
expect(await capsule.listFailed(NOW)).toHaveLength(1)
await capsule.failResume('operation-b', [failure({ reason: 'retry_failed' })], NOW)
expect(await capsule.listFailed(NOW)).toMatchObject([{ reason: 'retry_failed' }])
})

it('forgets every record of any state except the ones kept, without a fence', async () => {
await capsule.record(
[marker(), marker({ sessionId: 'second' }), marker({ sessionId: 'kept' })],
Expand Down Expand Up @@ -487,16 +514,17 @@ describe('durable restart offers', () => {
expect(await capsule.list(later)).toEqual([])
})

it('dismisses pending and active recovery records', async () => {
// On a shared host the action may be another device's resume: dismissing what this listing showed
// must not take its reservation, or a refusal it meets would never be filed.
it('dismisses pending records and leaves a chat another action is resuming to that action', async () => {
await capsule.record([marker(), marker({ sessionId: 'second' })], NOW)
await capsule.beginResume([SESSION], 'operation-a', NOW)

expect(await capsule.clearAll(NOW)).toBe(1)
expect(await capsule.list(NOW)).toEqual([])

// A later failed action cannot resurrect a record the user explicitly dismissed.
await capsule.rollbackResume('operation-a', NOW)
expect(await capsule.list(NOW)).toEqual([])
await capsule.failResume('operation-a', [failure()], NOW)
expect(await capsule.listFailed(NOW)).toMatchObject([{ marker: marker() }])
})

it('fences a late teardown write until a genuinely newer interruption', async () => {
Expand Down Expand Up @@ -647,3 +675,29 @@ it('does not retain lock timers after reads, writes, or failed publications', as
vi.useRealTimers()
}
})

describe('whether the capsule holds anything', () => {
it('is no for a missing file and for one every record left', async () => {
expect(await capsule.holdsAnyRecord()).toBe(false)
await capsule.record([marker()], NOW)
await capsule.dismiss([SESSION], NOW)
expect(await capsule.holdsAnyRecord()).toBe(false)
})

it('counts a pending offer, a reservation, and a filed failure alike', async () => {
await capsule.record([marker()], NOW)
expect(await capsule.holdsAnyRecord()).toBe(true)
await capsule.beginResume([SESSION], 'operation-a', NOW)
// Reserved, so the listing no longer shows it — the file still holds it.
expect(await capsule.list(NOW)).toEqual([])
expect(await capsule.holdsAnyRecord()).toBe(true)
await capsule.failResume('operation-a', [failure()], NOW)
expect(await capsule.list(NOW)).toEqual([])
expect(await capsule.holdsAnyRecord()).toBe(true)
})

it('counts unreadable bytes as holding something', async () => {
await writeFile(filePath, '{not json')
expect(await capsule.holdsAnyRecord()).toBe(true)
})
})
Loading
Loading