handoff
This commit is contained in:
@@ -3,7 +3,6 @@ import type { IPty } from 'node-pty';
|
||||
|
||||
export interface AttachPtyOptions {
|
||||
sessionName: string;
|
||||
windowName: string;
|
||||
projectRoot: string;
|
||||
cols: number;
|
||||
rows: number;
|
||||
@@ -19,16 +18,24 @@ function cleanEnv(): { [key: string]: string } {
|
||||
return out;
|
||||
}
|
||||
|
||||
// Spawns a tmux client attached to the given session+window. `-d` detaches any
|
||||
// other client so a browser refresh takes over the same window without
|
||||
// duplicate input. tmux server (and the window) persists across PTY exits.
|
||||
// v1.10.8c: no `-d` (multi-attach friendly — boolab pattern). With per-pane
|
||||
// tmux sessions, dropping `-d` means multiple browser tabs viewing the same
|
||||
// pane share one tmux session as N clients; tmux fans I/O at the session
|
||||
// layer just like boolab's backend. The earlier `-d` flag detached EVERY
|
||||
// other client of the session — across windows — which caused the
|
||||
// "[detached] from session" bug whenever a new pane attached to a chat
|
||||
// session that already had another pane open.
|
||||
//
|
||||
// Tmux server + session persist across PTY exits, so a refresh resumes with
|
||||
// full scrollback. Explicit destroy happens via the /kill route (called from
|
||||
// the frontend when the user closes a pane).
|
||||
export function attachPty(opts: AttachPtyOptions): IPty {
|
||||
return pty.spawn(
|
||||
'tmux',
|
||||
[
|
||||
'-f', opts.tmuxConfPath,
|
||||
'attach-session', '-d',
|
||||
'-t', `${opts.sessionName}:${opts.windowName}`,
|
||||
'attach-session',
|
||||
'-t', opts.sessionName,
|
||||
],
|
||||
{
|
||||
name: 'xterm-256color',
|
||||
|
||||
Reference in New Issue
Block a user