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(chat): Flash-Hinweis als Etikett neben dem Agent-Schalter statt als Band ueber der Eingabe

purplec4ed80e7abdf
diff --git a/src/components/chat/ChatInput.tsx b/src/components/chat/ChatInput.tsx
index 50ce3d30..074a4e2f 100644
--- a/src/components/chat/ChatInput.tsx
+++ b/src/components/chat/ChatInput.tsx
@@ -3,7 +3,6 @@ import { SamplingControls } from './SamplingControls'
import { Send, Square, Paperclip, X, Brain, Gauge, Terminal } from 'lucide-react'
import { matchAgentCommands, type AgentCommand, type CommandScope } from '../../lib/agent-commands'
import { VoiceButton } from './VoiceButton'
-import { FlashChatNotice } from './FlashChatNotice'
import { ModelMarks } from './ModelMarks'
import { ApprovalDialog } from './ApprovalDialog'
import { useVoiceStore } from '../../stores/voiceStore'
@@ -399,7 +398,10 @@ export function ChatInput({ onSend, onStop, isGenerating, waitingForLocalLane, l
<div className={`px-3 pb-2 pt-1 w-full ${COMPOSER_MAX_W} mx-auto`}>
{/* Was dieses Modell kann, bevor die Frage getippt ist. */}
<ModelMarks />
- <FlashChatNotice />
+ {/* Was eine Runde auf diesem Modell kostet, steht seit 19.09.2026 nicht
+ mehr hier: dort war es ein stehendes Band, das den Agent-Schalter
+ und Nachbarn nach oben schob. Es lebt jetzt als kleines Etikett in
+ der Sitzungsleiste, direkt neben AgentModeToggle (ChatView.tsx). */}
{/* Approval used to live here as a popup over the chat input.
Per user feedback ("eventuell in den chat einarbeiten") it now
renders INSIDE the pending tool-call block in MessageList, so
diff --git a/src/components/chat/ChatView.tsx b/src/components/chat/ChatView.tsx
index 21bc3110..c0bb7f30 100644
--- a/src/components/chat/ChatView.tsx
+++ b/src/components/chat/ChatView.tsx
@@ -15,6 +15,7 @@ import { RetrievalErrorBar } from './RetrievalErrorBar'
import { LuEngineSwitchBar } from './LuEngineSwitchBar'
import { useDocsAvailability } from '../../hooks/useDocsAvailability'
import { AgentModeToggle } from './AgentModeToggle'
+import { FlashChatNotice } from './FlashChatNotice'
import { AgentWorkspaceBadge } from './AgentWorkspaceBadge'
import { ErrorBoundary } from '../ui/ErrorBoundary'
import { CHAT_BASE_SYSTEM_PROMPT } from '../../lib/system-prompt'
@@ -504,6 +505,12 @@ export function ChatView() {
<div className={`w-full ${COMPOSER_MAX_W} mx-auto px-3`}>
<div data-testid="chat-session-strip" className="flex items-center gap-1.5 px-2 py-0.5">
<AgentModeToggle />
+ {/* Was diese Runde kostet, direkt neben dem Agent-Schalter
+ (David, 19.09.2026): kein Band mehr ueber der Eingabe,
+ das diese Leiste nach oben schob, sondern ein Etikett
+ in genau dieser Leiste. Rendert `null` ohne
+ Flash-Modell, verschiebt also nichts, wenn es fehlt. */}
+ <FlashChatNotice />
<AgentWorkspaceBadge />
{/* Spacer */}
diff --git a/src/components/chat/CodexView.tsx b/src/components/chat/CodexView.tsx
index 8cd2f791..9b4b61c1 100644
--- a/src/components/chat/CodexView.tsx
+++ b/src/components/chat/CodexView.tsx
@@ -14,6 +14,7 @@ import { MarkdownRenderer } from './MarkdownRenderer'
import { TokenCounter } from './TokenCounter'
import { ContextDropdown } from './ContextDropdown'
import { SmallModelModeToggle } from './SmallModelModeToggle'
+import { FlashChatNotice } from './FlashChatNotice'
import { WorkingAnchor } from './WorkingAnchor'
import { useCodexConfirmStore } from '../../stores/codexConfirmStore'
import { PluginsDropdown } from './PluginsDropdown'
@@ -275,6 +276,10 @@ export function CodexView() {
des Fensterwaehlers, nicht dieselbe Zahl ein zweites Mal daneben. */}
<ContextDropdown><TokenCounter /></ContextDropdown>
<SmallModelModeToggle />
+ {/* Was diese Runde kostet, denselben Ort wie im Chat-Reiter
+ (ChatView.tsx): ein Etikett in dieser Leiste statt eines Bandes
+ ueber der Eingabe. Rendert `null` ohne Flash-Modell. */}
+ <FlashChatNotice />
</div>
{/* R2-21: der Sperrgrund hing bisher nur als `title` am Entfernen-Knopf,
diff --git a/src/components/chat/FlashChatNotice.tsx b/src/components/chat/FlashChatNotice.tsx
index 8d6e1cd9..29ac9fd8 100644
--- a/src/components/chat/FlashChatNotice.tsx
+++ b/src/components/chat/FlashChatNotice.tsx
@@ -1,15 +1,21 @@
-import { useEffect } from 'react'
+import { useCallback, useEffect, useId, useRef, useState } from 'react'
+import { X } from 'lucide-react'
import { useModelStore } from '../../stores/modelStore'
import { clearFlashNotices, useFlashBillingStore } from '../../lib/flash-ui'
import { FLASH_UNPAID_NOTICE, useFlashEntitlement } from '../../lib/flash-entitlement'
+import { useDismissOnEscape } from '../../hooks/useDismissOnEscape'
/**
- * Was eine Runde auf dem gewaehlten Modell dieses Konto kostet.
+ * Was eine Runde auf dem gewaehlten Modell dieses Konto kostet, als kleiner
+ * Hinweis in der Sitzungsleiste statt als stehendes Band ueber der Eingabe.
*
- * Der stehende Satz beschreibt die Freimenge, und die hat nur ein bezahlter
- * Plan. Ein Starter-Konto zahlt fuer genau diese Modelle und liest deshalb
- * einen ehrlichen Satz statt der Zusage (T7 hat am 11.09.2026 das Gegenteil
- * gemessen: dieselbe Zusage wie beim Planbesitzer, und ein Credit war weg).
+ * David, 19.09.2026: das alte Band stand dauerhaft ueber dem Eingabefeld, sah
+ * schlecht aus und schob den Agent-Schalter, die Kontextanzeige und Memories
+ * nach oben. Der Hinweis ist jetzt ein einzeiliges Etikett neben dem
+ * Agent-Schalter, das ein Popup oeffnet statt Platz zu beanspruchen. Bauart
+ * wortgleich mit `SamplingControls`, dem Haus-Muster fuer genau dieses Popup
+ * (Trigger oeffnet, Escape/X/Aussenklick schliessen, Fokus geht rein und
+ * zurueck), damit nicht ein zweites Muster fuer dasselbe Verhalten entsteht.
*
* Zwei Sorten Text leben hier und verhalten sich mit Absicht verschieden:
* - die Zeilen je Anfrage melden eine Antwort, die schon zurueck ist. Sie
@@ -19,7 +25,30 @@ import { FLASH_UNPAID_NOTICE, useFlashEntitlement } from '../../lib/flash-entitl
* dieses Kontos. Das veraltet durch einen Blur nicht, er bleibt stehen.
* Seine Kontohaelfte kommt aus dem Kontospeicher, den `useCloudAuth` im
* Takt aus `/api/me` nachzieht.
+ *
+ * Das Etikett selbst traegt die Farbe: GRUEN nur, wenn diese Runde wirklich
+ * keine Credits kostet (bezahlter Plan, Freimenge nicht aufgebraucht). Faellt
+ * die Anfrage auf Credits zurueck (Freimenge aufgebraucht) oder zahlt das
+ * Konto ohnehin fuer dieses Modell (kein bezahlter Plan), steht an derselben
+ * Stelle derselbe neutrale Text, nie Gruen: eine falsche Zusage waere hier
+ * schlimmer als keine.
*/
+
+const FOCUSABLE = 'button:not([disabled]), [tabindex]:not([tabindex="-1"])'
+
+/** Panel width, matching the sampling popup's own fixed width. */
+const PANEL_WIDTH = 260
+
+/** The close button's accessible name, mirrored in the web app. */
+export const FLASH_NOTICE_CLOSE_LABEL = 'Close Flash usage details'
+
+/** What the popup is called for a screen reader, mirrored in the web app. */
+export const FLASH_NOTICE_DIALOG_LABEL = 'Flash usage'
+
+/** The trigger's own label per state, mirrored in the web app. */
+export const FLASH_NOTICE_LABEL_FREE = 'Using no credits'
+export const FLASH_NOTICE_LABEL_CREDITS = 'Using credits'
+
export function FlashChatNotice() {
useEffect(() => {
// Another tab can change the account while this surface is unfocused.
@@ -31,43 +60,134 @@ export function FlashChatNotice() {
clearFlashNotices()
}
}, [])
+
+ const [open, setOpen] = useState(false)
+ const wrapRef = useRef<HTMLDivElement>(null)
+ const panelRef = useRef<HTMLDivElement>(null)
+ const panelId = useId()
+
const active = useModelStore((s) => s.models.find((m) => m.name === s.activeModel))
const policy = active && 'flash' in active ? active.flash : undefined
- const notice = useFlashBillingStore((s) => policy ? s.entries[policy.billingKey] : undefined)
+ const notice = useFlashBillingStore((s) => (policy ? s.entries[policy.billingKey] : undefined))
const paidPlan = useFlashEntitlement()
+
+ // Give the keyboard back to the trigger, but only while it is still in the
+ // popup: on an outside press the browser is already moving it somewhere the
+ // user chose. Same rule as SamplingControls.close.
+ const close = useCallback(() => {
+ const panel = panelRef.current
+ if (panel && panel.contains(document.activeElement)) {
+ wrapRef.current?.querySelector('button')?.focus()
+ }
+ setOpen(false)
+ }, [])
+ useDismissOnEscape(open, close)
+
+ useEffect(() => {
+ if (!open) return
+ const aus = (e: Event) => {
+ const target = e.target as Node | null
+ if (!target) return
+ if (wrapRef.current?.contains(target)) return
+ close()
+ }
+ document.addEventListener('pointerdown', aus)
+ return () => document.removeEventListener('pointerdown', aus)
+ }, [open, close])
+
+ useEffect(() => {
+ if (!open) return
+ panelRef.current?.querySelector<HTMLElement>(FOCUSABLE)?.focus()
+ }, [open])
+
if (!policy) return null
// Noch nicht beantwortet. Schweigen ist der einzige ehrliche Zustand: beide
- // Saetze darunter sind Aussagen ueber Geld.
+ // Saetze im Popup sind Aussagen ueber Geld.
if (paidPlan === null) return null
- if (!paidPlan) {
- return (
- <div className="mb-2 text-xs text-gray-500" data-testid="flash-chat-notice">
- <p>{FLASH_UNPAID_NOTICE}</p>
- </div>
- )
- }
+
+ // Gruen ist nur wahr, solange diese Runde wirklich nichts kostet: ein
+ // bezahlter Plan UND keine bereits gemeldete Rueckkehr auf Credits.
+ const usesCredits = !paidPlan || notice?.billing === 'credits'
+ const label = usesCredits ? FLASH_NOTICE_LABEL_CREDITS : FLASH_NOTICE_LABEL_FREE
+
return (
- <div className="mb-2 text-xs text-gray-500" data-testid="flash-chat-notice">
- <details>
- <summary className="cursor-pointer">Flash: {policy.dailyTokens.toLocaleString('en-US')} input and output tokens per UTC day without credits</summary>
- <p className="mt-1">
- One free request at a time per account. Resets at 00:00 UTC. API keys always use credits.
- A request that exceeds the remaining allowance uses credits instead.
- Without an explicit output limit, free requests allow up to {policy.defaultMaxOutput.toLocaleString('en-US')} output tokens.
- Each free request lasts at most {policy.requestSeconds} seconds.
- The request budget is reserved before generation. Failed or interrupted requests without final usage keep that reservation.
- </p>
- </details>
- {notice?.billing === 'credits' && (
- <p role="alert" className="mt-1 text-gray-700 dark:text-gray-200">
- {notice.ok ? 'This request uses credits instead of the free Flash allowance.' : 'This request requires credits. No generation started.'}
- {' '}Its token budget exceeds the available allowance.
- </p>
- )}
- {notice?.billing === 'flash' && (
- <p role="status" className="mt-1">
- Free Flash request. Remaining after reservation: {notice.remaining.toLocaleString('en-US')} tokens.
- </p>
+ <div className="relative shrink-0" ref={wrapRef} data-testid="flash-chat-notice">
+ <button
+ type="button"
+ aria-expanded={open}
+ aria-controls={panelId}
+ data-testid="flash-chat-notice-trigger"
+ title="Flash usage for this chat"
+ className={
+ usesCredits
+ ? 't-micro whitespace-nowrap text-gray-500 hover:text-gray-300 transition-colors'
+ : 't-micro whitespace-nowrap text-emerald-600 dark:text-emerald-400 hover:text-emerald-500 transition-colors'
+ }
+ onClick={() => setOpen(true)}
+ >
+ {label}
+ </button>
+
+ {open && (
+ <div
+ ref={panelRef}
+ id={panelId}
+ role="dialog"
+ aria-label={FLASH_NOTICE_DIALOG_LABEL}
+ data-testid="flash-chat-notice-panel"
+ // Out of flow, exactly like SamplingControls: the row it hangs off
+ // keeps its size and position to the pixel, whatever this says.
+ style={{
+ position: 'absolute',
+ left: 0,
+ top: '100%',
+ marginTop: 6,
+ width: PANEL_WIDTH,
+ }}
+ className="z-50 space-y-1.5 rounded-lg p-2.5 lu-elevated text-xs text-gray-500"
+ >
+ <div className="flex justify-end">
+ <button
+ type="button"
+ aria-label={FLASH_NOTICE_CLOSE_LABEL}
+ title={FLASH_NOTICE_CLOSE_LABEL}
+ data-testid="flash-chat-notice-close"
+ className="rounded p-0.5 text-gray-500 hover:text-gray-300"
+ onClick={close}
+ >
+ <X size={11} />
+ </button>
+ </div>
+
+ {!paidPlan ? (
+ <p>{FLASH_UNPAID_NOTICE}</p>
+ ) : (
+ <>
+ <p>
+ Flash: {policy.dailyTokens.toLocaleString('en-US')} input and output tokens per UTC day without credits.
+ Resets at 00:00 UTC.
+ </p>
+ <p>
+ One free request at a time per account. API keys always use credits.
+ A request that exceeds the remaining allowance uses credits instead.
+ Without an explicit output limit, free requests allow up to {policy.defaultMaxOutput.toLocaleString('en-US')} output tokens.
+ Each free request lasts at most {policy.requestSeconds} seconds.
+ The request budget is reserved before generation. Failed or interrupted requests without final usage keep that reservation.
+ </p>
+ {notice?.billing === 'credits' && (
+ <p role="alert" className="text-gray-700 dark:text-gray-200">
+ {notice.ok ? 'This request uses credits instead of the free Flash allowance.' : 'This request requires credits. No generation started.'}
+ {' '}Its token budget exceeds the available allowance.
+ </p>
+ )}
+ {notice?.billing === 'flash' && (
+ <p role="status">
+ Free Flash request. Remaining after reservation: {notice.remaining.toLocaleString('en-US')} tokens.
+ </p>
+ )}
+ </>
+ )}
+ </div>
)}
</div>
)
diff --git a/src/components/chat/__tests__/flash-chat-notice.test.ts b/src/components/chat/__tests__/flash-chat-notice.test.ts
index bbf2064f..4ae22fde 100644
--- a/src/components/chat/__tests__/flash-chat-notice.test.ts
+++ b/src/components/chat/__tests__/flash-chat-notice.test.ts
@@ -2,7 +2,11 @@
import { createElement } from 'react'
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'
-import { FlashChatNotice } from '../FlashChatNotice'
+import {
+ FLASH_NOTICE_LABEL_CREDITS,
+ FLASH_NOTICE_LABEL_FREE,
+ FlashChatNotice,
+} from '../FlashChatNotice'
import { useModelStore } from '../../../stores/modelStore'
import { captureFlashGeneration, clearFlashNotices, parseFlashPolicy, recordFlashResponse, useFlashBillingStore } from '../../../lib/flash-ui'
import { FLASH_UNPAID_NOTICE } from '../../../lib/flash-entitlement'
@@ -16,6 +20,9 @@ const signIn = (paidPlan: boolean | null) =>
{ licenseActive: true, tier: 'hosted', access: true, quota: null, paidPlan },
)
+/** Opens the popup by clicking the trigger label, the only way in. */
+const openPopup = () => fireEvent.click(screen.getByTestId('flash-chat-notice-trigger'))
+
beforeEach(() => {
useFlashBillingStore.setState({ entries: {} })
// Die bestehenden Faelle beschreiben das zahlende Konto.
@@ -26,9 +33,97 @@ beforeEach(() => {
})
afterEach(cleanup)
-describe('visible flash policy and billing', () => {
+describe('das Etikett neben dem Agent-Schalter', () => {
+ it('zeigt GRUEN "Using no credits" nur, wenn diese Runde wirklich nichts kostet', () => {
+ render(createElement(FlashChatNotice))
+ const trigger = screen.getByTestId('flash-chat-notice-trigger')
+ expect(trigger.textContent).toBe(FLASH_NOTICE_LABEL_FREE)
+ expect(trigger.className).toMatch(/emerald/)
+ })
+
+ it('faellt die Freimenge fuer diese Runde auf Credits zurueck, wird das Etikett neutral', () => {
+ render(createElement(FlashChatNotice))
+ act(() => recordFlashResponse(policy.billingKey, new Response('', { headers: {
+ 'x-lu-chat-billing': 'credits', 'x-lu-flash-remaining': '0',
+ } })))
+ const trigger = screen.getByTestId('flash-chat-notice-trigger')
+ expect(trigger.textContent).toBe(FLASH_NOTICE_LABEL_CREDITS)
+ expect(trigger.className).not.toMatch(/emerald/)
+ })
+
+ it('ein Konto ohne bezahlten Plan liest denselben neutralen Text, nie Gruen', () => {
+ signIn(false)
+ render(createElement(FlashChatNotice))
+ const trigger = screen.getByTestId('flash-chat-notice-trigger')
+ expect(trigger.textContent).toBe(FLASH_NOTICE_LABEL_CREDITS)
+ expect(trigger.className).not.toMatch(/emerald/)
+ })
+
+ it('sagt nichts, solange die Kontoabfrage nicht beantwortet ist', () => {
+ signIn(null)
+ render(createElement(FlashChatNotice))
+ expect(screen.queryByTestId('flash-chat-notice')).toBeNull()
+ })
+
+ it('sagt nichts fuer ein Modell ohne die Freimengenklasse, egal welcher Plan', () => {
+ const row = useModelStore.getState().models[0]
+ if (!('flash' in row)) throw new Error('Expected the flash model fixture')
+ useModelStore.setState({ models: [{ ...row, flash: undefined }] })
+ for (const plan of [true, false, null] as const) {
+ cleanup()
+ signIn(plan)
+ render(createElement(FlashChatNotice))
+ expect(screen.queryByTestId('flash-chat-notice')).toBeNull()
+ }
+ })
+})
+
+describe('das Popup, aus der Konstante, nicht getippt', () => {
+ it('nennt die Tagesmenge, die Rueckstellzeit und was danach passiert', () => {
+ render(createElement(FlashChatNotice))
+ openPopup()
+ const panel = screen.getByTestId('flash-chat-notice-panel')
+ expect(panel.textContent).toContain('50,000')
+ expect(panel.textContent).toContain('00:00 UTC')
+ expect(panel.textContent).toContain('uses credits instead')
+ expect(panel.textContent).toContain('8,192')
+ expect(panel.textContent).toContain('240 seconds')
+ })
+
+ it('liest fuer ein Konto ohne bezahlten Plan den ehrlichen Satz statt der Zusage', () => {
+ signIn(false)
+ render(createElement(FlashChatNotice))
+ openPopup()
+ expect(screen.getByTestId('flash-chat-notice-panel').textContent).toBe(FLASH_UNPAID_NOTICE)
+ })
+
+ it('schliesst per Escape', () => {
+ render(createElement(FlashChatNotice))
+ openPopup()
+ expect(screen.queryByTestId('flash-chat-notice-panel')).not.toBeNull()
+ fireEvent.keyDown(document, { key: 'Escape' })
+ expect(screen.queryByTestId('flash-chat-notice-panel')).toBeNull()
+ })
+
+ it('schliesst per X', () => {
+ render(createElement(FlashChatNotice))
+ openPopup()
+ fireEvent.click(screen.getByTestId('flash-chat-notice-close'))
+ expect(screen.queryByTestId('flash-chat-notice-panel')).toBeNull()
+ })
+
+ it('schliesst bei einem Klick ausserhalb', () => {
+ render(createElement(FlashChatNotice))
+ openPopup()
+ fireEvent.pointerDown(document.body)
+ expect(screen.queryByTestId('flash-chat-notice-panel')).toBeNull()
+ })
+})
+
+describe('Zeilen je Anfrage, aus den Antwortkoepfen', () => {
it('clears notices across focus changes and fences late responses', () => {
render(createElement(FlashChatNotice))
+ openPopup()
const generation = captureFlashGeneration()
const response = new Response('', { headers: { 'x-lu-chat-billing': 'credits', 'x-lu-flash-remaining': '0' } })
act(() => recordFlashResponse(policy.billingKey, response, generation))
@@ -43,39 +138,41 @@ describe('visible flash policy and billing', () => {
act(clearFlashNotices)
expect(screen.queryByRole('alert')).toBeNull()
})
- it('publishes the server-provided limits before a request', () => {
- render(createElement(FlashChatNotice))
- fireEvent.click(screen.getByText(/50,000 input and output tokens/))
- expect(screen.getByText(/API keys always use credits/).textContent).toContain('8,192')
- expect(screen.getByText(/API keys always use credits/).textContent).toContain('240 seconds')
- expect(screen.getByText(/API keys always use credits/).textContent).toContain('00:00 UTC')
- })
+
it('renders a persistent paid-fallback alert from response headers', () => {
render(createElement(FlashChatNotice))
+ openPopup()
act(() => recordFlashResponse(policy.billingKey, new Response('', { headers: {
'x-lu-chat-billing': 'credits', 'x-lu-flash-remaining': '0',
} })))
expect(screen.getByRole('alert').textContent).toContain('This request uses credits')
})
+
it('does not claim a failed credit check started generation', () => {
render(createElement(FlashChatNotice))
+ openPopup()
act(() => recordFlashResponse(policy.billingKey, new Response('', { status: 429, headers: {
'x-lu-chat-billing': 'credits', 'x-lu-flash-remaining': '0',
} })))
expect(screen.getByRole('alert').textContent).toContain('No generation started')
})
+
it('labels remaining tokens as a reservation, not final usage', () => {
render(createElement(FlashChatNotice))
+ openPopup()
act(() => recordFlashResponse(policy.billingKey, new Response('', { headers: {
'x-lu-chat-billing': 'flash', 'x-lu-flash-remaining': '12345',
} })))
expect(screen.getByRole('status').textContent).toContain('Remaining after reservation: 12,345')
})
+
it('does not show a notice for another endpoint or model', () => {
recordFlashResponse('other|model', new Response('', { headers: { 'x-lu-chat-billing': 'credits', 'x-lu-flash-remaining': '0' } }))
render(createElement(FlashChatNotice))
+ openPopup()
expect(screen.queryByRole('alert')).toBeNull()
})
+
it('offers no free usage claim when an old backend omits metadata', () => {
const row = useModelStore.getState().models[0]
if (!('flash' in row)) throw new Error('Expected the flash model fixture')
@@ -84,6 +181,7 @@ describe('visible flash policy and billing', () => {
expect(screen.queryByTestId('flash-chat-notice')).toBeNull()
expect(parseFlashPolicy(undefined, undefined, 'key')).toBeUndefined()
})
+
it('rejects malformed policy and billing metadata', () => {
expect(parseFlashPolicy({ ...wire, daily_tokens: -1 }, 'flash', 'key')).toBeUndefined()
expect(parseFlashPolicy({ ...wire, sessions_only: false }, 'flash', 'key')).toBeUndefined()
@@ -92,42 +190,3 @@ describe('visible flash policy and billing', () => {
expect(useFlashBillingStore.getState().entries).toEqual({})
})
})
-
-/**
- * R5-18: der stehende Satz versprach die Freimenge ohne jede Bedingung. T7 hat
- * am 11.09.2026 das Gegenteil gemessen: dieselbe Zusage wie beim Planbesitzer,
- * und ein Credit war weg. Drei Zustaende, drei Ausgaben, wie im Web.
- */
-describe('was der Satz ueber das Konto sagt', () => {
- it('reads one honest sentence on an account that pays for these models', () => {
- signIn(false)
- render(createElement(FlashChatNotice))
- expect(screen.getByTestId('flash-chat-notice').textContent).toBe(FLASH_UNPAID_NOTICE)
- expect(screen.queryByText(/50,000 input and output tokens/)).toBeNull()
- })
-
- it('says nothing at all while the account probe has not answered', () => {
- signIn(null)
- render(createElement(FlashChatNotice))
- expect(screen.queryByTestId('flash-chat-notice')).toBeNull()
- })
-
- it('keeps the full allowance text for a paid plan', () => {
- signIn(true)
- render(createElement(FlashChatNotice))
- expect(screen.getByText(/50,000 input and output tokens/)).toBeTruthy()
- expect(screen.queryByText(FLASH_UNPAID_NOTICE)).toBeNull()
- })
-
- it('stays silent for a model without the free class, whatever the plan', () => {
- const row = useModelStore.getState().models[0]
- if (!('flash' in row)) throw new Error('Expected the flash model fixture')
- useModelStore.setState({ models: [{ ...row, flash: undefined }] })
- for (const plan of [true, false, null] as const) {
- cleanup()
- signIn(plan)
- render(createElement(FlashChatNotice))
- expect(screen.queryByTestId('flash-chat-notice')).toBeNull()
- }
- })
-})
diff --git a/src/components/chat/__tests__/flash-hinweis-verschiebt-nichts.test.ts b/src/components/chat/__tests__/flash-hinweis-verschiebt-nichts.test.ts
new file mode 100644
index 00000000..2b115f18
--- /dev/null
+++ b/src/components/chat/__tests__/flash-hinweis-verschiebt-nichts.test.ts
@@ -0,0 +1,75 @@
+/**
+ * David, 19.09.2026: das Flash-Band stand dauerhaft ueber dem Eingabefeld und
+ * schob den Agent-Schalter, die Kontextanzeige und Memories nach oben. Der
+ * Hinweis ist jetzt ein einzeiliges Etikett in der Sitzungsleiste, direkt
+ * neben `AgentModeToggle`, mit einem Popup ausserhalb des Layoutflusses, genau
+ * wie `SamplingControls` (der Sampling-Regler).
+ *
+ * Dieser Test liest Quelltext, nicht das gerenderte DOM, aus demselben Grund
+ * wie `zwei-baender-sind-eine-flaeche.test.ts`: die Behauptung ist eine
+ * Platzierung im Baum, nicht ein Pixelwert, und der Quelltext sagt sie direkt.
+ */
+import { readFileSync } from 'node:fs'
+import { resolve } from 'node:path'
+import { describe, it, expect } from 'vitest'
+
+const COMPONENTS = resolve(__dirname, '..', '..')
+const read = (rel: string) => readFileSync(resolve(COMPONENTS, rel), 'utf-8')
+
+const CHAT_INPUT = read('chat/ChatInput.tsx')
+const CHAT_VIEW = read('chat/ChatView.tsx')
+const CODEX_VIEW = read('chat/CodexView.tsx')
+const NOTICE = read('chat/FlashChatNotice.tsx')
+const SAMPLING = read('chat/SamplingControls.tsx')
+
+describe('kein Element des Flash-Hinweises oberhalb des Eingabefelds', () => {
+ it('ChatInput kennt FlashChatNotice nicht mehr', () => {
+ expect(CHAT_INPUT).not.toContain('FlashChatNotice')
+ })
+})
+
+describe('der Hinweis steht in der Sitzungsleiste, neben dem Agent-Schalter', () => {
+ const stripStart = CHAT_VIEW.indexOf('data-testid="chat-session-strip"')
+
+ it('die Leiste wurde gefunden', () => {
+ expect(stripStart).toBeGreaterThan(-1)
+ })
+
+ it('AgentModeToggle und FlashChatNotice stehen beide darin, FlashChatNotice direkt danach', () => {
+ const strip = CHAT_VIEW.slice(stripStart, stripStart + 1500)
+ const agent = strip.indexOf('<AgentModeToggle')
+ const notice = strip.indexOf('<FlashChatNotice')
+ const spacer = strip.indexOf('flex-1')
+ expect(agent).toBeGreaterThan(-1)
+ expect(notice).toBeGreaterThan(-1)
+ expect(spacer).toBeGreaterThan(-1)
+ expect(notice).toBeGreaterThan(agent)
+ expect(notice).toBeLessThan(spacer)
+ })
+
+ it('und in der Code-Symbolleiste, derselbe Baustein wie im Chat', () => {
+ expect(CODEX_VIEW).toContain('<FlashChatNotice')
+ })
+})
+
+describe('das Popup liegt ausserhalb des Layoutflusses, wie der Sampling-Regler', () => {
+ it('FlashChatNotice setzt position: absolute fuers Panel, dieselbe Bauart', () => {
+ expect(NOTICE).toMatch(/position:\s*'absolute'/)
+ expect(SAMPLING).toMatch(/position:\s*'absolute'/)
+ })
+
+ it('der Ausloeser ist eine einzeilige Zeile, kein Block mit eigener Hoehe', () => {
+ // Kein `mb-*` und kein `flex-col` am Wurzelelement: eine Marke, die selbst
+ // Rand oder Zeilenumbruch mitbringt, macht die Leiste hoeher.
+ const wurzel = NOTICE.slice(NOTICE.indexOf('return ('), NOTICE.indexOf('{open &&'))
+ expect(wurzel).not.toMatch(/\bmb-\d/)
+ expect(wurzel).not.toMatch(/flex-col/)
+ expect(wurzel).toMatch(/whitespace-nowrap/)
+ })
+
+ it('schliesst per Escape, X und Aussenklick, wie SamplingControls', () => {
+ expect(NOTICE).toMatch(/useDismissOnEscape\(open, close\)/)
+ expect(NOTICE).toContain('pointerdown')
+ expect(NOTICE).toContain('FLASH_NOTICE_CLOSE_LABEL')
+ })
+})