Skip to content

feat: agents open files in the side-panel Preview (amicode_open_preview) + 16 MB HTML cap (#2130) - #2156

Draft
jacktrnr wants to merge 3 commits into
mainfrom
preview-open-2130
Draft

jacktrnr wants to merge 3 commits into
mainfrom
preview-open-2130

Conversation

@jacktrnr

@jacktrnr jacktrnr commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Closes #2130.

Agents can now put a file in the side-panel Preview themselves, so a live campaign dashboard shows up next to the conversation automatically instead of the session running open -a "Google Chrome" …. It also raises the Preview's size limit for HTML pages, so dashboards that embed their plots render instead of showing "File too large to preview".

What changed

The agent tool, amicode_open_preview (packages/extension/opencode-plugin/preview_open.ts)

  • One dependency-free definition, used by the MCP core table (src/amicode_tools_core.ts) and the plugin twin, so the parity test keeps them in step.
  • It resolves the path (accepts absolute paths, ~/… and file://), checks the file exists, and returns an AMICODE_PREVIEW {path,name,bytes} sentinel as its last line.
  • It refuses relative, missing and directory paths with a clear reason and no sentinel.
  • It warns the agent when a file is over the Preview's limit for its type.

The app side (ui/src/amicode/card.tsx, preview-open.ts, preview-open-card.tsx)

  • AmicodeToolCard watches the part. When an amicode_open_preview call it saw live (pending or running) completes, it posts the existing session-targeted preview-file open, with refresh: true. This happens once per part.
  • A replayed session mounts its parts already completed, so it never re-opens anything.
  • The finished call renders as a "Preview ‹file›" chip; clicking it re-opens the file.

The Preview (app/src/components/session/preview-file-view.tsx, preview-file-helpers.ts)

  • A preview-file message with refresh: true for the file a view already shows makes that view re-read it. This matters for files outside the project, which the engine's watcher never reports.
  • A view showing a placeholder (file too large, or a failed read) does a full reload instead.
  • Unsaved edits are never overwritten.
  • The watcher's re-read was moved into rereadFromDisk so both paths share it.
  • HTML pages may now be up to 16 MB (other text files stay at 1 MB). A dashboard with base64 plots, such as a real 1.73 MB one, now renders. The HTML renderer's own inlining budget (24 MB) was already above this.

Guidance for agents

  • The product's AGENTS.md tells agents to show results with amicode_open_preview and never an external browser.
  • The research skill's dashboard contract now says to open the dashboard once with the tool and still post the file:// link once.
  • The test that pins that contract gained a case for this.

Verification

  • pnpm --filter amicode test: 5824 passed, 0 failed on a clean run.
  • ./.notturno/gates (base origin/main): drift, typecheck and build pass. The only red was one of the 10 MB SSE frame-splitting timing tests (linear_sse_frame_splitting_1790, sse_fanin_driver_pump); a different one failed on each run. They are not touched by this diff, pass when re-run, and the machine was at load average ~35 from unrelated Julia jobs.
  • Materialized app/ui (bun):
    • typecheck is clean for both;
    • src/components/session: 291 tests pass;
    • src/amicode: 444 tests pass, including the new preview-open.test.ts.
  • Drift gate: PASS after refresh_manifest.
  • MCP end to end: I built bin/dist/mcp-amico.mjs and drove it over stdio. tools/list serves open_preview.
    • Calling it on a real 1.73 MB dashboard returns the sentinel.
    • A missing path and a relative path are refused with no sentinel.
  • Not tested by hand: I did not install a VSIX or click through it in a live window, because the machine was running four live sessions. The card-to-Preview link is covered by the pure gate tests and the wiring pins.

Notes

@jacktrnr jacktrnr self-assigned this Nov 8, 2026
@coderabbitai

coderabbitai Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

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.

feat(agent): let agents open files in the side-panel Preview

1 participant