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(extension): the star request asks at most once in a conversation and three times in all — in the first conversation, the next one, and three conversations after that; ignoring it counts the same as closing it, and a star in any panel still retires it for good

Shahriarc8f595bf857c
diff --git a/docs/guide/features/conversations.md b/docs/guide/features/conversations.md
index cd0ec9a..e36d8f7 100644
--- a/docs/guide/features/conversations.md
+++ b/docs/guide/features/conversations.md
@@ -140,10 +140,10 @@ Every action appears as it happens, with what it targeted and what came back.
When an agent finishes a turn cleanly, a small **Star us on GitHub** pill can appear above the
composer. **Star** opens the repository in a tab beside the one you are on, and the pill never comes
-back. **×** dismisses it for that conversation; it asks again in the next one, and after a second
-dismissal it waits two conversations, then three after every dismissal from then on. A stopped,
-failed or instant-command turn never raises it, and neither does a run in a tab you are not looking
-at.
+back. **×** dismisses it, and so does your next instruction. It asks at most once in a conversation
+and three times in all: in your first conversation, in the next one, and once more three
+conversations later. A stopped, failed or instant-command turn never raises it, and neither does a
+run in a tab you are not looking at.
---
diff --git a/docs/internals/state.md b/docs/internals/state.md
index 4dd47aa..15f11a6 100644
--- a/docs/internals/state.md
+++ b/docs/internals/state.md
@@ -84,9 +84,9 @@ the page (`browsentic/actionCues`, off when absent).
**Blocked sites** are `browsentic/blockedSites` in `storage.local`: a list of up to 500 patterns that
the daemon never receives. Removing the extension removes it; each browser keeps its own.
-**The star request** is `browsentic/starNudge` in `storage.local`: whether its star was clicked, how
-many times it was closed and the conversations it was closed in, and up to four conversation ids
-counted since the last close. It never leaves the browser.
+**The star request** is `browsentic/starNudge` in `storage.local`: whether its star was clicked, the
+conversations it asked in (three at most), and up to two conversation ids counted since the last
+ask. It never leaves the browser.
**The theme** is config.json's `theme`, mirrored into `storage.local` under `browsentic/theme` so a
page paints before any socket is up. `browsentic/theme.unsynced` marks a pick the daemon has not heard
diff --git a/src/lib/bridge/star-nudge.test.ts b/src/lib/bridge/star-nudge.test.ts
index 60710f7..bfc1ba8 100644
--- a/src/lib/bridge/star-nudge.test.ts
+++ b/src/lib/bridge/star-nudge.test.ts
@@ -5,76 +5,58 @@ import {
STAR_NUDGE_KEY,
UNASKED,
asStarNudge,
- isDue,
- noteClosed,
+ asksNow,
noteFinishedTurn,
noteStarred,
openRepositoryBeside,
- withClose,
withFinishedTurn,
withStar,
type StarNudge,
} from './star-nudge';
/** Plays turns finishing in each conversation in order, and lists the conversations that raised the ask. */
-function raisedAcross(start: StarNudge, conversations: string[]): string[] {
- const raised: string[] = [];
+function askedAcross(start: StarNudge, conversations: string[]): string[] {
+ const asked: string[] = [];
conversations.reduce((nudge, conversation) => {
const next = withFinishedTurn(nudge, conversation);
- if (isDue(next, conversation)) raised.push(conversation);
+ if (asksNow(nudge, next)) asked.push(conversation);
return next;
}, start);
- return raised;
+ return asked;
}
-const afterClosing = (...conversations: string[]): StarNudge => conversations.reduce(withClose, UNASKED);
+const afterTurnsIn = (...conversations: string[]): StarNudge => conversations.reduce(withFinishedTurn, UNASKED);
const stored = async () => (await fakeBrowser.storage.local.get(STAR_NUDGE_KEY))[STAR_NUDGE_KEY];
describe('when the star ask is raised', () => {
it('asks after the very first turn that finishes', () => {
- expect(raisedAcross(UNASKED, ['a'])).toEqual(['a']);
+ expect(askedAcross(UNASKED, ['a'])).toEqual(['a']);
});
- it('never asks again once the star was clicked', () => {
- expect(raisedAcross(withStar(UNASKED), ['a', 'b', 'c', 'd', 'e', 'f'])).toEqual([]);
- expect(raisedAcross(withStar(afterClosing('a', 'b', 'c')), ['d', 'e', 'f', 'g', 'h'])).toEqual([]);
- });
-
- it('after a first close, sits out the rest of that conversation and asks in the next', () => {
- expect(raisedAcross(afterClosing('a'), ['a', 'a', 'b'])).toEqual(['b']);
+ it('asks once in a conversation, however many turns finish there', () => {
+ expect(askedAcross(UNASKED, ['a', 'a', 'a'])).toEqual(['a']);
});
- it('after a second close, sits out two conversations and asks in the third', () => {
- expect(raisedAcross(afterClosing('a', 'b'), ['b', 'c', 'd', 'e'])).toEqual(['e']);
+ it('asks again in the next conversation, then sits out two, then never again', () => {
+ expect(askedAcross(UNASKED, ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'])).toEqual(['a', 'b', 'e']);
});
- it('after a third close and every one after it, sits out three conversations', () => {
- expect(raisedAcross(afterClosing('a', 'b', 'c'), ['d', 'e', 'f', 'g'])).toEqual(['g']);
- expect(raisedAcross(afterClosing('a', 'b', 'c', 'g'), ['h', 'i', 'j', 'k'])).toEqual(['k']);
+ it('counts a conversation once while it waits, however many turns finish in it', () => {
+ expect(askedAcross(UNASKED, ['a', 'b', 'c', 'c', 'd', 'd', 'e'])).toEqual(['a', 'b', 'e']);
});
- it('counts a conversation once, however many turns finish in it', () => {
- expect(raisedAcross(afterClosing('a', 'b'), ['c', 'c', 'c', 'd', 'd', 'e'])).toEqual(['e']);
+ it('never counts a conversation it already asked in while it waits', () => {
+ expect(askedAcross(UNASKED, ['a', 'b', 'c', 'a', 'b', 'd', 'e'])).toEqual(['a', 'b', 'e']);
});
- it('never asks again in a conversation where it was closed, nor counts it', () => {
- expect(raisedAcross(afterClosing('a', 'b'), ['c', 'd', 'a', 'e'])).toEqual(['e']);
- });
-
- it('takes a second close in the same conversation as the first', () => {
- const closed = afterClosing('a');
- expect(withClose(closed, 'a')).toBe(closed);
- });
-
- it('keeps a star through a close that lands after it', () => {
- expect(withClose(withStar(UNASKED), 'a').starred).toBe(true);
+ it('never asks again once the star was clicked', () => {
+ expect(askedAcross(withStar(UNASKED), ['a', 'b', 'c'])).toEqual([]);
+ expect(askedAcross(withStar(afterTurnsIn('a', 'b')), ['c', 'd', 'e', 'f', 'g'])).toEqual([]);
});
- it('keeps asking in any new conversation until it is answered, holding no more than it needs', () => {
- const ignored = ['b', 'c', 'd', 'e', 'f'].reduce(withFinishedTurn, afterClosing('a', 'b'));
- expect(ignored.finishedIn).toEqual(['c', 'd', 'e']);
- expect(isDue(withFinishedTurn(ignored, 'z'), 'z')).toBe(true);
+ it('holds nothing more once it has asked for the last time', () => {
+ expect(afterTurnsIn('a', 'b', 'c', 'd', 'e', 'f', 'g')).toEqual({ starred: false, askedIn: ['a', 'b', 'e'], finishedIn: [] });
});
});
@@ -84,27 +66,21 @@ describe('the stored star ask', () => {
it('reads anything unexpected as never asked, keeping only the conversation ids it can read', () => {
expect(asStarNudge(undefined)).toEqual(UNASKED);
expect(asStarNudge('starred')).toEqual(UNASKED);
- expect(asStarNudge({ starred: 'yes', closes: -2, closedIn: 'a', finishedIn: ['a', 7] })).toEqual({
- ...UNASKED,
- finishedIn: ['a'],
- });
+ expect(asStarNudge({ starred: 'yes', askedIn: 'a', finishedIn: ['a', 7] })).toEqual({ ...UNASKED, finishedIn: ['a'] });
});
- it('records each finished turn, each close and the star', async () => {
- expect(isDue(await noteFinishedTurn('a'), 'a')).toBe(true);
- expect(await stored()).toEqual({ starred: false, closes: 0, closedIn: [], finishedIn: ['a'] });
-
- await noteClosed('a');
- expect(isDue(await noteFinishedTurn('a'), 'a')).toBe(false);
- expect(isDue(await noteFinishedTurn('b'), 'b')).toBe(true);
+ it('records each ask and the star', async () => {
+ expect(await noteFinishedTurn('a')).toBe(true);
+ expect(await noteFinishedTurn('a')).toBe(false);
+ expect(await stored()).toEqual({ starred: false, askedIn: ['a'], finishedIn: [] });
await noteStarred();
- expect(isDue(await noteFinishedTurn('c'), 'c')).toBe(false);
- expect(await stored()).toMatchObject({ starred: true, closes: 1, closedIn: ['a'] });
+ expect(await noteFinishedTurn('b')).toBe(false);
+ expect(await stored()).toEqual({ starred: true, askedIn: ['a'], finishedIn: [] });
});
it('leaves storage alone when a turn changes nothing', async () => {
- await noteStarred();
+ await noteFinishedTurn('a');
const write = vi.spyOn(fakeBrowser.storage.local, 'set');
await noteFinishedTurn('a');
expect(write).not.toHaveBeenCalled();
diff --git a/src/lib/bridge/star-nudge.ts b/src/lib/bridge/star-nudge.ts
index 8b10d7e..f8711ba 100644
--- a/src/lib/bridge/star-nudge.ts
+++ b/src/lib/bridge/star-nudge.ts
@@ -3,16 +3,15 @@ import { LINKS } from '@/lib/about';
export const STAR_NUDGE_KEY = 'browsentic/starNudge';
-const CONVERSATIONS_SKIPPED_BY_CLOSES = [0, 0, 2, 3];
+const CONVERSATIONS_SKIPPED_BEFORE_ASK = [0, 0, 2];
export interface StarNudge {
starred: boolean;
- closes: number;
- closedIn: string[];
+ askedIn: string[];
finishedIn: string[];
}
-export const UNASKED: StarNudge = { starred: false, closes: 0, closedIn: [], finishedIn: [] };
+export const UNASKED: StarNudge = { starred: false, askedIn: [], finishedIn: [] };
const isText = (value: unknown): value is string => typeof value === 'string';
@@ -23,55 +22,43 @@ export function asStarNudge(value: unknown): StarNudge {
const held = value as Partial<Record<keyof StarNudge, unknown>>;
return {
starred: held.starred === true,
- closes: typeof held.closes === 'number' && held.closes > 0 ? Math.floor(held.closes) : 0,
- closedIn: texts(held.closedIn),
+ askedIn: texts(held.askedIn),
finishedIn: texts(held.finishedIn),
};
}
-export const conversationsSkipped = (closes: number): number =>
- CONVERSATIONS_SKIPPED_BY_CLOSES[Math.min(closes, CONVERSATIONS_SKIPPED_BY_CLOSES.length - 1)];
+const retired = (nudge: StarNudge): boolean =>
+ nudge.starred || nudge.askedIn.length >= CONVERSATIONS_SKIPPED_BEFORE_ASK.length;
-const waitedOut = (nudge: StarNudge): boolean => nudge.finishedIn.length > conversationsSkipped(nudge.closes);
-
-export const isDue = (nudge: StarNudge, sessionId: string): boolean =>
- !nudge.starred && !nudge.closedIn.includes(sessionId) && waitedOut(nudge);
+const waitedOut = (nudge: StarNudge): boolean =>
+ nudge.finishedIn.length > CONVERSATIONS_SKIPPED_BEFORE_ASK[nudge.askedIn.length];
export function withFinishedTurn(nudge: StarNudge, sessionId: string): StarNudge {
- const uncounted =
- !nudge.starred &&
- !nudge.closedIn.includes(sessionId) &&
- !nudge.finishedIn.includes(sessionId) &&
- !waitedOut(nudge);
- return uncounted ? { ...nudge, finishedIn: [...nudge.finishedIn, sessionId] } : nudge;
+ if (retired(nudge) || nudge.askedIn.includes(sessionId) || nudge.finishedIn.includes(sessionId)) return nudge;
+ const counted = { ...nudge, finishedIn: [...nudge.finishedIn, sessionId] };
+ return waitedOut(counted) ? { ...nudge, askedIn: [...nudge.askedIn, sessionId], finishedIn: [] } : counted;
}
-export function withClose(nudge: StarNudge, sessionId: string): StarNudge {
- if (nudge.closedIn.includes(sessionId)) return nudge;
- return {
- starred: nudge.starred,
- closes: nudge.closes + 1,
- closedIn: [...nudge.closedIn, sessionId],
- finishedIn: [],
- };
-}
+export const asksNow = (before: StarNudge, after: StarNudge): boolean => after.askedIn.length > before.askedIn.length;
export const withStar = (nudge: StarNudge): StarNudge => ({ ...nudge, starred: true });
-async function update(change: (nudge: StarNudge) => StarNudge): Promise<StarNudge> {
+async function update(change: (nudge: StarNudge) => StarNudge): Promise<[StarNudge, StarNudge]> {
const stored = await browser.storage.local.get(STAR_NUDGE_KEY);
const current = asStarNudge(stored[STAR_NUDGE_KEY]);
const next = change(current);
if (next !== current) await browser.storage.local.set({ [STAR_NUDGE_KEY]: next });
- return next;
+ return [current, next];
}
-export const noteFinishedTurn = (sessionId: string): Promise<StarNudge> =>
- update((nudge) => withFinishedTurn(nudge, sessionId));
-
-export const noteClosed = (sessionId: string): Promise<StarNudge> => update((nudge) => withClose(nudge, sessionId));
+export async function noteFinishedTurn(sessionId: string): Promise<boolean> {
+ const [before, after] = await update((nudge) => withFinishedTurn(nudge, sessionId));
+ return asksNow(before, after);
+}
-export const noteStarred = (): Promise<StarNudge> => update(withStar);
+export async function noteStarred(): Promise<void> {
+ await update(withStar);
+}
export async function openRepositoryBeside(): Promise<void> {
const [current] = await browser.tabs.query({ active: true, currentWindow: true });
diff --git a/src/lib/bridge/use-star-nudge.ts b/src/lib/bridge/use-star-nudge.ts
index 2bebbb6..d9f44d2 100644
--- a/src/lib/bridge/use-star-nudge.ts
+++ b/src/lib/bridge/use-star-nudge.ts
@@ -1,5 +1,5 @@
import { useEffect, useRef, useState } from 'react';
-import { STAR_NUDGE_KEY, asStarNudge, isDue, noteClosed, noteFinishedTurn, noteStarred, openRepositoryBeside } from './star-nudge';
+import { STAR_NUDGE_KEY, asStarNudge, noteFinishedTurn, noteStarred, openRepositoryBeside } from './star-nudge';
import { useLocalSetting } from './use-extension-settings';
import type { CompletedTurn } from './use-run';
@@ -9,19 +9,13 @@ export interface StarNudgeView {
close: () => void;
}
-interface Raise {
- sessionId: string;
- closes: number;
-}
-
/**
- * Raised by a turn that finished cleanly in the conversation on screen, and only there. The next run
- * there takes it down, so a turn that fails or is stopped never brings it back, and a close in any
- * other panel retires it.
+ * Raised at most once in a conversation, by a turn that finished cleanly while it was on screen. The
+ * next run there takes it down, and a star clicked in any panel retires it everywhere.
*/
export function useStarNudge(completed: CompletedTurn | null, onScreen: string | null, running: boolean): StarNudgeView {
const [nudge] = useLocalSetting(STAR_NUDGE_KEY, asStarNudge);
- const [raise, setRaise] = useState<Raise | null>(null);
+ const [raisedIn, setRaisedIn] = useState<string | null>(null);
const watching = useRef(onScreen);
useEffect(() => {
@@ -29,27 +23,23 @@ export function useStarNudge(completed: CompletedTurn | null, onScreen: string |
}, [onScreen]);
useEffect(() => {
- if (running) setRaise(null);
+ if (running) setRaisedIn(null);
}, [running]);
useEffect(() => {
if (!completed || completed.sessionId !== watching.current) return;
- void noteFinishedTurn(completed.sessionId).then((next) => {
- if (isDue(next, completed.sessionId)) setRaise({ sessionId: completed.sessionId, closes: next.closes });
+ void noteFinishedTurn(completed.sessionId).then((asks) => {
+ if (asks) setRaisedIn(completed.sessionId);
});
}, [completed]);
return {
- raised: raise !== null && raise.sessionId === onScreen && raise.closes === nudge.closes && isDue(nudge, raise.sessionId),
+ raised: raisedIn !== null && raisedIn === onScreen && !nudge.starred,
star: () => {
- setRaise(null);
+ setRaisedIn(null);
void openRepositoryBeside();
void noteStarred();
},
- close: () => {
- if (!raise) return;
- setRaise(null);
- void noteClosed(raise.sessionId);
- },
+ close: () => setRaisedIn(null),
};
}