feat: 内置 HTML 预览器 + 沙箱浏览器 tab(v0.5.0)

- html viewer:.html/.htm 沙箱 iframe 预览(相对资源经 /sidebar/html 路径编码路由加载,CSP sandbox + 信任围栏 + cwd 边界),预览/编辑切换
- browser tab:+ 菜单多开(browser:<n>),地址栏后退/前进/刷新/在浏览器中打开(15px 图标),URL 与标题按会话持久化(patchTab + nextBrowser)
- 安全:iframe 一律不透明源沙箱(无 allow-same-origin/top-navigation、no-referrer、权限策略全禁、禁 srcdoc);地址栏仅 http(s)、拒绝 localhost 等本机地址;界面实时沙箱状态(关闭红色警示)+ 临时解锁/恢复
- 设置:htmlViewerNoSandbox / htmlViewerDefaultUnsafe / browserNoSandbox / browserInterceptLinks 四个声明式二级设置(默认安全)
- 外链拦截:聊天/界面 http(s) 外链默认在侧边栏打开(openTab seed.url),Ctrl/Cmd 点击放行
- 嵌入拒绝面板:browser.probe 路由探测 X-Frame-Options/frame-ancestors,被拒站点显示原因 + 在浏览器中打开/仍然加载
- 设置页可滚动;内置 7 tab + 9 viewer;新增设计文档;268 个测试全绿
This commit is contained in:
Menghuan1918
2026-08-11 19:28:48 +08:00
parent 35cde82eb2
commit 302c20109f
36 changed files with 2084 additions and 58 deletions
+36
View File
@@ -35,6 +35,38 @@ export interface SidebarPrefs {
* own enable switch gates it too (both must be on for the takeover).
*/
interceptOpenPath: boolean
/**
* Whether the HTML previewer drops its sandboxed iframe. Sandbox ON (the
* default) renders previewed HTML in an opaque-origin iframe that cannot
* touch the GUI; turning it OFF runs the previewed page with the GUI's
* own origin — full read/write access to session files and internal
* APIs. Only for trusted local content; the setting copy warns.
*/
htmlViewerNoSandbox: boolean
/**
* Whether a newly opened HTML preview starts UNSANDBOXED (the per-surface
* temporary unlock pre-applied). Off by default: previews open sandboxed
* and the status row offers the one-tap unlock; when on, previews open
* in the red unsandboxed state and the status row offers a one-tap
* restore for the current file.
*/
htmlViewerDefaultUnsafe: boolean
/**
* Whether the browser tab drops its sandboxed iframe. Sandbox ON (the
* default) keeps browsed sites in an opaque origin with no GUI access;
* turning it OFF runs any visited site with the GUI's own origin — it
* can read session data and act as the logged-in GUI. Only for trusted
* sites; the setting copy warns.
*/
browserNoSandbox: boolean
/**
* Whether clicking an http(s) EXTERNAL link in the GUI (chat messages,
* tool rows, prose mentions) opens the sidebar browser instead of a new
* browser tab. On by default; gated on the browser tab's own enable
* switch (both must be on for the takeover). Ctrl/Cmd+click always
* bypasses the takeover.
*/
browserInterceptLinks: boolean
/**
* Per-tab enable switches, keyed by tab descriptor id (`'explorer'`,
* `'my-plugin:db'`). An ABSENT key means enabled — only an explicit
@@ -66,6 +98,10 @@ export const SIDEBAR_PREFS_DEFAULTS: SidebarPrefs = {
autoOpenSubagent: true,
agentTerminalTools: false,
interceptOpenPath: true,
htmlViewerNoSandbox: false,
htmlViewerDefaultUnsafe: false,
browserNoSandbox: false,
browserInterceptLinks: true,
tabsEnabled: {},
viewersEnabled: {},
}