Wave-5 chunk B: three model slots, search-engine row, first-run setup flow
Chunk B (owner-designed, model-slots wave) on the merged engine surface (main 1d66a17): AGENT SECTION — SLOTS ONLY (owner ruling) - The six per-role model rows are GONE; three slot rows instead: Strong (Prober + Teacher), Cheap (five workhorse roles), Vision (visual maker + PDF reader), roster + resolved-default in every hint. - Slot dropdowns share the app's menu language over the FEDERATED catalog (/api/models = keyed providers only, fresh per call — saving a key in Keys immediately widens the picker); the vision slot filters to image-capable models (Model.input); the menu's highlight now matches provider+id (ids can collide across providers). - Slots write the new models section (PUT /api/settings/models) through the dialog's write seam; per-role overrides stay schema-only. - ModelMenuList rows read 'provider · id' — federation makes the provider bookkeeping-relevant. Usage stamps render provider-qualified (prettyModel(qualified): 'Glm 5.3 Flash · openrouter') in the stats bar's turn lines. SEARCH ENGINE (search wave: no default, owner) - A row in Tools: Tavily/Brave via the shared-menu look, Automatic = the pin removed (auto-activation). The live reason line comes from /api/search; no engine key at all grays the whole row + disables the trigger (a keyless choice would only block auto-activation). FIRST-RUN SETUP FLOW (owner design A: composer CTA + send interception) - Chats cannot start until all three slots are picked — no defaults for 33 providers (slotsConfigured: all three slot models required). - The graph view's new-session dock (home) shows a 'Set up your models' CTA while unconfigured; submitting a topic opens the SetupDialog WITH THE DRAFT PRESERVED; Save stores the models section and the queued message sends. Same interception on /chat/new sends. - STAGED BY DEPENDENCY (owner: keys first, models after): no keyed provider → stage 1 deep-links the settings dialog on Keys (open now takes a section); a saved key reopens at stage 2 on the next submit. - Stage 2: Strong → Cheap → Vision pickers (federated, vision-filtered, all three required). Closable without configuring — browsing stays possible; the gate is the send, not the dialog. Layered Esc: an open slot menu eats Esc before the dialog. - Two closure bugs caught live: onDone→start/send captured the stale pre-save 'configured' (the flow now forces the replayed send); menu-Esc used to close the whole dialog. Settings-dialog provider: open(section?) lands on a section (stage 1 deep-link). Tests: composeSlotModel/composeSearchEngine pure, slot SSR replacing role rows, slotsConfigured/setupStage first-run gates, provider-qualified prettyModel. Gates: typecheck, lint, 792/792, build.
This commit is contained in:
+49
-11
@@ -9,6 +9,8 @@ import { GraphContextControl, effectiveContextTokens } from "@/components/graph-
|
||||
import { useDefaultSettings } from "@/components/default-settings";
|
||||
import { PhaseChip } from "@/components/phase-divider";
|
||||
import { SidebarToggle } from "@/components/sidebar";
|
||||
import { SetupDialog } from "@/components/setup-dialog";
|
||||
import { useSettingsDialog } from "@/components/settings/settings-dialog.tsx";
|
||||
import { StatsBar } from "@/components/stats-bar";
|
||||
import type { ChatSettings } from "@/src/core";
|
||||
|
||||
@@ -148,7 +150,13 @@ export function DraftShell({
|
||||
);
|
||||
}
|
||||
|
||||
export function NewSession({ initialSettings }: { initialSettings: ChatSettings | null }) {
|
||||
export function NewSession({
|
||||
initialSettings,
|
||||
initialConfigured,
|
||||
}: {
|
||||
initialSettings: ChatSettings | null;
|
||||
initialConfigured: boolean;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [text, setText] = useState("");
|
||||
const [busy, setBusy] = useState(false);
|
||||
@@ -160,8 +168,22 @@ export function NewSession({ initialSettings }: { initialSettings: ChatSettings
|
||||
// hands the choice up; it still rides the session POST then PUT-on-create.
|
||||
const { settings, save: saveDraft } = useDefaultSettings(initialSettings);
|
||||
|
||||
const send = useCallback(() => {
|
||||
// First-run gate (model-slots wave, owner 2026-09-20): the send
|
||||
// INTERCEPTS into the setup flow while unconfigured — no defaults for
|
||||
// 33 providers, chats cannot start. The draft stays in the textarea;
|
||||
// Save completes and the send replays.
|
||||
const [configured, setConfigured] = useState(initialConfigured);
|
||||
const [setupOpen, setSetupOpen] = useState(false);
|
||||
const { open: openSettings } = useSettingsDialog();
|
||||
|
||||
const send = useCallback((force = false) => {
|
||||
if (!text.trim() || busy) return;
|
||||
// `force` is the onDone path — the captured `configured` is still
|
||||
// the pre-save value; the state update hasn't landed yet.
|
||||
if (!configured && !force) {
|
||||
setSetupOpen(true);
|
||||
return;
|
||||
}
|
||||
setBusy(true);
|
||||
void startDraftSession(text, settings, fetch)
|
||||
.then((target) => {
|
||||
@@ -169,16 +191,32 @@ export function NewSession({ initialSettings }: { initialSettings: ChatSettings
|
||||
else setBusy(false);
|
||||
})
|
||||
.catch(() => setBusy(false));
|
||||
}, [text, busy, settings, router]);
|
||||
}, [text, busy, settings, router, configured]);
|
||||
|
||||
return (
|
||||
<DraftShell
|
||||
busy={busy}
|
||||
text={text}
|
||||
onChange={setText}
|
||||
onSend={send}
|
||||
settings={settings}
|
||||
onSettingsSaved={saveDraft}
|
||||
/>
|
||||
<>
|
||||
<DraftShell
|
||||
busy={busy}
|
||||
text={text}
|
||||
onChange={setText}
|
||||
onSend={send}
|
||||
settings={settings}
|
||||
onSettingsSaved={saveDraft}
|
||||
/>
|
||||
{/* First-run setup: the send interception's landing surface. */}
|
||||
<SetupDialog
|
||||
open={setupOpen}
|
||||
onClose={() => setSetupOpen(false)}
|
||||
onDone={() => {
|
||||
setConfigured(true);
|
||||
setSetupOpen(false);
|
||||
send(true); // the queued draft sends
|
||||
}}
|
||||
onOpenKeys={() => {
|
||||
setSetupOpen(false);
|
||||
openSettings("keys");
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user