chore(tui): /clean pass — inline one-off locals, tighten ConfirmPrompt
- providers.ts: drop the `dup` intermediate, fold the ternary inline - paths.ts (fmtCwdBranch): inline `b` into the `tag` template - prompts.tsx (ConfirmPrompt): hoist a single `lower = ch.toLowerCase()`, collapse the three early-return branches into two, drop the redundant bounds checks on arrow-key handlers (setSel is idempotent at 0/1), inline the `confirmLabel`/`cancelLabel` defaults at the use site - modelPicker.tsx / config/env.ts / providers.test.ts: auto-formatter reflows picked up by `npm run fix` - useInputHandlers.ts: drop the stray blank line that was tripping perfectionist/sort-imports (pre-existing lint error)
This commit is contained in:
@@ -181,7 +181,10 @@ export function ModelPicker({ gw, onCancel, onSelect, sessionId, t }: ModelPicke
|
||||
const idx = off + i
|
||||
|
||||
return (
|
||||
<Text color={providerIdx === idx ? t.color.cornsilk : t.color.dim} key={providers[idx]?.slug ?? `row-${idx}`}>
|
||||
<Text
|
||||
color={providerIdx === idx ? t.color.cornsilk : t.color.dim}
|
||||
key={providers[idx]?.slug ?? `row-${idx}`}
|
||||
>
|
||||
{providerIdx === idx ? '▸ ' : ' '}
|
||||
{i + 1}. {row}
|
||||
</Text>
|
||||
@@ -212,7 +215,10 @@ export function ModelPicker({ gw, onCancel, onSelect, sessionId, t }: ModelPicke
|
||||
const idx = off + i
|
||||
|
||||
return (
|
||||
<Text color={modelIdx === idx ? t.color.cornsilk : t.color.dim} key={`${provider?.slug ?? 'prov'}:${idx}:${row}`}>
|
||||
<Text
|
||||
color={modelIdx === idx ? t.color.cornsilk : t.color.dim}
|
||||
key={`${provider?.slug ?? 'prov'}:${idx}:${row}`}
|
||||
>
|
||||
{modelIdx === idx ? '▸ ' : ' '}
|
||||
{i + 1}. {row}
|
||||
</Text>
|
||||
|
||||
@@ -155,31 +155,21 @@ export function ConfirmPrompt({ onCancel, onConfirm, req, t }: ConfirmPromptProp
|
||||
const [sel, setSel] = useState(0)
|
||||
|
||||
useInput((ch, key) => {
|
||||
if (key.escape || (key.ctrl && ch.toLowerCase() === 'c')) {
|
||||
onCancel()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
const lower = ch.toLowerCase()
|
||||
|
||||
if (key.escape || (key.ctrl && lower === 'c') || lower === 'n') {
|
||||
return onCancel()
|
||||
}
|
||||
|
||||
if (lower === 'y') {
|
||||
onConfirm()
|
||||
|
||||
return
|
||||
return onConfirm()
|
||||
}
|
||||
|
||||
if (lower === 'n') {
|
||||
onCancel()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if (key.upArrow && sel > 0) {
|
||||
if (key.upArrow) {
|
||||
setSel(0)
|
||||
}
|
||||
|
||||
if (key.downArrow && sel < 1) {
|
||||
if (key.downArrow) {
|
||||
setSel(1)
|
||||
}
|
||||
|
||||
@@ -189,12 +179,10 @@ export function ConfirmPrompt({ onCancel, onConfirm, req, t }: ConfirmPromptProp
|
||||
})
|
||||
|
||||
const accent = req.danger ? t.color.error : t.color.warn
|
||||
const confirmLabel = req.confirmLabel ?? 'Yes'
|
||||
const cancelLabel = req.cancelLabel ?? 'No'
|
||||
|
||||
const rows = [
|
||||
{ color: t.color.cornsilk, label: cancelLabel },
|
||||
{ color: req.danger ? t.color.error : t.color.cornsilk, label: confirmLabel }
|
||||
{ color: t.color.cornsilk, label: req.cancelLabel ?? 'No' },
|
||||
{ color: req.danger ? t.color.error : t.color.cornsilk, label: req.confirmLabel ?? 'Yes' }
|
||||
]
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user