Skip to content

feat(harness): show retained Assistant session history [SAP-3292] - #1008

Closed
ynadge wants to merge 1 commit into
assistant-history-inspectionfrom
assistant-history-pane
Closed

ynadge wants to merge 1 commit into
assistant-history-inspectionfrom
assistant-history-pane

Conversation

@ynadge

@ynadge ynadge commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Primary change type

  • Feature

Problem and motivation

Assistant sessions need a readable saved record in existing Studio history, including when the session never had a Terminal vendor ID. Grouping by directory would hide distinct sessions.

Summary and scope

Display Assistant public transcripts through the existing history and transcript styles, group mixed entries only by exact Studio ID, and preserve independent Terminal history. Mark reconstructed/shortened/incomplete content, collapse recorded tools, support Back, and fence late history and End results across account/navigation changes. Opening the pane performs no native operation.

Related work

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

Depends on #1007. Native stack target: main. Uses the approved Assistant lifecycle flow; verified Resume and Continue actions follow separately.

Validation

E2E_PORT=6294 pnpm --filter @sapiom/harness test:ui web/e2e/assistant-history.spec.ts web/e2e/past-session-record.spec.ts web/e2e/assistant-end.spec.ts --workers=1 — 17 passed
Final restored-source Assistant history suite — 4 passed
Frontend TypeScript and scoped ESLint — passed, 5 existing warnings
New-file Prettier and git diff --check — passed
Exact-ID record/grouping guard mutations — both failed as expected, restored
1280x720 browser screenshot — visually reviewed

Tests and documentation

Browser cases cover mixed and Assistant-only history, missing/foreign records, delayed account/navigation changes, Back and zero native calls. Tests use mocked server/native transport; they do not replace integrated acceptance. Updated assistant-history.md. Increment:811 changed lines including tests/docs/changeset; pr:size is absent.

Compatibility and release impact

  • Breaking or externally visible changes: additive Assistant history behind the existing Assistant access state; Terminal remains the default surface.
  • Changeset: added for @sapiom/harness.
  • Runtime control: existing Assistant access owner and flag are retained; disabled state hides Assistant history and performs no Assistant reads. Enable with the complete lifecycle stack after required runtime acceptance. No new temporary flag to remove.
  • Fix-forward: correct history projection/guards while retaining saved records and existing Terminal identity.

Security

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

AI assistance

  • AI assistance used: Codex implemented the history UI and browser tests; root reviewed the diff, exact-ID/authority boundaries and rendered screenshot.

Checklist

  • CONTRIBUTING.md read; maintainer-authorized issue work.
  • One focused increment, tests, relevant checks, documentation, and release impact addressed above.
  • 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.

No baseline feature-before was captured. This is the resulting read-only reconstructed history view:

Recorded Assistant history

@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: ea192ea6-8542-4490-8851-1a5a0ddca4e5

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 4 potential issues.

Devin Review

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.

🔍 Badge omits Assistant-only history

The Past sessions badge counts only exited Terminal sessions. Saved Assistant-only entries can populate the flyout while its trigger shows no count.

(Refers to this code)

Devin Review

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

session,
})),
...pastSummaries.map((summary) => ({
...pastSummaries.filter((summary) => !summary.harnessSessionId || !assistantByStudio.has(summary.harnessSessionId)).map((summary) => ({

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.

🟡 Archived Terminal history disappears

A matching Assistant entry makes pastRows remove a transcript-only Terminal summary. No registry session provides another Terminal action, so its transcript becomes unreachable.

Learn more

Terminal history can exist only as a SessionSummary, without a corresponding registry session. The mixed-row filter removes that summary whenever Assistant history has the same Studio session ID. AssistantHistoryPane only receives a Terminal action when state.sessions contains that ID, so this case has no remaining route to the Terminal transcript.

Example: A swept Terminal session has summary harnessSessionId: "studio-a", while retained Assistant history also has harnessSessionId: "studio-a". The merged list shows only the Assistant row. Opening it offers no “View Terminal history” button because studio-a is absent from state.sessions.

Recommended fix: Preserve the matching SessionSummary on the merged Assistant row and provide an action that opens reviewPastSession(summary). Do not rely solely on registry sessions when deciding whether mixed Terminal history exists.

Devin Review

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

Comment on lines +1488 to +1494
if (authority && authority === assistantAuthorityKey()) {
setAssistantHistory((prev) => ({ authority, unavailable, entries: [
...new Map([
...(prev.authority === authority ? prev.entries.filter((entry) => !assistantCwds.has(entry.cwd)) : []),
...assistantEntries,
].map((entry) => [entry.harnessSessionId, entry])).values(),
] }));

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.

🟡 Partial-history warning clears prematurely

A successful narrow loadHistory replaces unavailable after an earlier directory failed. Stale entries from that failed directory then remain without an incomplete-history warning.

Learn more

Assistant entries are merged per successfully refreshed directory, but failure state is stored as one boolean for only the latest call. Failed directories retain their previous entries because they are absent from assistantCwds. A concurrent or later load for another directory can then set unavailable to false without refreshing the failed directory.

Example: The history menu loads /a and /b; /b fails, so its old rows remain and the warning appears. The dead-session pane then loads /a successfully. That second call writes unavailable: false, hiding the warning even though /b still contains stale, unverified rows.

Recommended fix: Track Assistant history failures per cwd under each authority. Clear a cwd's failure only after that cwd succeeds, and derive assistantHistoryUnavailable from whether any currently retained/requested cwd remains failed.

Devin Review

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

Comment on lines +37 to +96
const part = z.discriminatedUnion("type", [
z.object({
id,
type: z.literal("text"),
text: z.string().max(4000),
truncated: z.boolean(),
}),
z.object({
id,
type: z.literal("tool"),
callId: id,
name: z.string().max(256),
status: z.enum(["pending", "running", "completed", "error"]),
input: z.string().max(512),
output: z.string().max(512).nullable(),
error: z.string().max(512).nullable(),
startedAt: timestamp.nullable(),
completedAt: timestamp.nullable(),
truncated: z.boolean(),
}),
z.object({
id,
type: z.literal("file"),
name: z.string().nullable(),
mime: z.string(),
}),
z.object({ id, type: z.literal("omitted"), nativeType: z.string() }),
]);
const recordSchema = z.object({
schemaVersion: z.literal(1),
reconstructed: z.literal(true),
revision: count.positive(),
binding: z.object({
harnessSessionId: id,
cwd: z.string(),
conversationId: z.string().regex(/^ses_[A-Za-z0-9_-]{1,128}$/),
}),
capturedAt: z.string().datetime(),
turnCount: count,
messageCount: count,
limitations: z.array(z.string()),
turns: z.array(
z.object({
id,
incomplete: z.boolean(),
messages: z
.array(
z.object({
id,
role: z.enum(["user", "assistant"]),
parentId: id.nullable(),
createdAt: timestamp,
completedAt: timestamp.nullable(),
parts: z.array(part),
}),
)
.min(1),
}),
),
});

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.

🔍 Duplicated record schema can drift

The browser parser independently recreates the shared record validator with weaker constraints. Future record changes can diverge between server acceptance and rendering.

Devin Review

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

@ynadge ynadge closed this Sep 15, 2026
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