Skip to content

Commit 8a875dd

Browse files
committed
Add toggle open flag and tighten collapse spacing
1 parent cff6819 commit 8a875dd

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

cli/src/chat.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ export const App = ({
100100
requireAuth,
101101
hasInvalidCredentials,
102102
loadedAgentsData,
103+
initialToggleState,
103104
}: {
104105
initialPrompt: string | null
105106
agentId?: string
@@ -109,6 +110,7 @@ export const App = ({
109110
agents: Array<{ id: string; displayName: string }>
110111
agentsDir: string
111112
} | null
113+
initialToggleState: 'open' | 'closed' | null
112114
}) => {
113115
const renderer = useRenderer()
114116
const { width: measuredWidth } = useTerminalDimensions()
@@ -128,6 +130,7 @@ export const App = ({
128130

129131
const theme = chatTheme
130132
const markdownPalette = useMemo(() => createMarkdownPalette(theme), [theme])
133+
const shouldCollapseByDefault = initialToggleState !== 'open'
131134

132135
const [exitWarning, setExitWarning] = useState<string | null>(null)
133136
const exitArmedRef = useRef(false)
@@ -238,11 +241,13 @@ export const App = ({
238241
timestamp: new Date().toISOString(),
239242
}
240243

241-
// Set as collapsed by default
242-
setCollapsedAgents((prev) => new Set([...prev, agentListId]))
244+
// Set as collapsed by default unless forced open
245+
if (shouldCollapseByDefault) {
246+
setCollapsedAgents((prev) => new Set([...prev, agentListId]))
247+
}
243248
setMessages([initialMessage])
244249
}
245-
}, [loadedAgentsData, theme]) // Only run when loadedAgentsData changes
250+
}, [loadedAgentsData, theme, shouldCollapseByDefault]) // Only run when loadedAgentsData changes
246251

247252
const {
248253
inputValue,

cli/src/components/branch-item.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export const BranchItem = ({
150150
gap: 0,
151151
flexShrink: 0,
152152
marginTop: 1,
153-
marginBottom: 1,
153+
marginBottom: 0,
154154
}}
155155
>
156156
<box style={{ flexDirection: 'column', gap: 0 }}>
@@ -188,7 +188,7 @@ export const BranchItem = ({
188188
</text>
189189
)}
190190
{!isCollapsed && (
191-
<box style={{ flexDirection: 'column', gap: 1 }}>
191+
<box style={{ flexDirection: 'column', gap: 0 }}>
192192
{content && (
193193
<box
194194
border
@@ -220,7 +220,7 @@ export const BranchItem = ({
220220
frameColor={collapseButtonFrame}
221221
textColor={collapseButtonText}
222222
onPress={onToggle}
223-
style={{ alignSelf: 'flex-end', marginTop: 1 }}
223+
style={{ alignSelf: 'flex-end' }}
224224
/>
225225
</box>
226226
)}

cli/src/index.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type ParsedArgs = {
3737
initialPrompt: string | null
3838
agent?: string
3939
clearLogs: boolean
40+
toggleState: 'open' | 'closed' | null
4041
}
4142

4243
function parseArgs(): ParsedArgs {
@@ -51,6 +52,10 @@ function parseArgs(): ParsedArgs {
5152
'Specify which agent to use (e.g., "base", "ask", "file-picker")',
5253
)
5354
.option('--clear-logs', 'Remove any existing CLI log files before starting')
55+
.option(
56+
'--toggle <state>',
57+
'Force initial toggle state (open | closed)',
58+
)
5459
.helpOption('-h, --help', 'Show this help message')
5560
.argument('[prompt...]', 'Initial prompt to send to the agent')
5661
.allowExcessArguments(true)
@@ -63,10 +68,18 @@ function parseArgs(): ParsedArgs {
6368
initialPrompt: args.length > 0 ? args.join(' ') : null,
6469
agent: options.agent,
6570
clearLogs: options.clearLogs || false,
71+
toggleState:
72+
typeof options.toggle === 'string'
73+
? options.toggle.trim().toLowerCase() === 'open'
74+
? 'open'
75+
: options.toggle.trim().toLowerCase() === 'closed'
76+
? 'closed'
77+
: null
78+
: null,
6679
}
6780
}
6881

69-
const { initialPrompt, agent, clearLogs } = parseArgs()
82+
const { initialPrompt, agent, clearLogs, toggleState } = parseArgs()
7083

7184
if (clearLogs) {
7285
clearLogFile()
@@ -122,6 +135,7 @@ const AppWithAsyncAuth = () => {
122135
requireAuth={requireAuth}
123136
hasInvalidCredentials={hasInvalidCredentials}
124137
loadedAgentsData={loadedAgentsData}
138+
initialToggleState={toggleState}
125139
/>
126140
)
127141
}

0 commit comments

Comments
 (0)