Skip to content

An agentic browser harness: an AI side panel & orb in your own logged-in Chrome, Edge, Arc, Brave or even Firefox run by the agent/subscription you already use (Claude Code, Codex, Antigravity). Free, open source, no API key. Also an MCP server.

fix(hands-free): read a reply as it was written — names joined by underscores, arithmetic and a year opening a line all survive the markdown strip — and say an action one way wherever it is shown

Shahriar0f06e5884d1b
diff --git a/src/lib/handsfree/caption.test.ts b/src/lib/handsfree/caption.test.ts
index 3c84c4c..e166e64 100644
--- a/src/lib/handsfree/caption.test.ts
+++ b/src/lib/handsfree/caption.test.ts
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest';
-import { captionOf, readingMs, replyOf, sharedWords, wordsOf } from './caption';
+import { captionOf, readingMs, replyOf, sharedWords, spoken, wordsOf } from './caption';
describe('sharedWords', () => {
it('keeps the words a revised reading did not change', () => {
@@ -14,6 +14,18 @@ describe('captionOf', () => {
expect(captionOf('## Done\n\n- **Saved** the [draft](https://x.test) as `v2`')).toBe('Done Saved the draft as v2');
});
+ it('leaves identifiers, file names and arithmetic as they were written', () => {
+ expect(captionOf('Set `max_retry_count` in config_file_name.json, then 2*3*4 = 24')).toBe(
+ 'Set max_retry_count in config_file_name.json, then 2*3*4 = 24',
+ );
+ expect(captionOf('It is _really_ *done* — ~~maybe~~ __surely__.')).toBe('It is really done — maybe surely.');
+ });
+
+ it('keeps a year that opens a line, and still drops a numbered list’s markers', () => {
+ expect(captionOf('2023. That was the year.')).toBe('2023. That was the year.');
+ expect(captionOf('1. Open it\n2) Save it')).toBe('Open it Save it');
+ });
+
it('drops code blocks entirely', () => {
expect(captionOf('Ran it:\n```js\nconsole.log(1)\n```\nAll good.')).toBe('Ran it: All good.');
});
@@ -50,6 +62,13 @@ describe('replyOf', () => {
});
});
+describe('spoken', () => {
+ it('reads an action name the way a person would say it mid-sentence', () => {
+ expect(spoken('page.clickElement')).toBe('click element');
+ expect(spoken('injectCode')).toBe('inject code');
+ });
+});
+
describe('readingMs', () => {
it('stays between a glance and a paragraph', () => {
expect(readingMs('ok')).toBe(4_000);
diff --git a/src/lib/handsfree/caption.ts b/src/lib/handsfree/caption.ts
index d1aeb1e..bc56ec6 100644
--- a/src/lib/handsfree/caption.ts
+++ b/src/lib/handsfree/caption.ts
@@ -31,8 +31,8 @@ export function captionOf(markdown: string, max = MAX_SPOKEN_CHARS): string {
.replace(/```[\s\S]*?```/g, ' ')
.replace(/`([^`]*)`/g, '$1')
.replace(/!?\[([^\]]*)\]\([^)]*\)/g, '$1')
- .replace(/^\s{0,3}(#{1,6}|>|[-*+]|\d+[.)])\s+/gm, '')
- .replace(/(\*\*|__|\*|_|~~)(\S(?:.*?\S)?)\1/g, '$2')
+ .replace(/^\s{0,3}(#{1,6}|>|[-*+]|\d{1,2}[.)])\s+/gm, '')
+ .replace(/(?<![\w*~])(\*\*|__|\*|_|~~)(\S(?:.*?\S)?)\1(?![\w*~])/g, '$2')
.replace(/\s+/g, ' ')
.trim();
if (plain.length <= max) return plain;
@@ -41,5 +41,12 @@ export function captionOf(markdown: string, max = MAX_SPOKEN_CHARS): string {
return `${(lastSpace > max * 0.6 ? cut.slice(0, lastSpace) : cut).replace(/[\s,;:.–—-]+$/, '')}…`;
}
+/** `page.clickElement` as a person would say it, mid-sentence: “click element”. */
+export const spoken = (action: string): string =>
+ action
+ .replace(/^page\./, '')
+ .replace(/([a-z])([A-Z])/g, '$1 $2')
+ .toLowerCase();
+
/** Long enough to read at an unhurried pace, never so long it lingers after the page moved on. */
export const readingMs = (text: string): number => Math.min(16_000, Math.max(4_000, 2_500 + wordsOf(text).length * 300));