Skip to content

feat(harness): preserve End availability and failed cleanup state [SAP-3292] - #1003

Closed
ynadge wants to merge 1 commit into
assistant-session-endfrom
assistant-end-controls
Closed

ynadge wants to merge 1 commit into
assistant-session-endfrom
assistant-end-controls

Conversation

@ynadge

@ynadge ynadge commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Primary change type

  • Feature

Problem and motivation

Terminal exit can hide End while Assistant is still open. An unsuccessful or late End response can also remove the wrong current state or override newer navigation.

Summary and scope

Keep End available for open or ending Assistant sessions, use the existing confirmation flow with both-engine/history copy, and retain the row and selection after incomplete cleanup. Apply successful updates to current session state, preserving newer Resume and navigation. Dead-pane Close confirms before stopping an active Assistant.

Related work

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

Depends on #1002. Native stack target: main. Full retained Assistant history rendering and Resume controls follow separately.

Validation

24 focused and existing browser cases — passed
Five final End browser cases — passed
Three negative guard mutations — failed as expected, restored
pnpm --filter @sapiom/harness exec tsc --noEmit -p web/tsconfig.json — passed
Explicit frontend ESLint with --no-inline-config — zero errors, one existing unused-import warning
git diff --check — passed

Tests and documentation

Browser cases cover Assistant remaining open after Terminal exit, failed cleanup, unaffected session B, late End versus a newly started session and newer Resume. Three screenshots and exact commands are retained in the workspace handoff. Existing inline React hook suppressions reference an unconfigured plugin; the explicit lint run disables inline config. This is mock HTTP/SSE browser evidence. Incremental size: 430 changed lines including tests; pr:size is absent.

Compatibility and release impact

  • Breaking or externally visible changes: incomplete End keeps the session available for retry; confirmed End preserves saved Assistant history.
  • Changeset: covered by the immediately preceding End package changeset.
  • Fix-forward: correct selection/cleanup presentation while preserving server truth and retained history.

Security

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

AI assistance

  • AI assistance used: Codex implemented and reviewed the existing-pane integration; browser regressions and mutations validate the guards.

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.

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: f7c798fe-9027-4cb9-affc-b227c2b1a3b0

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 1 potential issue.

Devin Review

Comment on lines +1799 to +1812
setState((prev) =>
prev
? {
...prev,
sessions: retained
? prev.sessions.map((session) =>
session.id === id
? { ...session, status: "exited", ready: false }
: session,
)
: prev.sessions.filter((session) => session.id !== id),
}
: prev,
);

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.

🔴 Concurrent Resume is overwritten by End

When Resume resolves before its lifecycle event, closeSession marks the resumed session exited. The resumed Terminal disappears and selection moves away.

Learn more

A Resume and End can overlap for the same session. resumeSession immediately stores the running Resume response, but the Assistant lifecycle event arrives independently. If the older DELETE resolves during that gap, the lifecycle guard still sees ending and this state update changes the fresh running row back to exited. The following selection fallback then moves away from that session.

Example: End starts for session A. Resume returns a running row for A, but its open Assistant snapshot is delayed. The older End response then marks A exited and selects B, although A has resumed successfully.

Recommended fix: Add a per-session Resume generation or session-status revision fence. Capture it when End starts, and skip both the row update and fallback when a newer Resume or status projection has updated that session.

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