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 keeps its promises — a closed conversation is never asked again, a close after a star leaves the star, the next run takes the pill down so a failed or stopped turn never brings it back, a close in another panel retires it, and a click hides it at once so a double click counts once

Shahriar3076a41685c6
diff --git a/docs/guide/features/conversations.md b/docs/guide/features/conversations.md
index f0e9c20..97ab06f 100644
--- a/docs/guide/features/conversations.md
+++ b/docs/guide/features/conversations.md
@@ -139,7 +139,7 @@ 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 float above the
composer. **Star** opens the repository in a tab beside the one you are on, and the pill never comes
-back. **×** puts it away for the rest of that conversation; it asks again in the next one, and after
+back. **×** puts it away in that conversation for good; it asks again in the next one, and after
a second close it waits out two conversations, then three after every close from there on. 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 8073278..f6c3bca 100644
--- a/docs/internals/state.md
+++ b/docs/internals/state.md
@@ -82,8 +82,8 @@ browser shows (`browsentic/contextMenu`, both on when absent).
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 in which conversation, and up to four conversation ids counted since.
-It never leaves the browser.
+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 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/extension/entrypoints/sidepanel/App.tsx b/src/extension/entrypoints/sidepanel/App.tsx
index eaa5de3..8fea5ba 100644
--- a/src/extension/entrypoints/sidepanel/App.tsx
+++ b/src/extension/entrypoints/sidepanel/App.tsx
@@ -62,7 +62,7 @@ const DETACH_STUCK_MS = 1_500;
export default function App() {
const daemon = useDaemonState();
const run = useRun();
- const star = useStarNudge(run.completed, run.sessionId);
+ const star = useStarNudge(run.completed, run.sessionId, run.running);
const [voiceEnabled, setVoiceEnabled] = useVoiceEnabled();
const handsFree = useHandsFreeSupported();
const storedFiles = useStoredFiles();
diff --git a/src/lib/bridge/star-nudge.test.ts b/src/lib/bridge/star-nudge.test.ts
index 007cf13..60710f7 100644
--- a/src/lib/bridge/star-nudge.test.ts
+++ b/src/lib/bridge/star-nudge.test.ts
@@ -27,7 +27,7 @@ function raisedAcross(start: StarNudge, conversations: string[]): string[] {
return raised;
}
-const closedIn = (...conversations: string[]): StarNudge => conversations.reduce(withClose, UNASKED);
+const afterClosing = (...conversations: string[]): StarNudge => conversations.reduce(withClose, UNASKED);
const stored = async () => (await fakeBrowser.storage.local.get(STAR_NUDGE_KEY))[STAR_NUDGE_KEY];
@@ -38,28 +38,41 @@ describe('when the star ask is raised', () => {
it('never asks again once the star was clicked', () => {
expect(raisedAcross(withStar(UNASKED), ['a', 'b', 'c', 'd', 'e', 'f'])).toEqual([]);
- expect(raisedAcross(withStar(closedIn('a', 'b', 'c')), ['d', 'e', 'f', 'g', 'h'])).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(closedIn('a'), ['a', 'a', 'b'])).toEqual(['b']);
+ expect(raisedAcross(afterClosing('a'), ['a', 'a', 'b'])).toEqual(['b']);
});
it('after a second close, sits out two conversations and asks in the third', () => {
- expect(raisedAcross(closedIn('a', 'b'), ['b', 'c', 'd', 'e'])).toEqual(['e']);
+ expect(raisedAcross(afterClosing('a', 'b'), ['b', 'c', 'd', 'e'])).toEqual(['e']);
});
it('after a third close and every one after it, sits out three conversations', () => {
- expect(raisedAcross(closedIn('a', 'b', 'c'), ['d', 'e', 'f', 'g'])).toEqual(['g']);
- expect(raisedAcross(closedIn('a', 'b', 'c', 'g'), ['h', 'i', 'j', 'k'])).toEqual(['k']);
+ 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, however many turns finish in it', () => {
- expect(raisedAcross(closedIn('a', 'b'), ['c', 'c', 'c', 'd', 'd', 'e'])).toEqual(['e']);
+ expect(raisedAcross(afterClosing('a', 'b'), ['c', 'c', 'c', 'd', 'd', 'e'])).toEqual(['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('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, closedIn('a', 'b'));
+ 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);
});
@@ -68,10 +81,10 @@ describe('when the star ask is raised', () => {
describe('the stored star ask', () => {
beforeEach(() => fakeBrowser.reset());
- it('reads anything unexpected as never asked', () => {
+ 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: 4, finishedIn: ['a', 7] })).toEqual({
+ expect(asStarNudge({ starred: 'yes', closes: -2, closedIn: 'a', finishedIn: ['a', 7] })).toEqual({
...UNASKED,
finishedIn: ['a'],
});
@@ -79,7 +92,7 @@ describe('the stored star ask', () => {
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, finishedIn: ['a'] });
+ expect(await stored()).toEqual({ starred: false, closes: 0, closedIn: [], finishedIn: ['a'] });
await noteClosed('a');
expect(isDue(await noteFinishedTurn('a'), 'a')).toBe(false);
@@ -87,7 +100,7 @@ describe('the stored star ask', () => {
await noteStarred();
expect(isDue(await noteFinishedTurn('c'), 'c')).toBe(false);
- expect(await stored()).toMatchObject({ starred: true, closes: 1, closedIn: 'a' });
+ expect(await stored()).toMatchObject({ starred: true, closes: 1, closedIn: ['a'] });
});
it('leaves storage alone when a turn changes nothing', async () => {
diff --git a/src/lib/bridge/star-nudge.ts b/src/lib/bridge/star-nudge.ts
index 4f9a33d..8b10d7e 100644
--- a/src/lib/bridge/star-nudge.ts
+++ b/src/lib/bridge/star-nudge.ts
@@ -8,22 +8,24 @@ const CONVERSATIONS_SKIPPED_BY_CLOSES = [0, 0, 2, 3];
export interface StarNudge {
starred: boolean;
closes: number;
- closedIn?: string;
+ closedIn: string[];
finishedIn: string[];
}
-export const UNASKED: StarNudge = { starred: false, closes: 0, finishedIn: [] };
+export const UNASKED: StarNudge = { starred: false, closes: 0, closedIn: [], finishedIn: [] };
const isText = (value: unknown): value is string => typeof value === 'string';
+const texts = (value: unknown): string[] => (Array.isArray(value) ? value.filter(isText) : []);
+
export function asStarNudge(value: unknown): StarNudge {
if (typeof value !== 'object' || value === null) return UNASKED;
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: isText(held.closedIn) ? held.closedIn : undefined,
- finishedIn: Array.isArray(held.finishedIn) ? held.finishedIn.filter(isText) : [],
+ closedIn: texts(held.closedIn),
+ finishedIn: texts(held.finishedIn),
};
}
@@ -33,20 +35,26 @@ export const conversationsSkipped = (closes: number): number =>
const waitedOut = (nudge: StarNudge): boolean => nudge.finishedIn.length > conversationsSkipped(nudge.closes);
export const isDue = (nudge: StarNudge, sessionId: string): boolean =>
- !nudge.starred && sessionId !== nudge.closedIn && waitedOut(nudge);
+ !nudge.starred && !nudge.closedIn.includes(sessionId) && waitedOut(nudge);
export function withFinishedTurn(nudge: StarNudge, sessionId: string): StarNudge {
const uncounted =
- !nudge.starred && sessionId !== nudge.closedIn && !nudge.finishedIn.includes(sessionId) && !waitedOut(nudge);
+ !nudge.starred &&
+ !nudge.closedIn.includes(sessionId) &&
+ !nudge.finishedIn.includes(sessionId) &&
+ !waitedOut(nudge);
return uncounted ? { ...nudge, finishedIn: [...nudge.finishedIn, sessionId] } : nudge;
}
-export const withClose = (nudge: StarNudge, sessionId: string): StarNudge => ({
- starred: false,
- closes: nudge.closes + 1,
- closedIn: sessionId,
- finishedIn: [],
-});
+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 withStar = (nudge: StarNudge): StarNudge => ({ ...nudge, starred: true });
diff --git a/src/lib/bridge/use-star-nudge.ts b/src/lib/bridge/use-star-nudge.ts
index 9a2d67d..2bebbb6 100644
--- a/src/lib/bridge/use-star-nudge.ts
+++ b/src/lib/bridge/use-star-nudge.ts
@@ -9,35 +9,47 @@ export interface StarNudgeView {
close: () => void;
}
-/** Raised by a turn that finished cleanly in the conversation on screen, and only there. */
-export function useStarNudge(completed: CompletedTurn | null, onScreen: string | null): StarNudgeView {
+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.
+ */
+export function useStarNudge(completed: CompletedTurn | null, onScreen: string | null, running: boolean): StarNudgeView {
const [nudge] = useLocalSetting(STAR_NUDGE_KEY, asStarNudge);
- const [raisedIn, setRaisedIn] = useState<string | null>(null);
+ const [raise, setRaise] = useState<Raise | null>(null);
const watching = useRef(onScreen);
useEffect(() => {
watching.current = onScreen;
}, [onScreen]);
+ useEffect(() => {
+ if (running) setRaise(null);
+ }, [running]);
+
useEffect(() => {
if (!completed || completed.sessionId !== watching.current) return;
- let live = true;
void noteFinishedTurn(completed.sessionId).then((next) => {
- if (live && isDue(next, completed.sessionId)) setRaisedIn(completed.sessionId);
+ if (isDue(next, completed.sessionId)) setRaise({ sessionId: completed.sessionId, closes: next.closes });
});
- return () => {
- live = false;
- };
}, [completed]);
return {
- raised: raisedIn !== null && raisedIn === onScreen && isDue(nudge, raisedIn),
+ raised: raise !== null && raise.sessionId === onScreen && raise.closes === nudge.closes && isDue(nudge, raise.sessionId),
star: () => {
+ setRaise(null);
void openRepositoryBeside();
void noteStarred();
},
close: () => {
- if (raisedIn) void noteClosed(raisedIn);
+ if (!raise) return;
+ setRaise(null);
+ void noteClosed(raise.sessionId);
},
};
}