fix(ui): hide startup steps too short to name and hold labels long enough to read (#23299)

## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The task view names each startup stage of a run until the agent
works, for example "Preparing workspace" or "Starting agent".
> - Core and environment plugins report every startup step as it starts,
however short, and the task view decides which labels to show.
> - The view held each label for 500 ms and showed every change at once.
A step of a few milliseconds that started after a longer step appeared
at once and stayed up after it ended. Also, 500 ms is less than the time
most labels take to read.
> - This pull request adds a short show delay, so that steps too short
to name never appear, and holds each shown label for its reading time.
> - The benefit is a status line that changes only for steps that last,
and stays up long enough to read.

## Linked Issues or Issue Description

No public issue exists. Follows #22956, which added the startup stage
labels.

**Subsystem affected**
Task chat UI: the startup stage line of a running turn
(`ui/src/components/task-chat`).

**Problem or motivation**
A startup step that lasts a few milliseconds can show its label for 500
ms after the step ended. For example, a short "Connecting tools" step
inside a long "Starting agent" step changes the line twice. Also, the
500 ms hold is shorter than the time needed to read most labels.

**Proposed solution**
Use the common loading-indicator pattern of a show delay plus a minimum
display time. Base the minimum time on reading time:
- A new stage's label shows only after the stage stays current for 300
ms.
- A shown label stays up for 50 ms per character (20 characters a
second, the usual adult subtitle reading speed), and at least
five-sixths of a second (the usual subtitle minimum).

**Alternatives considered**
- Only a minimum display time (the current behavior). This prevents
flicker, but short steps still show and stay up after they end.
- Hide steps in the reporter. This would put a display rule in each
reporter. Reporters report every step, and the view decides what to
show.

## What Changed

- `useHeldLabel` shows a new label only after it stays current for
`STARTUP_LABEL_SHOW_DELAY_MS` (300 ms). Labels that come and go within
that time never show.
- A shown label stays up for `startupLabelHoldMs(label)`: the greater of
833 ms and 50 ms per character. Today's labels stay up for 0.83 s to
0.95 s.
- The end of startup (no label) has no show delay. The last label is
still held so that it can be read. Agent activity replaces the line as
before.
- The first label shows at once. A task opened during startup can show a
stage that is already old, and `Thinking` in its place would be wrong.
- `DESIGN.md` describes the show delay, the reading-time hold, and the
first label.

## Verification

- `npx vitest run src/components/task-chat/run-startup-stage.test.ts` in
`ui`: 9 tests pass. They cover the first label, the hold per label, the
show delay, a short step inside a longer one, a skip to the latest
stage, a longer hold for a longer label, and the end of startup.
- `npx vitest run src/components/TaskChatThread.test.tsx -t "startup
stage"` in `ui`: the startup stage thread tests pass.
- `pnpm --filter @paperclipai/ui typecheck` passes.
- CI runs the full suite.

## Risks

- Low risk. This changes display timing only.
- Each new label shows 300 ms later than before. A shown label can stay
up for up to about 0.65 s after its step ends, if the step is just
longer than the show delay.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use
(shell, file edits, web research).

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Nicky LeachandClaude Opus 5.5 authored and GitHub committed 2026-11-30 10:03:46 -08:00
1 parent 79dadd8655
commit 79ef767578
4 files changed
+135 -41

No files matched your search

+5 -2
View File
@@ -14,7 +14,7 @@ import { TooltipProvider } from "@/components/ui/tooltip";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { ConnectivityProvider, createConnectivityStore } from "@/lib/connectivity";
import { INITIAL_TRANSCRIPT_REVEAL_BUDGET_MS, TaskChatThread } from "./TaskChatThread";
import { STARTUP_LABEL_MIN_DISPLAY_MS } from "./task-chat/run-startup-stage";
import { STARTUP_LABEL_SHOW_DELAY_MS, startupLabelHoldMs } from "./task-chat/run-startup-stage";
import { IssueChatThread } from "./IssueChatThread";
import { TaskChatAgentIdentity, TaskTranscriptAgents } from "./task-chat/TaskChatBubble";
import type {
@@ -1834,8 +1834,11 @@ describe("TaskChatThread runtime transcript selection", () => {
// The stage is the activity line; the header keeps its usual Working status.
expect(container.querySelector('[data-testid="task-chat-turn-status-header"]')?.textContent).toContain("Working");
await act(async () => { await new Promise(resolve => setTimeout(resolve, STARTUP_LABEL_MIN_DISPLAY_MS + 50)); });
// A shown stage stays up long enough to read; the next one shows once it has stayed current for the show delay.
await act(async () => { await new Promise(resolve => setTimeout(resolve, startupLabelHoldMs("Connecting tools"))); });
renderThread({ ...props, activeRun: { ...run, startupStage: "starting_agent", startupSessionResumed: true } });
expect(activity()?.textContent).toBe("Connecting tools");
await act(async () => { await new Promise(resolve => setTimeout(resolve, STARTUP_LABEL_SHOW_DELAY_MS + 50)); });
expect(activity()?.textContent).toBe("Resuming session");
nativeTranscriptState.transcriptByRun.set(run.id, [