Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/tui/components/agent-modal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,27 @@ describe("validateProviderForm", () => {
expect(result.submission.keyless).toBeUndefined();
}
});

test("trims leading and trailing spaces on text fields at save", () => {
const result = validateProviderForm(
form({
name: " firepass ",
baseURL: " https://firepass.example/v1 ",
apiKey: " sk-key ",
models: " fp-large , fp-small ",
defaultModel: " fp-large ",
}),
undefined,
);
expect(result).toEqual({
ok: true,
submission: {
name: "firepass",
baseURL: "https://firepass.example/v1",
apiKey: "sk-key",
models: ["fp-large", "fp-small"],
defaultModel: "fp-large",
},
});
});
});
31 changes: 19 additions & 12 deletions src/tui/components/agent-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,13 @@ export function AgentModal({
const isCursor = i === formIndex;
const value = formValues[field];
const isKeyless = formValues.keyless === "yes";
// gap only between label and value — never between value and caret,
// or the caret sits after a phantom space the user did not type.
const showCaret =
isCursor &&
field !== "keyless" &&
field !== "bifrostVirtualKey" &&
!(field === "apiKey" && isKeyless);
return (
<Box key={field} flexDirection="row" gap={1}>
<Box width={16} flexShrink={0}>
Expand All @@ -977,16 +984,16 @@ export function AgentModal({
) : field === "apiKey" && isKeyless ? (
<Text color={color("muted")}>(disabled — keyless provider)</Text>
) : (
<Text color={value.length > 0 ? color("text") : color("muted")}>
{value.length > 0
? maskInput(field, value)
: field === "apiKey" && editingProvider !== undefined
? "leave blank to keep existing"
: FIELD_HINTS[field]}
</Text>
)}
{isCursor && field !== "keyless" && field !== "bifrostVirtualKey" && !(field === "apiKey" && isKeyless) && (
<Text color={color("accent")}>|</Text>
<Box>
<Text color={value.length > 0 ? color("text") : color("muted")}>
{value.length > 0
? maskInput(field, value)
: field === "apiKey" && editingProvider !== undefined
? "leave blank to keep existing"
: FIELD_HINTS[field]}
</Text>
{showCaret && <Text color={color("accent")}>|</Text>}
</Box>
)}
</Box>
);
Expand Down Expand Up @@ -1052,12 +1059,12 @@ export function AgentModal({
{isCursor ? " >" : ""}
</Text>
) : (
<>
<Box>
<Text color={profileFormValues[field].length > 0 ? color("text") : color("muted")}>
{profileFormValues[field].length > 0 ? profileFormValues[field] : PROFILE_FIELD_HINTS[field]}
</Text>
{isCursor && <Text color={color("accent")}>|</Text>}
</>
</Box>
)}
</Box>
);
Expand Down
11 changes: 7 additions & 4 deletions src/tui/components/codex-login-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,13 @@ export function CodexLoginModal({
<Box marginTop={1} flexDirection="column">
<Box flexDirection="row" gap={1}>
<Text color={color("muted")}>Profile name</Text>
<Text color={nameValue.length > 0 ? color("text") : color("muted")}>
{nameValue.length > 0 ? nameValue : "personal, work, ..."}
</Text>
<Text color={color("accent")}>|</Text>
{/* Keep value and caret in one Box so gap does not insert a phantom space. */}
<Box>
<Text color={nameValue.length > 0 ? color("text") : color("muted")}>
{nameValue.length > 0 ? nameValue : "personal, work, ..."}
</Text>
<Text color={color("accent")}>|</Text>
</Box>
</Box>
{nameError !== null && (
<Box marginTop={1}>
Expand Down
7 changes: 5 additions & 2 deletions src/tui/components/operator-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,13 @@ export function OperatorModal({
</Box>
{typing ? (
<Box flexDirection="column">
{/* gap only between › and value — never between value and caret */}
<Box flexDirection="row" gap={1}>
<Text color={color("brand")} bold>›</Text>
<Text color={color("text")}>{draft}</Text>
<Text color={color("brand")}>▌</Text>
<Box>
<Text color={color("text")}>{draft}</Text>
<Text color={color("brand")}>▌</Text>
</Box>
</Box>
<Box marginTop={1}>
<Text color={color("muted")}>Enter to confirm · Esc to cancel</Text>
Expand Down
Loading