From 52bd22f43000a86b0c92d70751fb7c8bc87d956f Mon Sep 17 00:00:00 2001 From: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Date: Thu, 12 Nov 2026 10:17:34 -0800 Subject: [PATCH] fix(native-chat): preview inside the picked tile; steady footer; scheme-aware edges MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - The tile wraps the row and its preview; the preview is indented to the label column without its own border, and a 1px inset gap separates the focus ring from a picked tile's border. - Skip/Submit gets a min width that fits 'Submit ↵', so the answer field keeps its width. - The answer box shows keyboard focus as the same 2px inset ring as options; the multiline field grows with its content up to 12 lines. - Card and option border mixes follow the chat's own scheme when it takes the terminal's colors. - Focus the card's first target with focusVisible so the ring shows even when a mouse click opened the card. --- .../appearance/native-chat-appearance-style.ts | 4 +++- .../prompts/NativeChatQuestionCard.test.tsx | 6 +++--- .../prompts/NativeChatQuestionCard.tsx | 4 ++-- .../NativeChatQuestionConfirmButton.tsx | 3 ++- .../prompts/NativeChatQuestionOption.tsx | 18 ++++++++++++------ .../use-native-chat-prompt-card-focus.ts | 3 ++- 6 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/renderer/src/components/native-chat/appearance/native-chat-appearance-style.ts b/src/renderer/src/components/native-chat/appearance/native-chat-appearance-style.ts index d01c4028497..a7ad3d10708 100644 --- a/src/renderer/src/components/native-chat/appearance/native-chat-appearance-style.ts +++ b/src/renderer/src/components/native-chat/appearance/native-chat-appearance-style.ts @@ -143,7 +143,9 @@ function applyTerminalChatColors( '--chat-inline-code-border-mix': light ? '9%' : '8%', '--chat-composer-mix': light ? '0%' : '4%', '--chat-composer-base': light ? 'var(--chat-canvas)' : 'transparent', - '--chat-composer-border-mix': light ? '11%' : '9%' + '--chat-composer-border-mix': light ? '11%' : '9%', + '--question-card-border-mix': light ? '14%' : '16%', + '--question-option-border-mix': light ? '16%' : '12%' }) } diff --git a/src/renderer/src/components/native-chat/prompts/NativeChatQuestionCard.test.tsx b/src/renderer/src/components/native-chat/prompts/NativeChatQuestionCard.test.tsx index ae7c0537cc7..10dddf73699 100644 --- a/src/renderer/src/components/native-chat/prompts/NativeChatQuestionCard.test.tsx +++ b/src/renderer/src/components/native-chat/prompts/NativeChatQuestionCard.test.tsx @@ -149,13 +149,13 @@ describe('NativeChatQuestionCard', () => { // Focus is a ring only; the picked look (primary border, fill) is reserved for aria-pressed rows. expect(rows[0]!.getAttribute('aria-pressed')).toBe('false') expect(rows[0]!.className).not.toMatch(/(^|\s)(focus:)?bg-accent(\s|$)/) - expect(rows[0]!.className).not.toContain('border-primary') + expect(rows[0]!.parentElement!.className).not.toContain('border-primary') expect(confirmButton().textContent).toBe('Skip') act(() => rows[1]!.click()) expect(rows[1]!.getAttribute('aria-pressed')).toBe('true') - expect(rows[1]!.className).toContain('border-primary') - expect(rows[0]!.className).not.toContain('border-primary') + expect(rows[1]!.parentElement!.className).toContain('border-primary') + expect(rows[0]!.parentElement!.className).not.toContain('border-primary') // The Enter hint is decoration; the button's name stays "Submit". const submit = confirmButton() expect(submit.querySelector('[aria-hidden]')?.textContent).toBe('↵') diff --git a/src/renderer/src/components/native-chat/prompts/NativeChatQuestionCard.tsx b/src/renderer/src/components/native-chat/prompts/NativeChatQuestionCard.tsx index dfa7f56e7e3..0cfef61f3a3 100644 --- a/src/renderer/src/components/native-chat/prompts/NativeChatQuestionCard.tsx +++ b/src/renderer/src/components/native-chat/prompts/NativeChatQuestionCard.tsx @@ -334,7 +334,7 @@ export function NativeChatQuestionCard({ {questionAllowsOther ? (
@@ -363,7 +363,7 @@ export function NativeChatQuestionCard({ onChange={(e) => setOther(index, e.target.value)} onClick={autoAdvance.cancel} placeholder={answerPlaceholder} - className="scrollbar-sleek min-h-16 min-w-0 flex-1 resize-none bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground disabled:cursor-default disabled:opacity-50" + className="scrollbar-sleek max-h-[12lh] min-h-16 min-w-0 flex-1 resize-none overflow-y-auto bg-transparent [field-sizing:content] text-sm text-foreground outline-none placeholder:text-muted-foreground disabled:cursor-default disabled:opacity-50" /> ) : ( void }): React.JSX.Element { return ( + // The tile wraps the row and its preview, so the preview reads as part of the picked option. // One root whether or not the preview shows, so selecting never remounts the focused row. -
+ // p-px leaves a 1px gap between the inset focus ring and the tile's border. +
+ {/* Indented to the label column (padding + badge + gap) and pulled up against the description. */} {preview && selected ? (
           {preview}
         
diff --git a/src/renderer/src/components/native-chat/prompts/use-native-chat-prompt-card-focus.ts b/src/renderer/src/components/native-chat/prompts/use-native-chat-prompt-card-focus.ts index 09ffad3343e..25d5c4430a8 100644 --- a/src/renderer/src/components/native-chat/prompts/use-native-chat-prompt-card-focus.ts +++ b/src/renderer/src/components/native-chat/prompts/use-native-chat-prompt-card-focus.ts @@ -7,7 +7,8 @@ const PROMPT_CARD_FOCUS_TARGET_SELECTOR = function focusPromptCard(card: HTMLElement): void { const target = card.querySelector(PROMPT_CARD_FOCUS_TARGET_SELECTOR) ?? card - target.focus() + // Show the ring even when a mouse click opened the card; number keys and Enter act on this row. + target.focus({ focusVisible: true }) } /** Focus the shown card requesting it unless keep already names a control inside it; return false when ineligible. */