Skip to content

feat(harness): explicitly start Terminal in dormant Studio sessions [SAP-3292] - #1005

Closed
ynadge wants to merge 3 commits into
terminal-retirement-followupfrom
dormant-terminal-activation
Closed

ynadge wants to merge 3 commits into
terminal-retirement-followupfrom
dormant-terminal-activation

Conversation

@ynadge

@ynadge ynadge commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Primary change type

  • Feature

Problem and motivation

A dormant Studio child has no Terminal vendor ID, so ordinary Resume cannot start its first Terminal. Creating another session would lose its Studio and Assistant association.

Summary and scope

Add explicit same-ID dormant Terminal activation and a boot-protected start endpoint. Revalidate workspace authority, prepare current credentials through the existing launch builder, and launch without initial prompts or automatic project bootstrap. Coalesce duplicate starts and fence End races before spawn. Register exit handlers before awaiting first publication so fast exit and cleanup are observed.

Related work

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

Depends on #1004 and consumes the allocator in #998. Native stack target: main. The Start Terminal UI follows the history/Continue pane work.

Validation

SessionManager focused and regression suite — 264 passed
pnpm --filter @sapiom/harness exec vitest run src/core/session-manager-activate-dormant.test.ts src/core/session-manager-retirement-review.test.ts src/core/session-manager-dormant.test.ts — root rerun, 50 passed
pnpm --filter @sapiom/harness exec vitest run src/server/rest.test.ts — 118 passed
pnpm --filter @sapiom/harness exec tsc --noEmit — passed
pnpm --filter @sapiom/harness build:server — passed
Scoped ESLint, new-test Prettier, git diff --check — passed

Tests and documentation

Twenty-three activation cases cover no bootstrap, fresh credentials, exact retry, current authority, End during preparation/publication, and real Assistant association preservation. Route tests reject overrides and map expected conflicts. Added dormant-terminal.md. Measured increment: 651 changed lines including tests and changeset; pr:size is absent.

Compatibility and release impact

  • Breaking or externally visible changes: additive explicit first-start endpoint; normal creation and Terminal Resume retain their separate behavior.
  • Changeset: added for @sapiom/harness.
  • Fix-forward: correct activation while retaining Studio identity, Assistant bindings and exact PTY cleanup evidence.

Security

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

AI assistance

  • AI assistance used: Codex implemented the manager and race tests; root reviewed the lifecycle boundaries, added the route/documentation, and reran focused and REST checks.

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

@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: 8316a22e-4211-4c71-a899-f505b3eddaeb

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 +880 to +881
try { res.json(await sessionManager.activateDormant(req.params.id)); }
catch (error) { if (!sendResumeError(res, error)) next(error); }

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.

🟡 Shutdown returns an internal error

During shutdown, activateDormant rejects with SessionManagerClosingError. sendResumeError omits that error, so Terminal start returns 500 instead of 409.

Learn more

Terminal start shares the resume error mapper, which handles preparation conflicts but omits the manager's shutdown error. The manager explicitly rejects every new dormant activation once beginShutdown() runs. The endpoint therefore reaches the generic Express error handler rather than returning a lifecycle conflict.

Example: A start request arrives after sessionManager.beginShutdown(). activateDormant() rejects with code SESSION_MANAGER_CLOSING; the client receives HTTP 500 rather than HTTP 409 with that code.

Recommended fix: Add SessionManagerClosingError to sendResumeError's 409 branch, and cover the Terminal start route with a shutdown rejection test.

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