Repository navigation
feat(tui): model tags on the right of the footer, YOLO tag on the input line #360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
dd1a842
9c861f6
ffc94cf
4e9d496
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1363,6 +1363,29 @@ export function Prompt(props: PromptProps) { | |
| ) | ||
| const borderHighlight = createMemo(() => tint(theme.border, highlight(), agentMetaAlpha())) | ||
|
|
||
| // The prompt measures itself: the session sidebar and the home width cap both make it narrower than the terminal. | ||
| let boxEl: BoxRenderable | undefined | ||
| const [boxWidth, setBoxWidth] = createSignal(0) | ||
| const innerWidth = createMemo(() => Math.max(10, (boxWidth() > 0 ? boxWidth() : dimensions().width - 5) - 4)) | ||
| const showProvider = createMemo(() => innerWidth() >= 60) | ||
| const tagsWidth = createMemo(() => { | ||
| let width = local.effort.current().length | ||
| if (showVariant()) width += 3 + (local.model.variant.current()?.length ?? 0) | ||
| if (showVision()) width += 3 + "vision".length | ||
| return width | ||
| }) | ||
| // Room left for the model name on the footer row, with a gap before the tags. | ||
| const modelRoom = createMemo(() => { | ||
| const agentName = store.mode === "shell" ? "Shell".length : (local.agent.current()?.name.length ?? 0) | ||
| const provider = showProvider() ? currentProviderLabel().length + 1 : 0 | ||
| return Math.max(4, innerWidth() - tagsWidth() - 2 - agentName - 3 - provider) | ||
| }) | ||
| const modelLabel = createMemo(() => Locale.truncate(local.model.parsed().model, modelRoom())) | ||
| // The placeholder shares its row with the YOLO tag. | ||
| const placeholderRoom = createMemo(() => | ||
| innerWidth() - (store.mode === "normal" && local.permission.mode === "yolo" ? 8 : 0), | ||
| ) | ||
|
|
||
| const placeholderText = createMemo(() => { | ||
| if (props.showPlaceholder === false) return undefined | ||
| if (store.mode === "shell") { | ||
|
|
@@ -1374,6 +1397,10 @@ export function Prompt(props: PromptProps) { | |
| if (!list().length) return undefined | ||
| return `Ask anything... "${list()[store.placeholder % list().length]}"` | ||
| }) | ||
| const clippedPlaceholder = createMemo(() => { | ||
| const text = placeholderText() | ||
| return text ? Locale.truncate(text, placeholderRoom()) : undefined | ||
| }) | ||
|
|
||
| const spinnerDef = createMemo(() => { | ||
| const agent = | ||
|
|
@@ -1402,6 +1429,10 @@ export function Prompt(props: PromptProps) { | |
| }} | ||
| > | ||
| <box | ||
| ref={(el: BoxRenderable) => { | ||
| boxEl = el | ||
| }} | ||
| onSizeChange={() => boxEl && setBoxWidth(boxEl.width)} | ||
| paddingLeft={2} | ||
| paddingRight={2} | ||
| paddingTop={1} | ||
|
|
@@ -1410,9 +1441,16 @@ export function Prompt(props: PromptProps) { | |
| flexGrow={1} | ||
| width="100%" | ||
| > | ||
| <Show when={store.mode === "normal" && local.permission.mode === "yolo"}> | ||
| <box position="absolute" top={1} right={2} paddingLeft={1} paddingRight={1} backgroundColor={theme.warning}> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WARNING: The YOLO badge overlays the editable first input row The badge is absolutely positioned on the textarea's first row (the textarea is Reserve space for the badge inside the input row (e.g. reduce the textarea width or add right padding while the badge is visible) rather than overlaying the editable area. |
||
| <text fg={selectedForeground(theme, theme.warning)} attributes={TextAttributes.BOLD}> | ||
| YOLO | ||
| </text> | ||
| </box> | ||
| </Show> | ||
| <textarea | ||
| width="100%" | ||
| placeholder={placeholderText()} | ||
| placeholder={clippedPlaceholder()} | ||
| placeholderColor={theme.textMuted} | ||
| textColor={leader() ? theme.textMuted : theme.text} | ||
| focusedTextColor={leader() ? theme.textMuted : theme.text} | ||
|
|
@@ -1486,7 +1524,7 @@ export function Prompt(props: PromptProps) { | |
| syntaxStyle={syntax()} | ||
| /> | ||
| <box flexDirection="row" flexShrink={0} paddingTop={1} gap={1} justifyContent="space-between"> | ||
| <box flexDirection="row" gap={1}> | ||
| <box flexDirection="row" gap={1} flexShrink={1} minWidth={0} height={1} overflow="hidden"> | ||
| <Show when={local.agent.current()} fallback={<box height={1} />}> | ||
| {(agent) => ( | ||
| <> | ||
|
|
@@ -1500,50 +1538,48 @@ export function Prompt(props: PromptProps) { | |
| flexShrink={0} | ||
| fg={fadeColor(leader() ? theme.textMuted : theme.text, modelMetaAlpha())} | ||
| > | ||
| {local.model.parsed().model} | ||
| </text> | ||
| <text fg={fadeColor(theme.textMuted, modelMetaAlpha())}>{currentProviderLabel()}</text> | ||
| {/* Agent effort is its own dial and shows even for | ||
| models without thinking variants. Its hue (fast | ||
| green, medium orange, thorough red) is drawn | ||
| beside the always-visible level name. */} | ||
| <text fg={fadeColor(theme.textMuted, modelMetaAlpha())}>·</text> | ||
| <text> | ||
| <span | ||
| style={{ | ||
| fg: fadeColor(effortColor(local.effort.current(), theme), modelMetaAlpha()), | ||
| bold: true, | ||
| }} | ||
| > | ||
| {local.effort.current()} | ||
| </span> | ||
| {modelLabel()} | ||
| </text> | ||
| <Show when={showVariant()}> | ||
| <text fg={fadeColor(theme.textMuted, variantMetaAlpha())}>·</text> | ||
| <text> | ||
| <span style={{ fg: fadeColor(theme.warning, variantMetaAlpha()), bold: true }}> | ||
| {local.model.variant.current()} | ||
| </span> | ||
| </text> | ||
| </Show> | ||
| <Show when={showVision()}> | ||
| <text fg={fadeColor(theme.textMuted, visionMetaAlpha())}>·</text> | ||
| <text> | ||
| <span style={{ fg: fadeColor(theme.accent, visionMetaAlpha()), bold: true }}>vision</span> | ||
| </text> | ||
| <Show when={showProvider()}> | ||
| <text fg={fadeColor(theme.textMuted, modelMetaAlpha())}>{currentProviderLabel()}</text> | ||
| </Show> | ||
| </box> | ||
| </Show> | ||
| </> | ||
| )} | ||
| </Show> | ||
| </box> | ||
| <box flexDirection="row" gap={1} alignItems="center"> | ||
| <Show when={store.mode === "normal" && local.permission.mode === "yolo"}> | ||
| <box paddingLeft={1} paddingRight={1} backgroundColor={theme.warning}> | ||
| <text fg={selectedForeground(theme, theme.warning)} attributes={TextAttributes.BOLD}> | ||
| YOLO | ||
| </text> | ||
| <box flexDirection="row" gap={1} alignItems="center" flexShrink={0}> | ||
| <Show when={store.mode === "normal"}> | ||
| <box flexDirection="row" gap={1} flexShrink={0}> | ||
| {/* Agent effort is its own dial and shows even for | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SUGGESTION: Moved block kept the old indentation, and one line exceeds the print width The children of the new tags box are still indented as if they were in the previous nesting level, and the badge line (1433) is 122 characters — over the repo's prettier |
||
| models without thinking variants. Its hue (fast | ||
| green, medium orange, thorough red) is drawn | ||
| beside the always-visible level name. */} | ||
| <text> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CRITICAL: The The effort label moved into the right-hand group without its leading separator, so the footer row now reads
Either keep a separator at the start of the new group, or update both tests in this PR. |
||
| <span | ||
| style={{ | ||
| fg: fadeColor(effortColor(local.effort.current(), theme), modelMetaAlpha()), | ||
| bold: true, | ||
| }} | ||
| > | ||
| {local.effort.current()} | ||
| </span> | ||
| </text> | ||
| <Show when={showVariant()}> | ||
| <text fg={fadeColor(theme.textMuted, variantMetaAlpha())}>·</text> | ||
| <text> | ||
| <span style={{ fg: fadeColor(theme.warning, variantMetaAlpha()), bold: true }}> | ||
| {local.model.variant.current()} | ||
| </span> | ||
| </text> | ||
| </Show> | ||
| <Show when={showVision()}> | ||
| <text fg={fadeColor(theme.textMuted, visionMetaAlpha())}>·</text> | ||
| <text> | ||
| <span style={{ fg: fadeColor(theme.accent, visionMetaAlpha()), bold: true }}>vision</span> | ||
| </text> | ||
| </Show> | ||
| </box> | ||
| </Show> | ||
| <Show when={hasRightContent()}>{props.right}</Show> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SUGGESTION:
modelRoomignores the width of the right-hand slotprops.right(thesession_prompt_right/home_prompt_rightplugin slot) is rendered in the same right-hand box as the tags and is not accounted for here. When a plugin supplies right content, the left box shrinks and the model name is hard-clipped byoverflow="hidden"with no ellipsis, which breaks the invariant this PR introduces. Subtract the right content's width as well.