test(frontend): cover NewSessionDialog model degradation + invalidate sessions on resume
- Add NewSessionDialog.test.tsx covering §9 graceful degradation:
empty models -> free-text input; non-empty models -> dropdown; plus a
createSession body-keys assertion
- Normalize model entries to {value,label} so object-shaped models
({provider,id}) render correctly in the dropdown (was assuming strings)
- NavSessions: invalidate the ["sessions"] query after a successful
resumeSession so the list/status refreshes immediately
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -38,8 +38,18 @@ export function NewSessionDialog({ onCreated }: Props) {
|
||||
enabled: open,
|
||||
});
|
||||
|
||||
const modelList: string[] = Array.isArray(modelsData?.models)
|
||||
? (modelsData.models as string[])
|
||||
// Model entries may be plain strings or objects ({ id, provider, ... });
|
||||
// normalize to { value, label } so the dropdown renders either shape.
|
||||
const modelList: { value: string; label: string }[] = Array.isArray(
|
||||
modelsData?.models,
|
||||
)
|
||||
? modelsData.models.map((m) => {
|
||||
if (typeof m === "string") return { value: m, label: m };
|
||||
const o = m as { id?: string; provider?: string };
|
||||
const value = o.id ?? "";
|
||||
const label = o.provider ? `${o.provider}/${value}` : value;
|
||||
return { value, label };
|
||||
})
|
||||
: [];
|
||||
|
||||
// When workspace list loads, pre-select the first one if nothing chosen yet
|
||||
@@ -140,8 +150,8 @@ export function NewSessionDialog({ onCreated }: Props) {
|
||||
>
|
||||
<option value="">— default —</option>
|
||||
{modelList.map((m) => (
|
||||
<option key={m} value={m}>
|
||||
{m}
|
||||
<option key={m.value} value={m.value}>
|
||||
{m.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
|
||||
Reference in New Issue
Block a user