|
1 | 1 | import { spawn, type IPty } from "node-pty"; |
2 | 2 | import { randomUUID } from "node:crypto"; |
| 3 | +import { dirname, resolve } from "node:path"; |
| 4 | +import { fileURLToPath } from "node:url"; |
3 | 5 | import { SCROLLBACK_BYTES } from "../config.js"; |
4 | 6 | import type { SessionInfo } from "../types/session.js"; |
| 7 | +import { sanitizeForReplay } from "./replay.js"; |
5 | 8 | import { Scrollback } from "./scrollback.js"; |
6 | 9 | import * as tmux from "./tmux.js"; |
7 | 10 |
|
| 11 | +const TMUX_CONF = resolve(dirname(fileURLToPath(import.meta.url)), "../../tmux.conf"); |
| 12 | + |
8 | 13 | export type OutputListener = (chunk: string) => void; |
9 | 14 | export type ExitListener = (code: number, signal?: number) => void; |
10 | 15 |
|
@@ -47,6 +52,8 @@ export class Session { |
47 | 52 | this.pty = spawn( |
48 | 53 | "tmux", |
49 | 54 | [ |
| 55 | + "-f", |
| 56 | + TMUX_CONF, |
50 | 57 | "new-session", |
51 | 58 | "-A", |
52 | 59 | "-s", |
@@ -79,8 +86,7 @@ export class Session { |
79 | 86 | } |
80 | 87 |
|
81 | 88 | private async configureTmux(): Promise<void> { |
82 | | - await tmux.setOption(this.tmuxName, "status", "off"); |
83 | | - await tmux.setOption(this.tmuxName, "history-limit", "10000"); |
| 89 | + await tmux.sourceFile(TMUX_CONF); |
84 | 90 | await tmux.setTitle(this.tmuxName, this._title); |
85 | 91 | } |
86 | 92 |
|
@@ -116,7 +122,7 @@ export class Session { |
116 | 122 | } |
117 | 123 |
|
118 | 124 | history(): string { |
119 | | - return this.scrollback.snapshot(); |
| 125 | + return sanitizeForReplay(this.scrollback.snapshot()); |
120 | 126 | } |
121 | 127 |
|
122 | 128 | subscribe(onData: OutputListener, onExit: ExitListener): () => void { |
|
0 commit comments