Skip to content

Add support for swapping underlying session sharing connection in terminal view and friends.#9311

Merged
zachbai merged 2 commits intomasterfrom
zb/reattachable-session-share
Apr 29, 2026
Merged

Add support for swapping underlying session sharing connection in terminal view and friends.#9311
zachbai merged 2 commits intomasterfrom
zb/reattachable-session-share

Conversation

@zachbai
Copy link
Copy Markdown
Contributor

@zachbai zachbai commented Apr 28, 2026

Description

Adds support for swapping out the viewer-side shared session piping for an existing TerminalView/Manager to support continuing cloud agent conversations across VM lifecycle boundary.

Adds SessionSharingInitialLoadMode for ignoring replay events when joining a shared session for a cloud agent task with agent scrollback.

@cla-bot cla-bot Bot added the cla-signed label Apr 28, 2026
@zachbai zachbai force-pushed the zb/reattachable-session-share branch from de84226 to e809b83 Compare April 28, 2026 22:56
@zachbai zachbai force-pushed the zb/refactor-ambient-agent-view-model branch 2 times, most recently from e39f7e7 to cc6e49d Compare April 28, 2026 22:59
@zachbai zachbai force-pushed the zb/reattachable-session-share branch from e809b83 to c1e697d Compare April 28, 2026 22:59
@zachbai zachbai changed the title Add support to ui/model layer for attaching a new backing session for a shared session viewer with the same terminal view/model Add support for swapping underlying session sharing connection in terminal view and friends. Apr 28, 2026
@zachbai zachbai force-pushed the zb/reattachable-session-share branch from c1e697d to da4fcc6 Compare April 28, 2026 23:08
@zachbai zachbai requested a review from harryalbert April 28, 2026 23:10
@zachbai zachbai marked this pull request as ready for review April 28, 2026 23:10
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented Apr 28, 2026

@zachbai

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

You can follow along in the session on Warp.

I completed the review and posted feedback on 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

Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

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

Overview

This PR reworks the shared-session viewer lifecycle so an ambient agent terminal can attach a fresh follow-up session, adds append-mode scrollback loading, and routes outbound viewer updates through a replaceable current network.

Concerns

  • Follow-up append mode still processes replayed agent conversation events after loading scrollback, which can duplicate existing cloud-agent history when the new session replays prior transcript state.
  • Ambient session-end handling guards only current_network clearing by session ID; stale events from a closed prior network can still unregister the active share and clear the new write-to-PTY channel.

Verdict

Found: 0 critical, 2 important, 0 suggestions

Request changes

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

Powered by Oz

}
SharedSessionInitialLoadMode::AppendFollowupScrollback => {
terminal_model
.append_followup_shared_session_scrollback(scrollback_blocks.as_slice());
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.

⚠️ [IMPORTANT] Append mode only changes scrollback loading; replay events from the follow-up session are still processed from event 0, so a session that replays the existing agent transcript can duplicate AI history. Preserve the load mode on EventLoop and skip replay events for follow-up joins.

manager.left_share(terminal_view.id());
});

model
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.

⚠️ [IMPORTANT] A late SessionEnded from the closed previous network still runs this teardown after a follow-up connects, which unregisters the active share and clears the new write-to-PTY channel. Guard all ambient teardown on ended_network matching current_network, not just the final current_network clear.

@zachbai zachbai changed the base branch from zb/refactor-ambient-agent-view-model to graphite-base/9311 April 29, 2026 16:48
@zachbai zachbai force-pushed the zb/reattachable-session-share branch from da4fcc6 to fadd66b Compare April 29, 2026 16:49
@zachbai zachbai force-pushed the graphite-base/9311 branch from cc6e49d to b7c64bc Compare April 29, 2026 16:49
@graphite-app graphite-app Bot changed the base branch from graphite-base/9311 to master April 29, 2026 16:49
@zachbai zachbai force-pushed the zb/reattachable-session-share branch from fadd66b to 5b9c748 Compare April 29, 2026 16:50
@zachbai zachbai force-pushed the zb/reattachable-session-share branch from 5b9c748 to 873ccb3 Compare April 29, 2026 18:45
@zachbai zachbai merged commit ca42aac into master Apr 29, 2026
25 checks passed
@zachbai zachbai deleted the zb/reattachable-session-share branch April 29, 2026 19:24
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