Skip to content

fix(harness): preserve scoped history and Terminal focus [SAP-3292] - #1040

Closed
ynadge wants to merge 1 commit into
assistant-visibility-reconciliationfrom
assistant-history-scope-and-focus
Closed

ynadge wants to merge 1 commit into
assistant-visibility-reconciliationfrom
assistant-history-scope-and-focus

Conversation

@ynadge

@ynadge ynadge commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Primary change type

  • Bug fix

Problem and motivation

A successful refresh in one workspace could hide another workspace's Assistant history error, while an older batch could overwrite newer history. Grouped Assistant rows could also lose a Terminal-only transcript or let an older Assistant reveal override an explicit Terminal selection.

Summary and scope

Track Assistant history errors and published request revisions per cwd within the existing authority partition. Group records by exact Studio and cwd, retain access to Terminal-only transcripts, and order explicit Terminal focus above prior Assistant reveals. Keep dormant Terminal state distinct from confirmed Studio End.

Related work

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

Depends on #1039. Native stack target: main.

Validation

86/86 history, End, Continue and Terminal browser cases plus 13/13 focused chat cases passed. Three deliberate ordering/error/focus regressions were detected and restored, followed by the clean suites. The screenshot-only directory case rerun passed. Frontend TypeScript, scoped formatting, explicit browser ESLint (zero errors; five existing unused warnings) and git diff --check passed. Fresh root build and lint passed; combined remaining tests and actual native/browser verification follow.

Tests and documentation

Added seven workspace ordering, mixed transcript, exact-cwd, focus and dormant Canvas regressions. Captured and inspected directory error/recovery, mixed history and Retry Resume images. Updated assistant-history.md. Increment: 398 changed lines including tests/docs/changeset; SDK pr:size is absent.

Compatibility and release impact

  • Existing shared UI styles and Terminal history behavior are retained. No CSS, new dependency, automatic native/Terminal startup, or runtime activation change.
  • Changeset: @sapiom/harness patch.
  • Fix-forward: Retain existing readable history and correct the workspace version fence or explicit focus generation.

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 change with the validation described above.

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

Disposable browser fixture action states; these are not historical baselines or native execution evidence.

Workspace unavailable Same workspace recovered
History failure History recovered
Recorded Assistant Retained Terminal transcript
Assistant record Terminal record

Review disposition

The raw/canonical workspace alias finding in this increment is addressed by #1043, which carries server-verified path pairs through history discovery, mixed rows and Resume. Its actual symlink browser/native/PTY verification and reviewed visuals are linked from that follow-up.

@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: 85be5de4-30f4-4634-85ec-76a68f3db871

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 +752 to +755
const reviewedAssistantTerminal = activeAssistantReview ? harness.state?.sessions.find((session) =>
session.id === activeAssistantReview.entry.harnessSessionId && session.cwd === activeAssistantReview.entry.cwd) : undefined;
const reviewedTerminalSummary = activeAssistantReview ? harness.history.find((summary) =>
summary.harnessSessionId === activeAssistantReview.entry.harnessSessionId && summary.cwd === activeAssistantReview.entry.cwd) : undefined;

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.

🟡 Aliased workspaces split mixed history

For symlinked workspaces, reviewedAssistantTerminal rejects the Terminal belonging to the reviewed Assistant. AssistantHistory.list returns realpath paths, while sessions retain their launch spelling. The mixed row loses its Terminal action and appears as separate history.

Learn more

Assistant history canonicalizes every requested and returned cwd with realpath. Terminal sessions retain the path normalized by path.resolve, which does not resolve symlinks. The new exact string comparisons therefore treat two spellings of the same directory as different scopes across both the rail and review pane.

Example: A session starts in /work/current, where current is a symlink to /repos/acme. Its Terminal session keeps /work/current, but its Assistant entry uses /repos/acme. Opening that Assistant shows no Terminal action, and history displays two rows instead of one mixed row.

Recommended fix: Give both history sources the same server-issued canonical cwd before comparing them. Apply the same identity rule in reviewedAssistantTerminal, reviewedTerminalSummary, assistantByStudio, and the row-level Terminal lookup; browser-only lexical normalization cannot resolve symlinks.

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