Skip to content

add TUI multi-session registry and focused-session root projection#13775

Open
harryalbert wants to merge 3 commits into
harry/code-1822-tui-orchestration-cardfrom
harry/code-1822-tui-multi-session
Open

add TUI multi-session registry and focused-session root projection#13775
harryalbert wants to merge 3 commits into
harry/code-1822-tui-orchestration-cardfrom
harry/code-1822-tui-multi-session

Conversation

@harryalbert

@harryalbert harryalbert commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Description

Adds TuiSessions, a process-local registry for retaining multiple live TUI terminal sessions and selecting which one is foreground. Each TuiSession owns a complete TuiTerminalSessionView plus the terminal manager that keeps its PTY and event loop alive. The eagerly-created view ID is also the session ID and shared-model terminal_surface_id, so the TUI does not introduce a second identity mapping.

RootTuiView becomes a projection of TuiSessions::focused_session() rather than the owner of one authenticated terminal child. Only the focused view is returned from child_view_ids() and rendered into the responder chain; background views remain alive without participating in layout or input routing. Login bootstrap creates and focuses the initial session through the same registry path that later orchestration children use.

Session activation restores the focused view's current input owner and exit-summary token. Subsequent PTY, blocker, CLI-subagent, and conversation-restore focus transitions are guarded by registry focus, preventing background sessions from stealing window focus or replacing the foreground resume hint.

This PR is the multi-session ownership primitive consumed by the local-child orchestration PR above. It intentionally does not add session navigation UI, persistence, or child-agent materialization.

Ownership and data flow

flowchart LR
  Bootstrap["Login bootstrap"] --> Create["Create full session view + terminal manager"]
  Create --> Registry["TuiSessions registry"]
  Registry --> Focused["Focused retained session"]
  Registry -. retains .-> Background["Background retained sessions"]
  Focused --> Root["RootTuiView projection"]
  Root --> Render["Render + responder chain"]
  Background -. excluded from .-> Render
Loading

Linked Issue

CODE-1822 — Orchestration

Review guide

  • crates/warp_tui/src/session_registry.rs — session identity, retained view/manager ownership, focused-session selection, activation, and events.
  • crates/warp_tui/src/root_view.rs and crates/warp_tui/src/session.rs — focused-view projection and the unified login/session-creation path.
  • crates/warp_tui/src/terminal_session_view.rs — focus-neutral construction, activation, background focus guards, and focused exit-summary ownership.
  • specs/code-1822-tui-multi-session/TECH.md — as-built ownership model, non-goals, and validation contract.

Testing

  • cargo check -p warp_tui --tests
  • Added unit coverage for session registration/focus events and focused root projection with two retained full session views
    No user-facing changes yet

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

CHANGELOG-NONE

Co-Authored-By: Oz oz-agent@warp.dev

@harryalbert
harryalbert force-pushed the harry/code-1822-tui-multi-session branch from b877cf4 to a725a0d Compare July 15, 2026 18:55
@harryalbert
harryalbert force-pushed the harry/code-1822-tui-orchestration-card branch from db49817 to 07f43ac Compare July 15, 2026 18:55
@harryalbert
harryalbert force-pushed the harry/code-1822-tui-multi-session branch from a725a0d to 7fde057 Compare July 15, 2026 22:12
@harryalbert
harryalbert force-pushed the harry/code-1822-tui-orchestration-card branch 2 times, most recently from 0503bbd to 6cf263f Compare July 16, 2026 02:44
@harryalbert
harryalbert force-pushed the harry/code-1822-tui-multi-session branch from 7fde057 to 289a5d1 Compare July 16, 2026 02:44
@harryalbert harryalbert mentioned this pull request Jul 16, 2026
4 tasks
@harryalbert
harryalbert changed the base branch from harry/code-1822-tui-orchestration-card to graphite-base/13775 July 16, 2026 11:57
@harryalbert
harryalbert force-pushed the graphite-base/13775 branch from 6cf263f to 70fcf39 Compare July 16, 2026 11:58
@harryalbert
harryalbert force-pushed the harry/code-1822-tui-multi-session branch from 289a5d1 to cbbd8d0 Compare July 16, 2026 11:58
@harryalbert
harryalbert changed the base branch from graphite-base/13775 to harry/code-1822-tui-orchestration-card July 16, 2026 11:58
@harryalbert
harryalbert force-pushed the harry/code-1822-tui-orchestration-card branch from 70fcf39 to ae11307 Compare July 16, 2026 12:44
@harryalbert
harryalbert force-pushed the harry/code-1822-tui-multi-session branch from cbbd8d0 to 6bb0618 Compare July 16, 2026 12:44
@harryalbert
harryalbert force-pushed the harry/code-1822-tui-orchestration-card branch from ae11307 to 78d63d7 Compare July 16, 2026 12:49
@harryalbert
harryalbert force-pushed the harry/code-1822-tui-multi-session branch from 6bb0618 to 6a04f77 Compare July 16, 2026 12:49
@harryalbert
harryalbert force-pushed the harry/code-1822-tui-orchestration-card branch from 78d63d7 to 6dceea3 Compare July 16, 2026 12:53
@harryalbert
harryalbert force-pushed the harry/code-1822-tui-multi-session branch from 6a04f77 to 1e9b80f Compare July 16, 2026 12:53
@harryalbert
harryalbert force-pushed the harry/code-1822-tui-orchestration-card branch from 6dceea3 to 18c23d5 Compare July 16, 2026 14:00
@harryalbert
harryalbert force-pushed the harry/code-1822-tui-multi-session branch 2 times, most recently from 063d148 to 97603f3 Compare July 16, 2026 14:17
@harryalbert
harryalbert force-pushed the harry/code-1822-tui-orchestration-card branch from 08a5d3e to e9d064f Compare July 16, 2026 14:19
@harryalbert
harryalbert force-pushed the harry/code-1822-tui-multi-session branch from 97603f3 to b030f4f Compare July 16, 2026 14:19
@harryalbert
harryalbert changed the base branch from harry/code-1822-tui-orchestration-card to graphite-base/13775 July 16, 2026 14:39
@harryalbert harryalbert changed the title Add TuiSessions multi-session container + focused-session root view add TUI multi-session registry and focused-session root projection Jul 16, 2026
@harryalbert
harryalbert force-pushed the harry/code-1822-tui-multi-session branch from b030f4f to 6a48d86 Compare July 16, 2026 15:59
@harryalbert
harryalbert changed the base branch from graphite-base/13775 to harry/code-1822-tui-orchestration-card July 16, 2026 15:59
@harryalbert
harryalbert marked this pull request as ready for review July 16, 2026 16:02
@harryalbert
harryalbert requested a review from kevinyang372 July 16, 2026 16:02
@oz-for-oss

oz-for-oss Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

@harryalbert

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@oz-for-oss oz-for-oss 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.

Overview

This PR introduces a process-local TuiSessions registry, moves RootTuiView to project only the focused retained session, and updates TUI session focus/exit-summary handling so background sessions stay alive without participating in rendering or input routing.

Concerns

  • No blocking correctness, security, or spec-drift concerns found in the annotated diff.
  • The provided spec_context.md contains no approved or repository spec context, so there were no external spec commitments to compare beyond the PR's own checked-in TECH notes.

Verdict

Found: 0 critical, 0 important, 0 suggestions

Approve

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

/// Whether the authenticated terminal session has been created yet. Mirrors the
/// GUI root view's `AuthOnboardingState` split between the pre-session login gate
/// and the live terminal session.
enum RootTuiState {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, we should keep the Auth vs Terminal RootTuiState

TuiSessions::new(driver, window_id, exit_summary, resume_token)
});
root.update(ctx, |_, ctx| {
ctx.subscribe_to_model(&sessions, |_, _, _, ctx| ctx.notify());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should subscribe to explicit events

Comment thread crates/warp_tui/src/session_registry.rs Outdated
}

/// Returns the window and exit-summary handle used to create session views.
pub(crate) fn surface_context(&self) -> (WindowId, TuiExitSummaryHandle) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to retain and return a WindowId here? I don't think we really need that for TUI no?

@harryalbert
harryalbert force-pushed the harry/code-1822-tui-multi-session branch from 6a48d86 to d97af3b Compare July 16, 2026 22:12
@harryalbert
harryalbert force-pushed the harry/code-1822-tui-orchestration-card branch from 194fd82 to a37739b Compare July 16, 2026 22:12
@harryalbert harryalbert mentioned this pull request Jul 16, 2026
4 tasks
@harryalbert
harryalbert force-pushed the harry/code-1822-tui-multi-session branch from d97af3b to eb8c75e Compare July 16, 2026 23:09
@harryalbert
harryalbert force-pushed the harry/code-1822-tui-orchestration-card branch from a37739b to d2f380b Compare July 16, 2026 23:09
harryalbert and others added 3 commits July 16, 2026 22:45
TuiSessions (SingletonEntity) owns all session cores with insertion order,
focus, and Added/Removed/FocusChanged events; all session creation flows
through it. RootTuiView becomes a projection: a lazy, retained view cache
keyed by session id, rendering and routing input to only the focused
session. The login bootstrap registers session 0 focused, and the terminal
manager handle moves onto the session core.

Co-Authored-By: Oz <oz-agent@warp.dev>
@harryalbert
harryalbert force-pushed the harry/code-1822-tui-multi-session branch from eb8c75e to 9fcd29b Compare July 17, 2026 02:57
@harryalbert
harryalbert force-pushed the harry/code-1822-tui-orchestration-card branch from d2f380b to 91a1b4a Compare July 17, 2026 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants