Skip to content

feat(library): asset-to-chat flow + open() preview tool#4117

Open
rafavalls wants to merge 1 commit into
mainfrom
rafavalls/asset-chat-library-fix
Open

feat(library): asset-to-chat flow + open() preview tool#4117
rafavalls wants to merge 1 commit into
mainfrom
rafavalls/asset-chat-library-fix

Conversation

@rafavalls

@rafavalls rafavalls commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

What is this contribution about?

Three fixes for the Library → Chat asset workflow:

  1. Deck tabs persist across thread switches — removed deck: from isPerThreadTab() since deck files live in the org home volume (persistent, org-scoped), not in a thread-specific path. Previously, creating a new thread while viewing a landing page would close the preview tab.

  2. Library "Open in chat" button — when previewing a home-volume HTML file in the Library, a chat icon appears in the top-left toolbar (same Toolbar.Toggles slot used by the agent chat button). Clicking it navigates to the last thread with the file open in the deck tab alongside the chat panel, so the asset stays visible.

  3. open(filepath) built-in tool — agents can now call open("pages/landing.html") after creating or editing an HTML file to immediately navigate the preview panel. The tool emits a transient data-open-preview stream part (no persistence, no ghost nav on reload), invalidates the stat cache so the iframe renders fresh, and the tool card is hidden from chat since the navigation already happened. A system prompt block tells models when to call it.

Screenshots/Demonstration

  • Library: HTML file previewed on the right → chat icon appears top-left → click opens thread with file in deck tab
  • New thread from a thread with deck tab open → deck tab is preserved (was previously dropped)

How to Test

  1. Start bun run dev, open the Library (/$org/files), browse to home → pages/, click an HTML file
  2. Verify the MessageCircle01 button appears in the top-left toolbar (after back/forward nav)
  3. Click it → should land in the last thread with ?main=deck:<path>&chat=1 (chat left, HTML right)
  4. With a deck tab open in a thread, click "New thread" → deck tab should still be visible in the new thread
  5. Ask Deco to "create a simple HTML landing page" → agent should call open() after writing the file → preview panel navigates automatically

Migration Notes

No database migrations or configuration changes required.

Review Checklist

  • PR title is clear and descriptive
  • Changes are tested and working
  • Documentation is updated (if needed)
  • No breaking changes

Summary by cubic

Improves the Library → Chat workflow: HTML previews persist across thread switches, and you can open a preview directly in chat. Adds an open(filepath) tool so agents can switch the preview automatically after creating or editing a page.

  • New Features

    • Library: show an “Open in chat” button when previewing a home-volume HTML file; opens the last thread with chat and the file in a deck tab.
    • Built-in tool: open(filepath) emits a transient data-open-preview event that navigates the preview and refreshes it; the tool card is hidden to avoid noise. Added an <open-preview> system prompt so models know when to call it.
  • Bug Fixes

    • Deck tabs are no longer per-thread, so HTML previews stay open when creating a new thread.

Written for commit ff2e969. Summary will update on new commits.

Review in cubic

- Remove `deck:` from `isPerThreadTab` so landing page tabs persist when
  creating a new thread (deck files live in the org home volume, not per-thread)
- Add chat button to Library toolbar (Toolbar.Toggles slot) when a home-volume
  HTML file is previewed; navigates to the last thread with the file open in
  the deck tab alongside chat
- Add `open(filepath)` built-in tool (cluster-only) that emits a transient
  `data-open-preview` stream part; the React client navigates the deck tab
  immediately with stat cache invalidation, matching data-deck-updated behavior
- Hide `tool-open` card in chat (navigation already happened, card is noise)
- Add `<open-preview>` system prompt block so agents know to call open() after
  writing an HTML page or deck

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant