Replay your coding agent sessions as a map and a timeline
Python agent-observabilityai-agentsclaudeclaude-codecodexcoding-agentscursordeveloper-toolsdevtoolsgithub-copilotkirollmobservabilityopencodeprivacypythonsession-replaytypescriptvisualization
test(viewer): replay shortcuts leave keys to the focused control
rav4nn9abe1a44c7d1
diff --git a/viewer/src/core/playback.test.ts b/viewer/src/core/playback.test.tsindex cfef6a5..b9ca766 100644--- a/viewer/src/core/playback.test.ts+++ b/viewer/src/core/playback.test.ts@@ -83,15 +83,29 @@ describe('playbackReducer', () => {});describe('replayKeyAction', () => {- const key = (k: string, mods: Partial<Record<string, boolean>> = {}) =>+ const key = (+ k: string,+ mods: Partial<Record<string, boolean>> = {},+ target: EventTarget = document.createElement('div')+ ) =>replayKeyAction({key: k,shiftKey: false,metaKey: false,ctrlKey: false,altKey: false,+ defaultPrevented: false,+ target,...mods,});+ // What Space, ArrowRight and E do with focus on the `data-t` element.+ const keysOn = (target: Element) =>+ [' ', 'ArrowRight', 'e'].map((k) => key(k, {}, target)?.type ?? null);+ const focused = (html: string) => {+ const host = document.createElement('div');+ host.innerHTML = html;+ return host.querySelector('[data-t]')!;+ };it('space toggles, arrows step (Shift steps 10)', () => {expect(key(' ')).toEqual({ type: 'toggle' });@@ -119,4 +133,49 @@ describe('replayKeyAction', () => {expect(key(' ', { ctrlKey: true })).toBeNull();expect(key('ArrowRight', { altKey: true })).toBeNull();});++ it('the replay region, a map dot and the page body get every shortcut', () => {+ for (const target of [+ focused('<div role="region" tabindex="-1" data-t><p>map</p></div>'),+ focused('<svg role="img"><circle tabindex="0" data-t></circle></svg>'),+ document.body,+ ])+ expect(keysOn(target)).toEqual(['toggle', 'step', 'jump']);+ });++ it('Space presses a focused button or link instead of playing', () => {+ for (const html of [+ '<button data-t>4×</button>',+ '<a href="#" data-t>PR #12</a>',+ ])+ expect(keysOn(focused(html)), html).toEqual([null, 'step', 'jump']);+ });++ it('tabs and radios keep Space and the arrows', () => {+ for (const html of [+ '<div role="tablist"><button role="tab" data-t>Details</button></div>',+ '<div role="radiogroup"><button role="radio" data-t>PR</button></div>',+ ])+ expect(keysOn(focused(html)), html).toEqual([null, null, 'jump']);+ });++ it('text fields, lists, menus and popups keep every key', () => {+ for (const html of [+ '<input data-t>',+ '<textarea data-t></textarea>',+ '<select data-t></select>',+ '<div contenteditable data-t></div>',+ '<input role="combobox" data-t>',+ '<div role="listbox"><button role="option" data-t>14:05</button></div>',+ '<div role="menu"><div role="menuitem" tabindex="-1" data-t>Next</div></div>',+ '<div role="dialog" tabindex="-1" data-t><p>All models</p></div>',+ '<div role="dialog"><button data-t>claude-opus</button></div>',+ ])+ expect(keysOn(focused(html)), html).toEqual([null, null, null]);+ });++ it('a key a control already handled maps to nothing', () => {+ expect(key(' ', { defaultPrevented: true })).toBeNull();+ expect(key('ArrowRight', { defaultPrevented: true })).toBeNull();+ });});