fix: improve Quick Prompt popup UX and settings design

- Fix window lifecycle: await renderer load before showing, debounce
  blur handler to prevent dropdown-induced dismiss
- Increase window height from 72px to 520px for response display
- Rewrite ModelSelector with tier-grouped upward-opening dropdown,
  reasoning effort controls, and Brain icon for reasoning models
- Rewrite QuickPromptInput with visible model trigger, animated
  chevron, auto-resize textarea, and proper stop button
- Improve QuickPromptResponse with compact thinking block, markdown
  code/pre/link styling, and refined spacing
- Polish QuickPromptActions with consistent sizing and hover states
- Redesign settings QuickPromptSettingsSection: replace flat radio
  list with compact grouped dropdown selector, only show reasoning
  effort when selected model supports it, combine hotkey toggle
  into single row
- Add markdown code block, inline code, and link CSS styles
- Fix dropdown animation direction for upward-opening selector
- Handle message-complete event in QuickPromptApp

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
David Kaya
2026-04-13 12:14:29 +02:00
co-authored by Copilot
parent fb5970cfa7
commit 952e69da9f
9 changed files with 413 additions and 245 deletions
+1 -1
View File
@@ -83,7 +83,7 @@ async function bootstrap(): Promise<void> {
const hotkeySettings = workspace.settings.quickPrompt ?? createDefaultQuickPromptSettings(); const hotkeySettings = workspace.settings.quickPrompt ?? createDefaultQuickPromptSettings();
globalHotkeyService.register(hotkeySettings, () => { globalHotkeyService.register(hotkeySettings, () => {
const win = ensureQuickPromptWindow(); const win = ensureQuickPromptWindow();
if (win) toggleQuickPromptWindow(win); if (win) void toggleQuickPromptWindow(win);
}); });
// Re-register hotkey when settings change // Re-register hotkey when settings change
+22 -6
View File
@@ -9,7 +9,8 @@ const { app, BrowserWindow, screen } = electron;
export function createQuickPromptWindow(): BrowserWindowType { export function createQuickPromptWindow(): BrowserWindowType {
const window = new BrowserWindow({ const window = new BrowserWindow({
width: 680, width: 680,
height: 72, height: 520,
minHeight: 72,
show: false, show: false,
frame: false, frame: false,
transparent: true, transparent: true,
@@ -19,6 +20,7 @@ export function createQuickPromptWindow(): BrowserWindowType {
maximizable: false, maximizable: false,
minimizable: false, minimizable: false,
fullscreenable: false, fullscreenable: false,
focusable: true,
title: 'Aryx Quick Prompt', title: 'Aryx Quick Prompt',
icon: resolveWindowIconPath({ icon: resolveWindowIconPath({
appPath: app.getAppPath(), appPath: app.getAppPath(),
@@ -39,23 +41,37 @@ export function createQuickPromptWindow(): BrowserWindowType {
void window.loadFile(join(__dirname, '../../dist/renderer/quickprompt.html')); void window.loadFile(join(__dirname, '../../dist/renderer/quickprompt.html'));
} }
// Hide on blur — but only if the window itself loses focus (not from
// devtools or transient focus changes during show/hide).
window.on('blur', () => { window.on('blur', () => {
if (window.isVisible()) { // Small delay: avoid hiding during transient focus shifts (e.g. model
window.webContents.send('quick-prompt:hide'); // selector dropdown causing a brief blur → refocus cycle).
window.hide(); setTimeout(() => {
} if (window.isVisible() && !window.isFocused()) {
window.webContents.send('quick-prompt:hide');
window.hide();
}
}, 100);
}); });
return window; return window;
} }
export function toggleQuickPromptWindow(window: BrowserWindowType): void { export async function toggleQuickPromptWindow(window: BrowserWindowType): Promise<void> {
if (window.isVisible()) { if (window.isVisible()) {
window.webContents.send('quick-prompt:hide'); window.webContents.send('quick-prompt:hide');
window.hide(); window.hide();
return; return;
} }
// Wait for the renderer to finish loading before showing — on the very
// first activation the page may still be loading from disk/dev-server.
if (window.webContents.isLoading()) {
await new Promise<void>((resolve) => {
window.webContents.once('did-finish-load', () => resolve());
});
}
centerOnActiveDisplay(window); centerOnActiveDisplay(window);
window.webContents.send('quick-prompt:show'); window.webContents.send('quick-prompt:show');
window.show(); window.show();
+165 -121
View File
@@ -1328,16 +1328,39 @@ function QuickPromptSettingsSection({
availableModels: ReadonlyArray<ModelDefinition>; availableModels: ReadonlyArray<ModelDefinition>;
onUpdate?: (patch: Partial<QuickPromptSettings>) => void; onUpdate?: (patch: Partial<QuickPromptSettings>) => void;
}) { }) {
const [modelDropdownOpen, setModelDropdownOpen] = useState(false);
const enabled = settings?.enabled ?? true; const enabled = settings?.enabled ?? true;
const hotkey = settings?.hotkey ?? 'Alt+Shift+C'; const hotkey = settings?.hotkey ?? 'Alt+Shift+C';
const defaultModel = settings?.defaultModel; const defaultModel = settings?.defaultModel;
const defaultReasoning = settings?.defaultReasoningEffort; const defaultReasoning = settings?.defaultReasoningEffort;
const hotkeyDisplay = hotkey const resolvedModel = defaultModel ? availableModels.find((m) => m.id === defaultModel) : undefined;
const modelSupportsReasoning = resolvedModel?.supportedReasoningEfforts?.length;
const hotkeyKeys = hotkey
.replace('Super', isMac ? '⌘' : 'Win') .replace('Super', isMac ? '⌘' : 'Win')
.replace('Alt', isMac ? '⌥' : 'Alt') .replace('Alt', isMac ? '⌥' : 'Alt')
.replace('Shift', '⇧') .replace('Shift', '⇧')
.replace(/\+/g, ' + '); .split('+')
.map((k) => k.trim());
// Group models by tier for the dropdown
const tierOrder = ['premium', 'standard', 'fast'] as const;
const tierLabels: Record<string, string> = { premium: 'Premium', standard: 'Standard', fast: 'Fast' };
const groupedModels = tierOrder
.map((tier) => ({
tier,
label: tierLabels[tier],
models: availableModels.filter((m) => m.tier === tier),
}))
.filter((g) => g.models.length > 0);
// Models without a tier
const untypedModels = availableModels.filter((m) => !m.tier);
if (untypedModels.length > 0) {
groupedModels.push({ tier: 'other' as never, label: 'Other', models: untypedModels });
}
return ( return (
<div> <div>
@@ -1348,147 +1371,168 @@ function QuickPromptSettingsSection({
</p> </p>
</div> </div>
{/* Enable / Disable */} {/* Enable / Disable + Keyboard Shortcut — compact row */}
<button <div className="mt-5 flex items-center gap-3 rounded-lg border border-[var(--color-border)] px-4 py-3">
className="mt-5 flex w-full items-center justify-between rounded-lg border border-[var(--color-border)] px-4 py-3 text-left transition hover:bg-[var(--color-surface-3)]/40"
onClick={() => onUpdate?.({ enabled: !enabled })}
type="button"
>
<div>
<span className="text-[13px] font-medium text-[var(--color-text-primary)]">
Enable global hotkey
</span>
<p className="text-[12px] text-[var(--color-text-muted)]">
Register a system-wide keyboard shortcut to summon the Quick Prompt overlay
</p>
</div>
<ToggleSwitch enabled={enabled} />
</button>
{/* Hotkey display */}
<div className="mt-6 mb-1">
<h3 className="font-display text-[13px] font-semibold text-[var(--color-text-primary)]">Keyboard Shortcut</h3>
<p className="mt-0.5 text-[12px] text-[var(--color-text-muted)]">
The key combination that opens the Quick Prompt overlay
</p>
</div>
<div className="mt-4 flex items-center gap-3 rounded-lg border border-[var(--color-border)] px-4 py-3">
<div className="flex gap-1.5">
{hotkeyDisplay.split(' + ').map((key) => (
<kbd
key={key}
className="rounded-md border border-[var(--color-border)] bg-[var(--color-surface-2)] px-2 py-0.5 font-mono text-[12px] text-[var(--color-text-secondary)]"
>
{key.trim()}
</kbd>
))}
</div>
</div>
{/* Default Model */}
<div className="mt-8 mb-1">
<h3 className="font-display text-[13px] font-semibold text-[var(--color-text-primary)]">Default Model</h3>
<p className="mt-0.5 text-[12px] text-[var(--color-text-muted)]">
The model used by Quick Prompt sessions. Can be overridden per-prompt.
</p>
</div>
<div className="mt-4 space-y-1.5">
{/* "Use workflow default" option */}
<button <button
className={`flex w-full items-center gap-3 rounded-lg border px-4 py-3 text-left transition-all duration-200 ${ className="flex flex-1 items-start gap-0 text-left"
!defaultModel onClick={() => onUpdate?.({ enabled: !enabled })}
? 'border-[var(--color-border-glow)] bg-[var(--color-accent-muted)]'
: 'border-[var(--color-border)] hover:bg-[var(--color-surface-3)]/40'
}`}
onClick={() => onUpdate?.({ defaultModel: undefined })}
type="button" type="button"
> >
<div <div className="flex-1">
className={`flex size-4 shrink-0 items-center justify-center rounded-full border-2 transition-all duration-200 ${ <span className="text-[13px] font-medium text-[var(--color-text-primary)]">
!defaultModel ? 'border-[var(--color-accent)]' : 'border-[var(--color-border)]' Global hotkey
}`}
>
{!defaultModel && <div className="size-2 rounded-full bg-[var(--color-accent)]" />}
</div>
<div>
<span className={`text-[13px] font-medium ${!defaultModel ? 'text-[var(--color-text-primary)]' : 'text-[var(--color-text-secondary)]'}`}>
Use workflow default
</span> </span>
<p className="text-[12px] text-[var(--color-text-muted)]"> <div className="mt-1.5 flex items-center gap-1">
Use whichever model is configured in the scratchpad workflow {hotkeyKeys.map((key) => (
</p> <kbd
key={key}
className="rounded-[5px] border border-[var(--color-border)] bg-[var(--color-surface-2)] px-2 py-[3px] font-mono text-[11px] font-medium leading-none text-[var(--color-text-secondary)] shadow-sm shadow-black/20"
>
{key}
</kbd>
))}
</div>
</div> </div>
</button> </button>
<button onClick={() => onUpdate?.({ enabled: !enabled })} type="button">
{availableModels.map((model) => { <ToggleSwitch enabled={enabled} />
const isSelected = defaultModel === model.id; </button>
return (
<button
className={`flex w-full items-center gap-3 rounded-lg border px-4 py-3 text-left transition-all duration-200 ${
isSelected
? 'border-[var(--color-border-glow)] bg-[var(--color-accent-muted)]'
: 'border-[var(--color-border)] hover:bg-[var(--color-surface-3)]/40'
}`}
key={model.id}
onClick={() => onUpdate?.({ defaultModel: model.id })}
type="button"
>
<div
className={`flex size-4 shrink-0 items-center justify-center rounded-full border-2 transition-all duration-200 ${
isSelected ? 'border-[var(--color-accent)]' : 'border-[var(--color-border)]'
}`}
>
{isSelected && <div className="size-2 rounded-full bg-[var(--color-accent)]" />}
</div>
<div className="flex-1">
<span className={`text-[13px] font-medium ${isSelected ? 'text-[var(--color-text-primary)]' : 'text-[var(--color-text-secondary)]'}`}>
{model.name}
</span>
{model.tier && (
<span className="ml-2 rounded bg-[var(--color-surface-3)] px-1.5 py-px text-[10px] text-[var(--color-text-muted)]">
{model.tier}
</span>
)}
</div>
</button>
);
})}
</div> </div>
{/* Reasoning Effort */} {/* Default Model — compact dropdown selector */}
{availableModels.some((m) => m.supportedReasoningEfforts?.length) && ( <div className="mt-6">
<> <h3 className="font-display text-[13px] font-semibold text-[var(--color-text-primary)]">Default Model</h3>
<div className="mt-8 mb-1"> <p className="mt-0.5 text-[12px] text-[var(--color-text-muted)]">
<h3 className="font-display text-[13px] font-semibold text-[var(--color-text-primary)]">Reasoning Effort</h3> Override the workflow model for Quick Prompt sessions
<p className="mt-0.5 text-[12px] text-[var(--color-text-muted)]"> </p>
Default reasoning effort for Quick Prompt. Higher effort produces more thorough answers.
</p>
</div>
<div className="mt-4 flex gap-2"> <div className="relative mt-3">
{/* Trigger button */}
<button
onClick={() => setModelDropdownOpen((prev) => !prev)}
className={`flex w-full items-center gap-3 rounded-lg border px-4 py-3 text-left transition ${
modelDropdownOpen
? 'border-[var(--color-accent)]/40 bg-[var(--color-accent-muted)]'
: 'border-[var(--color-border)] hover:bg-[var(--color-surface-3)]/40'
}`}
type="button"
aria-haspopup="listbox"
aria-expanded={modelDropdownOpen}
>
<div className="flex-1">
<span className="text-[13px] font-medium text-[var(--color-text-primary)]">
{resolvedModel?.name ?? 'Workflow default'}
</span>
{resolvedModel?.tier && (
<span className={`ml-2 inline-flex items-center gap-1 rounded-[4px] px-1.5 py-px text-[10px] font-medium ${
resolvedModel.tier === 'premium' ? 'bg-amber-400/10 text-amber-400' :
resolvedModel.tier === 'fast' ? 'bg-emerald-400/10 text-emerald-400' :
'bg-[var(--color-accent-muted)] text-[var(--color-text-accent)]'
}`}>
{resolvedModel.tier}
</span>
)}
</div>
<ChevronRight className={`size-4 text-[var(--color-text-muted)] transition-transform ${modelDropdownOpen ? 'rotate-90' : ''}`} />
</button>
{/* Dropdown */}
{modelDropdownOpen && (
<div className="absolute top-full left-0 right-0 z-10 mt-1 overflow-hidden rounded-xl border border-[var(--color-border)] bg-[var(--color-surface-1)] shadow-xl shadow-black/40">
<div className="max-h-[280px] overflow-y-auto p-1.5">
{/* Workflow default option */}
<button
onClick={() => { onUpdate?.({ defaultModel: undefined }); setModelDropdownOpen(false); }}
className={`flex w-full items-center gap-2 rounded-lg px-3 py-2 text-left transition ${
!defaultModel
? 'bg-[var(--color-accent-muted)] text-[var(--color-text-primary)]'
: 'text-[var(--color-text-secondary)] hover:bg-[var(--color-surface-2)] hover:text-[var(--color-text-primary)]'
}`}
type="button"
role="option"
aria-selected={!defaultModel}
>
<span className="flex-1 text-[12px] font-medium">Workflow default</span>
{!defaultModel && <CircleCheck className="size-3.5 text-[var(--color-accent)]" />}
</button>
{/* Grouped models */}
{groupedModels.map((group) => (
<div key={group.tier}>
<div className="mx-2 mt-2 mb-1 border-t border-[var(--color-border-subtle)]/50" />
<div className="px-2.5 pt-1.5 pb-0.5 text-[10px] font-semibold tracking-wider text-[var(--color-text-muted)] uppercase">
{group.label}
</div>
{group.models.map((model) => {
const isSelected = defaultModel === model.id;
return (
<button
key={model.id}
onClick={() => { onUpdate?.({ defaultModel: model.id }); setModelDropdownOpen(false); }}
className={`flex w-full items-center gap-2 rounded-lg px-3 py-[7px] text-left transition ${
isSelected
? 'bg-[var(--color-accent-muted)] text-[var(--color-text-primary)]'
: 'text-[var(--color-text-secondary)] hover:bg-[var(--color-surface-2)] hover:text-[var(--color-text-primary)]'
}`}
type="button"
role="option"
aria-selected={isSelected}
>
<span className="flex-1 truncate text-[12px] font-medium">{model.name}</span>
{model.supportedReasoningEfforts?.length ? (
<span className="text-[9px] font-semibold tracking-wide text-[var(--color-text-muted)] uppercase">reasoning</span>
) : null}
{isSelected && <CircleCheck className="size-3.5 flex-none text-[var(--color-accent)]" />}
</button>
);
})}
</div>
))}
</div>
</div>
)}
</div>
</div>
{/* Reasoning Effort — only shown when selected model supports it */}
{modelSupportsReasoning ? (
<div className="mt-6">
<h3 className="font-display text-[13px] font-semibold text-[var(--color-text-primary)]">Reasoning Effort</h3>
<p className="mt-0.5 text-[12px] text-[var(--color-text-muted)]">
Higher effort produces more thorough answers but takes longer
</p>
<div className="mt-3 flex gap-1.5">
{([undefined, 'low', 'medium', 'high'] as const).map((effort) => { {([undefined, 'low', 'medium', 'high'] as const).map((effort) => {
const isActive = defaultReasoning === effort; const isActive = defaultReasoning === effort;
const label = effort ?? 'Default'; const label = effort ?? 'Auto';
const displayLabel = label.charAt(0).toUpperCase() + label.slice(1);
// Only show efforts the model actually supports (plus "Auto")
if (effort && !resolvedModel?.supportedReasoningEfforts?.includes(effort)) return null;
return ( return (
<button <button
key={label} key={displayLabel}
onClick={() => onUpdate?.({ defaultReasoningEffort: effort })} onClick={() => onUpdate?.({ defaultReasoningEffort: effort })}
className={`flex-1 rounded-lg border py-2.5 text-[13px] font-medium transition-all duration-200 ${ className={`flex-1 rounded-lg border py-2 text-[12px] font-medium transition-all duration-150 ${
isActive isActive
? 'border-[var(--color-border-glow)] bg-[var(--color-accent-muted)] text-[var(--color-text-primary)]' ? 'border-[var(--color-accent)]/40 bg-[var(--color-accent)]/12 text-[var(--color-text-accent)]'
: 'border-[var(--color-border)] text-[var(--color-text-secondary)] hover:bg-[var(--color-surface-3)]/40' : 'border-[var(--color-border)] text-[var(--color-text-muted)] hover:border-[var(--color-border-glow)] hover:text-[var(--color-text-secondary)]'
}`} }`}
type="button" type="button"
> >
{label.charAt(0).toUpperCase() + label.slice(1)} {displayLabel}
</button> </button>
); );
})} })}
</div> </div>
</> </div>
)} ) : defaultModel ? (
<p className="mt-4 text-[11px] text-[var(--color-text-muted)]">
{resolvedModel?.name ?? 'Selected model'} does not support configurable reasoning effort.
</p>
) : null}
</div> </div>
); );
} }
@@ -1,5 +1,5 @@
import { useEffect, useRef } from 'react'; import { useEffect, useRef, useMemo } from 'react';
import { Check, Crown, Zap } from 'lucide-react'; import { Check, Crown, Zap, Brain } from 'lucide-react';
import type { ModelDefinition } from '@shared/domain/models'; import type { ModelDefinition } from '@shared/domain/models';
import type { ReasoningEffort } from '@shared/domain/workflow'; import type { ReasoningEffort } from '@shared/domain/workflow';
@@ -13,19 +13,25 @@ interface ModelSelectorProps {
onClose: () => void; onClose: () => void;
} }
const tierConfig = { const tierMeta: Record<string, { label: string; icon: typeof Crown; color: string; bg: string }> = {
premium: { label: 'Premium', icon: Crown, className: 'text-amber-400 bg-amber-400/10' }, premium: { label: 'Premium', icon: Crown, color: 'text-amber-400', bg: 'bg-amber-400/10' },
standard: { label: 'Standard', icon: Zap, className: 'text-[var(--color-text-accent)] bg-[var(--color-accent-muted)]' }, standard: { label: 'Standard', icon: Zap, color: 'text-[var(--color-text-accent)]', bg: 'bg-[var(--color-accent-muted)]' },
fast: { label: 'Fast', icon: Zap, className: 'text-emerald-400 bg-emerald-400/10' }, fast: { label: 'Fast', icon: Zap, color: 'text-emerald-400', bg: 'bg-emerald-400/10' },
} as const; };
const reasoningOptions: { value: ReasoningEffort; label: string }[] = [ const reasoningLevels: { value: ReasoningEffort; label: string; description: string }[] = [
{ value: 'low', label: 'Low' }, { value: 'low', label: 'Low', description: 'Fast, concise' },
{ value: 'medium', label: 'Medium' }, { value: 'medium', label: 'Med', description: 'Balanced' },
{ value: 'high', label: 'High' }, { value: 'high', label: 'High', description: 'Thorough' },
{ value: 'xhigh', label: 'Extra High' }, { value: 'xhigh', label: 'Max', description: 'Exhaustive' },
]; ];
interface ModelGroup {
tier: string;
label: string;
models: ModelDefinition[];
}
export function ModelSelector({ export function ModelSelector({
models, models,
selectedModelId, selectedModelId,
@@ -58,73 +64,113 @@ export function ModelSelector({
}, [onClose]); }, [onClose]);
const selectedModel = models.find((m) => m.id === selectedModelId); const selectedModel = models.find((m) => m.id === selectedModelId);
const supportedReasoningEfforts = selectedModel?.supportedReasoningEfforts; const supportedEfforts = selectedModel?.supportedReasoningEfforts;
// Group models by tier
const groups = useMemo((): ModelGroup[] => {
const tierOrder = ['premium', 'standard', 'fast', 'other'];
const grouped = new Map<string, ModelDefinition[]>();
for (const model of models) {
const tier = model.tier ?? 'other';
const list = grouped.get(tier) ?? [];
list.push(model);
grouped.set(tier, list);
}
return tierOrder
.filter((t) => grouped.has(t))
.map((tier) => ({
tier,
label: tier === 'other' ? 'Other' : tierMeta[tier]?.label ?? tier,
models: grouped.get(tier)!,
}));
}, [models]);
return ( return (
<div <div
ref={containerRef} ref={containerRef}
className="qp-dropdown-enter absolute bottom-0 left-4 right-4 z-10 translate-y-full rounded-xl border border-[var(--color-border)] bg-[var(--color-surface-1)] shadow-xl shadow-black/40" className="qp-dropdown-enter absolute bottom-full left-3 right-3 z-10 mb-1 overflow-hidden rounded-xl border border-[var(--color-border)] bg-[var(--color-surface-1)] shadow-2xl shadow-black/50"
role="listbox" role="listbox"
aria-label="Select model" aria-label="Select model"
> >
{/* Model list */} {/* Model list — grouped by tier */}
<div className="max-h-[240px] overflow-y-auto p-1.5"> <div className="max-h-[280px] overflow-y-auto overscroll-contain p-1.5">
{models.map((model) => { {groups.map((group, gi) => {
const isSelected = model.id === selectedModelId; const meta = tierMeta[group.tier];
const tier = model.tier ? tierConfig[model.tier] : undefined; const TierIcon = meta?.icon;
const TierIcon = tier?.icon;
return ( return (
<button <div key={group.tier}>
key={model.id} {gi > 0 && <div className="mx-2 my-1 border-t border-[var(--color-border-subtle)]/50" />}
onClick={() => onSelect(model)}
className={`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left transition ${
isSelected
? 'bg-[var(--color-accent-muted)] text-[var(--color-text-primary)]'
: 'text-[var(--color-text-secondary)] hover:bg-[var(--color-surface-2)] hover:text-[var(--color-text-primary)]'
}`}
type="button"
role="option"
aria-selected={isSelected}
>
<span className="flex-1 text-[12px] font-medium">{model.name}</span>
{tier && TierIcon && ( {/* Group header */}
<span className={`flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${tier.className}`}> <div className="flex items-center gap-1.5 px-2.5 pt-2 pb-1">
<TierIcon className="size-2.5" /> {TierIcon && <TierIcon className={`size-2.5 ${meta.color}`} />}
{tier.label} <span className={`text-[10px] font-semibold tracking-wider uppercase ${meta?.color ?? 'text-[var(--color-text-muted)]'}`}>
{group.label}
</span> </span>
)} </div>
{isSelected && <Check className="size-3.5 flex-none text-[var(--color-accent)]" />} {/* Models in this group */}
</button> {group.models.map((model) => {
const isSelected = model.id === selectedModelId;
return (
<button
key={model.id}
onClick={() => onSelect(model)}
className={`flex w-full items-center gap-2 rounded-lg px-3 py-[7px] text-left transition-colors ${
isSelected
? 'bg-[var(--color-accent-muted)] text-[var(--color-text-primary)]'
: 'text-[var(--color-text-secondary)] hover:bg-[var(--color-surface-2)] hover:text-[var(--color-text-primary)]'
}`}
type="button"
role="option"
aria-selected={isSelected}
>
<span className="flex-1 truncate text-[12px] font-medium">{model.name}</span>
{model.supportedReasoningEfforts?.length ? (
<Brain className="size-3 flex-none text-[var(--color-text-muted)]/60" aria-label="Supports reasoning" />
) : null}
{isSelected && <Check className="size-3.5 flex-none text-[var(--color-accent)]" />}
</button>
);
})}
</div>
); );
})} })}
</div> </div>
{/* Reasoning effort selector */} {/* Reasoning effort — only shown when selected model supports it */}
{supportedReasoningEfforts && supportedReasoningEfforts.length > 0 && ( {supportedEfforts && supportedEfforts.length > 0 && (
<div className="border-t border-[var(--color-border-subtle)] p-3"> <div className="border-t border-[var(--color-border-subtle)] px-3 py-2.5">
<p className="mb-2 text-[10px] font-medium tracking-wide text-[var(--color-text-muted)] uppercase"> <div className="mb-2 flex items-center gap-1.5">
Reasoning Effort <Brain className="size-3 text-[var(--color-text-muted)]" />
</p> <span className="text-[10px] font-semibold tracking-wider text-[var(--color-text-muted)] uppercase">
Reasoning Effort
</span>
</div>
<div className="flex gap-1"> <div className="flex gap-1">
{reasoningOptions {reasoningLevels
.filter((opt) => supportedReasoningEfforts.includes(opt.value)) .filter((lvl) => supportedEfforts.includes(lvl.value))
.map((opt) => { .map((lvl) => {
const isActive = selectedReasoning === opt.value; const isActive = selectedReasoning === lvl.value;
return ( return (
<button <button
key={opt.value} key={lvl.value}
onClick={() => onReasoningChange(isActive ? undefined : opt.value)} onClick={() => onReasoningChange(isActive ? undefined : lvl.value)}
className={`flex-1 rounded-md py-1 text-[11px] font-medium transition ${ className={`group flex-1 rounded-lg py-1.5 text-center transition-all ${
isActive isActive
? 'bg-[var(--color-accent)] text-white' ? 'bg-[var(--color-accent)] text-white shadow-md shadow-[var(--color-accent)]/20'
: 'bg-[var(--color-surface-2)] text-[var(--color-text-muted)] hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-secondary)]' : 'bg-[var(--color-surface-2)] text-[var(--color-text-muted)] hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-secondary)]'
}`} }`}
type="button" type="button"
title={lvl.description}
> >
{opt.label} <span className="text-[11px] font-semibold">{lvl.label}</span>
</button> </button>
); );
})} })}
@@ -8,39 +8,36 @@ interface QuickPromptActionsProps {
export function QuickPromptActions({ onDiscard, onClose, onContinueInAryx }: QuickPromptActionsProps) { export function QuickPromptActions({ onDiscard, onClose, onContinueInAryx }: QuickPromptActionsProps) {
return ( return (
<div className="qp-actions-enter flex items-center gap-2 border-t border-[var(--color-border-subtle)] px-5 py-3"> <div className="qp-actions-enter flex items-center gap-1.5 border-t border-[var(--color-border-subtle)]/60 px-4 py-2.5">
{/* Discard — destructive, muted */}
<button <button
onClick={onDiscard} onClick={onDiscard}
className="flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-[12px] font-medium text-[var(--color-text-muted)] transition hover:bg-[var(--color-status-error)]/10 hover:text-[var(--color-status-error)]" className="flex items-center gap-1.5 rounded-lg px-3 py-[6px] text-[11px] font-medium text-[var(--color-text-muted)] transition-colors hover:bg-[var(--color-status-error)]/8 hover:text-[var(--color-status-error)]"
type="button" type="button"
title="Delete this session" title="Delete this session permanently"
> >
<Trash2 className="size-3.5" /> <Trash2 className="size-3" />
Discard Discard
</button> </button>
{/* Close — neutral, preserves session */}
<button <button
onClick={onClose} onClick={onClose}
className="flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-[12px] font-medium text-[var(--color-text-secondary)] transition hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-primary)]" className="flex items-center gap-1.5 rounded-lg px-3 py-[6px] text-[11px] font-medium text-[var(--color-text-muted)] transition-colors hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-primary)]"
type="button" type="button"
title="Close and keep session" title="Close and keep session for later"
> >
<X className="size-3.5" /> <X className="size-3" />
Close Close
</button> </button>
<div className="flex-1" /> <div className="flex-1" />
{/* Continue in Aryx — primary action */}
<button <button
onClick={onContinueInAryx} onClick={onContinueInAryx}
className="brand-gradient-bg flex items-center gap-1.5 rounded-lg px-4 py-1.5 text-[12px] font-semibold text-white shadow-md shadow-[var(--color-accent)]/15 transition hover:shadow-lg hover:shadow-[var(--color-accent)]/25" className="brand-gradient-bg flex items-center gap-1.5 rounded-lg px-4 py-[6px] text-[11px] font-semibold text-white shadow-sm shadow-[var(--color-accent)]/15 transition-all hover:shadow-md hover:shadow-[var(--color-accent)]/25 hover:brightness-110"
type="button" type="button"
> >
Continue in Aryx Continue in Aryx
<ArrowRight className="size-3.5" /> <ArrowRight className="size-3" />
</button> </button>
</div> </div>
); );
@@ -71,6 +71,8 @@ export function QuickPromptApp() {
})); }));
} }
setPhase('streaming'); setPhase('streaming');
} else if (event.kind === 'message-complete') {
setPhase('complete');
} else if (event.kind === 'status' && event.status === 'idle') { } else if (event.kind === 'status' && event.status === 'idle') {
setPhase((prev) => (prev === 'streaming' ? 'complete' : prev)); setPhase((prev) => (prev === 'streaming' ? 'complete' : prev));
} else if (event.kind === 'error') { } else if (event.kind === 'error') {
@@ -1,5 +1,5 @@
import { useCallback, useEffect, useRef, useState } from 'react'; import { useCallback, useEffect, useRef, useState } from 'react';
import { ChevronDown, Loader2, Zap } from 'lucide-react'; import { ChevronDown, Loader2, Square, Sparkles } from 'lucide-react';
import type { ModelDefinition } from '@shared/domain/models'; import type { ModelDefinition } from '@shared/domain/models';
import type { ReasoningEffort } from '@shared/domain/workflow'; import type { ReasoningEffort } from '@shared/domain/workflow';
@@ -33,13 +33,21 @@ export function QuickPromptInput({
const [modelSelectorOpen, setModelSelectorOpen] = useState(false); const [modelSelectorOpen, setModelSelectorOpen] = useState(false);
const textareaRef = useRef<HTMLTextAreaElement>(null); const textareaRef = useRef<HTMLTextAreaElement>(null);
// Auto-focus on mount and when phase resets to idle // Auto-focus when phase resets to idle
useEffect(() => { useEffect(() => {
if (phase === 'idle') { if (phase === 'idle') {
textareaRef.current?.focus(); setTimeout(() => textareaRef.current?.focus(), 50);
} }
}, [phase]); }, [phase]);
// Auto-resize textarea
useEffect(() => {
const el = textareaRef.current;
if (!el) return;
el.style.height = 'auto';
el.style.height = `${Math.min(el.scrollHeight, 120)}px`;
}, [value]);
const handleKeyDown = useCallback( const handleKeyDown = useCallback(
(e: React.KeyboardEvent) => { (e: React.KeyboardEvent) => {
if (e.key === 'Enter' && !e.shiftKey) { if (e.key === 'Enter' && !e.shiftKey) {
@@ -52,65 +60,78 @@ export function QuickPromptInput({
[onSend, value, phase], [onSend, value, phase],
); );
const isDisabled = phase === 'streaming'; const reasoningLabel = selectedReasoning
? selectedReasoning === 'xhigh' ? 'xHigh' : selectedReasoning.charAt(0).toUpperCase() + selectedReasoning.slice(1)
: undefined;
return ( return (
<div className="relative flex flex-col"> <div className="relative flex flex-col">
{/* Text input row */} {/* Primary input area */}
<div className="flex items-start gap-3 px-5 pt-4 pb-3"> <div className="flex items-start gap-3 px-5 pt-4 pb-2">
{/* Spark icon */} <div className="mt-1 flex-none">
<div className="mt-0.5 flex-none">
{phase === 'streaming' ? ( {phase === 'streaming' ? (
<Loader2 className="size-[18px] animate-spin text-[var(--color-accent)]" /> <Loader2 className="size-[18px] animate-spin text-[var(--color-accent)]" aria-label="Processing" />
) : ( ) : (
<Zap className="size-[18px] text-[var(--color-text-muted)]" /> <Sparkles className="size-[18px] text-[var(--color-text-muted)]" />
)} )}
</div> </div>
{/* Textarea */}
<textarea <textarea
ref={textareaRef} ref={textareaRef}
value={value} value={value}
onChange={(e) => setValue(e.target.value)} onChange={(e) => setValue(e.target.value)}
onKeyDown={handleKeyDown} onKeyDown={handleKeyDown}
placeholder="Ask anything..." placeholder="Ask anything"
disabled={isDisabled} disabled={phase === 'streaming'}
rows={1} rows={1}
className="auto-resize-textarea min-h-[28px] max-h-[120px] flex-1 resize-none bg-transparent font-[var(--font-body)] text-[14px] leading-[1.6] text-[var(--color-text-primary)] outline-none placeholder:text-[var(--color-text-muted)] disabled:opacity-40" className="min-h-[28px] max-h-[120px] flex-1 resize-none bg-transparent font-[var(--font-body)] text-[14px] leading-[1.6] text-[var(--color-text-primary)] outline-none placeholder:text-[var(--color-text-muted)]/60 disabled:opacity-40"
aria-label="Quick prompt input"
/> />
{/* Cancel button during streaming */}
{phase === 'streaming' && ( {phase === 'streaming' && (
<button <button
onClick={onCancel} onClick={onCancel}
className="mt-0.5 flex-none rounded-md px-2.5 py-1 text-[12px] font-medium text-[var(--color-text-secondary)] transition hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-primary)]" className="mt-0.5 flex flex-none items-center gap-1.5 rounded-md border border-[var(--color-border)] bg-[var(--color-surface-2)] px-2.5 py-1 text-[11px] font-medium text-[var(--color-text-secondary)] transition hover:border-[var(--color-status-error)]/40 hover:bg-[var(--color-status-error)]/10 hover:text-[var(--color-status-error)]"
type="button" type="button"
aria-label="Stop generating"
> >
<Square className="size-2.5 fill-current" />
Stop Stop
</button> </button>
)} )}
</div> </div>
{/* Model selector row */} {/* Footer bar: model selector + shortcuts */}
<div className="flex items-center gap-2 border-t border-[var(--color-border-subtle)] px-5 py-2"> <div className="flex items-center gap-2 border-t border-[var(--color-border-subtle)]/60 px-5 py-2">
<button <button
onClick={() => setModelSelectorOpen((prev) => !prev)} onClick={() => setModelSelectorOpen((prev) => !prev)}
className="flex items-center gap-1.5 rounded-md px-2 py-1 text-[11px] text-[var(--color-text-muted)] transition hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-secondary)]" className={`flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[11px] transition ${
modelSelectorOpen
? 'bg-[var(--color-accent-muted)] text-[var(--color-text-accent)]'
: 'text-[var(--color-text-muted)] hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-secondary)]'
}`}
type="button" type="button"
aria-haspopup="listbox" aria-haspopup="listbox"
aria-expanded={modelSelectorOpen} aria-expanded={modelSelectorOpen}
> >
<span className="font-medium">{selectedModel?.name ?? 'Select model'}</span> <span className="max-w-[160px] truncate font-medium">{selectedModel?.name ?? 'Select model'}</span>
{selectedReasoning && ( {reasoningLabel && (
<span className="rounded bg-[var(--color-accent-muted)] px-1.5 py-px text-[10px] text-[var(--color-text-accent)]"> <span className="rounded-[4px] bg-[var(--color-accent)]/15 px-1.5 py-px text-[9px] font-semibold tracking-wide text-[var(--color-text-accent)] uppercase">
{selectedReasoning} {reasoningLabel}
</span> </span>
)} )}
<ChevronDown className="size-3" /> <ChevronDown className={`size-3 transition-transform ${modelSelectorOpen ? 'rotate-180' : ''}`} />
</button> </button>
<span className="ml-auto text-[10px] text-[var(--color-text-muted)] select-none opacity-60"> <span className="ml-auto flex items-center gap-3 text-[10px] text-[var(--color-text-muted)] select-none opacity-50">
Enter to send · Esc to dismiss <kbd className="rounded border border-[var(--color-border-subtle)] bg-[var(--color-surface-2)] px-1 py-px font-mono text-[9px]">
</kbd>
<span>Send</span>
<kbd className="rounded border border-[var(--color-border-subtle)] bg-[var(--color-surface-2)] px-1 py-px font-mono text-[9px]">
Esc
</kbd>
<span>Dismiss</span>
</span> </span>
</div> </div>
@@ -31,40 +31,43 @@ export function QuickPromptResponse({
return ( return (
<div <div
ref={scrollRef} ref={scrollRef}
className="qp-response-enter max-h-[min(55vh,520px)] overflow-y-auto border-t border-[var(--color-border-subtle)]" className="qp-response-enter max-h-[min(50vh,480px)] overflow-y-auto overscroll-contain border-t border-[var(--color-border-subtle)]/60"
> >
{/* Error state */} {/* Error state */}
{phase === 'error' && error && ( {phase === 'error' && error && (
<div className="flex items-start gap-3 px-5 py-4"> <div className="flex items-start gap-3 px-5 py-4">
<AlertCircle className="mt-0.5 size-4 flex-none text-[var(--color-status-error)]" /> <AlertCircle className="mt-0.5 size-4 flex-none text-[var(--color-status-error)]" />
<p className="text-[13px] leading-relaxed text-[var(--color-status-error)]">{error}</p> <div>
<p className="text-[12px] font-semibold text-[var(--color-status-error)]">Something went wrong</p>
<p className="mt-1 text-[12px] leading-relaxed text-[var(--color-status-error)]/80">{error}</p>
</div>
</div> </div>
)} )}
{/* Thinking block — collapsed visualization */} {/* Thinking block — compact collapsed visualization */}
{thinkingContent && ( {thinkingContent && (
<div className="mx-5 mt-4 mb-2 rounded-lg border border-[var(--color-border-subtle)] bg-[var(--color-surface-0)]/50 px-4 py-3"> <div className="mx-5 mt-3 mb-1 rounded-lg border border-[var(--color-border-subtle)]/50 bg-[var(--color-surface-0)]/40 px-3.5 py-2.5">
<div className="flex items-center gap-2 text-[11px] font-medium text-[var(--color-text-muted)]"> <div className="flex items-center gap-2 text-[10px] font-semibold tracking-wide text-[var(--color-text-muted)] uppercase">
<Brain className="size-3.5" /> <Brain className="size-3" />
<span>Thinking</span> <span>Reasoning</span>
{phase === 'streaming' && !content && ( {phase === 'streaming' && !content && (
<span className="flex gap-0.5 ml-1"> <span className="ml-0.5 flex gap-[3px]">
<span className="thinking-dot inline-block size-1 rounded-full bg-[var(--color-text-muted)]" /> <span className="thinking-dot inline-block size-[3px] rounded-full bg-[var(--color-text-muted)]" />
<span className="thinking-dot inline-block size-1 rounded-full bg-[var(--color-text-muted)]" /> <span className="thinking-dot inline-block size-[3px] rounded-full bg-[var(--color-text-muted)]" />
<span className="thinking-dot inline-block size-1 rounded-full bg-[var(--color-text-muted)]" /> <span className="thinking-dot inline-block size-[3px] rounded-full bg-[var(--color-text-muted)]" />
</span> </span>
)} )}
</div> </div>
<p className="mt-1.5 text-[12px] leading-relaxed text-[var(--color-text-muted)] line-clamp-3"> <p className="mt-1 text-[11px] leading-relaxed text-[var(--color-text-muted)]/70 italic line-clamp-2">
{thinkingContent.slice(-300)} {thinkingContent.slice(-200)}
</p> </p>
</div> </div>
)} )}
{/* Main response content */} {/* Main response content */}
{content && ( {content && (
<div className="px-5 py-4"> <div className="px-5 py-3.5">
<div className="markdown-content text-[13.5px] text-[var(--color-text-primary)]"> <div className="markdown-content text-[13px] leading-[1.7] text-[var(--color-text-primary)]">
<ReactMarkdown remarkPlugins={[remarkGfm]}>{content}</ReactMarkdown> <ReactMarkdown remarkPlugins={[remarkGfm]}>{content}</ReactMarkdown>
</div> </div>
</div> </div>
@@ -72,13 +75,13 @@ export function QuickPromptResponse({
{/* Streaming indicator when no content yet */} {/* Streaming indicator when no content yet */}
{phase === 'streaming' && !content && !thinkingContent && ( {phase === 'streaming' && !content && !thinkingContent && (
<div className="flex items-center gap-3 px-5 py-5"> <div className="flex items-center gap-3 px-5 py-4">
<span className="flex gap-1"> <span className="flex gap-[3px]">
<span className="thinking-dot inline-block size-1.5 rounded-full bg-[var(--color-accent)]" /> <span className="thinking-dot inline-block size-[5px] rounded-full bg-[var(--color-accent)]" />
<span className="thinking-dot inline-block size-1.5 rounded-full bg-[var(--color-accent)]" /> <span className="thinking-dot inline-block size-[5px] rounded-full bg-[var(--color-accent)]" />
<span className="thinking-dot inline-block size-1.5 rounded-full bg-[var(--color-accent)]" /> <span className="thinking-dot inline-block size-[5px] rounded-full bg-[var(--color-accent)]" />
</span> </span>
<span className="text-[12px] text-[var(--color-text-muted)]">Generating response</span> <span className="text-[12px] text-[var(--color-text-muted)]">Generating</span>
</div> </div>
)} )}
</div> </div>
+42 -3
View File
@@ -795,15 +795,15 @@ body {
animation: qp-actions-in 0.2s cubic-bezier(0.16, 1, 0.3, 1) 0.05s both; animation: qp-actions-in 0.2s cubic-bezier(0.16, 1, 0.3, 1) 0.05s both;
} }
/* Dropdown entrance */ /* Dropdown entrance — opens upward */
@keyframes qp-dropdown-in { @keyframes qp-dropdown-in {
from { from {
opacity: 0; opacity: 0;
transform: translateY(calc(100% - 4px)) scale(0.98); transform: translateY(6px) scale(0.97);
} }
to { to {
opacity: 1; opacity: 1;
transform: translateY(100%); transform: translateY(0) scale(1);
} }
} }
@@ -917,3 +917,42 @@ body {
max-width: 100%; max-width: 100%;
border-radius: 0.5rem; border-radius: 0.5rem;
} }
.markdown-content code {
font-family: var(--font-mono);
font-size: 0.85em;
background: var(--color-surface-2);
border: 1px solid var(--color-border-subtle);
border-radius: 0.25rem;
padding: 0.15em 0.35em;
color: var(--color-text-primary);
}
.markdown-content pre {
background: var(--color-surface-0);
border: 1px solid var(--color-border);
border-radius: 0.5rem;
padding: 0.875em 1em;
overflow-x: auto;
margin-top: 0.75em;
margin-bottom: 0.75em;
}
.markdown-content pre code {
background: none;
border: none;
padding: 0;
font-size: 0.8125rem;
line-height: 1.6;
}
.markdown-content a {
color: var(--color-text-accent);
text-decoration: underline;
text-decoration-color: var(--color-text-accent);
text-underline-offset: 2px;
}
.markdown-content a:hover {
color: var(--color-accent-hover);
}