Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

fix(create): the prompt assistant sits in the prompt field's corner (FEHLER-Q4 #2)

purplece7ee32fda14
diff --git a/src/components/create/experimental/Composer.tsx b/src/components/create/experimental/Composer.tsx
index e1aaab9c..452961d2 100644
--- a/src/components/create/experimental/Composer.tsx
+++ b/src/components/create/experimental/Composer.tsx
@@ -398,8 +398,16 @@ export function Composer({ onOpenAdvanced, onOpenWorkflows }: Props) {
<div className="rounded-[var(--radius-panel)] bg-white/[0.03] border border-white/[0.06] focus-within:border-white/15 transition-colors">
{needPrompt && (
- <div className="px-3.5 pt-3">
+ // The prompt assistant (B43) sits in the field's corner, not in the
+ // action bar: there every pixel is the model chip's, whose whole
+ // name has to fit at 760 px (FEHLER-Q4 #2). The field keeps its
+ // width and only leaves room for the button inside (pr-7).
+ <div className="relative px-3.5 pt-3">
+ <div className="absolute top-2 right-2">
+ <PromptAssistant onUse={setPrompt} align="right" />
+ </div>
<PromptField
+ className="pr-7"
value={prompt}
onChange={setPrompt}
placeholder={
@@ -505,7 +513,6 @@ export function Composer({ onOpenAdvanced, onOpenWorkflows }: Props) {
Negative
</button>
)}
- {needPrompt && <PromptAssistant onUse={setPrompt} />}
{needPrompt && <PromptHistory onPick={setPrompt} />}
<div className="flex-1" />
{/* The backend axis moved to the global header switch (2.5.7) —
diff --git a/src/components/create/experimental/PromptAssistant.tsx b/src/components/create/experimental/PromptAssistant.tsx
index 236fbd5f..e227ebe9 100644
--- a/src/components/create/experimental/PromptAssistant.tsx
+++ b/src/components/create/experimental/PromptAssistant.tsx
@@ -19,7 +19,12 @@ import { useClickAway } from '../ui/useClickAway'
* model through the same call as "Improve my prompt". Nothing replaces the
* prompt until the user presses Use.
*/
-export function PromptAssistant({ onUse }: { onUse: (prompt: string) => void }) {
+export function PromptAssistant({ onUse, align = 'left' }: {
+ onUse: (prompt: string) => void
+ /** Which edge of the button the panel lines up with. In the prompt field's
+ * right corner it opens leftwards, so it stays inside the composer. */
+ align?: 'left' | 'right'
+}) {
const intent = useCreateStore((s) => s.intent())
const kind = improveKindForIntent(intent)
const runModel = useCreateStore((s) =>
@@ -86,7 +91,7 @@ export function PromptAssistant({ onUse }: { onUse: (prompt: string) => void })
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: panel.nachOben ? 4 : -4 }}
transition={{ duration: 0.12 }}
- className={cn('lu-elevated absolute left-0 z-50 w-80 rounded-lg p-2.5 space-y-2 overflow-y-auto scrollbar-thin', panel.nachOben ? 'bottom-full mb-1.5' : 'top-full mt-1.5')}
+ className={cn('lu-elevated absolute z-50 w-80', align === 'right' ? 'right-0' : 'left-0', 'rounded-lg p-2.5 space-y-2 overflow-y-auto scrollbar-thin', panel.nachOben ? 'bottom-full mb-1.5' : 'top-full mt-1.5')}
data-testid="prompt-assistant"
data-family={family}
>
diff --git a/src/components/create/experimental/__tests__/prompt-assistant-b43.test.tsx b/src/components/create/experimental/__tests__/prompt-assistant-b43.test.tsx
index 35b991f3..de882e5e 100644
--- a/src/components/create/experimental/__tests__/prompt-assistant-b43.test.tsx
+++ b/src/components/create/experimental/__tests__/prompt-assistant-b43.test.tsx
@@ -121,10 +121,15 @@ describe('B43: the assistant in the composer', () => {
})
describe('B43: where it sits', () => {
- it('next to the prompt history in the composer, writing into the prompt', async () => {
+ it('in the prompt field\'s corner, writing into the prompt, and not in the action bar', async () => {
+ // FEHLER-Q4 #2: in the action bar it took the width the model chip needs
+ // to show its whole name at 760 px (e2e/mac-persona-walk.spec.ts).
const { readFileSync } = await import('node:fs')
const { resolve } = await import('node:path')
const src = readFileSync(resolve(__dirname, '../Composer.tsx'), 'utf8')
- expect(src).toMatch(/\{needPrompt && <PromptAssistant onUse=\{setPrompt\} \/>\}\n\s*\{needPrompt && <PromptHistory/)
+ expect(src.match(/<PromptAssistant /g)).toHaveLength(1)
+ expect(src).toMatch(/<div className="absolute top-2 right-2">\s*<PromptAssistant onUse=\{setPrompt\} align="right" \/>\s*<\/div>\s*<PromptField\s+className="pr-7"/)
+ const bar = src.slice(src.indexOf('{/* Action bar */}'))
+ expect(bar).not.toContain('<PromptAssistant')
})
})