mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-25 04:33:03 +00:00
Keep Assistant queue state out of active status text
This commit is contained in:
@@ -5679,16 +5679,20 @@ describe('AIChat', () => {
|
||||
]);
|
||||
|
||||
const status = screen.getByLabelText('Assistant active turn status');
|
||||
await waitFor(() =>
|
||||
expect(status).toHaveTextContent('Preparing Pulse context. · 1 follow-up queued'),
|
||||
await waitFor(() => expect(status).toHaveTextContent('Preparing Pulse context.'));
|
||||
expect(status).not.toHaveTextContent('follow-up queued');
|
||||
expect(screen.getByLabelText('Queued follow-up messages')).toHaveTextContent(
|
||||
'1 follow-up queued',
|
||||
);
|
||||
expect(status).not.toHaveTextContent('OpenRouter is starting the response.');
|
||||
|
||||
await vi.advanceTimersByTimeAsync(WORKFLOW_STATUS_PACE_MS);
|
||||
expect(status).toHaveTextContent('Reading current Pulse inventory. · 1 follow-up queued');
|
||||
expect(status).toHaveTextContent('Reading current Pulse inventory.');
|
||||
expect(status).not.toHaveTextContent('follow-up queued');
|
||||
|
||||
await vi.advanceTimersByTimeAsync(WORKFLOW_STATUS_PACE_MS);
|
||||
expect(status).toHaveTextContent('OpenRouter is starting the response. · 1 follow-up queued');
|
||||
expect(status).toHaveTextContent('OpenRouter is starting the response.');
|
||||
expect(status).not.toHaveTextContent('follow-up queued');
|
||||
expect(status).not.toHaveTextContent('Preparing Pulse context.');
|
||||
expect(status).not.toHaveTextContent('Reading current Pulse inventory.');
|
||||
});
|
||||
@@ -5842,7 +5846,10 @@ describe('AIChat', () => {
|
||||
|
||||
expect(activityDock).toContainElement(screen.getByLabelText('Assistant active turn status'));
|
||||
expect(screen.getByLabelText('Assistant active turn status')).toHaveTextContent(
|
||||
'Generating response · 1 follow-up queued',
|
||||
'Generating response',
|
||||
);
|
||||
expect(screen.getByLabelText('Assistant active turn status')).not.toHaveTextContent(
|
||||
'follow-up queued',
|
||||
);
|
||||
expect(activityDock).toContainElement(screen.getByLabelText('Queued follow-up messages'));
|
||||
expect(screen.getByText('1 follow-up queued')).toBeInTheDocument();
|
||||
|
||||
@@ -61,7 +61,8 @@ describe('getAssistantActiveTurnStatus', () => {
|
||||
),
|
||||
).toEqual({
|
||||
type: 'thinking',
|
||||
text: 'Sending prompt · 1 follow-up queued',
|
||||
text: 'Sending prompt',
|
||||
queuedFollowUpCount: 1,
|
||||
startedAt: 1_000,
|
||||
});
|
||||
});
|
||||
@@ -82,7 +83,8 @@ describe('getAssistantActiveTurnStatus', () => {
|
||||
),
|
||||
).toEqual({
|
||||
type: 'thinking',
|
||||
text: 'OpenRouter is starting the response. · 2 follow-ups queued',
|
||||
text: 'OpenRouter is starting the response.',
|
||||
queuedFollowUpCount: 2,
|
||||
startedAt: 1_000,
|
||||
});
|
||||
});
|
||||
@@ -1016,7 +1018,8 @@ describe('getAssistantActiveTurnStatus', () => {
|
||||
),
|
||||
).toEqual({
|
||||
type: 'generating',
|
||||
text: 'Generating response · 2 follow-ups queued',
|
||||
text: 'Generating response',
|
||||
queuedFollowUpCount: 2,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ export interface AssistantActiveTurnStatus {
|
||||
text: string;
|
||||
type: AssistantActiveTurnStatusKind;
|
||||
startedAt?: number;
|
||||
queuedFollowUpCount?: number;
|
||||
}
|
||||
|
||||
interface AssistantActiveTurnStatusCandidate extends AssistantActiveTurnStatus {
|
||||
@@ -581,21 +582,15 @@ export const getAssistantQueuedFollowUpCount = (messages: ChatMessage[]): number
|
||||
0,
|
||||
);
|
||||
|
||||
export const getAssistantQueuedFollowUpStatusSuffix = (messages: ChatMessage[]): string => {
|
||||
const count = getAssistantQueuedFollowUpCount(messages);
|
||||
if (count <= 0) return '';
|
||||
return ` · ${count} ${count === 1 ? 'follow-up' : 'follow-ups'} queued`;
|
||||
};
|
||||
|
||||
export const withAssistantQueuedFollowUpStatus = (
|
||||
status: AssistantActiveTurnStatus,
|
||||
messages: ChatMessage[],
|
||||
): AssistantActiveTurnStatus => {
|
||||
const suffix = getAssistantQueuedFollowUpStatusSuffix(messages);
|
||||
if (!suffix) return status;
|
||||
const count = getAssistantQueuedFollowUpCount(messages);
|
||||
if (count <= 0) return status;
|
||||
return {
|
||||
...status,
|
||||
text: `${status.text}${suffix}`,
|
||||
queuedFollowUpCount: count,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -2437,6 +2437,9 @@ export const AIChat: Component<AIChatProps> = (props) => {
|
||||
currentStatusNow(),
|
||||
);
|
||||
});
|
||||
const activityDockQueuedFollowUpCount = createMemo(() =>
|
||||
Math.max(currentStatus()?.queuedFollowUpCount || 0, chat.queuedFollowUpCount()),
|
||||
);
|
||||
createEffect(() => {
|
||||
const status = currentStatus();
|
||||
if (!status?.startedAt) return;
|
||||
@@ -4491,7 +4494,7 @@ export const AIChat: Component<AIChatProps> = (props) => {
|
||||
when={
|
||||
currentStatus() ||
|
||||
autonomousWarningVisible() ||
|
||||
chat.queuedFollowUpCount() > 0
|
||||
activityDockQueuedFollowUpCount() > 0
|
||||
}
|
||||
>
|
||||
<div
|
||||
@@ -4593,7 +4596,7 @@ export const AIChat: Component<AIChatProps> = (props) => {
|
||||
</button>
|
||||
</div>
|
||||
</Show>
|
||||
<Show when={chat.queuedFollowUpCount() > 0}>
|
||||
<Show when={activityDockQueuedFollowUpCount() > 0}>
|
||||
<div
|
||||
class={`px-2.5 py-1.5 ${
|
||||
currentStatus() || autonomousWarningVisible()
|
||||
@@ -4606,7 +4609,11 @@ export const AIChat: Component<AIChatProps> = (props) => {
|
||||
<div class="flex min-h-7 items-center gap-2">
|
||||
<ClockIcon class="h-3.5 w-3.5 shrink-0" aria-hidden="true" />
|
||||
<span class="min-w-0 flex-1 truncate text-xs font-medium">
|
||||
{pluralizeCount(chat.queuedFollowUpCount(), 'follow-up', 'follow-ups')}{' '}
|
||||
{pluralizeCount(
|
||||
activityDockQueuedFollowUpCount(),
|
||||
'follow-up',
|
||||
'follow-ups',
|
||||
)}{' '}
|
||||
{chat.queuedFollowUpsPaused() ? 'paused' : 'queued'}
|
||||
</span>
|
||||
<button
|
||||
|
||||
Reference in New Issue
Block a user