Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions apps/web/src/components/HomeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2779,10 +2779,10 @@ export function HomeView({
// route through the default design router; in Ask mode they stay plain
// chat conversations with no hidden router plugin.
const resolvedSkillId = submittedActive ? null : activeSkill?.id ?? null;
const routedPluginId =
sessionMode === 'design'
? submittedActive?.record.id ?? DEFAULT_UNSELECTED_SCENARIO_PLUGIN_ID
: submittedActive?.record.id ?? null;
const routedPluginId = submittedActive?.record.id
?? (sessionMode === 'design' && !resolvedSkillId
? DEFAULT_UNSELECTED_SCENARIO_PLUGIN_ID
: null);
// The example-prompt override is a one-shot marker. Decide whether to
// send it now, but defer spending the marker until the create is
// accepted — a rejected attempt stays retryable and must resend it.
Expand Down
4 changes: 2 additions & 2 deletions apps/web/tests/components/HomeView.context-picker.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ describe('HomeView context picker', () => {

expect(onSubmit).toHaveBeenCalledWith(expect.objectContaining({
prompt: '@Prototype Lab',
pluginId: DEFAULT_UNSELECTED_SCENARIO_PLUGIN_ID,
pluginId: null,
skillId: SKILL.id,
projectKind: 'prototype',
}));
Expand Down Expand Up @@ -480,7 +480,7 @@ describe('HomeView context picker', () => {
fireEvent.click(screen.getByTestId('home-hero-submit'));

expect(onSubmit).toHaveBeenCalledWith(expect.objectContaining({
pluginId: DEFAULT_UNSELECTED_SCENARIO_PLUGIN_ID,
pluginId: null,
skillId: DECK_SKILL.id,
projectKind: 'deck',
}));
Expand Down
55 changes: 55 additions & 0 deletions apps/web/tests/components/HomeView.prefill.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { act } from 'react';
import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react';
import { afterEach, describe, expect, it, vi } from 'vitest';
import type { SkillSummary } from '@open-design/contracts';

vi.mock('../../src/components/home-hero/PlaceholderCarousel', () => ({
PlaceholderCarousel: () => null,
Expand All @@ -25,6 +26,7 @@ import { requestHomeChip } from '../../src/runtime/home-intent';
import {
createPluginAuthoringHandoff,
createPluginUseHandoff,
createSkillUseHandoff,
PLUGIN_AUTHORING_DEFAULT_GOAL,
PLUGIN_AUTHORING_PROMPT,
} from '../../src/components/home-hero/plugin-authoring';
Expand Down Expand Up @@ -139,6 +141,21 @@ const HIDDEN_DEFAULT_PLUGIN = {
},
};

const INDUSTRIAL_PRODUCT_DESIGN_SKILL: SkillSummary = {
id: 'industrial-product-design',
name: 'Industrial Product Design',
description: 'Generate evidence-aware industrial product design directions.',
triggers: ['industrial design'],
mode: 'design-system',
previewType: 'markdown',
designSystemRequired: false,
defaultFor: [],
upstream: null,
hasBody: true,
examplePrompt: 'Develop three industrial design directions for an air purifier.',
aggregatesExamples: false,
};

// The Prototype chip binds to the bundled `example-web-prototype`
// plugin (which ships its own seed + layouts + checklist) instead of
// the generic od-new-generation router. Mirror that here so the
Expand Down Expand Up @@ -933,6 +950,44 @@ describe('HomeView prompt handoff', () => {
}));
});

it('submits an explicitly selected skill without the hidden default plugin', async () => {
const fetchMock = vi.fn<typeof fetch>(async (url) => {
if (typeof url === 'string' && url === '/api/plugins') {
return new Response(JSON.stringify({ plugins: [HIDDEN_DEFAULT_PLUGIN] }), {
status: 200,
headers: { 'content-type': 'application/json' },
});
}
throw new Error(`unexpected fetch ${url}`);
});
vi.stubGlobal('fetch', fetchMock);
const onSubmit = vi.fn();

render(
<HomeView
projects={[]}
skills={[INDUSTRIAL_PRODUCT_DESIGN_SKILL]}
onSubmit={onSubmit}
onOpenProject={() => undefined}
onViewAllProjects={() => undefined}
promptHandoff={createSkillUseHandoff(12, INDUSTRIAL_PRODUCT_DESIGN_SKILL)}
/>,
);

await waitFor(() => {
expect(screen.getByTestId('home-hero-active-skill').textContent)
.toContain('Industrial Product Design');
});
fireEvent.click(screen.getByTestId('home-hero-submit'));

expect(onSubmit).toHaveBeenCalledWith(expect.objectContaining({
prompt: 'Develop three industrial design directions for an air purifier.',
pluginId: null,
skillId: 'industrial-product-design',
appliedPluginSnapshotId: null,
}));
});

it('falls back to od-new-generation when od-plugin-authoring is not registered yet', async () => {
const fetchMock = vi.fn<typeof fetch>(async (url) => {
if (typeof url === 'string' && url === '/api/plugins') {
Expand Down
Loading