Skip to content

Commit e11419d

Browse files
committed
feat(tui): show session state (Idle/Working/Retrying) in prompt footer
1 parent f3f3659 commit e11419d

1 file changed

Lines changed: 59 additions & 34 deletions

File tree

packages/tui/src/component/prompt/index.tsx

Lines changed: 59 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,6 +1343,26 @@ export function Prompt(props: PromptProps) {
13431343
})
13441344
const maxHeight = createMemo(() => tuiConfig.prompt?.max_height ?? Math.max(6, Math.floor(dimensions().height / 3)))
13451345
const moveLabelWidth = createMemo(() => Math.max(12, Math.min(44, dimensions().width - 48)))
1346+
const stateLabel = createMemo(() => {
1347+
switch (status().type) {
1348+
case "idle":
1349+
return "Idle"
1350+
case "busy":
1351+
return "Working"
1352+
case "retry":
1353+
return "Retrying"
1354+
}
1355+
})
1356+
const stateColor = createMemo(() => {
1357+
switch (status().type) {
1358+
case "idle":
1359+
return theme.textMuted
1360+
case "busy":
1361+
return theme.accent
1362+
case "retry":
1363+
return theme.error
1364+
}
1365+
})
13461366

13471367
return (
13481368
<>
@@ -1649,41 +1669,46 @@ export function Prompt(props: PromptProps) {
16491669
)}
16501670
</Match>
16511671
</Switch>
1652-
<Show when={status().type !== "retry"}>
1653-
<box gap={2} flexDirection="row">
1654-
<Show when={editorContextLabelState() !== "none" ? editorFileLabelDisplay() : undefined}>
1655-
{(file) => (
1656-
<text fg={editorContextLabelState() === "pending" ? theme.secondary : theme.textMuted}>{file()}</text>
1657-
)}
1658-
</Show>
1659-
<Switch>
1660-
<Match when={store.mode === "normal"}>
1661-
<Switch>
1662-
<Match when={usage()}>
1663-
{(item) => (
1664-
<text fg={theme.textMuted} wrapMode="none">
1665-
{[item().context, item().cost].filter(Boolean).join(" · ")}
1672+
<box gap={2} flexDirection="row">
1673+
<text fg={stateColor()}>{stateLabel()}</text>
1674+
<Show when={status().type !== "retry"}>
1675+
<box gap={2} flexDirection="row">
1676+
<Show when={editorContextLabelState() !== "none" ? editorFileLabelDisplay() : undefined}>
1677+
{(file) => (
1678+
<text fg={editorContextLabelState() === "pending" ? theme.secondary : theme.textMuted}>
1679+
{file()}
1680+
</text>
1681+
)}
1682+
</Show>
1683+
<Switch>
1684+
<Match when={store.mode === "normal"}>
1685+
<Switch>
1686+
<Match when={usage()}>
1687+
{(item) => (
1688+
<text fg={theme.textMuted} wrapMode="none">
1689+
{[item().context, item().cost].filter(Boolean).join(" · ")}
1690+
</text>
1691+
)}
1692+
</Match>
1693+
<Match when={true}>
1694+
<text fg={theme.text}>
1695+
{agentShortcut()} <span style={{ fg: theme.textMuted }}>agents</span>
16661696
</text>
1667-
)}
1668-
</Match>
1669-
<Match when={true}>
1670-
<text fg={theme.text}>
1671-
{agentShortcut()} <span style={{ fg: theme.textMuted }}>agents</span>
1672-
</text>
1673-
</Match>
1674-
</Switch>
1675-
<text fg={theme.text}>
1676-
{paletteShortcut()} <span style={{ fg: theme.textMuted }}>commands</span>
1677-
</text>
1678-
</Match>
1679-
<Match when={store.mode === "shell"}>
1680-
<text fg={theme.text}>
1681-
esc <span style={{ fg: theme.textMuted }}>exit shell mode</span>
1682-
</text>
1683-
</Match>
1684-
</Switch>
1685-
</box>
1686-
</Show>
1697+
</Match>
1698+
</Switch>
1699+
<text fg={theme.text}>
1700+
{paletteShortcut()} <span style={{ fg: theme.textMuted }}>commands</span>
1701+
</text>
1702+
</Match>
1703+
<Match when={store.mode === "shell"}>
1704+
<text fg={theme.text}>
1705+
esc <span style={{ fg: theme.textMuted }}>exit shell mode</span>
1706+
</text>
1707+
</Match>
1708+
</Switch>
1709+
</box>
1710+
</Show>
1711+
</box>
16871712
</box>
16881713
</box>
16891714
<Autocomplete

0 commit comments

Comments
 (0)