Fix terminal snapshots reflowing after resize
Terminal snapshots now carry soft-wrap row metadata only to clients that advertise support, so restored output can resize like live output without breaking older clients.
This commit is contained in:
@@ -65,6 +65,10 @@ export interface TerminalSessionControllerOptions {
|
||||
hasBinaryChannel: () => boolean;
|
||||
isPathWithinRoot: (rootPath: string, candidatePath: string) => boolean;
|
||||
sessionLogger: pino.Logger;
|
||||
// Whether the connected client can reflow restored snapshots. When true the
|
||||
// daemon attaches per-row soft-wrap flags to snapshots; otherwise it omits them
|
||||
// so old (strict-schema) clients still parse the snapshot.
|
||||
clientSupportsWrapReflow?: () => boolean;
|
||||
}
|
||||
|
||||
export interface TerminalSessionControllerMetrics {
|
||||
@@ -104,6 +108,7 @@ export class TerminalSessionController {
|
||||
private readonly hasBinaryChannel: () => boolean;
|
||||
private readonly isPathWithinRoot: (rootPath: string, candidatePath: string) => boolean;
|
||||
private readonly sessionLogger: pino.Logger;
|
||||
private readonly clientSupportsWrapReflow: () => boolean;
|
||||
|
||||
private readonly subscribedDirectories = new Set<string>();
|
||||
private unsubscribeTerminalsChanged: (() => void) | null = null;
|
||||
@@ -119,6 +124,7 @@ export class TerminalSessionController {
|
||||
this.hasBinaryChannel = options.hasBinaryChannel;
|
||||
this.isPathWithinRoot = options.isPathWithinRoot;
|
||||
this.sessionLogger = options.sessionLogger;
|
||||
this.clientSupportsWrapReflow = options.clientSupportsWrapReflow ?? (() => false);
|
||||
}
|
||||
|
||||
start(): void {
|
||||
@@ -801,7 +807,9 @@ export class TerminalSessionController {
|
||||
activeStream: ActiveTerminalStream,
|
||||
terminalManager: TerminalManager,
|
||||
): Promise<SnapshotSendResult> {
|
||||
const snapshot = await terminalManager.getTerminalState(activeStream.terminalId);
|
||||
const snapshot = await terminalManager.getTerminalState(activeStream.terminalId, {
|
||||
includeWrapFlags: this.clientSupportsWrapReflow(),
|
||||
});
|
||||
if (this.activeStreams.get(activeStream.slot) !== activeStream) {
|
||||
return { shouldContinue: false };
|
||||
}
|
||||
@@ -829,10 +837,10 @@ export class TerminalSessionController {
|
||||
return { shouldContinue: true };
|
||||
}
|
||||
|
||||
const snapshot = await terminalManager.getTerminalState(
|
||||
activeStream.terminalId,
|
||||
snapshotOptions,
|
||||
);
|
||||
const snapshot = await terminalManager.getTerminalState(activeStream.terminalId, {
|
||||
...snapshotOptions,
|
||||
includeWrapFlags: this.clientSupportsWrapReflow(),
|
||||
});
|
||||
if (this.activeStreams.get(activeStream.slot) !== activeStream) {
|
||||
return { shouldContinue: false };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user