fix(web): sample the live-output generation before selectSession fetches (#814)

- selectSession now samples _liveOutputGen before its fresh fetch, as the refresh and manual-pull paths do, so output that arrives during the download keeps the session marked for Reload history.
- Test: live output during the fresh fetch keeps the mark after a mux-full-history replay.
This commit is contained in:
Hadrien Kerlero committed 2026-11-23 00:31:49 +01:00
1 parent 7794f74282
commit 4848886330
2 files changed
+22 -3

No files matched your search

+20 -2
View File
@@ -1548,7 +1548,7 @@ describe('manual history banner action', () => {
});
describe('selectSession only clears live-output marks for actual full mux captures', () => {
it.each(['mux-full-history', 'history'])('checks the response source: %s', async (source) => {
function makeSelectApp(source = 'mux-full-history') {
const errors = vi.fn();
const select = loadAppMethod('selectSession', {
console: { log: vi.fn(), error: errors },
@@ -1576,7 +1576,7 @@ describe('selectSession only clears live-output marks for actual full mux captur
'scrollToLastNonEmptyLine',
].map((name) => [name, vi.fn()])
);
Object.assign(app, methods, {
const selection = Object.assign(app, methods, {
activeSessionId: 's2',
_fullHistoryLoaded: new Set(),
_liveOutputSinceFullPull: new Set(['s1']),
@@ -1586,11 +1586,29 @@ describe('selectSession only clears live-output marks for actual full mux captur
sendResize: async () => false,
});
Object.assign(app.terminal, { scrollToBottom: vi.fn() });
return { app: selection, select, errors };
}
it.each(['mux-full-history', 'history'])('checks the response source: %s', async (source) => {
const { app, select, errors } = makeSelectApp(source);
await select.call(app, 's1');
expect(errors).not.toHaveBeenCalled();
expect(app.chunkedTerminalWrite).toHaveBeenCalledOnce();
expect(Reflect.get(app, '_liveOutputSinceFullPull').has('s1')).toBe(source !== 'mux-full-history');
});
it('keeps the mark when live output arrives during the fresh fetch', async () => {
const { app, select, errors } = makeSelectApp();
const fetchCapture = app._fetchTerminalCapture.getMockImplementation()!;
app._fetchTerminalCapture.mockImplementationOnce(async (url) => {
app._liveOutputGen.set('s1', (app._liveOutputGen.get('s1') || 0) + 1);
return fetchCapture(url);
});
await select.call(app, 's1');
expect(errors).not.toHaveBeenCalled();
expect(app.chunkedTerminalWrite).toHaveBeenCalledOnce();
expect(app._liveOutputSinceFullPull.has('s1')).toBe(true);
});
});
describe('drop-recovery refresh clears the live-output mark only for a mux capture', () => {