@agent-native/core 0.153.10 → 0.154.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/corpus/README.md +1 -1
  2. package/corpus/templates/analytics/AGENTS.md +20 -30
  3. package/corpus/templates/analytics/actions/search-dashboard-references.ts +58 -0
  4. package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +1 -1
  5. package/corpus/templates/analytics/app/lib/utils.ts +1 -1
  6. package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/ViewSqlPopover.tsx +1 -1
  7. package/corpus/templates/analytics/server/lib/agent-chat-plan-mode.ts +2 -0
  8. package/corpus/templates/analytics/server/lib/dashboards-store.ts +366 -3
  9. package/corpus/templates/analytics/server/lib/real-data-actions.ts +3 -1
  10. package/corpus/templates/analytics/server/plugins/agent-chat.ts +6 -2
  11. package/corpus/templates/calendar/app/components/calendar/EventDialog.tsx +1 -1
  12. package/corpus/templates/calendar/app/lib/utils.ts +1 -1
  13. package/corpus/templates/clips/app/components/recorder/recorder-engine.ts +32 -5
  14. package/corpus/templates/clips/app/components/sharing/share-ui.tsx +15 -15
  15. package/corpus/templates/clips/app/i18n/en-US.ts +3 -3
  16. package/corpus/templates/clips/app/lib/utils.ts +5 -6
  17. package/corpus/templates/clips/chrome-extension/src/offscreen.ts +43 -8
  18. package/corpus/templates/clips/desktop/src/app.tsx +26 -12
  19. package/corpus/templates/clips/desktop/src/lib/recorder.ts +23 -9
  20. package/corpus/templates/clips/desktop/src-tauri/src/native_screen/custom_capture.rs +261 -11
  21. package/corpus/templates/clips/desktop/src-tauri/src/native_screen.rs +21 -3
  22. package/corpus/templates/clips/shared/mic-audio-cleanup.ts +350 -0
  23. package/corpus/templates/content/app/i18n-data.ts +10 -10
  24. package/corpus/templates/content/scripts/check-native-deps.mjs +181 -15
  25. package/corpus/templates/design/.agents/skills/design-generation/SKILL.md +79 -7
  26. package/corpus/templates/design/.agents/skills/design-systems/SKILL.md +14 -2
  27. package/corpus/templates/design/.agents/skills/visual-edit/SKILL.md +2 -2
  28. package/corpus/templates/design/.generated/bridge/editor-chrome.generated.ts +35 -11
  29. package/corpus/templates/design/actions/get-design-system.ts +103 -3
  30. package/corpus/templates/design/actions/import-design-tokens.ts +37 -8
  31. package/corpus/templates/design/actions/import-github.ts +32 -138
  32. package/corpus/templates/design/actions/index-design-system-with-builder.ts +49 -16
  33. package/corpus/templates/design/actions/present-design-variants.ts +93 -4
  34. package/corpus/templates/design/actions/run-design-audit.ts +229 -0
  35. package/corpus/templates/design/actions/sync-design-system-with-builder.ts +64 -0
  36. package/corpus/templates/design/app/components/design/code-workbench/commands.ts +2 -2
  37. package/corpus/templates/design/app/components/design/inspector/DesignColorPicker.tsx +17 -4
  38. package/corpus/templates/design/app/components/design/inspector/GradientEditor.tsx +5 -1
  39. package/corpus/templates/design/app/components/design/inspector/ImageFillControls.tsx +5 -1
  40. package/corpus/templates/design/app/hooks/use-question-flow.ts +81 -5
  41. package/corpus/templates/design/app/i18n/en-US.ts +1 -1
  42. package/corpus/templates/design/app/i18n-data.ts +32 -1
  43. package/corpus/templates/design/app/i18n-keyboard-shortcuts.ts +10 -10
  44. package/corpus/templates/design/app/pages/DesignSystemSetup.tsx +83 -11
  45. package/corpus/templates/design/app/pages/DesignSystems.tsx +14 -0
  46. package/corpus/templates/design/app/pages/design-editor/generation-prompt-directives.ts +22 -0
  47. package/corpus/templates/design/changelog/2026-08-13-a-screen-that-would-render-behind-an-invisible-alpine-overla.md +6 -0
  48. package/corpus/templates/design/changelog/2026-08-13-attach-a-ui-screenshot-and-the-design-is-reproduced-not-rein.md +6 -0
  49. package/corpus/templates/design/changelog/2026-08-13-linking-a-design-system-means-you-never-get-generic-directio.md +6 -0
  50. package/corpus/templates/design/changelog/2026-08-13-the-design-audit-now-reports-when-a-screen-ignores-its-linke.md +6 -0
  51. package/corpus/templates/design/changelog/2026-08-13-the-design-system-preview-now-shows-how-many-named-tokens-we.md +6 -0
  52. package/corpus/templates/design/changelog/2026-08-13-your-design-system-prompt-and-reference-screenshots-now-reac.md +6 -0
  53. package/corpus/templates/design/server/lib/builder-design-system-proxy.ts +18 -2
  54. package/corpus/templates/design/shared/design-review.ts +1 -0
  55. package/corpus/templates/design/shared/html-integrity.ts +171 -0
  56. package/corpus/templates/mail/app/lib/utils.ts +1 -1
  57. package/corpus/templates/slides/.agents/skills/design-systems/SKILL.md +10 -6
  58. package/corpus/templates/slides/actions/index-design-system-with-builder.ts +41 -3
  59. package/corpus/templates/slides/actions/sync-design-system-with-builder.ts +64 -0
  60. package/corpus/templates/slides/app/components/deck/DeckCard.tsx +1 -1
  61. package/corpus/templates/slides/app/components/design-system/DesignSystemSetup.tsx +193 -20
  62. package/corpus/templates/slides/app/components/editor/EditorSidebar.tsx +58 -33
  63. package/corpus/templates/slides/app/components/editor/EditorToolbar.tsx +28 -41
  64. package/corpus/templates/slides/app/components/editor/ExportMenu.tsx +119 -91
  65. package/corpus/templates/slides/app/components/editor/ImageOverlay.tsx +16 -0
  66. package/corpus/templates/slides/app/components/editor/SlideEditor.tsx +158 -31
  67. package/corpus/templates/slides/app/components/editor/SlideOverflowWarning.tsx +30 -14
  68. package/corpus/templates/slides/app/components/editor/SpeakerNotesPanel.tsx +2 -2
  69. package/corpus/templates/slides/app/components/editor/canvas-interactions/slides-canvas-adapter.ts +4 -1
  70. package/corpus/templates/slides/app/components/editor/rich-text-selection.ts +14 -0
  71. package/corpus/templates/slides/app/components/editor/slide-text-targets.ts +24 -0
  72. package/corpus/templates/slides/app/global.css +24 -0
  73. package/corpus/templates/slides/app/hooks/use-navigation-state.ts +5 -1
  74. package/corpus/templates/slides/app/i18n/en-US.ts +19 -10
  75. package/corpus/templates/slides/app/lib/deck-filter.ts +47 -0
  76. package/corpus/templates/slides/app/lib/export-google-slides-client.ts +15 -4
  77. package/corpus/templates/slides/app/lib/export-pptx-client.ts +637 -1
  78. package/corpus/templates/slides/app/lib/image-download.ts +84 -0
  79. package/corpus/templates/slides/app/lib/utils.ts +1 -1
  80. package/corpus/templates/slides/app/pages/Index.tsx +25 -9
  81. package/corpus/templates/slides/netlify.toml +1 -0
  82. package/corpus/templates/slides/server/lib/builder-design-system-proxy.ts +14 -2
  83. package/dist/agent/production-agent.js +1 -1
  84. package/dist/brand-kit/types.d.ts +10 -2
  85. package/dist/cli/code.js +1 -1
  86. package/dist/cli/index.js +30 -1
  87. package/dist/cli/native-dependencies.d.ts +24 -0
  88. package/dist/cli/native-dependencies.js +264 -0
  89. package/dist/cli/plan-local.js +1 -1
  90. package/dist/cli/skills-content/design-visual-edit-skill.d.ts +1 -1
  91. package/dist/cli/skills-content/design-visual-edit-skill.js +2 -2
  92. package/dist/cli/visualize-repo.js +1 -1
  93. package/dist/client/FeedbackButton.js +12 -12
  94. package/dist/client/agent-chat-adapter.js +3 -4
  95. package/dist/client/assistant-ui-recovery.d.ts +1 -1
  96. package/dist/client/assistant-ui-recovery.js +4 -0
  97. package/dist/client/chat/message-components.d.ts +11 -3
  98. package/dist/client/chat/message-components.js +31 -5
  99. package/dist/client/chat/tool-call-display.d.ts +2 -1
  100. package/dist/client/chat/tool-call-display.js +33 -15
  101. package/dist/client/db-admin/SqlEditor.js +1 -1
  102. package/dist/client/dev-overlay/DevOverlay.js +2 -2
  103. package/dist/client/extensions/portable-extension.js +4 -0
  104. package/dist/client/guided-questions.d.ts +8 -0
  105. package/dist/client/guided-questions.js +12 -3
  106. package/dist/client/sharing/ShareButton.js +16 -24
  107. package/dist/client/sse-event-processor.js +35 -15
  108. package/dist/client/tool-display.d.ts +9 -0
  109. package/dist/client/tool-display.js +39 -0
  110. package/dist/client/vite-dev-recovery-script.js +1 -1
  111. package/dist/collab/awareness.d.ts +2 -2
  112. package/dist/collab/routes.d.ts +1 -1
  113. package/dist/collab/struct-routes.d.ts +1 -1
  114. package/dist/extensions/html-shell.js +5 -0
  115. package/dist/notifications/routes.d.ts +1 -1
  116. package/dist/observability/routes.d.ts +3 -3
  117. package/dist/resources/handlers.d.ts +1 -1
  118. package/dist/secrets/routes.d.ts +3 -3
  119. package/dist/server/agent-chat/prompt-resources.js +17 -16
  120. package/dist/server/agent-chat-plugin.d.ts +9 -0
  121. package/dist/server/agent-chat-plugin.js +29 -7
  122. package/dist/server/builder-design-systems.d.ts +33 -1
  123. package/dist/server/builder-design-systems.js +293 -11
  124. package/dist/server/design-token-utils.d.ts +11 -0
  125. package/dist/server/design-token-utils.js +68 -16
  126. package/dist/server/index.d.ts +1 -1
  127. package/dist/server/index.js +1 -1
  128. package/package.json +3 -3
@@ -1 +1 @@
1
- export declare const DESIGN_VISUAL_EDIT_SKILL_MD = "---\nname: visual-edit\ndescription: >-\n Open a running local app in Design overview mode as URL-backed iframe screens\n for visual editing, flow review, duplication, and route-state exploration.\n Use when the user asks to inspect, compare, or edit a real local app visually\n in Design.\nmetadata:\n visibility: exported\n---\n\n# Visual Edit\n\nUse `/visual-edit` when the user wants to inspect or edit a real local app\nvisually instead of generating standalone Alpine HTML. The source of truth is\nthe running localhost app plus its route URLs. Design shows those routes as\niframe-backed screens on the infinite canvas.\n\n## Installing this skill for an external MCP host\n\nThe hosted install path\n(`npx @agent-native/core@latest skills add visual-edit`, or `design` for the\nfull Design bundle) installs the exported instructions and registers the\nhosted Design MCP connector together. The open Skills CLI path\n(`npx skills@latest add BuilderIO/agent-native --skill visual-edit`) installs\nexported instructions only, with no MCP connector registration.\n\n## Put Design Beside The Chat\n\nPrefer the interactive MCP App returned by `open-visual-edit` when the coding\nhost renders it. The user gets the Design canvas beside the conversation, and\n**Apply design updates** can submit the bounded source-edit handoff back to the\ncurrent host conversation through the standard MCP Apps message bridge. The\nhost may ask the user to confirm the current conversation or choose a new one.\n\nOtherwise, `openUrl` is a credential-free, read-only fallback that is safe to\nshow in model text or retain in logs. Do not claim that fallback is editable:\nthe edit capability is intentionally available only to the host-managed MCP App\nlauncher, where it is hidden from the model and redeemed once.\n\n- In Codex Desktop, prefer the rendered MCP App. Use the in-app Browser for the\n credential-free `openUrl` only when a read-only fallback is acceptable.\n- In Claude Code Desktop's Code tab, prefer the rendered MCP App. Preview\n `openUrl` in the Browser pane only as the read-only fallback.\n- In VS Code, use the Agent Native Design webview/deep link described below.\n- Inline browser availability is host-dependent. CLI, remote, or restricted\n sessions may not expose one. If the inline surface is unavailable or disabled,\n return the normal **Open design** link instead of claiming it opened.\n\nPrefer the MCP App surface for a connected Design plugin, then the host's\nbrowser/preview tool as the universal fallback. Keep the canvas beside chat\nwhen the host supports rearrangeable panes.\n\nInside Design, use **Show/Hide UI** from the `Cmd+K` menu or press Figma's\n`Shift+\\` shortcut to toggle all editing chrome so only the canvas remains.\nThe same action is available from Design's empty-canvas context menu.\n\n## Core Model\n\n- Each screen is a URL-backed iframe, not copied HTML.\n- Each screen keeps URL metadata: `connectionId`, `routeId`, `path`,\n `url`, `bridgeUrl`, title, and viewport size.\n- Localhost Edit mode renders the running app through the local bridge as a live\n iframe with the same editor bridge used by HTML designs. It is never a frozen\n static DOM snapshot. Editing is direct DOM manipulation against that live\n document; the parallel `/snapshot` fetch feeds the editable source model only\n and must never be rendered in the frame.\n- **The `/visual-edit` skill needs no Design account sign-in.**\n `open-visual-edit` mints a five-minute, single-use capability for the exact\n `/visual-edit/:designId` local-editor route. The MCP host redeems it outside\n model-visible text, then opens the existing editor with localhost edit access.\n This capability is not an account session: `/_agent-native/session` remains\n signed out, and account-backed save/share/generate actions remain denied.\n- The skill enters through local `pnpm action open-visual-edit`. When that CLI\n has no account session, the action uses a stable, workspace-scoped local\n principal to register the bridge, create/reuse the local design, and place\n screens. That principal exists only inside the in-process CLI call; it is not\n a browser login and cannot be selected by an HTTP, MCP, or tunneled caller.\n- Public links are always read-only, including on loopback. Loopback peer\n identity is not an authentication boundary because a tunnel or reverse proxy\n can make a remote request appear local. A bare `/visual-edit/:designId` or\n `/design/:designId` URL carries no capability and must never release the\n connection's `previewToken`.\n- The live editor is same-origin through the local bridge proxy. This boots\n CSR apps and root-relative assets, but it is still a localhost editing proxy:\n app-origin cookies, WebSockets/HMR, SSE, and non-GET app API calls may need a\n future dev-server/plugin integration for perfect parity with the app's own\n origin.\n- **There are exactly two views.** The infinite canvas is where all editing\n happens, and the responsive interactive view (Interact) is where the app runs\n for real. There is no third \"full view\"/focused-edit state \u2014 clicking a screen\n in the Screens list, or the view toggle, opens the responsive view, and\n closing it returns to the canvas.\n- Interact keeps the left and right rails and adds a device bar above the canvas\n (device preset, editable width/height, zoom, close). It renders the app's\n normal URL so navigation, scrolling, links, and form controls behave as they\n would in the browser, and the wheel scrolls the app rather than panning the\n canvas. The canvas view is the opposite: the wheel pans and zooms it, and\n native interaction inside the frame is suppressed.\n- While a localhost screen has pending live visual edits, do not switch back to\n Interact until the user either applies the edits to source or explicitly\n aborts/discards the preview.\n- Alt-drag duplicates a screen. For localhost screens, duplication copies the\n iframe frame and URL metadata; change the copy's path/query for a new state.\n- Flow visualization is multiple URL states: `/checkout?step=shipping`,\n `/checkout?step=payment`, `/checkout?step=done`, etc.\n- When the user gives a named flow or numbered screen list, preserve that order\n and create one screen per URL/path. Shorthand like\n `localhost:1234/onboarding/1` means\n `http://localhost:1234/onboarding/1`.\n\n## Useful Canvas Sets\n\nTranslate the user's requested review into the smallest useful set of frames:\n\n- **Multi-step flow:** one ordered frame per route or query state, such as cart,\n shipping, payment, and confirmation.\n- **Multiple pages:** one frame per meaningful route, such as home, pricing,\n docs, and account settings.\n- **Responsive comparison:** repeat the same route at the requested desktop,\n tablet, and mobile viewports so they align in one row.\n- **State review:** repeat a route for meaningful URL-addressable states such as\n empty, loading, error, modal-open, or selected-item views.\n\nDo not expand every discovered route or every viewport unless the user asks for\nan exhaustive audit. Preserve the user's labels and sequence so the canvas reads\nlike the workflow they described.\n\n## Select And Reprompt\n\nWhen a chat message begins with `[Reprompt selection]`, the selected subtree is\na hard write boundary. The only mutation path is `propose-node-rewrite` with\nthe exact `repromptId`, target, and `baseVersionHash` captured in\n`design-reprompt-pending:<designId>:<fileId>`. Never use `apply-visual-edit`,\n`apply-source-edit`, `write-source`, `write-local-file`, `edit-design`, or any\nother content-writing action for that request. Clarifying questions are allowed,\nbut a requested change must remain a proposal.\n\nProduce one variant by default. Produce two or three only when the instruction\nasks for options. A retry includes `priorProposalId`; keep the same target and\nbase version, incorporate the feedback, and call `propose-node-rewrite` again.\nThe UI previews the returned subtree without persisting it.\n\nUse `resolve-node-rewrite` for the accept/reject lifecycle. Accept applies the\nchosen variant as one version-checked inline/Yjs content transaction so one\nundo restores the prior structure; reject clears the proposal without changing\ncontent. For conversational resolution such as \"apply the second one,\" call\n`view-screen`, read the active `design.reprompt.proposal`, and pass its\n`proposalId` plus the zero-based `variantIndex` to `resolve-node-rewrite`.\n\n## Review Quality\n\n- Treat the running app as the truth. Preserve its component language, tokens,\n route state, and real content unless the user explicitly asks for a new visual\n direction.\n- Use multiple URL states to reveal meaningful UX moments: empty/loading/error\n states, focused panels, modals, responsive breakpoints, and completed flow\n steps when those matter to the review.\n- For visual edits, compare before/after at the relevant viewport sizes and\n check key hover/focus/scroll states when the app exposes them.\n\n## Account And Sharing Model\n\n- `/visual-edit/:id` is the dedicated local-editor surface. The one-time\n handoff returned by `open-visual-edit` opens it with edit access without a\n Design login. A copied or bare `/visual-edit/:id` URL is read-only because it\n does not carry the capability.\n- The capability permits live iframe inspection and session-local edits,\n undo/redo, **Apply design updates** through the connected host/local agent,\n and **Copy prompt**. Those flows hand bounded source instructions back to the\n coding agent; they do not silently persist account-owned Design data.\n- Public `/design/:id` links stay read-only without a signed-in owner/editor\n session. Never use the local capability to upgrade that ordinary sharing\n surface.\n- Prefer links returned by Design actions or `/_agent-native/open` deep links.\n Do not surface URLs with `_session=` tokens or hand-build capability URLs.\n- Do not attempt account-backed write actions with the browser capability. The\n trusted local `open-visual-edit` CLI call may register its bridge, create or\n reuse its workspace-owned local design, and place screens without an account.\n Direct source-file action writes, generation, saving into an account, and\n sharing still require an authenticated action caller. If a signed-out visitor\n wants those durable account operations, send them through the framework\n sign-in return flow first.\n\n## Required Local Bridge\n\nThe live-edit bridge is unlocked by a shared secret (the \"bridge token\") that\nmust match on two sides: the local bridge process, and the user's connection row\nin Design (which the browser reads to authorize `/live-edit-bridge`,\n`/read-file`, `/write-file`). Get them to match by letting the\n`open-visual-edit` action mint the token, then starting the\nbridge with it. This is the only ordering that works for the remote-MCP flow \u2014\nthe bridge cannot push its own token to the server without a CLI auth token, so\nthe server mints instead and the bridge adopts.\n\nFrom the target app repo, make sure its dev server is running, then:\n\n**1. Discover routes without starting a durable bridge** (one-shot, exits):\n\n```bash\nnpx @agent-native/core@latest design connect --url http://localhost:5173 --root . --json\n```\n\nThis prints the manifest (routes + capabilities). Parse it to build\n`routeManifest` for the next step. (Skip this if the user already gave explicit\npaths/URLs to place.)\n\nInside the agent-native monorepo itself, use the workspace CLI instead of\n`npx` \u2014 `npx` installs the last published `@agent-native/core`, which will not\ncontain local changes and costs a slow install on every call:\n\n```bash\npnpm dev:cli design connect --url http://localhost:5173 --root templates/<app> --json\n```\n\n**2. Call `open-visual-edit`** (see Action Flow below) with NO `bridgeToken`.\nThe server mints one, stores it on the user's connection row, copies it into the\nplaced screens' metadata, and returns it to you as `bridgeToken`. Capture it.\n\n**3. Start the persistent bridge adopting that token** (single line; prefer the\nenv var so the secret does not appear in `ps`):\n\n```bash\nAGENT_NATIVE_BRIDGE_TOKEN=\"<bridgeToken from step 2>\" npx @agent-native/core@latest design connect --url http://localhost:5173 --root . --daemon\n```\n\n(Equivalently, pass `--bridge-token <token>`.) This starts a detached bridge on\n`http://127.0.0.1:7331`, adopts the server-minted token \u2014 so bridge and row\nagree and live-edit authorizes with no self-registration \u2014 and stays alive after\nthe command exits.\n\nFor a manual health/manifest check on the running bridge:\n\n```bash\ncurl http://127.0.0.1:7331/health\n```\n\n`/health` needs no token. The full manifest at `/manifest.json` is\npreview-token protected, so an unauthenticated `curl` of it returns\n`{\"ok\":false,\"error\":\"invalid or missing preview token\"}` \u2014 that response means\nthe bridge is up, not that it is broken.\n\nOnly use `--json` for the step-1 route probe. Never use `--json`, `--once`,\nor `--dry-run` for the durable step-3 bridge: they print the manifest and exit,\nso Design falls back to a non-editable live iframe.\n\nThe bridge listens on a single fixed port (7331) and refuses to start for a\nsecond, different app. It is detached with no log file, so if `--daemon` reports\na timeout, check for a stale process (`lsof -ti:7331`) before retrying.\n\n## Action Flow\n\nPrefer the single `open-visual-edit` action. It registers or\nrefreshes the localhost bridge connection, mints and stores the bridge token,\ncreates or reuses a Design project, places URL-backed screens, stores the active\nvisual-edit context, and navigates to overview mode in one call. This avoids\ncreating a private design under a synthetic CLI user and then handing the browser\na tokenized URL that may be shadowed by an existing session.\n\nCall it BEFORE starting the durable bridge (step 3 above): it does not contact\nthe bridge, so the bridge need not be running yet, and you need its returned\n`bridgeToken` to start the bridge with a matching secret. Omit `bridgeToken`\non the call so the server mints one.\n\n```bash\npnpm action open-visual-edit '{\n \"title\": \"Docs homepage visual edit\",\n \"devServerUrl\": \"http://localhost:5173\",\n \"bridgeUrl\": \"http://127.0.0.1:7331\",\n \"rootPath\": \"/absolute/path/to/app\",\n \"routeManifest\": { \"...\": \"from /manifest.json\" },\n \"paths\": [\"/\", \"/pricing\", \"/checkout?step=payment\"]\n}'\n```\n\nThe action returns `designId`, `connectionId`, `bridgeToken`, `screens`,\n`urlPath`, and a credential-free `openUrl`. Its MCP App metadata separately\ncarries the one-time editor launcher so the host can redeem it without showing\nthe capability to the model or retaining it in the action link. Keep\n`designId`/`connectionId` in the chat context for follow-ups, and pass\n`bridgeToken` to `design connect` (step 3) to start the bridge. On follow-up\ncalls reusing an existing `connectionId`, the same token is returned (it is\nminted once and reused), so the running bridge stays valid.\n\n### Desktop and mobile side by side\n\nPass `viewports` to place every requested route once per viewport. Frames lay\nout as a grid: one row per route, one column per viewport. Presets are\n`desktop` (1280x900), `laptop` (1440x900), `tablet` (834x1112), and `mobile`\n(390x844); an explicit `{ \"label\": \"...\", \"width\": N, \"height\": N }` also works.\n\n```bash\npnpm action open-visual-edit '{\n \"title\": \"Tasks responsive visual edit\",\n \"devServerUrl\": \"http://localhost:5173\",\n \"bridgeUrl\": \"http://127.0.0.1:7331\",\n \"rootPath\": \"/absolute/path/to/app\",\n \"paths\": [\"/tasks\", \"/inbox\"],\n \"viewports\": [\"desktop\", \"mobile\"]\n}'\n```\n\nPrefer this over two separate calls with `defaultWidth`/`defaultHeight`: it\nkeeps each route's viewports aligned in a row and titles them\n`Tasks \u2014 Desktop` / `Tasks \u2014 Mobile` so the canvas reads clearly. `viewports`\noverrides `defaultWidth`/`defaultHeight`. With no `routes`/`paths`, it expands\nevery route in the localhost manifest, which is usually far more frames than\nthe user wants \u2014 name the paths.\n\n### Adding more page frames later\n\nCall `open-visual-edit` again with the same `designId` and `connectionId` and\nonly the new paths. Existing frames for the same route and viewport are\nrefreshed in place rather than duplicated, and a frame the user has dragged or\nresized keeps its position unless you explicitly pass `x`/`y`/`width`/`height`.\n\n```bash\npnpm action open-visual-edit '{\n \"designId\": \"<existing-design-id>\",\n \"connectionId\": \"<existing-connection-id>\",\n \"devServerUrl\": \"http://localhost:5173\",\n \"paths\": [\"/settings\", \"/team\"],\n \"startY\": 2200\n}'\n```\n\nDo NOT add `defaultWidth`/`defaultHeight` just to restate the default size:\nsupplying either one marks the viewport as explicitly requested, which\noverwrites frame sizes the user has already adjusted on the canvas.\n\nFor a numbered flow the user describes in chat, keep the labels and order:\n\n```bash\npnpm action open-visual-edit '{\n \"designId\": \"<existing-design-id>\",\n \"connectionId\": \"<existing-connection-id>\",\n \"devServerUrl\": \"http://localhost:1234\",\n \"routes\": [\n { \"url\": \"localhost:1234/onboarding/1\", \"title\": \"Screen 1\" },\n { \"url\": \"localhost:1234/onboarding/2\", \"title\": \"Screen 2\" },\n { \"url\": \"localhost:1234/onboarding/3\", \"title\": \"Screen 3\" }\n ]\n}'\n```\n\nIf no `routes` or `paths` are supplied, `open-visual-edit` uses every route\nfrom the localhost manifest.\n\nFallback, only when `open-visual-edit` is unavailable:\n\n1. Register or refresh the bridge with `connect-localhost`, passing the\n `/manifest.json` result as `routeManifest` and `capabilities`.\n2. Create or reuse a Design project with `create-design`.\n3. Place URL-backed screens with `add-localhost-screens`.\n4. Navigate to overview mode with `navigate`.\n\n## Open The Design Surface\n\n- Use the `link`, `deepLink`, or MCP App embed returned by Design actions so\n the user sees the canvas. Follow **Put Design Beside The Chat**: prefer the\n MCP App; otherwise surface the credential-free **Open design** link.\n- Return or open the MCP App first. Its host-managed launcher carries the\n one-time local-editor capability. The credential-free `openUrl` / action link\n is the safe read-only fallback; never build a capability URL yourself.\n- Never return or open a hand-built `/design/:id?_session=...` URL.\n- If the user is working in VS Code, the Agent Native extension can open the\n same URL via\n `vscode://builder.agent-native/open?url=<encoded-design-url>`. Its\n `Agent Native: Open Design Canvas` command also starts the local bridge and\n opens hosted Design in the VS Code side panel.\n- After `open-visual-edit`, confirm the Design editor is in overview mode\n with the requested URL-backed frames visible, and that they render the app\n rather than a spinner. Do not stop at \"screens added\" when the user asked to\n inspect or edit visually.\n\n## Applying Visual Edits Back To Source\n\nCanvas edits on a localhost screen do not write source as you make them. They\naccumulate as pending edits and the editor shows an **Apply design updates**\nbutton on the canvas. In an MCP App, clicking it hands the bounded structured\nprompt to the current host coding conversation. In an ordinary browser or\nstandalone Design page, it falls back to the local Design agent. The dropdown's\n**Copy prompt to your agent** action is the universal manual fallback.\n\n- Style, text, and drag/drop structure edits all collect into the same pending\n batch, so the user can make several changes and apply once.\n- After the write lands, the target app's own dev-server HMR refreshes the\n frames \u2014 no manual reload. If frames do not refresh, the write did not land;\n say so rather than assuming.\n- The separate disk-icon \"Apply to source\" button is the deterministic\n whole-file HTML/CSS writer. It is intentionally disabled for compiled\n `.jsx`/`.tsx` routes \u2014 those must go through the agent path above.\n\n## Editing URLs\n\nKeep localhost screens as URL files plus `screenMetadata[fileId]`. Do not\nreplace them with copied `srcdoc` HTML unless the user explicitly asks for a\nfrozen snapshot. To change a state, rerun `open-visual-edit` with the new\npath/query or duplicate the screen and update the copy's URL metadata.\n\n## Local Files in the Code Tab\n\nOnce a connection is registered, the design editor's Code panel (left rail \u2192\nCode, or `navigate --view editor --designId <id> --leftPanel code`) shows a\nlocal-files workspace root for that connection next to the design's own files.\nTreat that root like VS Code opened at the connected project directory: file\ntree, search, open/edit, and save are backed by the real local files. It lists\nthe connected app's text/code files through the bridge\n(`list-local-files` / `read-local-file`); build output, `node_modules`,\n`.git`, and secret-looking paths (`.env*`, key files) are always excluded.\n\n- Browsing and reading need only editor access on the design plus the running\n bridge.\n- Saving goes through `write-local-file`: the first save opens the\n write-consent dialog (an 8-hour, folder-scoped grant) and retries\n automatically once granted. Only text/code files are writable; secret paths\n are always blocked.\n- If the agent calls `write-local-file` directly (not through a UI save) and it\n fails with \"no write-consent grant\", call `request-localhost-write-consent`.\n It opens the write-consent dialog in the editor, or reports `alreadyGranted`\n if one already exists. Granting is human-only \u2014\n `grant-localhost-write-consent` is hidden from agents, so you cannot approve\n it yourself. Tell the user to click \"Allow writes\", then retry\n `write-local-file` once. Do not keep retrying blindly: the write stays\n blocked until the user approves.\n- Saves are conflict-checked against the file's on-disk version \u2014 a file that\n changed since it was read fails with a version conflict instead of being\n overwritten.\n\n## React Source Writeback\n\n- Use compiler/debug provenance (project-relative file, line, column,\n component, and runtime multiplicity) to locate React/TSX source. Treat it as\n evidence, not as permission for a generic AST structural transform.\n- Read `positionPrecision` on every anchor before you trust `line`/`column`.\n `authored` means those are the real JSX coordinates. `transformed` means they\n are the dev server's own output coordinates \u2014 React 19 removed `_debugSource`\n and exposes only an owner stack, so this is the normal case on a Vite/Next\n dev server, and the line will not match the file. `unknown` means no tier was\n reported. On anything but `authored`, use the file and component to find the\n element by its JSX shape and re-derive the line from the file you read; never\n edit at the reported line.\n- A single-instance leaf text edit, literal `className`/`class` edit, or flat\n literal `style={{ ... }}` property may use `apply-visual-edit` with a\n `local-file` source and a complete `target.sourceAnchor`. Forward the\n anchor's `positionPrecision` with it \u2014 the action refuses a `transformed`\n anchor with `status: \"needsAgent\"` instead of seeking to a line that means\n something else in the authored file. Preview first (omit `persist`), inspect\n `proposedDiff`, then call with `persist: true`.\n- Reparenting, grouping/ungrouping, wrappers, dynamic expressions, repeated\n `.map()` instances, shared components, breakpoint-scoped edits, and\n cross-file changes go through the coding agent with complete subject/target\n anchors and their runtime relationship. `apply-visual-edit` refuses these\n with `status: \"needsAgent\"` rather than guessing.\n- Before each write, read the file and pass its exact `versionHash` to\n `write-local-file` with `requireExpectedVersionHash: true`; on conflict,\n re-read and re-plan. Keep the optimistic preview until HMR/runtime confirms\n the result. Human write consent remains mandatory and agents cannot grant it.\n\n## Verification\n\n- `list-localhost-connections` returns the expected connection and routes.\n- The Design editor opens in overview mode.\n- Every requested screen renders the intended localhost URL, showing real app\n content rather than an endless loading spinner.\n- The screen iframe carries a `src`, not a `srcdoc`. A localhost screen with a\n `srcdoc` is a bug, not a slow load \u2014 check it in the browser devtools before\n reporting the canvas as working.\n- Alt-dragging a screen copies the URL-backed frame, not an inline HTML clone.\n- A query/path edit changes only the target screen's URL metadata and iframe.\n- The Code tab shows a local-files root for the connection and opens its files.\n";
1
+ export declare const DESIGN_VISUAL_EDIT_SKILL_MD = "---\nname: visual-edit\ndescription: >-\n Open a running local app in Design overview mode as URL-backed iframe screens\n for visual editing, flow review, duplication, and route-state exploration.\n Use when the user asks to inspect, compare, or edit a real local app visually\n in Design.\nmetadata:\n visibility: exported\n---\n\n# Visual Edit\n\nUse `/visual-edit` when the user wants to inspect or edit a real local app\nvisually instead of generating standalone Alpine HTML. The source of truth is\nthe running localhost app plus its route URLs. Design shows those routes as\niframe-backed screens on the infinite canvas.\n\n## Installing this skill for an external MCP host\n\nThe hosted install path\n(`npx @agent-native/core@latest skills add visual-edit`, or `design` for the\nfull Design bundle) installs the exported instructions and registers the\nhosted Design MCP connector together. The open Skills CLI path\n(`npx skills@latest add BuilderIO/agent-native --skill visual-edit`) installs\nexported instructions only, with no MCP connector registration.\n\n## Put Design Beside The Chat\n\nPrefer the interactive MCP App returned by `open-visual-edit` when the coding\nhost renders it. The user gets the Design canvas beside the conversation, and\n**Apply design updates** can submit the bounded source-edit handoff back to the\ncurrent host conversation through the standard MCP Apps message bridge. The\nhost may ask the user to confirm the current conversation or choose a new one.\n\nOtherwise, `openUrl` is a credential-free, read-only fallback that is safe to\nshow in model text or retain in logs. Do not claim that fallback is editable:\nthe edit capability is intentionally available only to the host-managed MCP App\nlauncher, where it is hidden from the model and redeemed once.\n\n- In Codex Desktop, prefer the rendered MCP App. Use the in-app Browser for the\n credential-free `openUrl` only when a read-only fallback is acceptable.\n- In Claude Code Desktop's Code tab, prefer the rendered MCP App. Preview\n `openUrl` in the Browser pane only as the read-only fallback.\n- In VS Code, use the Agent Native Design webview/deep link described below.\n- Inline browser availability is host-dependent. CLI, remote, or restricted\n sessions may not expose one. If the inline surface is unavailable or disabled,\n return the normal **Open design** link instead of claiming it opened.\n\nPrefer the MCP App surface for a connected Design plugin, then the host's\nbrowser/preview tool as the universal fallback. Keep the canvas beside chat\nwhen the host supports rearrangeable panes.\n\nInside Design, use **Show/Hide UI** from the `Cmd K` menu or press Figma's\n`Shift \\` shortcut to toggle all editing chrome so only the canvas remains.\nThe same action is available from Design's empty-canvas context menu.\n\n## Core Model\n\n- Each screen is a URL-backed iframe, not copied HTML.\n- Each screen keeps URL metadata: `connectionId`, `routeId`, `path`,\n `url`, `bridgeUrl`, title, and viewport size.\n- Localhost Edit mode renders the running app through the local bridge as a live\n iframe with the same editor bridge used by HTML designs. It is never a frozen\n static DOM snapshot. Editing is direct DOM manipulation against that live\n document; the parallel `/snapshot` fetch feeds the editable source model only\n and must never be rendered in the frame.\n- **The `/visual-edit` skill needs no Design account sign-in.**\n `open-visual-edit` mints a five-minute, single-use capability for the exact\n `/visual-edit/:designId` local-editor route. The MCP host redeems it outside\n model-visible text, then opens the existing editor with localhost edit access.\n This capability is not an account session: `/_agent-native/session` remains\n signed out, and account-backed save/share/generate actions remain denied.\n- The skill enters through local `pnpm action open-visual-edit`. When that CLI\n has no account session, the action uses a stable, workspace-scoped local\n principal to register the bridge, create/reuse the local design, and place\n screens. That principal exists only inside the in-process CLI call; it is not\n a browser login and cannot be selected by an HTTP, MCP, or tunneled caller.\n- Public links are always read-only, including on loopback. Loopback peer\n identity is not an authentication boundary because a tunnel or reverse proxy\n can make a remote request appear local. A bare `/visual-edit/:designId` or\n `/design/:designId` URL carries no capability and must never release the\n connection's `previewToken`.\n- The live editor is same-origin through the local bridge proxy. This boots\n CSR apps and root-relative assets, but it is still a localhost editing proxy:\n app-origin cookies, WebSockets/HMR, SSE, and non-GET app API calls may need a\n future dev-server/plugin integration for perfect parity with the app's own\n origin.\n- **There are exactly two views.** The infinite canvas is where all editing\n happens, and the responsive interactive view (Interact) is where the app runs\n for real. There is no third \"full view\"/focused-edit state \u2014 clicking a screen\n in the Screens list, or the view toggle, opens the responsive view, and\n closing it returns to the canvas.\n- Interact keeps the left and right rails and adds a device bar above the canvas\n (device preset, editable width/height, zoom, close). It renders the app's\n normal URL so navigation, scrolling, links, and form controls behave as they\n would in the browser, and the wheel scrolls the app rather than panning the\n canvas. The canvas view is the opposite: the wheel pans and zooms it, and\n native interaction inside the frame is suppressed.\n- While a localhost screen has pending live visual edits, do not switch back to\n Interact until the user either applies the edits to source or explicitly\n aborts/discards the preview.\n- Alt-drag duplicates a screen. For localhost screens, duplication copies the\n iframe frame and URL metadata; change the copy's path/query for a new state.\n- Flow visualization is multiple URL states: `/checkout?step=shipping`,\n `/checkout?step=payment`, `/checkout?step=done`, etc.\n- When the user gives a named flow or numbered screen list, preserve that order\n and create one screen per URL/path. Shorthand like\n `localhost:1234/onboarding/1` means\n `http://localhost:1234/onboarding/1`.\n\n## Useful Canvas Sets\n\nTranslate the user's requested review into the smallest useful set of frames:\n\n- **Multi-step flow:** one ordered frame per route or query state, such as cart,\n shipping, payment, and confirmation.\n- **Multiple pages:** one frame per meaningful route, such as home, pricing,\n docs, and account settings.\n- **Responsive comparison:** repeat the same route at the requested desktop,\n tablet, and mobile viewports so they align in one row.\n- **State review:** repeat a route for meaningful URL-addressable states such as\n empty, loading, error, modal-open, or selected-item views.\n\nDo not expand every discovered route or every viewport unless the user asks for\nan exhaustive audit. Preserve the user's labels and sequence so the canvas reads\nlike the workflow they described.\n\n## Select And Reprompt\n\nWhen a chat message begins with `[Reprompt selection]`, the selected subtree is\na hard write boundary. The only mutation path is `propose-node-rewrite` with\nthe exact `repromptId`, target, and `baseVersionHash` captured in\n`design-reprompt-pending:<designId>:<fileId>`. Never use `apply-visual-edit`,\n`apply-source-edit`, `write-source`, `write-local-file`, `edit-design`, or any\nother content-writing action for that request. Clarifying questions are allowed,\nbut a requested change must remain a proposal.\n\nProduce one variant by default. Produce two or three only when the instruction\nasks for options. A retry includes `priorProposalId`; keep the same target and\nbase version, incorporate the feedback, and call `propose-node-rewrite` again.\nThe UI previews the returned subtree without persisting it.\n\nUse `resolve-node-rewrite` for the accept/reject lifecycle. Accept applies the\nchosen variant as one version-checked inline/Yjs content transaction so one\nundo restores the prior structure; reject clears the proposal without changing\ncontent. For conversational resolution such as \"apply the second one,\" call\n`view-screen`, read the active `design.reprompt.proposal`, and pass its\n`proposalId` plus the zero-based `variantIndex` to `resolve-node-rewrite`.\n\n## Review Quality\n\n- Treat the running app as the truth. Preserve its component language, tokens,\n route state, and real content unless the user explicitly asks for a new visual\n direction.\n- Use multiple URL states to reveal meaningful UX moments: empty/loading/error\n states, focused panels, modals, responsive breakpoints, and completed flow\n steps when those matter to the review.\n- For visual edits, compare before/after at the relevant viewport sizes and\n check key hover/focus/scroll states when the app exposes them.\n\n## Account And Sharing Model\n\n- `/visual-edit/:id` is the dedicated local-editor surface. The one-time\n handoff returned by `open-visual-edit` opens it with edit access without a\n Design login. A copied or bare `/visual-edit/:id` URL is read-only because it\n does not carry the capability.\n- The capability permits live iframe inspection and session-local edits,\n undo/redo, **Apply design updates** through the connected host/local agent,\n and **Copy prompt**. Those flows hand bounded source instructions back to the\n coding agent; they do not silently persist account-owned Design data.\n- Public `/design/:id` links stay read-only without a signed-in owner/editor\n session. Never use the local capability to upgrade that ordinary sharing\n surface.\n- Prefer links returned by Design actions or `/_agent-native/open` deep links.\n Do not surface URLs with `_session=` tokens or hand-build capability URLs.\n- Do not attempt account-backed write actions with the browser capability. The\n trusted local `open-visual-edit` CLI call may register its bridge, create or\n reuse its workspace-owned local design, and place screens without an account.\n Direct source-file action writes, generation, saving into an account, and\n sharing still require an authenticated action caller. If a signed-out visitor\n wants those durable account operations, send them through the framework\n sign-in return flow first.\n\n## Required Local Bridge\n\nThe live-edit bridge is unlocked by a shared secret (the \"bridge token\") that\nmust match on two sides: the local bridge process, and the user's connection row\nin Design (which the browser reads to authorize `/live-edit-bridge`,\n`/read-file`, `/write-file`). Get them to match by letting the\n`open-visual-edit` action mint the token, then starting the\nbridge with it. This is the only ordering that works for the remote-MCP flow \u2014\nthe bridge cannot push its own token to the server without a CLI auth token, so\nthe server mints instead and the bridge adopts.\n\nFrom the target app repo, make sure its dev server is running, then:\n\n**1. Discover routes without starting a durable bridge** (one-shot, exits):\n\n```bash\nnpx @agent-native/core@latest design connect --url http://localhost:5173 --root . --json\n```\n\nThis prints the manifest (routes + capabilities). Parse it to build\n`routeManifest` for the next step. (Skip this if the user already gave explicit\npaths/URLs to place.)\n\nInside the agent-native monorepo itself, use the workspace CLI instead of\n`npx` \u2014 `npx` installs the last published `@agent-native/core`, which will not\ncontain local changes and costs a slow install on every call:\n\n```bash\npnpm dev:cli design connect --url http://localhost:5173 --root templates/<app> --json\n```\n\n**2. Call `open-visual-edit`** (see Action Flow below) with NO `bridgeToken`.\nThe server mints one, stores it on the user's connection row, copies it into the\nplaced screens' metadata, and returns it to you as `bridgeToken`. Capture it.\n\n**3. Start the persistent bridge adopting that token** (single line; prefer the\nenv var so the secret does not appear in `ps`):\n\n```bash\nAGENT_NATIVE_BRIDGE_TOKEN=\"<bridgeToken from step 2>\" npx @agent-native/core@latest design connect --url http://localhost:5173 --root . --daemon\n```\n\n(Equivalently, pass `--bridge-token <token>`.) This starts a detached bridge on\n`http://127.0.0.1:7331`, adopts the server-minted token \u2014 so bridge and row\nagree and live-edit authorizes with no self-registration \u2014 and stays alive after\nthe command exits.\n\nFor a manual health/manifest check on the running bridge:\n\n```bash\ncurl http://127.0.0.1:7331/health\n```\n\n`/health` needs no token. The full manifest at `/manifest.json` is\npreview-token protected, so an unauthenticated `curl` of it returns\n`{\"ok\":false,\"error\":\"invalid or missing preview token\"}` \u2014 that response means\nthe bridge is up, not that it is broken.\n\nOnly use `--json` for the step-1 route probe. Never use `--json`, `--once`,\nor `--dry-run` for the durable step-3 bridge: they print the manifest and exit,\nso Design falls back to a non-editable live iframe.\n\nThe bridge listens on a single fixed port (7331) and refuses to start for a\nsecond, different app. It is detached with no log file, so if `--daemon` reports\na timeout, check for a stale process (`lsof -ti:7331`) before retrying.\n\n## Action Flow\n\nPrefer the single `open-visual-edit` action. It registers or\nrefreshes the localhost bridge connection, mints and stores the bridge token,\ncreates or reuses a Design project, places URL-backed screens, stores the active\nvisual-edit context, and navigates to overview mode in one call. This avoids\ncreating a private design under a synthetic CLI user and then handing the browser\na tokenized URL that may be shadowed by an existing session.\n\nCall it BEFORE starting the durable bridge (step 3 above): it does not contact\nthe bridge, so the bridge need not be running yet, and you need its returned\n`bridgeToken` to start the bridge with a matching secret. Omit `bridgeToken`\non the call so the server mints one.\n\n```bash\npnpm action open-visual-edit '{\n \"title\": \"Docs homepage visual edit\",\n \"devServerUrl\": \"http://localhost:5173\",\n \"bridgeUrl\": \"http://127.0.0.1:7331\",\n \"rootPath\": \"/absolute/path/to/app\",\n \"routeManifest\": { \"...\": \"from /manifest.json\" },\n \"paths\": [\"/\", \"/pricing\", \"/checkout?step=payment\"]\n}'\n```\n\nThe action returns `designId`, `connectionId`, `bridgeToken`, `screens`,\n`urlPath`, and a credential-free `openUrl`. Its MCP App metadata separately\ncarries the one-time editor launcher so the host can redeem it without showing\nthe capability to the model or retaining it in the action link. Keep\n`designId`/`connectionId` in the chat context for follow-ups, and pass\n`bridgeToken` to `design connect` (step 3) to start the bridge. On follow-up\ncalls reusing an existing `connectionId`, the same token is returned (it is\nminted once and reused), so the running bridge stays valid.\n\n### Desktop and mobile side by side\n\nPass `viewports` to place every requested route once per viewport. Frames lay\nout as a grid: one row per route, one column per viewport. Presets are\n`desktop` (1280x900), `laptop` (1440x900), `tablet` (834x1112), and `mobile`\n(390x844); an explicit `{ \"label\": \"...\", \"width\": N, \"height\": N }` also works.\n\n```bash\npnpm action open-visual-edit '{\n \"title\": \"Tasks responsive visual edit\",\n \"devServerUrl\": \"http://localhost:5173\",\n \"bridgeUrl\": \"http://127.0.0.1:7331\",\n \"rootPath\": \"/absolute/path/to/app\",\n \"paths\": [\"/tasks\", \"/inbox\"],\n \"viewports\": [\"desktop\", \"mobile\"]\n}'\n```\n\nPrefer this over two separate calls with `defaultWidth`/`defaultHeight`: it\nkeeps each route's viewports aligned in a row and titles them\n`Tasks \u2014 Desktop` / `Tasks \u2014 Mobile` so the canvas reads clearly. `viewports`\noverrides `defaultWidth`/`defaultHeight`. With no `routes`/`paths`, it expands\nevery route in the localhost manifest, which is usually far more frames than\nthe user wants \u2014 name the paths.\n\n### Adding more page frames later\n\nCall `open-visual-edit` again with the same `designId` and `connectionId` and\nonly the new paths. Existing frames for the same route and viewport are\nrefreshed in place rather than duplicated, and a frame the user has dragged or\nresized keeps its position unless you explicitly pass `x`/`y`/`width`/`height`.\n\n```bash\npnpm action open-visual-edit '{\n \"designId\": \"<existing-design-id>\",\n \"connectionId\": \"<existing-connection-id>\",\n \"devServerUrl\": \"http://localhost:5173\",\n \"paths\": [\"/settings\", \"/team\"],\n \"startY\": 2200\n}'\n```\n\nDo NOT add `defaultWidth`/`defaultHeight` just to restate the default size:\nsupplying either one marks the viewport as explicitly requested, which\noverwrites frame sizes the user has already adjusted on the canvas.\n\nFor a numbered flow the user describes in chat, keep the labels and order:\n\n```bash\npnpm action open-visual-edit '{\n \"designId\": \"<existing-design-id>\",\n \"connectionId\": \"<existing-connection-id>\",\n \"devServerUrl\": \"http://localhost:1234\",\n \"routes\": [\n { \"url\": \"localhost:1234/onboarding/1\", \"title\": \"Screen 1\" },\n { \"url\": \"localhost:1234/onboarding/2\", \"title\": \"Screen 2\" },\n { \"url\": \"localhost:1234/onboarding/3\", \"title\": \"Screen 3\" }\n ]\n}'\n```\n\nIf no `routes` or `paths` are supplied, `open-visual-edit` uses every route\nfrom the localhost manifest.\n\nFallback, only when `open-visual-edit` is unavailable:\n\n1. Register or refresh the bridge with `connect-localhost`, passing the\n `/manifest.json` result as `routeManifest` and `capabilities`.\n2. Create or reuse a Design project with `create-design`.\n3. Place URL-backed screens with `add-localhost-screens`.\n4. Navigate to overview mode with `navigate`.\n\n## Open The Design Surface\n\n- Use the `link`, `deepLink`, or MCP App embed returned by Design actions so\n the user sees the canvas. Follow **Put Design Beside The Chat**: prefer the\n MCP App; otherwise surface the credential-free **Open design** link.\n- Return or open the MCP App first. Its host-managed launcher carries the\n one-time local-editor capability. The credential-free `openUrl` / action link\n is the safe read-only fallback; never build a capability URL yourself.\n- Never return or open a hand-built `/design/:id?_session=...` URL.\n- If the user is working in VS Code, the Agent Native extension can open the\n same URL via\n `vscode://builder.agent-native/open?url=<encoded-design-url>`. Its\n `Agent Native: Open Design Canvas` command also starts the local bridge and\n opens hosted Design in the VS Code side panel.\n- After `open-visual-edit`, confirm the Design editor is in overview mode\n with the requested URL-backed frames visible, and that they render the app\n rather than a spinner. Do not stop at \"screens added\" when the user asked to\n inspect or edit visually.\n\n## Applying Visual Edits Back To Source\n\nCanvas edits on a localhost screen do not write source as you make them. They\naccumulate as pending edits and the editor shows an **Apply design updates**\nbutton on the canvas. In an MCP App, clicking it hands the bounded structured\nprompt to the current host coding conversation. In an ordinary browser or\nstandalone Design page, it falls back to the local Design agent. The dropdown's\n**Copy prompt to your agent** action is the universal manual fallback.\n\n- Style, text, and drag/drop structure edits all collect into the same pending\n batch, so the user can make several changes and apply once.\n- After the write lands, the target app's own dev-server HMR refreshes the\n frames \u2014 no manual reload. If frames do not refresh, the write did not land;\n say so rather than assuming.\n- The separate disk-icon \"Apply to source\" button is the deterministic\n whole-file HTML/CSS writer. It is intentionally disabled for compiled\n `.jsx`/`.tsx` routes \u2014 those must go through the agent path above.\n\n## Editing URLs\n\nKeep localhost screens as URL files plus `screenMetadata[fileId]`. Do not\nreplace them with copied `srcdoc` HTML unless the user explicitly asks for a\nfrozen snapshot. To change a state, rerun `open-visual-edit` with the new\npath/query or duplicate the screen and update the copy's URL metadata.\n\n## Local Files in the Code Tab\n\nOnce a connection is registered, the design editor's Code panel (left rail \u2192\nCode, or `navigate --view editor --designId <id> --leftPanel code`) shows a\nlocal-files workspace root for that connection next to the design's own files.\nTreat that root like VS Code opened at the connected project directory: file\ntree, search, open/edit, and save are backed by the real local files. It lists\nthe connected app's text/code files through the bridge\n(`list-local-files` / `read-local-file`); build output, `node_modules`,\n`.git`, and secret-looking paths (`.env*`, key files) are always excluded.\n\n- Browsing and reading need only editor access on the design plus the running\n bridge.\n- Saving goes through `write-local-file`: the first save opens the\n write-consent dialog (an 8-hour, folder-scoped grant) and retries\n automatically once granted. Only text/code files are writable; secret paths\n are always blocked.\n- If the agent calls `write-local-file` directly (not through a UI save) and it\n fails with \"no write-consent grant\", call `request-localhost-write-consent`.\n It opens the write-consent dialog in the editor, or reports `alreadyGranted`\n if one already exists. Granting is human-only \u2014\n `grant-localhost-write-consent` is hidden from agents, so you cannot approve\n it yourself. Tell the user to click \"Allow writes\", then retry\n `write-local-file` once. Do not keep retrying blindly: the write stays\n blocked until the user approves.\n- Saves are conflict-checked against the file's on-disk version \u2014 a file that\n changed since it was read fails with a version conflict instead of being\n overwritten.\n\n## React Source Writeback\n\n- Use compiler/debug provenance (project-relative file, line, column,\n component, and runtime multiplicity) to locate React/TSX source. Treat it as\n evidence, not as permission for a generic AST structural transform.\n- Read `positionPrecision` on every anchor before you trust `line`/`column`.\n `authored` means those are the real JSX coordinates. `transformed` means they\n are the dev server's own output coordinates \u2014 React 19 removed `_debugSource`\n and exposes only an owner stack, so this is the normal case on a Vite/Next\n dev server, and the line will not match the file. `unknown` means no tier was\n reported. On anything but `authored`, use the file and component to find the\n element by its JSX shape and re-derive the line from the file you read; never\n edit at the reported line.\n- A single-instance leaf text edit, literal `className`/`class` edit, or flat\n literal `style={{ ... }}` property may use `apply-visual-edit` with a\n `local-file` source and a complete `target.sourceAnchor`. Forward the\n anchor's `positionPrecision` with it \u2014 the action refuses a `transformed`\n anchor with `status: \"needsAgent\"` instead of seeking to a line that means\n something else in the authored file. Preview first (omit `persist`), inspect\n `proposedDiff`, then call with `persist: true`.\n- Reparenting, grouping/ungrouping, wrappers, dynamic expressions, repeated\n `.map()` instances, shared components, breakpoint-scoped edits, and\n cross-file changes go through the coding agent with complete subject/target\n anchors and their runtime relationship. `apply-visual-edit` refuses these\n with `status: \"needsAgent\"` rather than guessing.\n- Before each write, read the file and pass its exact `versionHash` to\n `write-local-file` with `requireExpectedVersionHash: true`; on conflict,\n re-read and re-plan. Keep the optimistic preview until HMR/runtime confirms\n the result. Human write consent remains mandatory and agents cannot grant it.\n\n## Verification\n\n- `list-localhost-connections` returns the expected connection and routes.\n- The Design editor opens in overview mode.\n- Every requested screen renders the intended localhost URL, showing real app\n content rather than an endless loading spinner.\n- The screen iframe carries a `src`, not a `srcdoc`. A localhost screen with a\n `srcdoc` is a bug, not a slow load \u2014 check it in the browser devtools before\n reporting the canvas as working.\n- Alt-dragging a screen copies the URL-backed frame, not an inline HTML clone.\n- A query/path edit changes only the target screen's URL metadata and iframe.\n- The Code tab shows a local-files root for the connection and opens its files.\n";
@@ -51,8 +51,8 @@ Prefer the MCP App surface for a connected Design plugin, then the host's
51
51
  browser/preview tool as the universal fallback. Keep the canvas beside chat
52
52
  when the host supports rearrangeable panes.
53
53
 
54
- Inside Design, use **Show/Hide UI** from the \`Cmd+K\` menu or press Figma's
55
- \`Shift+\\\` shortcut to toggle all editing chrome so only the canvas remains.
54
+ Inside Design, use **Show/Hide UI** from the \`Cmd K\` menu or press Figma's
55
+ \`Shift \\\` shortcut to toggle all editing chrome so only the canvas remains.
56
56
  The same action is available from Design's empty-canvas context menu.
57
57
 
58
58
  ## Core Model
@@ -536,7 +536,7 @@ export async function runVisualizeRepo(argv) {
536
536
  bridge.result.urlFile
537
537
  ? `Open URL written to ${bridge.result.urlFile}`
538
538
  : "",
539
- "Press Ctrl+C to stop.",
539
+ "Press Ctrl C to stop.",
540
540
  ]
541
541
  .filter(Boolean)
542
542
  .join("\n") + "\n");
@@ -24,7 +24,7 @@ const FEEDBACK_COPY = {
24
24
  invalidUrl: "Invalid feedback URL",
25
25
  emptyError: "Please write something first",
26
26
  sendError: "Couldn't send feedback",
27
- keyboardHint: "{{shortcut}}+Enter to send",
27
+ keyboardHint: "{{shortcut}} Enter to send",
28
28
  },
29
29
  "zh-CN": {
30
30
  label: "反馈",
@@ -36,7 +36,7 @@ const FEEDBACK_COPY = {
36
36
  invalidUrl: "反馈 URL 无效",
37
37
  emptyError: "请先写点内容",
38
38
  sendError: "无法发送反馈",
39
- keyboardHint: "{{shortcut}}+Enter 发送",
39
+ keyboardHint: "{{shortcut}} Enter 发送",
40
40
  },
41
41
  "zh-TW": {
42
42
  label: "意見回饋",
@@ -48,7 +48,7 @@ const FEEDBACK_COPY = {
48
48
  invalidUrl: "意見回饋 URL 無效",
49
49
  emptyError: "請先輸入內容",
50
50
  sendError: "無法送出意見回饋",
51
- keyboardHint: "{{shortcut}}+Enter 送出",
51
+ keyboardHint: "{{shortcut}} Enter 送出",
52
52
  },
53
53
  "es-ES": {
54
54
  label: "Comentarios",
@@ -60,7 +60,7 @@ const FEEDBACK_COPY = {
60
60
  invalidUrl: "URL de comentarios no válida",
61
61
  emptyError: "Escribe algo primero",
62
62
  sendError: "No se pudieron enviar los comentarios",
63
- keyboardHint: "{{shortcut}}+Enter para enviar",
63
+ keyboardHint: "{{shortcut}} Enter para enviar",
64
64
  },
65
65
  "fr-FR": {
66
66
  label: "Retour",
@@ -72,7 +72,7 @@ const FEEDBACK_COPY = {
72
72
  invalidUrl: "URL de retour invalide",
73
73
  emptyError: "Écrivez quelque chose d'abord",
74
74
  sendError: "Impossible d'envoyer le retour",
75
- keyboardHint: "{{shortcut}}+Entrée pour envoyer",
75
+ keyboardHint: "{{shortcut}} Entrée pour envoyer",
76
76
  },
77
77
  "de-DE": {
78
78
  label: "Feedback",
@@ -84,7 +84,7 @@ const FEEDBACK_COPY = {
84
84
  invalidUrl: "Ungültige Feedback-URL",
85
85
  emptyError: "Bitte zuerst etwas schreiben",
86
86
  sendError: "Feedback konnte nicht gesendet werden",
87
- keyboardHint: "{{shortcut}}+Enter zum Senden",
87
+ keyboardHint: "{{shortcut}} Enter zum Senden",
88
88
  },
89
89
  "ja-JP": {
90
90
  label: "フィードバック",
@@ -96,7 +96,7 @@ const FEEDBACK_COPY = {
96
96
  invalidUrl: "フィードバック URL が無効です",
97
97
  emptyError: "先に内容を入力してください",
98
98
  sendError: "送信できませんでした",
99
- keyboardHint: "{{shortcut}}+Enter で送信",
99
+ keyboardHint: "{{shortcut}} Enter で送信",
100
100
  },
101
101
  "ko-KR": {
102
102
  label: "피드백",
@@ -108,7 +108,7 @@ const FEEDBACK_COPY = {
108
108
  invalidUrl: "피드백 URL이 올바르지 않습니다",
109
109
  emptyError: "먼저 내용을 입력해 주세요",
110
110
  sendError: "피드백을 보낼 수 없습니다",
111
- keyboardHint: "{{shortcut}}+Enter로 보내기",
111
+ keyboardHint: "{{shortcut}} Enter로 보내기",
112
112
  },
113
113
  "pt-BR": {
114
114
  label: "Feedback",
@@ -120,7 +120,7 @@ const FEEDBACK_COPY = {
120
120
  invalidUrl: "URL de feedback inválida",
121
121
  emptyError: "Escreva algo primeiro",
122
122
  sendError: "Não foi possível enviar o feedback",
123
- keyboardHint: "{{shortcut}}+Enter para enviar",
123
+ keyboardHint: "{{shortcut}} Enter para enviar",
124
124
  },
125
125
  "hi-IN": {
126
126
  label: "फ़ीडबैक",
@@ -132,7 +132,7 @@ const FEEDBACK_COPY = {
132
132
  invalidUrl: "फ़ीडबैक URL अमान्य है",
133
133
  emptyError: "पहले कुछ लिखें",
134
134
  sendError: "फ़ीडबैक भेजा नहीं जा सका",
135
- keyboardHint: "भेजने के लिए {{shortcut}}+Enter",
135
+ keyboardHint: "भेजने के लिए {{shortcut}} Enter",
136
136
  },
137
137
  "ar-SA": {
138
138
  label: "ملاحظات",
@@ -144,7 +144,7 @@ const FEEDBACK_COPY = {
144
144
  invalidUrl: "رابط الملاحظات غير صالح",
145
145
  emptyError: "اكتب شيئا أولا",
146
146
  sendError: "تعذر إرسال الملاحظات",
147
- keyboardHint: "{{shortcut}}+Enter للإرسال",
147
+ keyboardHint: "{{shortcut}} Enter للإرسال",
148
148
  },
149
149
  };
150
150
  function parseTarget(url) {
@@ -373,6 +373,6 @@ function FeedbackPopoverButton({ variant = "sidebar", label, url, className, sid
373
373
  submit();
374
374
  }, placeholder: resolvedPlaceholder, rows: 5, maxLength: 10000, className: "w-full resize-none rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring" }), _jsx("input", { type: "text", tabIndex: -1, autoComplete: "off", "aria-hidden": "true", value: honeypot, onChange: (e) => setHoneypot(e.target.value), style: honeypotStyle }), _jsxs("div", { className: "flex items-center justify-between gap-3", children: [_jsx("div", { className: cn("text-[11px]", error ? "text-destructive" : "text-muted-foreground/75"), children: error ??
375
375
  copy.keyboardHint.replace("{{shortcut}}", /Mac|iPhone|iPad/.test(navigator.userAgent)
376
- ? "⌘"
376
+ ? "Cmd"
377
377
  : "Ctrl") }), _jsx("button", { type: "submit", disabled: submitting || !value.trim(), className: "inline-flex h-8 items-center justify-center rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50", children: submitting ? copy.submitting : copy.submit })] })] })) }) })] }));
378
378
  }
@@ -7,6 +7,7 @@ import { captureError } from "./analytics.js";
7
7
  import { agentNativePath } from "./api-path.js";
8
8
  import { formatChatErrorText, normalizeChatError } from "./error-format.js";
9
9
  import { AgentAutoContinueSignal, INTERRUPTED_TOOL_RESULT, appendMissingFinalResponseWarning, readSSEStream, settleInterruptedToolCalls, } from "./sse-event-processor.js";
10
+ import { isDelegatedAgentToolCall, isToolCallInFlight, } from "./tool-display.js";
10
11
  const TEXT_ATTACHMENT_CONTENT_TYPES = new Set([
11
12
  "application/json",
12
13
  "application/x-ndjson",
@@ -891,7 +892,7 @@ function describeContinuationAdvance(content, preparingToolName) {
891
892
  }
892
893
  continue;
893
894
  }
894
- if (part.activity === true) {
895
+ if (part.activity === true && !isDelegatedAgentToolCall(part)) {
895
896
  work.add(`preparing ${part.toolName}`);
896
897
  stall ??= { kind: "preparing", toolName: part.toolName };
897
898
  }
@@ -923,9 +924,7 @@ function describeContinuationAdvance(content, preparingToolName) {
923
924
  * must not count this against the stalled/empty continuation budgets.
924
925
  */
925
926
  export function hasInFlightToolCall(content) {
926
- return content.some((part) => part.type === "tool-call" &&
927
- part.result === undefined &&
928
- part.activity !== true);
927
+ return content.some((part) => isToolCallInFlight(part));
929
928
  }
930
929
  /**
931
930
  * Server truth for "does this run still look alive?", used to keep the client
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- type AssistantUiRecoverableErrorKind = "assistant-ui-stale-message-index" | "assistant-ui-duplicate-resource-key" | "assistant-ui-react-fiber-unmount";
2
+ type AssistantUiRecoverableErrorKind = "assistant-ui-stale-message-index" | "assistant-ui-duplicate-resource-key" | "assistant-ui-react-fiber-unmount" | "assistant-ui-react-update-depth";
3
3
  export declare function assistantUiRecoverableRenderErrorKind(error: unknown): AssistantUiRecoverableErrorKind | null;
4
4
  export declare function isAssistantUiStaleIndexError(error: unknown): boolean;
5
5
  export declare function isAssistantUiRecoverableRenderError(error: unknown): boolean;
@@ -13,6 +13,10 @@ export function assistantUiRecoverableRenderErrorKind(error) {
13
13
  if (/^Tried to unmount a fiber that is already unmounted\b/.test(message)) {
14
14
  return "assistant-ui-react-fiber-unmount";
15
15
  }
16
+ // guard:allow-raw-color — #185 is a React diagnostic code, not a UI color.
17
+ if (/Maximum update depth exceeded|Minified React error #185/.test(message)) {
18
+ return "assistant-ui-react-update-depth";
19
+ }
16
20
  return null;
17
21
  }
18
22
  export function isAssistantUiStaleIndexError(error) {
@@ -57,6 +57,10 @@ export declare function resolveAssistantRequestId(message: unknown, activeRun: {
57
57
  runId: string;
58
58
  } | null, threadId: string): string | undefined;
59
59
  export declare function MessageBranchPicker(): React.JSX.Element;
60
+ export declare function ChatImageAttachmentPreview({ src, alt, }: {
61
+ src: string;
62
+ alt: string;
63
+ }): React.JSX.Element;
60
64
  export declare function MessageActionsMenu({ showRevert, onRevert, threadId, }?: {
61
65
  showRevert?: boolean;
62
66
  onRevert?: () => void;
@@ -68,13 +72,14 @@ export declare function isMissingFinalResponseWarningText(text: string): boolean
68
72
  export declare function latestUserMessageText(messages: readonly unknown[]): string;
69
73
  export declare function userMessageTextBeforeAssistant(messages: readonly unknown[], assistantMessageId: string): string;
70
74
  export declare function assistantMessageHasUnresolvedTool(content: unknown): boolean;
75
+ export declare function assistantMessageHasActiveTool(content: unknown): boolean;
71
76
  export declare function assistantMessageHasCompletedCustomUi(content: unknown): boolean;
72
77
  export declare function assistantMessageHasCustomUi(content: unknown): boolean;
73
78
  export declare function computeActiveTailToolCallId(content: ContentPart[] | undefined, { chatRunning, isLast }: {
74
79
  chatRunning: boolean;
75
80
  isLast: boolean;
76
81
  }): string | null;
77
- export declare function shouldShowAssistantMessageFooter({ isLast, chatRunning, activeRunId, messageRunId, activeTurnId, messageTurnId, hasRenderableContent, statusIsTerminal, hasUnresolvedTool, }: {
82
+ export declare function shouldShowAssistantMessageFooter({ isLast, chatRunning, activeRunId, messageRunId, activeTurnId, messageTurnId, hasRenderableContent, statusIsTerminal, hasUnresolvedTool, hasActiveTool, }: {
78
83
  isLast: boolean;
79
84
  chatRunning: boolean;
80
85
  activeRunId?: string | null;
@@ -84,6 +89,7 @@ export declare function shouldShowAssistantMessageFooter({ isLast, chatRunning,
84
89
  hasRenderableContent: boolean;
85
90
  statusIsTerminal: boolean;
86
91
  hasUnresolvedTool?: boolean;
92
+ hasActiveTool?: boolean;
87
93
  }): boolean;
88
94
  /**
89
95
  * Server-authoritative "a run for this thread is still active and running".
@@ -93,21 +99,23 @@ export declare function shouldShowAssistantMessageFooter({ isLast, chatRunning,
93
99
  */
94
100
  export declare const ServerRunActiveContext: React.Context<boolean>;
95
101
  export declare const UserStoppedRunContext: React.Context<(runId?: string) => boolean>;
96
- export declare function shouldShowMissingFinalResponse({ isCurrentTurnRunning, serverRunActive, statusIsTerminal, hasAssistantText, hasUnresolvedTool, hasCompletedCustomUi, userStoppedRun, }: {
102
+ export declare function shouldShowMissingFinalResponse({ isCurrentTurnRunning, serverRunActive, statusIsTerminal, hasAssistantText, hasUnresolvedTool, hasCompletedCustomUi, hasActiveTool, userStoppedRun, }: {
97
103
  isCurrentTurnRunning: boolean;
98
104
  serverRunActive?: boolean;
99
105
  statusIsTerminal: boolean;
100
106
  hasAssistantText: boolean;
101
107
  hasUnresolvedTool: boolean;
102
108
  hasCompletedCustomUi?: boolean;
109
+ hasActiveTool?: boolean;
103
110
  userStoppedRun?: boolean;
104
111
  }): boolean;
105
112
  export declare function useSettledFlag(active: boolean, delayMs: number): boolean;
106
- export declare function shouldShowAssistantWorkSummary({ isLast, isComplete, hasCollapsibleWork, hasUnresolvedTool, chatRunning, }: {
113
+ export declare function shouldShowAssistantWorkSummary({ isLast, isComplete, hasCollapsibleWork, hasUnresolvedTool, hasActiveTool, chatRunning, }: {
107
114
  isLast: boolean;
108
115
  isComplete: boolean;
109
116
  hasCollapsibleWork: boolean;
110
117
  hasUnresolvedTool: boolean;
118
+ hasActiveTool?: boolean;
111
119
  chatRunning: boolean;
112
120
  }): boolean;
113
121
  export declare function getAssistantWorkSummaryDurationMs(durationMs: number | null | undefined, groupStartIndex: number, firstWorkPartIndex: number): number | null | undefined;
@@ -11,11 +11,12 @@ import React, { useState, useEffect, useCallback, useRef } from "react";
11
11
  import { getActiveRun } from "../active-run-state.js";
12
12
  import { agentNativePath } from "../api-path.js";
13
13
  import { writeClipboardText } from "../clipboard.js";
14
+ import { Dialog, DialogClose, DialogContent, DialogTitle, } from "../components/ui/dialog.js";
14
15
  import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "../components/ui/dropdown-menu.js";
15
16
  import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "../components/ui/tooltip.js";
16
17
  import { ThumbsFeedback } from "../observability/ThumbsFeedback.js";
17
18
  import { McpConnectionSuggestion } from "../resources/McpConnectionSuggestion.js";
18
- import { isCallAgentToolCallShadowed, shadowedCallAgentToolCallIds, } from "../tool-display.js";
19
+ import { isCallAgentToolCallShadowed, isToolCallActive, shadowedCallAgentToolCallIds, } from "../tool-display.js";
19
20
  import { cn } from "../utils.js";
20
21
  import { MarkdownText, renderMarkdownToClipboardHtml, SmoothMarkdownText, } from "./markdown-renderer.js";
21
22
  import { getAssistantRunDurationMs } from "./repo-helpers.js";
@@ -292,11 +293,18 @@ function UserMessageAttachments() {
292
293
  !!p.image);
293
294
  const imageSrc = uploadUrl || imagePart?.image || null;
294
295
  if (imageSrc) {
295
- return (_jsx("div", { className: "h-16 w-16 overflow-hidden rounded-lg border border-border/70 bg-muted/50", title: att.name, children: _jsx("img", { src: imageSrc, alt: att.name, className: "h-full w-full object-cover" }) }, att.id));
296
+ return (_jsx(ChatImageAttachmentPreview, { src: imageSrc, alt: att.name }, att.id));
296
297
  }
297
298
  return (_jsxs("div", { className: "flex items-center gap-1.5 rounded-lg border border-border/70 bg-muted/50 px-2 py-1.5 text-xs text-muted-foreground", title: att.name, children: [_jsx(IconFile, { className: "h-3.5 w-3.5 shrink-0" }), _jsx("span", { className: "truncate max-w-[120px]", children: att.name || "file" })] }, att.id));
298
299
  }) }));
299
300
  }
301
+ export function ChatImageAttachmentPreview({ src, alt, }) {
302
+ const [open, setOpen] = useState(false);
303
+ return (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", "aria-label": `Preview ${alt}`, title: alt, onClick: () => setOpen(true), className: "h-16 w-16 cursor-zoom-in overflow-hidden rounded-lg border border-border/70 bg-muted/50 p-0 transition-[border-color,box-shadow] hover:border-foreground/40 hover:shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2", children: _jsx("img", { src: src, alt: alt, className: "h-full w-full object-cover" }) }), _jsx(Dialog, { open: open, onOpenChange: setOpen, children: _jsxs(DialogContent, { hideClose: true, "aria-describedby": undefined, className: "fixed inset-0 left-0 top-0 flex h-screen max-h-none w-screen max-w-none translate-x-0 translate-y-0 items-center justify-center gap-0 overflow-hidden rounded-none border-0 bg-foreground/90 p-0 text-background shadow-none backdrop-blur-sm dark:bg-background/95 dark:text-foreground", onOpenAutoFocus: (event) => event.preventDefault(), children: [_jsx(DialogTitle, { className: "sr-only", children: alt || "Image preview" }), _jsx("div", { className: "flex h-full w-full items-center justify-center overflow-auto p-6", onClick: (event) => {
304
+ if (event.target === event.currentTarget)
305
+ setOpen(false);
306
+ }, children: _jsx("img", { src: src, alt: alt, draggable: false, className: "max-h-[90vh] max-w-[92vw] rounded-lg object-contain shadow-2xl" }) }), _jsx(DialogClose, { asChild: true, children: _jsx("button", { type: "button", "aria-label": "Close image preview", className: "absolute end-4 top-4 inline-flex size-9 items-center justify-center rounded-full border border-background/25 bg-background/10 text-background transition-colors hover:bg-background/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring dark:border-foreground/25 dark:bg-foreground/10 dark:text-foreground dark:hover:bg-foreground/20", children: _jsx(IconX, { className: "size-4" }) }) })] }) })] }));
307
+ }
300
308
  // ─── UserMessageEditComposer ──────────────────────────────────────────────────
301
309
  function UserMessageEditComposer() {
302
310
  return (_jsxs(ComposerPrimitive.Root, { className: "flex flex-col gap-2 rounded-lg border border-border bg-background px-3 py-2 shadow-sm", children: [_jsx(ComposerPrimitive.Input, { className: "w-full resize-none bg-transparent text-sm leading-relaxed text-foreground placeholder:text-muted-foreground focus:outline-none", rows: 1, submitMode: "enter" }), _jsxs("div", { className: "flex justify-end gap-2", children: [_jsx(ComposerPrimitive.Cancel, { asChild: true, children: _jsx("button", { type: "button", className: "cursor-pointer rounded-md px-2 py-1 text-xs font-medium text-muted-foreground hover:bg-accent hover:text-foreground", children: "Cancel" }) }), _jsx(ComposerPrimitive.Send, { asChild: true, children: _jsx("button", { type: "submit", className: "cursor-pointer rounded-md bg-foreground px-2 py-1 text-xs font-medium text-background hover:opacity-90 disabled:opacity-50", children: "Save" }) })] })] }));
@@ -545,6 +553,15 @@ export function assistantMessageHasUnresolvedTool(content) {
545
553
  return record.type === "tool-call" && record.result === undefined;
546
554
  });
547
555
  }
556
+ export function assistantMessageHasActiveTool(content) {
557
+ if (!Array.isArray(content))
558
+ return false;
559
+ return content.some((part) => {
560
+ if (!part || typeof part !== "object")
561
+ return false;
562
+ return isToolCallActive(part);
563
+ });
564
+ }
548
565
  export function assistantMessageHasCompletedCustomUi(content) {
549
566
  if (!Array.isArray(content))
550
567
  return false;
@@ -606,7 +623,7 @@ export function computeActiveTailToolCallId(content, { chatRunning, isLast }) {
606
623
  ? part.toolCallId
607
624
  : latestToolCallId, null) ?? null);
608
625
  }
609
- export function shouldShowAssistantMessageFooter({ isLast, chatRunning, activeRunId, messageRunId, activeTurnId, messageTurnId, hasRenderableContent, statusIsTerminal, hasUnresolvedTool, }) {
626
+ export function shouldShowAssistantMessageFooter({ isLast, chatRunning, activeRunId, messageRunId, activeTurnId, messageTurnId, hasRenderableContent, statusIsTerminal, hasUnresolvedTool, hasActiveTool, }) {
610
627
  if (!hasRenderableContent)
611
628
  return false;
612
629
  const ownsActiveTurn = activeTurnId != null &&
@@ -622,6 +639,8 @@ export function shouldShowAssistantMessageFooter({ isLast, chatRunning, activeRu
622
639
  const ownsActiveRun = isLast || ownsActiveTurn || ownsLegacyRun;
623
640
  if (chatRunning && ownsActiveRun)
624
641
  return false;
642
+ if (hasActiveTool)
643
+ return false;
625
644
  if (!isLast)
626
645
  return true;
627
646
  if (hasUnresolvedTool)
@@ -636,7 +655,7 @@ export function shouldShowAssistantMessageFooter({ isLast, chatRunning, activeRu
636
655
  */
637
656
  export const ServerRunActiveContext = React.createContext(false);
638
657
  export const UserStoppedRunContext = React.createContext(() => false);
639
- export function shouldShowMissingFinalResponse({ isCurrentTurnRunning, serverRunActive, statusIsTerminal, hasAssistantText, hasUnresolvedTool, hasCompletedCustomUi, userStoppedRun, }) {
658
+ export function shouldShowMissingFinalResponse({ isCurrentTurnRunning, serverRunActive, statusIsTerminal, hasAssistantText, hasUnresolvedTool, hasCompletedCustomUi, hasActiveTool, userStoppedRun, }) {
640
659
  if (userStoppedRun)
641
660
  return false;
642
661
  if (serverRunActive)
@@ -647,6 +666,7 @@ export function shouldShowMissingFinalResponse({ isCurrentTurnRunning, serverRun
647
666
  statusIsTerminal &&
648
667
  !hasAssistantText &&
649
668
  !hasUnresolvedTool &&
669
+ !hasActiveTool &&
650
670
  !hasCompletedCustomUi);
651
671
  }
652
672
  /**
@@ -668,9 +688,11 @@ export function useSettledFlag(active, delayMs) {
668
688
  }, [active, delayMs]);
669
689
  return active && (delayMs <= 0 || settled);
670
690
  }
671
- export function shouldShowAssistantWorkSummary({ isLast, isComplete, hasCollapsibleWork, hasUnresolvedTool, chatRunning, }) {
691
+ export function shouldShowAssistantWorkSummary({ isLast, isComplete, hasCollapsibleWork, hasUnresolvedTool, hasActiveTool, chatRunning, }) {
672
692
  if (!hasCollapsibleWork)
673
693
  return false;
694
+ if (hasActiveTool)
695
+ return false;
674
696
  // An unresolved tool means "still working" only while the turn is actually
675
697
  // running. On a stalled or interrupted turn it used to hide the summary
676
698
  // forever, so the longest turns showed no "Worked for Xm Ys" at all.
@@ -798,6 +820,7 @@ export function AssistantMessage() {
798
820
  const isUserStoppedRun = assistantMessageWasUserStopped(msg) || userStoppedRun(messageRunId);
799
821
  const hasRenderableContent = assistantMessageHasRenderableContent(msg);
800
822
  const hasUnresolvedTool = assistantMessageHasUnresolvedTool(msg.content);
823
+ const hasActiveTool = assistantMessageHasActiveTool(msg.content);
801
824
  const missingWarningText = missingFinalResponseWarningText(msg.content);
802
825
  const responseConnectionText = finalResponseTextFromContent(msg.content);
803
826
  const statusIsTerminal = assistantMessageStatusIsTerminal(msg);
@@ -818,6 +841,7 @@ export function AssistantMessage() {
818
841
  statusIsTerminal,
819
842
  hasAssistantText: responseConnectionText.trim().length > 0,
820
843
  hasUnresolvedTool,
844
+ hasActiveTool,
821
845
  hasCompletedCustomUi,
822
846
  userStoppedRun: isUserStoppedRun,
823
847
  });
@@ -876,6 +900,7 @@ export function AssistantMessage() {
876
900
  hasRenderableContent,
877
901
  statusIsTerminal,
878
902
  hasUnresolvedTool,
903
+ hasActiveTool,
879
904
  });
880
905
  const cpCtx = React.useContext(CheckpointContext);
881
906
  useEffect(() => {
@@ -995,6 +1020,7 @@ export function AssistantMessage() {
995
1020
  isComplete,
996
1021
  hasCollapsibleWork,
997
1022
  hasUnresolvedTool,
1023
+ hasActiveTool,
998
1024
  chatRunning,
999
1025
  });
1000
1026
  if (!showSummary)
@@ -78,7 +78,7 @@ export declare function AnimatedCollapse({ open, children, }: {
78
78
  open: boolean;
79
79
  children: React.ReactNode;
80
80
  }): React.JSX.Element | null;
81
- export declare function ToolCallDisplay({ toolName, toolCallId, argsText, args, result, mcpApp, chatUI, isRunning, outcome, structuredMeta, approval, repeatCount, isLatestRunning, isActiveTail, }: {
81
+ export declare function ToolCallDisplay({ toolName, toolCallId, argsText, args, result, mcpApp, chatUI, isRunning, outcome, structuredMeta, activity, approval, repeatCount, isLatestRunning, isActiveTail, }: {
82
82
  toolName: string;
83
83
  toolCallId?: string;
84
84
  argsText?: string;
@@ -90,6 +90,7 @@ export declare function ToolCallDisplay({ toolName, toolCallId, argsText, args,
90
90
  /** "unknown": the stream ended mid-flight, so the side effect may have landed. */
91
91
  outcome?: "unknown";
92
92
  structuredMeta?: Record<string, unknown>;
93
+ activity?: boolean;
93
94
  approval?: {
94
95
  approvalKey: string;
95
96
  dismissed?: boolean;
@@ -11,7 +11,7 @@ import { McpAppRenderer } from "../mcp-apps/McpAppRenderer.js";
11
11
  import { findMcpIntegrationForToolName } from "../resources/mcp-integration-catalog.js";
12
12
  import { McpIntegrationLogo } from "../resources/McpIntegrationLogo.js";
13
13
  import { BashCell, EditCell, WriteCell, FilesChangedSummary, } from "../tool-cells/index.js";
14
- import { humanizeToolName, isCallAgentToolCallShadowed, } from "../tool-display.js";
14
+ import { humanizeToolName, isCallAgentToolCallShadowed, isToolCallActive, } from "../tool-display.js";
15
15
  import { cn } from "../utils.js";
16
16
  import { ActionChatUiSurface } from "./action-chat-ui-surface.js";
17
17
  import { SmoothMarkdownText, HighlightedCodeBlock, } from "./markdown-renderer.js";
@@ -273,23 +273,34 @@ function ApprovalAffordance({ toolName, toolCallId, approval, }) {
273
273
  }, className: cn("inline-flex items-center gap-1 rounded-md border border-border px-2.5 py-1 text-xs font-medium transition-colors", "text-foreground hover:bg-muted"), children: [_jsx(IconX, { className: "h-3.5 w-3.5" }), "Deny"] })] }));
274
274
  }
275
275
  // ─── ToolCallDisplay ──────────────────────────────────────────────────────────
276
- export function ToolCallDisplay({ toolName, toolCallId, argsText, args, result, mcpApp, chatUI, isRunning, outcome, structuredMeta, approval, repeatCount, isLatestRunning = isRunning, isActiveTail, }) {
276
+ export function ToolCallDisplay({ toolName, toolCallId, argsText, args, result, mcpApp, chatUI, isRunning, outcome, structuredMeta, activity, approval, repeatCount, isLatestRunning = isRunning, isActiveTail, }) {
277
+ const isDelegatedAgentCall = toolName === "call-agent" || toolName.startsWith("agent:");
278
+ const effectiveIsRunning = isRunning ||
279
+ (isDelegatedAgentCall &&
280
+ isToolCallActive({
281
+ type: "tool-call",
282
+ toolName,
283
+ result,
284
+ outcome,
285
+ activity,
286
+ structuredMeta,
287
+ }));
277
288
  const showActiveTail = isActiveTail ?? isLatestRunning;
278
289
  // Delegate to bespoke cells when structured metadata is present.
279
290
  // These must be separate components so hook order in ToolCallDisplayGeneric
280
291
  // is always stable (no conditional hook calls).
281
292
  const toolKind = structuredMeta?.toolKind;
282
- const wrapToolDisplay = (children) => (_jsx(ToolActivityPresentation, { toolName: toolName, isRunning: isRunning, toolCallId: toolCallId, suppressLongRunningHint: toolName === "call-agent" || toolName.startsWith("agent:"), children: children }));
293
+ const wrapToolDisplay = (children) => (_jsx(ToolActivityPresentation, { toolName: toolName, isRunning: effectiveIsRunning, toolCallId: toolCallId, suppressLongRunningHint: toolName === "call-agent" || toolName.startsWith("agent:"), children: children }));
283
294
  if (toolKind === "bash") {
284
- return wrapToolDisplay(_jsx(BashCell, { meta: structuredMeta, output: result, isRunning: isRunning }));
295
+ return wrapToolDisplay(_jsx(BashCell, { meta: structuredMeta, output: result, isRunning: effectiveIsRunning }));
285
296
  }
286
297
  if (toolKind === "edit") {
287
- return wrapToolDisplay(_jsx(EditCell, { meta: structuredMeta, isRunning: isRunning }));
298
+ return wrapToolDisplay(_jsx(EditCell, { meta: structuredMeta, isRunning: effectiveIsRunning }));
288
299
  }
289
300
  if (toolKind === "write") {
290
- return wrapToolDisplay(_jsx(WriteCell, { meta: structuredMeta, isRunning: isRunning }));
301
+ return wrapToolDisplay(_jsx(WriteCell, { meta: structuredMeta, isRunning: effectiveIsRunning }));
291
302
  }
292
- return wrapToolDisplay(_jsx(ToolCallDisplayGeneric, { toolName: toolName, toolCallId: toolCallId, argsText: argsText, args: args, result: result, mcpApp: mcpApp, chatUI: chatUI, isRunning: isRunning, outcome: outcome, isActiveTail: showActiveTail, structuredMeta: structuredMeta, approval: approval, repeatCount: repeatCount }));
303
+ return wrapToolDisplay(_jsx(ToolCallDisplayGeneric, { toolName: toolName, toolCallId: toolCallId, argsText: argsText, args: args, result: result, mcpApp: mcpApp, chatUI: chatUI, isRunning: effectiveIsRunning, outcome: outcome, isActiveTail: showActiveTail, structuredMeta: structuredMeta, approval: approval, repeatCount: repeatCount }));
293
304
  }
294
305
  function ToolCallDisplayGeneric({ toolName, toolCallId, argsText, args, result, mcpApp, chatUI, isRunning, outcome, isActiveTail, structuredMeta, approval, repeatCount, }) {
295
306
  const suppressInlineOpenApp = React.useContext(SuppressInlineOpenAppContext);
@@ -460,17 +471,24 @@ function AgentActivityToolCallRow({ tool, isActiveTail, }) {
460
471
  // ─── ToolCallFallback ──────────────────────────────────────────────────────────
461
472
  export function ToolCallFallback({ toolName, toolCallId, args, argsText, result, ...rest }) {
462
473
  const chatRunning = React.useContext(ChatRunningContext);
463
- // A spinner is a claim that something is running right now, so it needs an
464
- // actually-running chat. `chatRunning` already stays true across
465
- // auto-continuation gaps and server-active runs (resolveAssistantChatRunningState),
466
- // so an activity placeholder alone must never resurrect one on rehydrated
467
- // history.
468
- const isRunning = result === undefined && chatRunning;
474
+ // `chatRunning` covers ordinary live activity. An unresolved tool or a
475
+ // delegated-agent row is also explicit work evidence, while a generic
476
+ // activity placeholder alone must stay frozen when history is rehydrated.
477
+ const isRunning = rest.outcome !== "unknown" &&
478
+ ((result === undefined && chatRunning) ||
479
+ isToolCallActive({
480
+ type: "tool-call",
481
+ toolName,
482
+ result,
483
+ outcome: rest.outcome,
484
+ activity: rest.activity,
485
+ structuredMeta: rest.structuredMeta,
486
+ }));
469
487
  return (_jsx(ToolCallDisplay, { toolName: toolName, toolCallId: toolCallId, args: args, argsText: argsText, result: typeof result === "string"
470
488
  ? result
471
489
  : result !== undefined
472
490
  ? JSON.stringify(result)
473
- : undefined, mcpApp: rest.mcpApp, chatUI: rest.chatUI, structuredMeta: rest.structuredMeta, isRunning: isRunning, outcome: rest.outcome, isActiveTail: rest.isActiveTail, isLatestRunning: rest.isLatestRunning, approval: rest.approval, repeatCount: rest.repeatCount }));
491
+ : undefined, mcpApp: rest.mcpApp, chatUI: rest.chatUI, structuredMeta: rest.structuredMeta, activity: rest.activity, isRunning: isRunning, outcome: rest.outcome, isActiveTail: rest.isActiveTail, isLatestRunning: rest.isLatestRunning, approval: rest.approval, repeatCount: rest.repeatCount }));
474
492
  }
475
493
  // ─── ReconnectStreamMessage ────────────────────────────────────────────────────
476
494
  // Renders the agent's in-progress response during reconnection (outside
@@ -496,7 +514,7 @@ export function ReconnectStreamMessage({ content, allowActivitySpinner = true, }
496
514
  if (part.type === "reasoning") {
497
515
  return (_jsx(ReasoningCell, { text: part.text, isStreaming: chatRunning && i === streamingReasoningPartIndex, resetKey: `reconnect-reasoning-${i}`, defaultOpen: i === latestReasoningPartIndex, collapseWhenReplaced: i < latestReasoningPartIndex }, `reconnect-reasoning-${i}`));
498
516
  }
499
- return (_jsx(ToolCallDisplay, { toolName: part.toolName, toolCallId: part.toolCallId, argsText: part.argsText, args: part.args, result: part.result, mcpApp: part.mcpApp, chatUI: part.chatUI, structuredMeta: part.structuredMeta, outcome: part.outcome, isRunning: part.result === undefined &&
517
+ return (_jsx(ToolCallDisplay, { toolName: part.toolName, toolCallId: part.toolCallId, argsText: part.argsText, args: part.args, result: part.result, mcpApp: part.mcpApp, chatUI: part.chatUI, structuredMeta: part.structuredMeta, activity: part.activity, outcome: part.outcome, isRunning: part.result === undefined &&
500
518
  (chatRunning || (allowActivitySpinner && part.activity === true)), isActiveTail: i === latestActiveToolIndex, approval: part.approval, repeatCount: part.repeatCount }, `reconnect-tool-${i}`));
501
519
  };
502
520
  const renderedParts = [];