diff --git a/src/renderer/src/assets/main.css b/src/renderer/src/assets/main.css index ecaafaac289..883d9061562 100644 --- a/src/renderer/src/assets/main.css +++ b/src/renderer/src/assets/main.css @@ -101,6 +101,9 @@ --color-agent-question: var(--agent-question); --color-agent-working: var(--agent-working); --color-agent-question-text: var(--agent-question-text); + --color-question-card-border: var(--question-card-border); + --color-question-option-border: var(--question-option-border); + --color-chat-focus-ring: var(--chat-focus-ring); --color-chart-1: var(--chart-1); --color-chart-2: var(--chart-2); --color-chart-3: var(--chart-3); @@ -262,6 +265,9 @@ --agent-working: var(--color-yellow-500); /* Legible weight for text/glyphs on a tinted --agent-question surface. */ --agent-question-text: var(--color-orange-700); + /* Answer card edge and the outline shared by its option tiles, badges, answer field and Skip. */ + --question-card-border-mix: 14%; + --question-option-border-mix: 16%; /* Keep PR-state hues stable across theme changes. */ --workspace-status-done: #c7a594; --workspace-status-review: #16a34a; @@ -379,6 +385,8 @@ --ai-action-accent: var(--color-violet-400); --agent-question: var(--color-orange-500); --agent-question-text: var(--color-orange-300); + --question-card-border-mix: 16%; + --question-option-border-mix: 12%; --workspace-status-done: #c7a594; --workspace-status-review: #16a34a; --workspace-status-progress: #d4a300; @@ -743,6 +751,17 @@ body[data-modal-overlay-open] var(--chat-source-foreground) var(--chat-composer-border-mix), transparent ); + /* From the chat's own foreground, so the edges stay visible when chat follows the terminal's colors. */ + --question-card-border: color-mix( + in srgb, + var(--chat-source-foreground) var(--question-card-border-mix), + transparent + ); + --question-option-border: color-mix( + in srgb, + var(--chat-source-foreground) var(--question-option-border-mix), + transparent + ); /* Mixed toward the foreground so each clears text contrast on the canvas in either scheme. */ --chat-focus-ring: color-mix(in srgb, var(--chat-source-foreground) 50%, var(--chat-canvas)); --chat-warning: color-mix(in srgb, var(--status-warning) 70%, var(--chat-source-foreground)); 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.fixture.tsx b/src/renderer/src/components/native-chat/prompts/NativeChatQuestionCard.fixture.tsx index 5e68681bfc9..e65800d12b6 100644 --- a/src/renderer/src/components/native-chat/prompts/NativeChatQuestionCard.fixture.tsx +++ b/src/renderer/src/components/native-chat/prompts/NativeChatQuestionCard.fixture.tsx @@ -173,7 +173,7 @@ export const pendingAnswer = defineFixture({ option.click() await new Promise(requestAnimationFrame) ;[...frame.querySelectorAll('button')] - .find((button) => button.textContent === 'Submit') + .find((button) => button.textContent?.startsWith('Submit')) ?.click() await new Promise(requestAnimationFrame) } @@ -272,3 +272,61 @@ export const previews = defineFixture({ await new Promise(requestAnimationFrame) } }) + +const dispatchOptions = [ + { + label: 'Yes, investigate and report', + description: "I'll find the config and summarize it." + }, + { + label: 'No, I know what it is', + description: "You're already aware of it; I'll leave it alone." + }, + { + label: 'Ask me later', + description: 'Keep the dispatches running for now.' + } +] + +function FocusedQuestion({ steps = 1 }: { steps?: number }) { + return ( +
+ ({ + question: + i === 0 + ? 'I found active dispatches from an automation I do not recognize. Should I look into it?' + : 'Where should the report go?', + header: i === 0 ? 'Investigate' : 'Report', + multiSelect: false, + options: dispatchOptions + })) + }} + onAnswer={() => {}} + onCancel={() => {}} + onCollapse={() => {}} + shouldFocus + /> +
+ ) +} + +// Keyboard focus lands on option 1 as the card opens; it must not look picked. +export const keyboardFocus = defineFixture({ + width: 720, + render: () => +}) + +export const multiStep = defineFixture({ + width: 720, + render: () => +}) + +export const narrow = defineFixture({ + width: 400, + render: () => +}) 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 1e89b19d5aa..10dddf73699 100644 --- a/src/renderer/src/components/native-chat/prompts/NativeChatQuestionCard.test.tsx +++ b/src/renderer/src/components/native-chat/prompts/NativeChatQuestionCard.test.tsx @@ -126,4 +126,44 @@ describe('NativeChatQuestionCard', () => { pressKey({ key: 'Enter' }, rows[1]!) expect(onAnswer).toHaveBeenCalledWith([{ indices: [1], other: '' }]) }) + it('opens with focus on option 1 without picking it, and Skip turns into Submit once picked', () => { + vi.useFakeTimers() + container.setAttribute('data-native-chat-root', 'true') + act(() => { + root.render( + {}} + onCancel={() => {}} + shouldFocus + /> + ) + }) + act(() => vi.runAllTimers()) + const rows = container.querySelectorAll('button[aria-pressed]') + const confirmButton = (): HTMLButtonElement => + [...container.querySelectorAll('button')].find((button) => + /^(Skip|Submit)/.test(button.textContent ?? '') + )! + expect(document.activeElement).toBe(rows[0]) + // 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]!.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]!.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('↵') + expect( + [...submit.childNodes] + .filter((node) => !(node instanceof Element && node.hasAttribute('aria-hidden'))) + .map((node) => node.textContent) + .join('') + ).toBe('Submit') + }) }) diff --git a/src/renderer/src/components/native-chat/prompts/NativeChatQuestionCard.tsx b/src/renderer/src/components/native-chat/prompts/NativeChatQuestionCard.tsx index 2546790c7ec..0cfef61f3a3 100644 --- a/src/renderer/src/components/native-chat/prompts/NativeChatQuestionCard.tsx +++ b/src/renderer/src/components/native-chat/prompts/NativeChatQuestionCard.tsx @@ -1,5 +1,4 @@ import { ImeTextarea } from '@/lib/text-input/ime/ime-text-field' -import { Textarea } from '@/components/ui/textarea' import { useRef, useState, type RefObject } from 'react' import { Check, Pencil, X } from 'lucide-react' import { cn } from '@/lib/class-names' @@ -7,6 +6,7 @@ import { translate } from '@/i18n/i18n' import { useTranslate } from '@/i18n/use-translate' import { NativeChatQuestionText } from './NativeChatQuestionText' import { NativeChatQuestionOption } from './NativeChatQuestionOption' +import { NativeChatQuestionConfirmButton } from './NativeChatQuestionConfirmButton' import type { AskAnswerSelection } from '../../../../../shared/native-chat/input/native-chat-ask-answer' import type { AskPrompt } from '../../../../../shared/native-chat/input/native-chat-ask-types' import { NativeChatPromptCollapseToggle } from './NativeChatPromptCollapse' @@ -283,12 +283,13 @@ export function NativeChatQuestionCard({ ) : null} -
+ {/* One 14px gutter (px-3.5) for the question, option tiles and footer, so their edges line up. */} +
{collapse ? (
-
+ {/* Option rings are inset, so the scroll clip cannot cut them. */} +
{q.options.map((opt, i) => ( pickOption(i)} /> ))} -
- {questionAllowsOther ? ( - <> - - {currentTypedAnswerChosen ? ( - - ) : ( - - )} - - {/* Deliver free text verbatim as a tool result; composer slash commands and autocomplete do not apply. */} - {freeTextInput?.multiline ? ( -