Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions dashboard/e2e/thread.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,10 @@ test('an attached file that is not an image travels as a path, and reads as a ch
}
});

test('a turn with nothing to show yet shows the spinner, and stops once it has', async () => {
test('a turn shows the spinner from the send until it ends, also while text is the last thing said', async () => {
await start({
// Long enough to read the spinner's style before the answer replaces it.
prompts: [{ match: () => true, gapMs: 2500, updates: reply('Eventually.') }],
// Long enough to read the spinner before the first chunk and between the chunks.
prompts: [{ match: () => true, gapMs: 2500, updates: reply('Eventually. ', 'Done.') }],
});

const { page, errors, close } = await openPage(
Expand All @@ -266,10 +266,16 @@ test('a turn with nothing to show yet shows the spinner, and stops once it has',
)
.toBe('spinner-block');

// And it is gone as soon as there is something to read instead.
// The turn is not over after the first text, so the spinner stays.
await expect
.poll(() => page.getByText('Eventually.').isVisible(), { timeout: 10_000 })
.toBe(true);
expect(await spinner.count()).toBe(1);

// And it is gone when the turn ends.
await expect
.poll(() => page.getByText('Eventually. Done.').isVisible(), { timeout: 10_000 })
.toBe(true);
await expect.poll(() => spinner.count()).toBe(0);
expect(errors).toEqual([]);
} finally {
Expand Down Expand Up @@ -923,6 +929,8 @@ test('a sub agent is a closed card that shows its run when opened', async () =>
const label = card.locator('[data-slot="tool-fallback-trigger-label"]');
const shimmers = () => label.evaluate((el) => el.classList.contains('shimmer'));
expect(await shimmers()).toBe(true);
// No turn runs, so the card is the only thing that shows work.
expect(await page.getByRole('img', { name: 'Assistant is working' }).count()).toBe(0);

stub.gateway.emit({
sessionUpdate: 'subagent_state_update',
Expand Down
37 changes: 25 additions & 12 deletions dashboard/src/components/assistant-ui/elements/thread.aui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ const ThreadRoot: FC<{
<ThreadPrimitive.Messages>
{() => <ThreadMessage />}
</ThreadPrimitive.Messages>
<TurnIndicator />
</div>

<ThreadPrimitive.ViewportFooter
Expand Down Expand Up @@ -372,6 +373,28 @@ export const ThreadMessage: FC = () => {
return <AssistantMessageComponent />;
};

/**
* Boxes edit: the spinner under the last message while the turn of the agent
* runs, whatever the last message holds. It shows that the agent has not
* handed the conversation back.
*
* It uses the spinner of the dashboard, because it is often the only thing on
* screen while a turn thinks, and a pulsing dot looks like a page that stopped
* repainting.
*/
const TurnIndicator: FC = () => {
const running = useAuiState((s) => s.thread.isRunning);
if (!running) return null;
return (
<span
data-slot="aui_turn-indicator"
className="inline-flex items-center px-2 py-1"
>
<Spinner label="Assistant is working" />
</span>
);
};

/** The round button that scrolls the thread to its end. It hides at the end. */
const ThreadScrollToBottom: FC = () => {
return (
Expand Down Expand Up @@ -596,6 +619,8 @@ const AssistantMessage: FC = () => {
className="text-foreground px-2 leading-relaxed wrap-break-word"
>
<MessagePrimitive.GroupedParts
/* Boxes edit: the thread shows the indicator, see TurnIndicator. */
indicator="never"
groupBy={groupPartByType({
reasoning: ["group-chainOfThought", "group-reasoning"],
"tool-call": ["group-chainOfThought", "group-tool"],
Expand Down Expand Up @@ -652,18 +677,6 @@ const AssistantMessage: FC = () => {
<Image {...part} />
</div>
);
case "indicator":
/* Boxes edit: uses the spinner of the dashboard. It is often the
only thing on screen while a turn thinks, and a pulsing dot
looks like a page that stopped repainting. */
return (
<span
data-slot="aui_assistant-message-indicator"
className="inline-flex items-center py-1"
>
<Spinner label="Assistant is working" />
</span>
);
default:
return null;
}
Expand Down
Loading