Skip to content

feat(harness): resume Assistant from retained history [SAP-3292] - #1016

Closed
ynadge wants to merge 1 commit into
assistant-resume-preflightfrom
assistant-resume-controls
Closed

ynadge wants to merge 1 commit into
assistant-resume-preflightfrom
assistant-resume-controls

Conversation

@ynadge

@ynadge ynadge commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Primary change type

  • Feature

Problem and motivation

Users can read retained Assistant history but need a verified, explicit way to reopen the original conversation without starting work.

Summary and scope

Add Check Resume availability and Resume Assistant to retained history. Preserve the operation UUID across uncertain responses and navigation retries. Adopt a result only while account, host, selection and foreground intent still match; newer bus state owns Terminal status. Show missing native history separately from unavailable original context. A restarted Assistant opens paused.

Related work

Related issue: https://linear.app/sapiom/issue/SAP-3292

Depends on #1015. Native stack target: main. Public route wiring follows.

Validation

History/Resume, End and legacy Terminal transcript browser cases — 31 passed
Chat default, draft, authority, lease and foreground regression cases — 13 passed
Three deliberate mutations — detected, source restored, final checks passed
Frontend TypeScript, scoped ESLint, formatting and diff checks — passed (2 existing warnings)

Tests and documentation

Reviewed desktop and mobile Resume, native paused history, and missing-history/context screenshots. Browser evidence and mutation logs are retained in the task workspace. These fixtures validate UI behavior; native and installed-runtime proof is separate. Updated assistant-history.md. Increment:807 changed lines including tests/docs/changeset; SDK pr:size is absent.

Compatibility and release impact

  • Terminal remains the default. Reading history starts no native runtime.
  • Changeset: @sapiom/harness patch.
  • Fix-forward: keep explicit Resume, exact operation identity and account/navigation fences while correcting presentation or adoption.

Security

  • No secrets, credentials, private data, or unsanitized logs included.
  • No suspected vulnerability disclosed publicly.

AI assistance

  • AI assistance used: Codex implemented the approved flow, ran browser and mutation checks, and reviewed the rendered states.

Checklist

  • CONTRIBUTING.md read; maintainer-authorized issue work.
  • One focused increment, checks, documentation and release impact addressed.
  • I can explain and maintain the submitted changes.

Devin Review

Review evidence

These images show disposable browser fixture states before and after an explicit user action, not a historical pre-implementation baseline. They do not establish native execution or an installed activated release.

Before action After action
Before action After action

@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 6a6a369e-ae2a-4e4c-9402-d02d9dd46551

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@devin-ai-integration devin-ai-integration 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.

Devin Review found 3 potential issues.

Devin Review

Comment on lines +43 to +44
const response = await fetch(
`/api/sessions/${encodeURIComponent(entry.harnessSessionId)}/assistant/${action}`,

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.

🔴 Resume controls always return 404

assistantActionRequest posts to two routes the server never registers. Every availability check and Resume attempt fails outside the mocked tests.

Learn more

The browser sends both actions through assistantActionRequest, but createAssistantRecordsRouter only registers history listing and record reading. The main server mounts that router under /api, then eventually returns 404 for unmatched API requests. The Playwright setup intercepts both missing routes, so its successful Resume scenarios do not exercise production route wiring.

Example: Clicking “Check Resume availability” sends POST /api/sessions/assistant-only/assistant/inspect. No Express handler matches it, so the response is 404 and the UI reports that restoration failed instead of revealing “Resume Assistant.”

Recommended fix: Add boot-token-gated POST /sessions/:id/assistant/inspect and POST /sessions/:id/assistant/resume handlers to createAssistantRecordsRouter. Wire them to AssistantNativeHistory.inspect and AssistantNativeHistory.resume, validate expectedRevision and operationId, map transport failures to the documented response shape, and add server integration tests for both routes.

Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +51 to +52
operations.delete(`${entry.harnessSessionId}:${observedRevision.current}`);
observedRevision.current = current.lifecycle.revision;

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.

🟡 Uncertain Resume loses operation identity

operations.delete removes the UUID when a committed Resume publishes its lifecycle before the response fails. Retrying creates another operation instead of reconciling the first.

Learn more

Resume stores its UUID under the inspected lifecycle revision before sending the request. The server publishes the committed lifecycle before returning HTTP, so a lost response can leave the browser observing a newer revision while busy === "resume". Once the failed request clears busy, this effect treats that known commit as an unrelated lifecycle change and deletes the UUID for the original revision. The next availability check targets the newer revision, and Resume allocates a different UUID.

Example: Revision 2 resumes with operation A. The server commits revision 3 and publishes it, but the HTTP response is lost. When the request fails, the effect deletes session:2; the next click creates operation B rather than retrying A against revision 2.

Recommended fix: Track whether the lifecycle advance occurred during the active Resume and preserve that request's inspected revision and UUID after an uncertain failure. Only discard an operation when a lifecycle change is proven unrelated or the server definitively rejects that operation. Add an end-to-end case that publishes the committed lifecycle before returning 503, then asserts the retry retains both the original expectedRevision and operationId.

Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +51 to +72
operations.delete(`${entry.harnessSessionId}:${observedRevision.current}`);
observedRevision.current = current.lifecycle.revision;
request.current?.abort();
request.current = null;
setInspected(null);
setFailure(null);
setBusy(null);
}, [entry.harnessSessionId, current.lifecycle.revision, busy, operations]);
const run = async (action: "inspect" | "resume") => {
if (request.current) return;
const abort = new AbortController();
request.current = abort;
setBusy(action);
setFailure(null);
try {
if (action === "inspect") {
const next = await inspectAssistant(current, bootToken, abort.signal);
if (!abort.signal.aborted) setInspected(next);
} else if (inspected?.nativeResume === "available") {
const key = `${entry.harnessSessionId}:${inspected.lifecycle.revision}`;
const operationId = operations.get(key) ?? crypto.randomUUID();
operations.set(key, operationId);

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.

🔍 Operation ownership is distributed

The shared operations map mutates outside React state, while several effects govern eviction. Centralizing its lifecycle would make reconciliation boundaries testable.

Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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