fix(ui): drop in-terminal Connecting/Connected/reconnecting lines

The tab connection dot (green/amber/red) already shows connection state, so the
'[terminal] Connecting…/Connected' and 'Disconnected — reconnecting' lines just
cluttered the scrollback. Rely on the dot; keep only the actionable exit message.
This commit is contained in:
Yaojia Wang
2026-06-18 07:39:29 +02:00
parent 5df3f9158c
commit 25269cad3f

View File

@@ -19,9 +19,7 @@ import { folderFromTitle, cwdFromOsc7 } from './title-util.js'
const RESET = '\x1b[0m' const RESET = '\x1b[0m'
const BOLD = '\x1b[1m' const BOLD = '\x1b[1m'
const DIM = '\x1b[2m' const DIM = '\x1b[2m'
const YELLOW = '\x1b[33m'
const RED = '\x1b[31m' const RED = '\x1b[31m'
const GREEN = '\x1b[32m'
const CYAN = '\x1b[36m' const CYAN = '\x1b[36m'
function statusLine(msg: string): string { function statusLine(msg: string): string {
@@ -195,16 +193,14 @@ export class TerminalSession {
connect(): void { connect(): void {
if (this.disposed || this.isConnecting) return if (this.disposed || this.isConnecting) return
this.isConnecting = true this.isConnecting = true
this.setStatus('connecting') this.setStatus('connecting') // connection state shows on the tab dot, not in the terminal
this.term.write(statusLine(`${YELLOW}Connecting…${RESET}`))
const socket = new WebSocket(buildWsUrl()) const socket = new WebSocket(buildWsUrl())
this.ws = socket this.ws = socket
socket.addEventListener('open', () => { socket.addEventListener('open', () => {
this.reconnectDelay = 1000 this.reconnectDelay = 1000
this.setStatus('connected') this.setStatus('connected') // tab dot turns green; no in-terminal "Connected" line
this.term.write(statusLine(`${GREEN}${BOLD}Connected${RESET}`))
// Send cwd only on a fresh session (M6 "new tab here"); on reconnect the // Send cwd only on a fresh session (M6 "new tab here"); on reconnect the
// sessionId is already set and the server ignores cwd. // sessionId is already set and the server ignores cwd.
const attachMsg: ClientMessage = const attachMsg: ClientMessage =
@@ -282,12 +278,9 @@ export class TerminalSession {
private scheduleReconnect(): void { private scheduleReconnect(): void {
if (this.reconnectTimer !== null) return if (this.reconnectTimer !== null) return
this.setStatus('reconnecting') this.setStatus('reconnecting') // amber tab dot signals it; no in-terminal line
const delay = this.reconnectDelay const delay = this.reconnectDelay
this.reconnectDelay = Math.min(this.reconnectDelay * 2, 30_000) this.reconnectDelay = Math.min(this.reconnectDelay * 2, 30_000)
this.term.write(
statusLine(`${YELLOW}Disconnected — reconnecting in ${(delay / 1000).toFixed(0)}s…${RESET}`),
)
this.reconnectTimer = setTimeout(() => { this.reconnectTimer = setTimeout(() => {
this.reconnectTimer = null this.reconnectTimer = null
this.connect() this.connect()