Skip to content

🀯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

πŸ› fix(topic): stop the sidebar clock when the answer is already done (#19751)

Arvin Xu9266926e452c
diff --git a/src/features/AgentSidebar/Topic/List/Item/index.test.tsx b/src/features/AgentSidebar/Topic/List/Item/index.test.tsx
index 15db1675453..ec663cc0c5d 100644
--- a/src/features/AgentSidebar/Topic/List/Item/index.test.tsx
+++ b/src/features/AgentSidebar/Topic/List/Item/index.test.tsx
@@ -289,6 +289,40 @@ describe('TopicItem active state', () => {
expect(screen.queryByTestId('topic-item-icon')).not.toBeInTheDocument();
});
+ // Same masked tail, now with the server fallback in play: the answer is
+ // visibly complete (ring masked) while the operation finishes its terminal
+ // bookkeeping, which on the server routinely runs for seconds. `runStartedAt`
+ // only knows the persisted `running` status, so it stays set across that
+ // whole window β€” without the ring's own gate the row kept counting next to a
+ // finished answer.
+ it('hides the running elapsed time during the masked running tail', () => {
+ vi.useFakeTimers();
+ const now = Date.UTC(2026, 0, 1, 0, 2, 37);
+ vi.setSystemTime(now);
+ runningStartTimeMock.value = undefined;
+ activeTopicIdMock.value = 'tpc_test';
+ agentRuntimeRunningMock.value = true;
+ useTopicNavigationMock.mockReturnValue({
+ isInAgentSubRoute: false,
+ isInTopicContextRoute: true,
+ navigateToTopic: vi.fn(),
+ routeTopicId: 'tpc_test',
+ urlTopicId: 'tpc_test',
+ });
+
+ render(
+ <TopicItem
+ id="tpc_test"
+ runStartedAt={new Date(now - 157_000).toISOString()}
+ status="running"
+ title="Topic"
+ />,
+ );
+
+ expect(screen.queryByTestId('ring-loading')).not.toBeInTheDocument();
+ expect(screen.queryByText('02:37')).not.toBeInTheDocument();
+ });
+
it('keeps idle topics iconless', () => {
useTopicNavigationMock.mockReturnValue({
isInAgentSubRoute: false,
diff --git a/src/features/AgentSidebar/Topic/List/Item/index.tsx b/src/features/AgentSidebar/Topic/List/Item/index.tsx
index 1729ebcbb13..11806d22a7d 100644
--- a/src/features/AgentSidebar/Topic/List/Item/index.tsx
+++ b/src/features/AgentSidebar/Topic/List/Item/index.tsx
@@ -538,11 +538,20 @@ const TopicItemRow = memo<TopicItemRowProps>(
extra={
<>
<TopicMigrationIndicator agentId={activeAgentId} topicId={id} />
- <RunningElapsedTime
- agentId={activeAgentId}
- runStartedAt={runStartedAt}
- topicId={id}
- />
+ {/* Gated on the SAME boolean that draws the running ring: both say
+ "this row is visibly running", and a row that stopped spinning
+ must not keep counting. The server `runStartedAt` fallback only
+ knows the persisted `running` status, which outlives the answer
+ β€” it stays set through the post-visible-output tail where the
+ ring is deliberately masked (#16518) and the terminal
+ bookkeeping can run for tens of seconds. */}
+ {shouldShowRunningIcon && (
+ <RunningElapsedTime
+ agentId={activeAgentId}
+ runStartedAt={runStartedAt}
+ topicId={id}
+ />
+ )}
</>
}
onClick={handleClick}