A local-first multi-agent app development platform, built on PenguinHarness
Draft example cards fill the composer instead of sending (#398)
Yaowei Zhengb6cf45aed2d5
diff --git a/changelog/unreleased/2026-08-21-draft-example-fill.md b/changelog/unreleased/2026-08-21-draft-example-fill.mdnew file mode 100644index 00000000..2e3c4afa--- /dev/null+++ b/changelog/unreleased/2026-08-21-draft-example-fill.md@@ -0,0 +1,19 @@+# Home-screen examples fill the composer instead of sending++- **Date:** 2026-08-21+- **Type:** feature+- **Scope:** `web`+- **PR:** [#398](https://github.com/Prism-Shadow/penguin-harness/pull/398)++[中文版](2026-08-21-draft-example-fill.zh.md)++Clicking an example on the new-chat screen used to create the Session and submit the canned prompt on the spot. It now fills the composer and stops: the prompt lands in the text body, the example's skills are preselected in the skills dropdown, and the user presses Send — which builds exactly the message the card used to submit by itself.++## Details++- The prompt goes into the textarea as plain text. The `[use_skills]` block is still assembled at send time, so the visible draft stays editable rather than showing a marker block.+- The example's skills are preselected only when the selected Agent has them installed, and they join whatever was already selected instead of replacing it.+- The prompt takes the text body outright: a typed-but-unsent draft is cleared first, so the box holds the example and nothing else, and clicking through several examples never stacks one canned prompt behind another. Skills are the exception and stay additive — the selection cannot tell an example's pin from a choice the user made, while the text body carries no such ambiguity.+- The composer takes focus with the caret at the top of the prompt and the textarea scrolled there — a long prompt no longer arrives showing only its last line.+- The per-card loading spinner is gone, along with the disabled states that only guarded submission. A row still waits for the Agent's installed skills, without which the skill preselect would silently drop the example's skills.+- Each row's tooltip gains a second line saying the click fills the composer, in both languages.diff --git a/changelog/unreleased/2026-08-21-draft-example-fill.zh.md b/changelog/unreleased/2026-08-21-draft-example-fill.zh.mdnew file mode 100644index 00000000..78a356cd--- /dev/null+++ b/changelog/unreleased/2026-08-21-draft-example-fill.zh.md@@ -0,0 +1,19 @@+# 首页示例改为填入输入框,不再直接发送++- **Date:** 2026-08-21+- **Type:** feature+- **Scope:** `web`+- **PR:** [#398](https://github.com/Prism-Shadow/penguin-harness/pull/398)++[English](2026-08-21-draft-example-fill.md)++在新对话页点击示例,原先会当场创建 Session 并提交预置提示词。现在点击只填入输入框:提示词进入正文,示例声明的 Skill 在技能下拉里被预选,再由用户自己点发送——发出的正是这张卡片过去自行提交的那条消息。++## 细节++- 提示词以纯文本进入输入框。`[use_skills]` 块仍在发送时组装,因此可见的草稿始终是可编辑的正文,而不是一段标记块。+- 示例的 Skill 只在当前 Agent 已安装时才预选,并且是叠加到已有选择上,而不是覆盖它。+- 提示词直接占据整个正文:已输入但未发送的草稿会先被清空,输入框里只剩这一段示例,连点多个示例也不会堆出两段预置提示词。Skill 是唯一的例外,仍为叠加——已选列表无法区分示例的预选与用户自己的选择,而正文没有这种歧义。+- 输入框获得焦点,光标停在提示词开头并滚动到顶部——长提示词不会再落在最后一行上。+- 卡片上的加载指示已移除,只为提交把关的禁用条件一并撤下。行仍会等待当前 Agent 的已安装 Skill 列表:没有它,技能预选会悄悄丢掉示例声明的 Skill。+- 每行的悬浮提示新增一行说明,点明点击是填入输入框,中英文同步。diff --git a/packages/web/src/features/chat/chat-input.tsx b/packages/web/src/features/chat/chat-input.tsxindex 341f83ae..8a400bc6 100644--- a/packages/web/src/features/chat/chat-input.tsx+++ b/packages/web/src/features/chat/chat-input.tsx@@ -51,7 +51,8 @@* wrapped the same way); the selection clears once sending succeeds. Quick-invoke pre-selects via* initialSkills (read once on mount; once the installed list is ready, names not in that list are* pruned); the slash menu also lists installed skills, and pressing Enter on `/<skill_name>`- * selects it.+ * selects it. The draft screen's example cards reach in through `controlRef` to fill the text+ * body and preselect their skills — a fill, never a send: the user presses Send.* While a Task is running the input stays enabled and the toolbar keeps ONE action button:* an empty composer shows Stop (abort), and typing turns that same button into Send, which* follows the remembered mid-run send mode — steer (delivered between turns as a@@ -64,7 +65,15 @@* Renders only the card body itself: outer positioning such as bottom-docking or vertical* centering is decided by the page.*/-import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";+import {+ useCallback,+ useEffect,+ useImperativeHandle,+ useLayoutEffect,+ useMemo,+ useRef,+ useState,+} from "react";import type { ChangeEvent, ClipboardEvent, KeyboardEvent, ReactNode, RefObject } from "react";import type {AgentSummary,@@ -108,6 +117,7 @@ import {} from "./skill-use";import { GOAL_ICON, UNLIMITED_BUDGET, parseBudgetInput } from "./goal-use";import { mergeRecalledDraft } from "./recall-draft";+import { buildExampleFill } from "./example-fill";import {caretOnFirstLine,caretOnLastLine,@@ -852,6 +862,20 @@ function appendAttachmentParts(}}+/**+ * What a parent can ask of a mounted composer, handed over through ChatInput's `controlRef`.+ * One entry so far: the draft screen's example cards fill this composer instead of submitting+ * on their own.+ */+export interface ComposerControl {+ /**+ * Put an example's prompt in the text body and preselect the skills it pins — without+ * sending anything. `exampleSkills` is the example's full list; names the current Agent+ * has not installed are dropped here, where the installed list already lives.+ */+ fillExample: (prompt: string, exampleSkills: readonly string[]) => void;+}+export function ChatInput({status,onSend,@@ -899,6 +923,7 @@ export function ChatInput({onOpenModels,onRetryModelAuth,onNewSession,+ controlRef,}: {status: SessionStatus;/**@@ -1091,6 +1116,15 @@ export function ChatInput({onRetryModelAuth?: () => void;/** Navigates to a fresh draft (`/chat/new`); renders the notice's "New Session" button when supplied. */onNewSession?: () => void;+ /**+ * Handle for the one thing a parent reaches in and does: the draft screen's example cards+ * fill this composer (see ComposerControl). A ref rather than a `fill` prop because it is a+ * one-shot action, not state — the same example clicked twice has to land twice, which a+ * prop can only express by carrying a nonce. Lifting the body text and the skill selection+ * out of here instead would drag every other writer of them (slash commands, the recall+ * restore, ↑/↓ history, the post-send clear) out with them.+ */+ controlRef?: RefObject<ComposerControl | null>;}) {const { locale } = useLocale();// Admin-settable, delivered on /api/me: the pre-flight checks below and the numbers in their@@ -1408,6 +1442,45 @@ export function ChatInput({[selectedSkills, onSkillsChange],);+ /**+ * Fill from a draft-screen example card, without sending (see ComposerControl): the prompt+ * REPLACES the text body — any draft is cleared first — and the example's installed skills+ * join the selection, so pressing Send builds exactly the `[use_skills]` message the card+ * used to submit on its own. Why text replaces while skills merge is buildExampleFill.+ */+ const fillExample = useCallback(+ (prompt: string, exampleSkills: readonly string[]) => {+ const fill = buildExampleFill({+ prompt,+ exampleSkills,+ installedSkills: skills.map((s) => s.name),+ selectedSkills,+ });+ setText(fill.text);+ onTextChange?.(fill.text);+ setCaret(0);+ // The merge only ever appends, so an unchanged length means an unchanged selection —+ // and calling back for nothing would rewrite the cached draft on every repeat click.+ if (fill.skills.length !== selectedSkills.length) {+ setSelectedSkills(fill.skills);+ onSkillsChange?.(fill.skills);+ }+ // After the commit: the textarea is controlled, so the value and its new height only+ // exist once React has rendered them (same rAF convention as applyRecalled/applyHistory).+ requestAnimationFrame(() => {+ const el = textareaRef.current;+ if (!el) return;+ el.focus();+ // The prompt owns the box, so its first line is the top of it — a long prompt showing+ // only its last line reads as broken.+ el.setSelectionRange(0, 0);+ el.scrollTop = 0;+ });+ },+ [skills, selectedSkills, onTextChange, onSkillsChange],+ );+ useImperativeHandle(controlRef, () => ({ fillExample }), [fillExample]);+/** The slash token currently under the caret (kept in a ref so command run() closures always remove the live token). */const slashMatchRef = useRef<ReturnType<typeof matchSlash>>(null);const commands = useMemo<SlashCommand[]>(() => {diff --git a/packages/web/src/features/chat/draft-view.tsx b/packages/web/src/features/chat/draft-view.tsxindex 8bb8e11c..318b3f30 100644--- a/packages/web/src/features/chat/draft-view.tsx+++ b/packages/web/src/features/chat/draft-view.tsx@@ -62,11 +62,11 @@ import { PenguinLogo } from "../../components/ui/penguin-logo";import { toastError } from "../../components/ui/toast";import { useVersionInfo } from "../../lib/use-version-info";import { ChatInput } from "./chat-input";+import type { ComposerControl } from "./chat-input";import { adoptDockScope } from "../dock/dock-state";import { setDockCwd } from "../dock/dock-terminal";-import { buildSkillsMessage } from "./skill-use";import { EXAMPLE_FOLDERS } from "./example-tasks";-import type { ExampleFolderId, ExampleTask, ExampleTaskId } from "./example-tasks";+import type { ExampleFolderId, ExampleTask } from "./example-tasks";import { clearDraft, draftKey, loadDraft, saveDraft } from "./draft-cache";import type { DraftCache } from "./draft-cache";import {@@ -604,27 +604,19 @@ export function DraftView({setApprovalMode(mode);}, []);- // One in-flight guard shared by both send entry points (composer send / example task): a- // second submission while one is running would create a second Session with- // its own first task and a racing navigation. The ref is the synchronous guard; the state- // drives disabled styling on the example button (the composer has its own busy state).+ // Synchronous in-flight guard for the one send entry point (the composer): a second+ // submission while one is running would create a second Session with its own first task and+ // a racing navigation. A ref rather than state — the composer disables its own send button+ // off its `busy` state, and nothing else on this page renders differently mid-send.const sendingRef = useRef(false);- const [sending, setSending] = useState(false);// First message sent: only now is the Session created (Agent / Workspace / Model / approval// mode are all locked in together), then the route jumps once sent; returns false on any- // failure, so the input area keeps the draft and can resend. `keepDraft` is set by sends- // that did not consume the composer text (the example task), so a typed-but-unsent draft- // survives the navigation instead of being silently discarded.+ // failure, so the input area keeps the draft and can resend.const onSend = useCallback(- async (- input: TaskInputPart[],- keepDraft = false,- goal: { budget: number } | null = null,- ): Promise<boolean> => {+ async (input: TaskInputPart[], goal: { budget: number } | null = null): Promise<boolean> => {if (!agentId || sendingRef.current) return false;sendingRef.current = true;- setSending(true);let createdId: string | null = null;try {const body: SessionCreateRequest = { approvalMode };@@ -643,7 +635,7 @@ export function DraftView({// also carries the post-self-heal id, matching where we navigate.const fresh = await api.getSession(res.sessionId).catch(() => null);add(fresh?.session ?? created.session);- if (!keepDraft) discardDraft();+ discardDraft();// The draft now has an id of its own, so its docks move with it: anything left// behind under the draft's scope would surface in the NEXT new conversation// instead (dock-state.ts).@@ -659,33 +651,25 @@ export function DraftView({return false;} finally {sendingRef.current = false;- setSending(false);}},[projectId, agentId, approvalMode, modelRef, workspace, add, discardDraft, navigate],);- // Example tasks: one click submits the canned prompt exactly like a hand-typed send (the- // busy id drives the clicked card's spinner; the shared in-flight guard and all failure- // handling live in onSend). keepDraft: an example never consumes the composer text, so a- // typed-but-unsent draft must survive. The selected model / Workspace / approval mode apply as-is.- const [exampleBusy, setExampleBusy] = useState<ExampleTaskId | null>(null);- const runExample = useCallback(- async (task: ExampleTask) => {- if (exampleBusy !== null) return;- setExampleBusy(task.id);- try {- const names = task.skills.filter((n) => agentSkills.some((s) => s.name === n));- await onSend(- [{ type: "text", text: buildSkillsMessage(names, S.chat.exampleTasks[task.id].prompt) }],- true,- );- } finally {- setExampleBusy(null);- }- },- [exampleBusy, agentSkills, onSend],- );+ /**+ * Example tasks: a click FILLS the composer — the prompt into the text body, the example's+ * skills into the skills dropdown — and sends nothing. The user reads what landed, edits it+ * if they want, and presses Send, which then builds the very message this card used to+ * submit by itself (the `[use_skills]` block is the send path's job, so the textarea never+ * shows a marker block). Filling is instant and local: there is no busy state and no+ * in-flight guard to keep here, and everything else — where the prompt goes when text is+ * already typed, focus, the caret — is the composer's, reached through this handle.+ */+ const composerRef = useRef<ComposerControl | null>(null);+ const fillExample = useCallback((task: ExampleTask) => {+ // S is a live binding swapped on locale change: read the prompt at click time, not at render.+ composerRef.current?.fillExample(S.chat.exampleTasks[task.id].prompt, task.skills);+ }, []);/*** The open example folder — bookmark-style, and ALWAYS exactly one: selecting another closes@@ -734,7 +718,8 @@ export function DraftView({<ChatInputstatus="idle"- onSend={(input, goal) => onSend(input, false, goal)}+ controlRef={composerRef}+ onSend={onSend}onStop={async () => undefined}onCompact={async () => undefined}modelRef={modelRef}@@ -765,16 +750,17 @@ export function DraftView({<WorkspaceSelect projectId={projectId} workspace={workspace} onChange={changeWorkspace} /></div>- {/* Example tasks: one-click canned builds showing off the one-sentence → app flow.+ {/* Example tasks: canned builds showing off the one-sentence → app flow; a click fills+ the composer with the prompt and the user sends it (see fillExample).Bookmark-style folders with ALWAYS exactly one open — selecting another closes theprevious, and the open one cannot be collapsed. The block is therefore threefolder rows plus one folder's rows, with the folders kept within one row of eachother (3–4 examples each), so switching folders moves what sits below by at mostone row and no scroll container is needed — a scrollbar inside a seven-lineshowcase reads as a defect. Each example is a single-line title; its one-sentence- description rides in the row tooltip rather than a second line. Rows are disabled- until agents/models/skills are resolved (onSend would silently no-op without an- Agent). */}+ description rides in the row tooltip rather than a second line. Rows stay disabled+ until the Agent's installed skills are known — that is all a fill still waits for,+ and without it the preselect would silently drop the example's skills. */}<div className="mt-6 space-y-1">{EXAMPLE_FOLDERS.map((folder) => {const open = folder.id === openFolder;@@ -825,23 +811,12 @@ export function DraftView({<li key={task.id}><buttontype="button"- title={copy.desc}- disabled={- exampleBusy !== null ||- sending ||- !skillsLoaded ||- !agentId ||- !models- }- onClick={() => void runExample(task)}+ title={`${copy.desc}\n${S.chat.exampleFillHint}`}+ disabled={!skillsLoaded}+ onClick={() => fillExample(task)}className="flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-gray-600 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-900 disabled:cursor-default disabled:opacity-60 disabled:hover:bg-transparent dark:text-gray-400 dark:hover:bg-gray-800/70 dark:hover:text-gray-200"><span className="min-w-0 flex-1 truncate">{copy.label}</span>- {exampleBusy === task.id && (- <span className="shrink-0 text-xs text-gray-400">- {S.common.loading}- </span>- )}</button></li>);diff --git a/packages/web/src/features/chat/example-fill.ts b/packages/web/src/features/chat/example-fill.tsnew file mode 100644index 00000000..cd9908bd--- /dev/null+++ b/packages/web/src/features/chat/example-fill.ts@@ -0,0 +1,47 @@+/**+ * How a clicked draft-screen example lands in the composer.+ *+ * The click FILLS the composer and sends nothing — the user reads what arrived and presses+ * Send. Two decisions whose reasons are invisible at the call site live here beside them+ * (same split as recall-draft.ts):+ *+ * - **The example takes the whole text body.** Whatever was typed is cleared first, so the+ * box holds the prompt and nothing else. Appending behind a draft was tried and reverted:+ * it left the user to find and delete the leftover half themselves, and browsing the list+ * stacked one canned prompt behind another. A click asks for *this* prompt, so that is+ * what the box gets, and the caret parks at the top of it — a long prompt scrolled to its+ * last line reads as broken.+ * - **The example's skills join the selection instead of replacing it**, and only those the+ * selected Agent actually has installed. The composer wraps the selection into a+ * `[use_skills]` block at send time, so pressing Send produces exactly the message this card+ * used to submit by itself; an uninstalled name would pin a Skill that isn't there, and+ * dropping the existing selection would throw away a pick the user had already made. The+ * selection is additive where the text is not, because it cannot tell an earlier example's+ * pin from the user's own choice — text has no such ambiguity.+ *+ * The prompt itself goes in verbatim. Building the `[use_skills]` block here instead would put+ * a marker block in the textarea, which is not something a user can sensibly edit — and the+ * send path would wrap it a second time.+ */+export interface ExampleFill {+ /** The composer's new body text: the example's prompt, alone. */+ text: string;+ /** The new skill selection: what was already selected, plus the example's installed skills. */+ skills: string[];+}++export function buildExampleFill(args: {+ /** The example's prompt, read from the active dictionary. */+ prompt: string;+ /** Skill names the example pins. */+ exampleSkills: readonly string[];+ /** Skill names installed on the selected Agent. */+ installedSkills: readonly string[];+ /** Skill names currently selected in the composer. */+ selectedSkills: readonly string[];+}): ExampleFill {+ const added = args.exampleSkills.filter(+ (name) => args.installedSkills.includes(name) && !args.selectedSkills.includes(name),+ );+ return { text: args.prompt, skills: [...args.selectedSkills, ...added] };+}diff --git a/packages/web/src/features/chat/example-tasks.ts b/packages/web/src/features/chat/example-tasks.tsindex c372acc2..e2924623 100644--- a/packages/web/src/features/chat/example-tasks.ts+++ b/packages/web/src/features/chat/example-tasks.ts@@ -13,8 +13,8 @@** Copy and prompts live in the active locale dictionary at `S.chat.exampleFolders[id]` and* `S.chat.exampleTasks[id]`, which is also where the rule for how long a prompt may get is- * stated. Skills listed here are pinned only when the selected Agent has them installed; an- * empty list sends the prompt unchanged.+ * stated. Skills listed here are preselected in the composer only when the selected Agent has+ * them installed; an empty list fills the prompt alone.*/export const EXAMPLE_FOLDERS = [{diff --git a/packages/web/src/lib/strings-en.ts b/packages/web/src/lib/strings-en.tsindex 2fcdb6a5..73de2298 100644--- a/packages/web/src/lib/strings-en.ts+++ b/packages/web/src/lib/strings-en.ts@@ -1166,6 +1166,8 @@ export const en: Strings = {agents: "Build and optimize agents",schedules: "Create scheduled tasks",},+ /** Second tooltip line on an example row: the click fills the composer, it does not send. */+ exampleFillHint: "Click to fill the composer — edit it if you like, then send",exampleTasks: {game: {label: "2D penguin sled game",diff --git a/packages/web/src/lib/strings.ts b/packages/web/src/lib/strings.tsindex 1ac3015c..d207fdf9 100644--- a/packages/web/src/lib/strings.ts+++ b/packages/web/src/lib/strings.ts@@ -1128,13 +1128,15 @@ export const zh = {agents: "搭建和优化智能体",schedules: "创建定时任务",},+ /** Second tooltip line on an example row: the click fills the composer, it does not send. */+ exampleFillHint: "点击填入输入框,可修改后自行发送",/**- * Example task cards on the draft screen: one click loads the canned prompt for the user.- * Keep a prompt SHORT — a short paragraph, around 100 Chinese characters, carrying what to- * build plus the constraints the result would be wrong without. File layouts, field lists,- * step-by-step headings and self-test instructions are what the Agent works out or asks- * about, so they stay out; the older briefs below are still far longer and are being trimmed- * to match.+ * Example task cards on the draft screen: one click fills the composer with the canned+ * prompt, which the user reads, edits and sends. That is why a prompt is SHORT — a short+ * paragraph, around 100 Chinese characters, carrying what to build plus the constraints the+ * result would be wrong without. File layouts, field lists, step-by-step headings and+ * self-test instructions are what the Agent works out or asks about, so they stay out; the+ * older briefs below are still far longer and are being trimmed to match.*/exampleTasks: {game: {diff --git a/packages/web/test/example-fill.test.ts b/packages/web/test/example-fill.test.tsnew file mode 100644index 00000000..738ae96a--- /dev/null+++ b/packages/web/test/example-fill.test.ts@@ -0,0 +1,166 @@+/**+ * Clicking a draft-screen example FILLS the composer and sends nothing.+ *+ * Two halves. buildExampleFill decides what the composer becomes — the plain prompt (never a+ * `[use_skills]` block, which the send path builds and a user cannot sensibly edit), taking the+ * text body outright so a typed draft is cleared rather than appended to, with the example's+ * installed skills joining the selection so that pressing Send produces exactly the message the+ * card used to submit itself.+ * And the click path in draft-view.tsx, checked with the TypeScript parser the way+ * test/command-policy-add-rule.test.ts checks JSX structure: a regex cannot tell which handler+ * an onClick names, and "the card no longer submits" is precisely a claim about that handler.+ */+import { describe, expect, it } from "vitest";+import { readFileSync } from "node:fs";+import { fileURLToPath } from "node:url";+import ts from "typescript";+import { buildExampleFill } from "../src/features/chat/example-fill";+import { buildSkillsMessage } from "../src/features/chat/skill-use";+import { zh } from "../src/lib/strings";++const PROMPT = "Build a cute penguin sledding game.";++const fill = (over: Partial<Parameters<typeof buildExampleFill>[0]> = {}) =>+ buildExampleFill({+ prompt: PROMPT,+ exampleSkills: [],+ installedSkills: [],+ selectedSkills: [],+ ...over,+ });++describe("buildExampleFill — what lands in the text body", () => {+ it("puts the plain prompt in an empty composer", () => {+ expect(fill().text).toBe(PROMPT);+ });++ it("never writes the [use_skills] block into the textarea", () => {+ // The composer wraps the selection at send time; wrapping here would both double it up and+ // leave a marker block in a box the user is meant to edit.+ const f = fill({ exampleSkills: ["web-design"], installedSkills: ["web-design"] });+ expect(f.text).toBe(PROMPT);+ expect(f.text).not.toContain("use_skills");+ expect(f.text).not.toBe(buildSkillsMessage(["web-design"], PROMPT));+ });++ it("clears a typed draft rather than appending behind it", () => {+ // A click asks for THIS prompt; leaving the old text in front made the user find and+ // delete the leftover half themselves.+ expect(fill({ prompt: PROMPT }).text).toBe(PROMPT);+ });++ it("leaves nothing of a previous example behind when a second one is clicked", () => {+ // Browsing the list must not stack one canned prompt behind another.+ const second = fill({ prompt: "Other prompt." });+ expect(second.text).toBe("Other prompt.");+ expect(second.text).not.toContain(PROMPT);+ });++ it("carries the dictionary prompt through verbatim, newlines and all", () => {+ const prompt = zh.chat.exampleTasks.gamecenter.prompt;+ expect(fill({ prompt }).text).toBe(prompt);+ });+});++describe("buildExampleFill — what lands in the skills dropdown", () => {+ it("preselects the example's skills", () => {+ expect(fill({ exampleSkills: ["web-design"], installedSkills: ["web-design"] }).skills).toEqual(+ ["web-design"],+ );+ });++ it("drops skills the selected Agent has not installed", () => {+ // Pinning a Skill that isn't there is what the old auto-submit filtered out too.+ const f = fill({+ exampleSkills: ["penguin-sdk", "web-design"],+ installedSkills: ["web-design"],+ });+ expect(f.skills).toEqual(["web-design"]);+ });++ it("joins the existing selection instead of replacing it, without duplicating", () => {+ const f = fill({+ exampleSkills: ["penguin-sdk", "web-design"],+ installedSkills: ["penguin-sdk", "web-design", "memory"],+ selectedSkills: ["memory", "web-design"],+ });+ expect(f.skills).toEqual(["memory", "web-design", "penguin-sdk"]);+ });++ it("leaves the selection untouched for an example that pins nothing", () => {+ const selectedSkills = ["memory"];+ expect(fill({ selectedSkills, installedSkills: selectedSkills }).skills).toEqual(["memory"]);+ });+});++const SOURCE = fileURLToPath(new URL("../src/features/chat/draft-view.tsx", import.meta.url));+const source = ts.createSourceFile(+ SOURCE,+ readFileSync(SOURCE, "utf8"),+ ts.ScriptTarget.Latest,+ /* setParentNodes */ true,+ ts.ScriptKind.TSX,+);++/** Attribute text of the first JSX element carrying `marker` among its attributes. */+function attributes(marker: string): string | null {+ let found: string | null = null;+ const visit = (node: ts.Node): void => {+ if (found !== null) return;+ const tag = ts.isJsxSelfClosingElement(node)+ ? node+ : ts.isJsxElement(node)+ ? node.openingElement+ : null;+ if (tag) {+ const text = tag.attributes.getText(source);+ if (text.includes(marker)) {+ found = text;+ return;+ }+ }+ ts.forEachChild(node, visit);+ };+ visit(source);+ return found;+}++/** Body of a top-level-ish `const <name> = …` declaration (the click handler). */+function declaration(name: string): string | null {+ let found: string | null = null;+ const visit = (node: ts.Node): void => {+ if (found === null && ts.isVariableDeclaration(node) && node.name.getText(source) === name) {+ found = node.getText(source);+ }+ ts.forEachChild(node, visit);+ };+ visit(source);+ return found;+}++describe("the example row's click path", () => {+ it("routes the click to the fill handler", () => {+ const attrs = attributes("copy.desc");+ expect(attrs, "the example row button").not.toBeNull();+ expect(attrs).toContain("fillExample(task)");+ });++ it("cannot send: the handler neither posts a task nor creates a Session", () => {+ const handler = declaration("fillExample");+ expect(handler, "the fillExample handler").not.toBeNull();+ expect(handler).toContain("composerRef.current?.fillExample");+ expect(handler).not.toContain("onSend");+ expect(handler).not.toContain("api.");+ });++ it("hands the composer handle to ChatInput, or the click would land nowhere", () => {+ expect(attributes('status="idle"')).toContain("controlRef={composerRef}");+ });++ it("keeps no submit-time machinery on the rows", () => {+ const text = source.getFullText();+ // The spinner and the shared in-flight guard were the auto-submit's; filling is instant.+ expect(text).not.toContain("exampleBusy");+ expect(text).not.toContain("keepDraft");+ });+});