Skip to content

Commit e41ceab

Browse files
committed
Collapse file-picker by default
1 parent f76272a commit e41ceab

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

cli/src/hooks/use-send-message.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ import { has, isEqual } from 'lodash'
22
import { useCallback, useEffect, useRef } from 'react'
33

44
import { getCodebuffClient, formatToolOutput } from '../utils/codebuff-client'
5-
import { MAIN_AGENT_ID, shouldHideAgent } from '../utils/constants'
5+
import {
6+
MAIN_AGENT_ID,
7+
shouldHideAgent,
8+
shouldCollapseByDefault,
9+
} from '../utils/constants'
610
import { createValidationErrorBlocks } from '../utils/create-validation-error-blocks'
711
import { getErrorObject } from '../utils/error'
812
import { formatTimestamp } from '../utils/helpers'
@@ -1130,10 +1134,13 @@ export const useSendMessage = ({
11301134
setCollapsedAgents((prev) => {
11311135
const next = new Set(prev)
11321136
next.delete(tempId)
1133-
// Only collapse if parent is NOT main agent (i.e., it's a nested agent)
1137+
// Collapse if:
1138+
// 1. Parent is NOT main agent (nested agent), OR
1139+
// 2. Agent type is in the collapsed-by-default list
11341140
if (
1135-
event.parentAgentId &&
1136-
event.parentAgentId !== MAIN_AGENT_ID
1141+
(event.parentAgentId &&
1142+
event.parentAgentId !== MAIN_AGENT_ID) ||
1143+
shouldCollapseByDefault(event.agentType)
11371144
) {
11381145
next.add(event.agentId)
11391146
}
@@ -1233,10 +1240,13 @@ export const useSendMessage = ({
12331240
)
12341241

12351242
setStreamingAgents((prev) => new Set(prev).add(event.agentId))
1236-
// Only collapse if parent is NOT main agent (i.e., it's a nested agent)
1243+
// Collapse if:
1244+
// 1. Parent is NOT main agent (nested agent), OR
1245+
// 2. Agent type is in the collapsed-by-default list
12371246
if (
1238-
event.parentAgentId &&
1239-
event.parentAgentId !== MAIN_AGENT_ID
1247+
(event.parentAgentId &&
1248+
event.parentAgentId !== MAIN_AGENT_ID) ||
1249+
shouldCollapseByDefault(event.agentType)
12401250
) {
12411251
setCollapsedAgents((prev) =>
12421252
new Set(prev).add(event.agentId),

cli/src/utils/constants.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ export const shouldHideAgent = (agentId: string): boolean => {
88
return HIDDEN_AGENT_IDS.some((hiddenId) => agentId.includes(hiddenId))
99
}
1010

11+
// Agent IDs that should be collapsed by default when they start
12+
export const COLLAPSED_BY_DEFAULT_AGENT_IDS = ['file-picker'] as const
13+
14+
/**
15+
* Check if an agent should be collapsed by default
16+
*/
17+
export const shouldCollapseByDefault = (agentType: string): boolean => {
18+
return COLLAPSED_BY_DEFAULT_AGENT_IDS.some((collapsedId) =>
19+
agentType.includes(collapsedId),
20+
)
21+
}
22+
1123
/**
1224
* The parent agent ID for all root-level agents
1325
*/

0 commit comments

Comments
 (0)