Skip to content

Commit 117eb7f

Browse files
committed
refactor(cli): improve code formatting and simplify repo path UI in chat.tsx
1 parent 824f0d1 commit 117eb7f

File tree

1 file changed

+32
-27
lines changed

1 file changed

+32
-27
lines changed

cli/src/chat.tsx

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -222,25 +222,30 @@ export const App = ({
222222
}
223223
}, [authQuery.isSuccess, authQuery.isError, authQuery.data, user])
224224

225-
226225
// Update logo when terminal width changes
227226
useEffect(() => {
228227
if (messages.length > 0) {
229-
const systemMessage = messages.find(m => m.id.startsWith('system-loaded-agents-'))
228+
const systemMessage = messages.find((m) =>
229+
m.id.startsWith('system-loaded-agents-'),
230+
)
230231
if (systemMessage?.blocks) {
231-
const logoBlockIndex = systemMessage.blocks.findIndex(b => b.type === 'text' && b.content.includes('█'))
232+
const logoBlockIndex = systemMessage.blocks.findIndex(
233+
(b) => b.type === 'text' && b.content.includes('█'),
234+
)
232235
if (logoBlockIndex !== -1) {
233-
setMessages(prev => prev.map(msg => {
234-
if (msg.id === systemMessage.id) {
235-
const newBlocks = [...msg.blocks!]
236-
newBlocks[logoBlockIndex] = {
237-
type: 'text',
238-
content: '\n\n' + logoBlock,
236+
setMessages((prev) =>
237+
prev.map((msg) => {
238+
if (msg.id === systemMessage.id) {
239+
const newBlocks = [...msg.blocks!]
240+
newBlocks[logoBlockIndex] = {
241+
type: 'text',
242+
content: '\n\n' + logoBlock,
243+
}
244+
return { ...msg, blocks: newBlocks }
239245
}
240-
return { ...msg, blocks: newBlocks }
241-
}
242-
return msg
243-
}))
246+
return msg
247+
}),
248+
)
244249
}
245250
}
246251
}
@@ -283,18 +288,17 @@ export const App = ({
283288
}
284289

285290
const renderRepoPathInfo = () => (
286-
<box style={{ flexDirection: 'row', gap: 0, flexWrap: 'wrap' }}>
287-
<text wrap={false}>Codebuff can read and write files in </text>
291+
<text wrap={true}>
292+
Codebuff can read and write files in{' '}
288293
<TerminalLink
289294
text={displayPath}
290295
color="#3b82f6"
291-
inline={false}
292-
lineWrap={false}
293-
containerStyle={{ flexDirection: 'row', width: 'auto' }}
296+
inline={true}
297+
underlineOnHover={true}
294298
onActivate={handleActivateRepoPath}
295299
/>
296-
<text wrap={false}>, and run terminal commands to help you build.</text>
297-
</box>
300+
, and run terminal commands to help you build.
301+
</text>
298302
)
299303

300304
blocks.push({
@@ -478,7 +482,6 @@ export const App = ({
478482
// Track main agent streaming elapsed time
479483
const mainAgentTimer = useElapsedTime()
480484

481-
482485
const agentRefsMap = useRef<Map<string, any>>(new Map())
483486
const hasAutoSubmittedRef = useRef(false)
484487
const activeSubagentsRef = useRef<Set<string>>(activeSubagents)
@@ -1014,7 +1017,6 @@ export const App = ({
10141017
exitWarning || hasStatus || shouldShowQueuePreview,
10151018
)
10161019

1017-
10181020
const statusIndicatorNode = (
10191021
<StatusIndicator
10201022
theme={theme}
@@ -1047,13 +1049,16 @@ export const App = ({
10471049
}
10481050

10491051
// Get agent info by ID
1050-
const createAgentInfoEntry = (
1051-
agent: any,
1052-
): [string, LocalAgentInfo] => [agent.id, agent as LocalAgentInfo]
1052+
const createAgentInfoEntry = (agent: any): [string, LocalAgentInfo] => [
1053+
agent.id,
1054+
agent as LocalAgentInfo,
1055+
]
10531056

10541057
const agentInfoById = new Map<string, LocalAgentInfo>(
1055-
(loadedAgentsData?.agents.map(createAgentInfoEntry) ||
1056-
[]) as [string, LocalAgentInfo][],
1058+
(loadedAgentsData?.agents.map(createAgentInfoEntry) || []) as [
1059+
string,
1060+
LocalAgentInfo,
1061+
][],
10571062
)
10581063

10591064
const formatErrorLine = (

0 commit comments

Comments
 (0)