Skip to content

Replay your coding agent sessions as a map and a timeline

fix(viewer): leave Space to summaries and role=button controls

rav4nn776d319d2bfd
diff --git a/viewer/src/core/playback.test.ts b/viewer/src/core/playback.test.ts
index b9ca766..f21165e 100644
--- a/viewer/src/core/playback.test.ts
+++ b/viewer/src/core/playback.test.ts
@@ -98,7 +98,6 @@ describe('replayKeyAction', () => {
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) => {
@@ -138,15 +137,18 @@ describe('replayKeyAction', () => {
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>'),
+ focused('<div contenteditable="false" data-t>14:05</div>'),
document.body,
])
expect(keysOn(target)).toEqual(['toggle', 'step', 'jump']);
});
- it('Space presses a focused button or link instead of playing', () => {
+ it('Space presses a focused button, link or summary instead of playing', () => {
for (const html of [
'<button data-t>4×</button>',
'<a href="#" data-t>PR #12</a>',
+ '<details><summary data-t>Tool categories</summary></details>',
+ '<svg><text role="button" tabindex="0" data-t>index.ts</text></svg>',
])
expect(keysOn(focused(html)), html).toEqual([null, 'step', 'jump']);
});
@@ -165,6 +167,7 @@ describe('replayKeyAction', () => {
'<textarea data-t></textarea>',
'<select data-t></select>',
'<div contenteditable data-t></div>',
+ '<div contenteditable="plaintext-only" 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>',
diff --git a/viewer/src/core/playback.ts b/viewer/src/core/playback.ts
index 4b776e2..189629f 100644
--- a/viewer/src/core/playback.ts
+++ b/viewer/src/core/playback.ts
@@ -99,16 +99,13 @@ const JUMP_KEYS: Record<string, JumpKey> = {
r: 'retry',
};
-// Focused controls that use a replay key themselves, by what the key would
-// do: text fields, lists and popups take every key, tabs and radios also take
-// the arrows, and buttons and links also take Space.
const TAKES_EVERY_KEY =
- 'input, textarea, select, [contenteditable], [role="combobox"], [role="listbox"], [role="option"], [role="menu"], [role="dialog"]';
+ 'input, textarea, select, [contenteditable]:not([contenteditable="false"]), [role="combobox"], [role="listbox"], [role="option"], [role="menu"], [role="dialog"]';
const TAKES_ARROWS = `${TAKES_EVERY_KEY}, [role="tab"], [role="radio"]`;
const KEPT_BY: Record<ReplayKeyAction['type'], string> = {
jump: TAKES_EVERY_KEY,
step: TAKES_ARROWS,
- toggle: `${TAKES_ARROWS}, button, a[href]`,
+ toggle: `${TAKES_ARROWS}, button, summary, a[href], [role="button"]`,
};
/**