fix(terminal): replay snapshot history at the PTY size it was drawn for
Opening the terminal panel sometimes showed stray fragments on the prompt row: zsh's end-of-line mark and pieces of the prompt path. The shell had laid its output out for one PTY width, but the client replayed that history into an emulator of another width (an early size estimate, a remount, or a renderer rebuild after fonts loaded). ghostty-web's reflow then left fragments the shell's SIGWINCH redraw never clears. The server now reports the PTY cols/rows in every snapshot, the transport carries them through projections and accepted resizes, and the viewport replays a sized snapshot chunk at that size before returning to the fitted size. The container-based size estimate only seeds newly spawned shells and is no longer sent to a running PTY. Tests cover the sized replay, the store chunk size, the transport projection, and the server snapshot; verified in a production build by reloading with the panel open and switching tabs at a changed width.
This commit is contained in:
@@ -423,6 +423,20 @@ describe('terminal state reconciliation', () => {
|
||||
expect(buffer(tabId).chunks).toBe(previous);
|
||||
});
|
||||
|
||||
test('records the PTY size a snapshot was drawn for and treats a size change as a new snapshot', () => {
|
||||
const tabId = setup();
|
||||
useTerminalStore.getState().replaceBuffer('/repo', tabId, 'prompt', 8, { cols: 94, rows: 56 });
|
||||
expect(buffer(tabId).chunks[0].size).toEqual({ cols: 94, rows: 56 });
|
||||
const previous = buffer(tabId).chunks;
|
||||
useTerminalStore.getState().replaceBuffer('/repo', tabId, 'prompt', 8, { cols: 94, rows: 56 });
|
||||
expect(buffer(tabId).chunks).toBe(previous);
|
||||
useTerminalStore.getState().replaceBuffer('/repo', tabId, 'prompt', 8, { cols: 80, rows: 24 });
|
||||
expect(buffer(tabId).chunks).not.toBe(previous);
|
||||
expect(buffer(tabId).chunks[0].size).toEqual({ cols: 80, rows: 24 });
|
||||
useTerminalStore.getState().appendToBuffer('/repo', tabId, ' live', 9);
|
||||
expect(buffer(tabId).chunks[1].size).toBe(undefined);
|
||||
});
|
||||
|
||||
test('caps multibyte scrollback by UTF-8 bytes', () => {
|
||||
const tabId = setup();
|
||||
useTerminalStore.getState().appendToBuffer('/repo', tabId, '界'.repeat(200_000), 1);
|
||||
|
||||
Reference in New Issue
Block a user