Skip to content

Replay your coding agent sessions as a map and a timeline

fix(viewer): open the linked session when it is past the first page

rav4nn23a759c506fa
diff --git a/viewer/src/App.tsx b/viewer/src/App.tsx
index 4bf3784..4914f91 100644
--- a/viewer/src/App.tsx
+++ b/viewer/src/App.tsx
@@ -74,8 +74,6 @@ export function App() {
// `demo` doubles as the sample switch: present means show the bundled
// sessions, absent means the user's own. `sample` is the reveal state of
// the locked block, kept in the URL so it survives the source swap.
- // `sq` (the sessions search) and `win` (the time window) are here because
- // they decide which sessions the explorer can select at all.
const [sampleQuery, setSampleQuery] = useQueryStates({
demo: parseAsString,
sample: parseAsString,
@@ -171,7 +169,14 @@ export function App() {
mode={mode}
source={source}
picker={picker}
- onBack={openedFiles ? () => setShowFiles(false) : undefined}
+ onBack={
+ openedFiles
+ ? () => {
+ setShowFiles(false);
+ void setSampleQuery({ session: null });
+ }
+ : undefined
+ }
baseLabel={baseSource.label}
account={mode === 'server' ? <AccountChip base={base} state={account.data} /> : null}
/>
diff --git a/viewer/src/app/sampleMode.test.ts b/viewer/src/app/sampleMode.test.ts
index 696c200..54b307e 100644
--- a/viewer/src/app/sampleMode.test.ts
+++ b/viewer/src/app/sampleMode.test.ts
@@ -1,3 +1,5 @@
+import fs from 'node:fs';
+import path from 'node:path';
import { describe, expect, it } from 'vitest';
import {
LIST_FILTER_PARAMS,
@@ -20,12 +22,14 @@ describe('the query "See sample" pushes', () => {
expect(SAMPLE_QUERY.sample).toBe('1');
});
+ it('names a session the bundled sessions have', () => {
+ const index = JSON.parse(
+ fs.readFileSync(path.resolve(__dirname, '../../public/demo/index.json'), 'utf8')
+ ) as { sessions: { sessionId: string }[] };
+ expect(index.sessions.map((s) => s.sessionId)).toContain(SAMPLE_SESSION_ID);
+ });
+
it('clears every filter the sessions list applies', () => {
- // The explorer selects the first row of the FILTERED list when the
- // session it is asked for is not in it. A search or a time window that
- // excludes the sample therefore landed the reader on a different
- // session, with the preview still blurred. A new list
- // filter has to be cleared here too, which is what this asserts.
for (const key of LIST_FILTER_PARAMS)
expect(SAMPLE_QUERY[key], `${key} is cleared`).toBeNull();
expect([...LIST_FILTER_PARAMS]).toEqual(['sq', 'win']);
diff --git a/viewer/src/app/sampleMode.tsx b/viewer/src/app/sampleMode.tsx
index eded547..c063536 100644
--- a/viewer/src/app/sampleMode.tsx
+++ b/viewer/src/app/sampleMode.tsx
@@ -4,9 +4,6 @@ import { createContext, useContext, type ReactNode } from 'react';
* The bundled demo session that opened a PR (`scripts/make-demo.mjs`, first
* entry). It is the only demo session with a PR in it, so it is the one worth
* swapping to when someone asks what the review loop looks like.
- *
- * A wrong id here is not fatal: the explorer falls back to the first session
- * in the list, which is this one.
*/
export const SAMPLE_SESSION_ID =
'local:claude-code:5f2c9a1e-7b44-4d0e-9c1a-demo00000001';
@@ -31,12 +28,6 @@ export interface SampleQuery {
}
/**
- * Showing the sample swaps the view onto `SAMPLE_SESSION_ID` *and* clears
- * every list filter, because the explorer falls back to the first row of the
- * **filtered** list when the session it is asked for is not in it: a search
- * or a time window that excludes the sample would otherwise leave the reader
- * on some other session with the preview still blurred.
- *
* It is a pushed history entry, so the browser's own Back button restores the
* filters the reader had -- which is why they are cleared through the URL
* rather than as local state.
diff --git a/viewer/src/explorer/SessionExplorer.tsx b/viewer/src/explorer/SessionExplorer.tsx
index a6f5e45..5507658 100644
--- a/viewer/src/explorer/SessionExplorer.tsx
+++ b/viewer/src/explorer/SessionExplorer.tsx
@@ -146,9 +146,7 @@ function useExplorerSessions(windowKey: WindowKey) {
[list.data]
);
const listIds = useMemo(() => sessions.map((s) => s.sessionId), [sessions]);
- const selectedId = sessions.some((s) => s.sessionId === selected)
- ? selected
- : (sessions[0]?.sessionId ?? null);
+ const selectedId = selected || sessions[0]?.sessionId || null;
const selectedRow = sessions.find((s) => s.sessionId === selectedId) ?? null;
const mapQuery = useSessionExplorerMap(selectedId, listIds);
return {
@@ -257,7 +255,13 @@ export function SessionExplorer({
<WindowSelect windowKey={windowKey} onChange={onWindowChange} />
) : null;
- if (!sessions.length && !data.debouncedSearch && !list.hasNextPage) {
+ const showLinked = !!data.selected && !scanning;
+ if (
+ !sessions.length &&
+ !data.debouncedSearch &&
+ !list.hasNextPage &&
+ !showLinked
+ ) {
// The window select lives in the sidebar, which this state replaces, so
// it is rendered here too -- otherwise "try a longer window" would have
// no control to act on.