DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
feat(desktop): dsh iframe 帧内 console 报错纳入运行日志
hairyf3eebdd6c2823
diff --git a/src-tauri/src/bridge/system_os.rs b/src-tauri/src/bridge/system_os.rsindex f85a66bf..f420d554 100644--- a/src-tauri/src/bridge/system_os.rs+++ b/src-tauri/src/bridge/system_os.rs@@ -155,7 +155,9 @@ pub async fn clear_service_logs(app_handle: AppHandle) -> Result<(), String> {/// `log::*`;仅对旧版本已落盘、尚未轮转掉的 `frontend:` 行做一次兜底剔除。据此把/// 「运行日志」拆成:/// - `### 前台日志`:取自前端独立文件 `logs/desktop.frontdesk.log`-/// (`logger::init` 单独落盘,见 logger/mod.rs),仅含前端 `console.*`;+/// (`logger::init` 单独落盘,见 logger/mod.rs),含壳层前端 `console.*` 与+/// 注入脚本从 dsh iframe 转回的帧内 console/未捕获异常(标识 `[iframe]`,+/// 见 desktop/frame_log.rs);/// - `### 后台日志`:取自 `logs/desktop.log`,剔除残余 `target: "frontend"` 行,/// 仅保留后端 `log::*`。/// 每段取末尾最多 `MAX_LINES` 行(前端日志量大,仅取一半 `FRONTEND_MAX_LINES`),diff --git a/src-tauri/src/desktop/builder.rs b/src-tauri/src/desktop/builder.rsindex 36713ac6..e9f6bf71 100644--- a/src-tauri/src/desktop/builder.rs+++ b/src-tauri/src/desktop/builder.rs@@ -577,7 +577,7 @@ pub fn build_main_window(app: &tauri::AppHandle<Wry>) -> tauri::Result<tauri::We// 非 Windows(macOS/Linux)没有 WebView2 的 FrameCreated/ContentLoading 流程,// 直接用 Tauri 的 initialization_script_for_all_frames 把兼容桥、通知桥、- // 剪贴板图片桥与 boot 探测桥注入所有 frame(脚本均带幂等守卫,重复注入安全)。+ // 剪贴板图片桥、帧内日志桥与 boot 探测桥注入所有 frame(脚本均带幂等守卫,重复注入安全)。// 导航桥(侧边栏)、缩放快捷键与 iframe 全局样式已分别由 dsh-tauri /// dsh-tauri-ui 插件在 iframe 内实现,不再注入对应脚本。#[cfg(not(windows))]@@ -586,6 +586,7 @@ pub fn build_main_window(app: &tauri::AppHandle<Wry>) -> tauri::Result<tauri::We.initialization_script_for_all_frames(crate::desktop::compat::ITERATOR_HELPERS_SHIM_JS).initialization_script_for_all_frames(crate::desktop::notification::NOTIFICATION_SHIM_JS).initialization_script_for_all_frames(crate::desktop::paste::PASTE_SHIM_JS)+ .initialization_script_for_all_frames(crate::desktop::frame_log::FRAME_LOG_BRIDGE_JS).initialization_script_for_all_frames(crate::desktop::plugin_boot::PLUGIN_BOOT_RELOAD_JS);let webview_window = webview_builder.build()?;@@ -670,13 +671,14 @@ pub fn build_extra_window(app: &tauri::AppHandle<Wry>) -> tauri::Result<tauri::W.icon(app.default_window_icon().unwrap().clone())?;// 非 Windows 平台没有 WebView2 的 FrameCreated/ContentLoading 流程,兼容桥、- // 通知桥、剪贴板图片桥与 boot 探测桥必须按窗口重新注入(与主窗口一致)。+ // 通知桥、剪贴板图片桥、帧内日志桥与 boot 探测桥必须按窗口重新注入(与主窗口一致)。#[cfg(not(windows))]let webview_builder = webview_builder.initialization_script_for_all_frames(crate::desktop::compat::ABORT_SIGNAL_ANY_SHIM_JS).initialization_script_for_all_frames(crate::desktop::compat::ITERATOR_HELPERS_SHIM_JS).initialization_script_for_all_frames(crate::desktop::notification::NOTIFICATION_SHIM_JS).initialization_script_for_all_frames(crate::desktop::paste::PASTE_SHIM_JS)+ .initialization_script_for_all_frames(crate::desktop::frame_log::FRAME_LOG_BRIDGE_JS).initialization_script_for_all_frames(crate::desktop::plugin_boot::PLUGIN_BOOT_RELOAD_JS);#[cfg(target_os = "macos")]diff --git a/src-tauri/src/desktop/frame_log.js.inc b/src-tauri/src/desktop/frame_log.js.incnew file mode 100644index 00000000..32dc4af6--- /dev/null+++ b/src-tauri/src/desktop/frame_log.js.inc@@ -0,0 +1,154 @@+(function () {+ // 只在帧内工作:壳层顶层文档的 console 已由 src/utils/logger.ts 劫持并直连+ // log_frontend,这里再劫持一次会让每条壳层日志落盘两份。+ if (window === window.top) return+ if (window.__dsh_frame_log_bridge__) return+ window.__dsh_frame_log_bridge__ = true++ var SOURCE = 'dsh-frame-log-bridge'+ var TYPE = 'dsh://frame-log'+ var MAX_CHARS = 2000+ var LIMIT_WINDOW_MS = 1000+ var MAX_PER_WINDOW = 20++ var consoleRef = window.console+ if (!consoleRef) return++ var originalWarn = consoleRef.warn+ var originalError = consoleRef.error+ var windowStart = Date.now()+ var sentInWindow = 0+ var suppressed = 0++ function framePath() {+ try {+ var path = String(window.location.pathname || '')+ return path.length > 80 ? path.slice(0, 80) : path+ } catch (_) {+ return ''+ }+ }++ function isErrorLike(value) {+ return !!value+ && typeof value === 'object'+ && typeof value.message === 'string'+ && typeof value.stack === 'string'+ }++ function errorText(error) {+ var name = error && error.name ? String(error.name) : 'Error'+ var message = error && error.message ? String(error.message) : ''+ var header = message ? name + ': ' + message : name+ var stack = error && typeof error.stack === 'string' ? error.stack : ''+ if (!stack) return header+ return stack.indexOf(header) === 0 ? stack : header + '\n' + stack+ }++ function stringify(value) {+ if (typeof value === 'string') return value+ if (isErrorLike(value)) return errorText(value)+ if (value === undefined) return 'undefined'+ if (typeof value === 'function') return '[Function ' + (value.name || 'anonymous') + ']'+ try {+ var text = JSON.stringify(value, function (key, item) {+ if (typeof item === 'bigint') return String(item) + 'n'+ if (typeof item === 'function') return '[Function ' + (item.name || 'anonymous') + ']'+ if (isErrorLike(item)) return errorText(item)+ return item+ })+ return typeof text === 'string' ? text : String(value)+ } catch (_) {+ try {+ return String(value)+ } catch (_) {+ return '[Unserializable]'+ }+ }+ }++ function compose(args) {+ var parts = []+ for (var index = 0; index < args.length; index += 1) parts.push(stringify(args[index]))+ return parts.join(' ')+ }++ function post(level, message) {+ try {+ var path = framePath()+ var text = path && path !== '/' ? path + ' ' + message : message+ if (text.length > MAX_CHARS) text = text.slice(0, MAX_CHARS) + '…[truncated]'+ window.parent.postMessage({+ source: SOURCE,+ type: TYPE,+ level: level,+ message: text+ }, '*')+ } catch (_) {}+ }++ function send(level, message) {+ var now = Date.now()+ if (now - windowStart >= LIMIT_WINDOW_MS) {+ windowStart = now+ sentInWindow = 0+ if (suppressed > 0) {+ var dropped = suppressed+ suppressed = 0+ post('warn', dropped + ' frame log entries suppressed')+ }+ }+ if (sentInWindow >= MAX_PER_WINDOW) {+ suppressed += 1+ return+ }+ sentInWindow += 1+ post(level, message)+ }++ function capture(level, original, args) {+ try {+ original.apply(consoleRef, args)+ } catch (_) {}+ send(level, compose(args))+ }++ if (typeof originalWarn === 'function') {+ consoleRef.warn = function () {+ capture('warn', originalWarn, arguments)+ }+ }++ if (typeof originalError === 'function') {+ consoleRef.error = function () {+ capture('error', originalError, arguments)+ }+ }++ window.addEventListener('error', function (event) {+ var where = event && event.filename+ ? event.filename + ':' + event.lineno + ':' + event.colno + ' '+ : ''+ var text = event && isErrorLike(event.error)+ ? errorText(event.error)+ : String((event && event.message) || 'unknown error')+ send('error', '[uncaught] ' + where + text)+ })++ window.addEventListener('unhandledrejection', function (event) {+ var reason = event ? event.reason : undefined+ send('error', '[unhandledrejection] ' + stringify(reason))+ })++ // dsh 应用内部还嵌套 iframe(插件面板等),它们的 postMessage 只会到中间那一层+ // 文档;这里逐层向上接力,接力链在「宿主直接内嵌的那一层」终止(顶层文档无本脚本)。+ window.addEventListener('message', function (event) {+ var data = event && event.data+ if (!data || typeof data !== 'object' || data.source !== SOURCE || data.type !== TYPE) return+ if (event.source === window.parent) return+ if (window.parent === window) return+ try {+ window.parent.postMessage(data, '*')+ } catch (_) {}+ })+})()diff --git a/src-tauri/src/desktop/frame_log.rs b/src-tauri/src/desktop/frame_log.rsnew file mode 100644index 00000000..608b895c--- /dev/null+++ b/src-tauri/src/desktop/frame_log.rs@@ -0,0 +1,30 @@+//! 帧内前端日志桥:把 dsh iframe(含其内部嵌套 frame)的 `console.warn/error`+//! 与未捕获异常送回宿主,落盘到 `desktop.frontdesk.log`。+//!+//! iframe 与壳层跨源,帧内 `console.*` 既没有壳层的 console 劫持(`src/utils/logger.ts`+//! 只跑在壳层文档里),也没有宿主侧通路,报障时「运行日志」里只有壳层自己的前台日志,+//! 帧内报错完全缺失。脚本按 `dsh-notification-bridge` / `dsh-clipboard-image-bridge`+//! 同一套注入通道(Windows 在 FrameCreated → ContentLoading 时 ExecuteScript,其余平台+//! `initialization_script_for_all_frames`)下发,带 `__dsh_frame_log_bridge__` 幂等守卫;+//! 顶层文档直接返回,避免与壳层日志重复。宿主侧由 `src/layout/components/iframe.tsx`+//! 的 `dsh://frame-log` 分支调 `log_frontend`(`target: "iframe"`)。++/// iframe 内:console.warn/error 与未捕获异常 → `dsh://frame-log` → 宿主落盘。+pub(crate) const FRAME_LOG_BRIDGE_JS: &str = include_str!("frame_log.js.inc");++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn frame_log_bridge_only_taps_frames_and_stays_idempotent() {+ assert!(FRAME_LOG_BRIDGE_JS.contains("window.__dsh_frame_log_bridge__"));+ assert!(FRAME_LOG_BRIDGE_JS.contains("if (window === window.top) return"));+ assert!(FRAME_LOG_BRIDGE_JS.contains("dsh://frame-log"));+ assert!(FRAME_LOG_BRIDGE_JS.contains("dsh-frame-log-bridge"));+ assert!(FRAME_LOG_BRIDGE_JS.contains("unhandledrejection"));+ assert!(FRAME_LOG_BRIDGE_JS.contains("originalError"));+ assert!(FRAME_LOG_BRIDGE_JS.contains("window.parent.postMessage"));+ assert!(!FRAME_LOG_BRIDGE_JS.contains("location.reload"));+ }+}diff --git a/src-tauri/src/desktop/mod.rs b/src-tauri/src/desktop/mod.rsindex e9f66a4e..868a5cfa 100644--- a/src-tauri/src/desktop/mod.rs+++ b/src-tauri/src/desktop/mod.rs@@ -3,6 +3,7 @@ pub mod autostart;pub mod builder;pub mod compat;pub mod deep_link;+pub mod frame_log;#[cfg(target_os = "linux")]pub mod linux_tray;pub mod notification;diff --git a/src-tauri/src/desktop/notification.rs b/src-tauri/src/desktop/notification.rsindex 3cc23b4e..df9011a4 100644--- a/src-tauri/src/desktop/notification.rs+++ b/src-tauri/src/desktop/notification.rs@@ -323,11 +323,12 @@ pub fn enable_notification_permissions(let _ = frame3.add_ContentLoading(&FrameContentLoadingEventHandler::create(Box::new(move |_, _| {- // 通知桥、剪贴板图片桥与 boot 探测桥需要 iframe 上下文执行。+ // 通知桥、剪贴板图片桥、帧内日志桥与 boot 探测桥需要 iframe 上下文执行。// (导航桥 / 缩放快捷键 / 全局样式已分别由 dsh-tauri、dsh-tauri-ui 插件承担。)for script in [crate::desktop::notification::NOTIFICATION_SHIM_JS,crate::desktop::paste::PASTE_SHIM_JS,+ crate::desktop::frame_log::FRAME_LOG_BRIDGE_JS,crate::desktop::plugin_boot::PLUGIN_BOOT_RELOAD_JS,] {let script = HSTRING::from(script);diff --git a/src-tauri/src/logger/mod.rs b/src-tauri/src/logger/mod.rsindex aba4bca6..bc46d8b4 100644--- a/src-tauri/src/logger/mod.rs+++ b/src-tauri/src/logger/mod.rs@@ -2,7 +2,7 @@//!//! 目标://! - 后端:`log::*`(业务,`dsh` target 表示 Harness 输出)→ `tracing` 经 `tracing_log::LogTracer` → `tracing-subscriber` + `tracing-appender`(non-blocking)+ `EnvFilter`-//! - 前端:`console.*` 劫持 → `log_frontend`(`target: "frontend"`)→ 独立 `desktop.frontdesk.log`(标识 `frontend`,同格式);文件层对 `frontend` target 直接跳过,后端 `desktop.log` 不混入前端日志(前端日志仅终端 / `desktop.frontdesk.log` 可见)+//! - 前端:`console.*` 劫持 → `log_frontend`(`target: "frontend"`)→ 独立 `desktop.frontdesk.log`(标识 `frontend`,同格式);文件层对 `frontend` target 直接跳过,后端 `desktop.log` 不混入前端日志(前端日志仅终端 / `desktop.frontdesk.log` 可见)。同一文件也接收 dsh iframe 的帧内 console/未捕获异常(注入脚本转发,标识为 `[iframe]`,见 `desktop/frame_log.rs`)//! - 格式:`[YYYY-MM-DD HH:MM:SS.mmmZ] LEVEL target: message`(例 `INFO dsh:` / `INFO frontend:`)//! - 轮转:`desktop.log` + `desktop.frontdesk.log` 各 5MiB,保留 `.1 ~ .3`//! - 降噪:`reqwest`/`hyper` 默认 `warn`,可通过 `RUST_LOG=reqwest=debug` 覆盖diff --git a/src/layout/components/iframe.tsx b/src/layout/components/iframe.tsxindex 8623ce42..cfebc7f3 100644--- a/src/layout/components/iframe.tsx+++ b/src/layout/components/iframe.tsx@@ -22,7 +22,7 @@ import { Loadable } from './loadable'/*** iframe → 宿主 的桥消息(宿主侧按 `type` 分发,不比对 `source`)。- * 只列 iframe 自身关心的桥:通知 / 插件异常 / 剪贴板图片 / 插件 boot+ * 只列 iframe 自身关心的桥:通知 / 插件异常 / 剪贴板图片 / 插件 boot / 帧内日志* (导航桥的 `dsh://sidebar:collapsed` 由 `webview.tsx` 处理)。*/interface IframeBridgeMessage {@@ -39,6 +39,9 @@ interface IframeBridgeMessage {action?: string/** 插件 boot 桥:失败页文本 */detail?: string+ /** 帧内日志桥:console 级别(warn/error)与已序列化文本 */+ level?: string+ message?: stringsidebar?: CSSPropertiesmarked?: CSSProperties@@ -124,6 +127,11 @@ export function Iframe({ iframeRef }: IframeProps) {case 'dsh://style':setDshStyle(data)break+ // 帧内日志:iframe 跨源、帧内 console.* 没有宿主侧通路,由注入脚本转回来后+ // 直写 desktop.frontdesk.log,随「复制运行日志」的前台日志一并提供+ case 'dsh://frame-log':+ handleFrameLog(data)+ break}})@@ -182,6 +190,15 @@ export function Iframe({ iframeRef }: IframeProps) {setting.zoom(action)}+ function handleFrameLog(data: IframeBridgeMessage) {+ // 桥消息一律按不可信输入处理:非字符串/超长文本直接丢弃或截断+ if (typeof data.message !== 'string' || data.message === '')+ return+ const level = data.level === 'error' ? 'error' : 'warn'+ void invoke('log_frontend', { level, target: 'iframe', message: data.message.slice(0, 2048) })+ .catch(error => console.error('[frame-log] log_frontend failed:', error))+ }+function handleNotificationClicked(payload: NotificationClickedPayload) {post({type: 'dsh://focus-session',diff --git a/test/frame-log.test.ts b/test/frame-log.test.tsnew file mode 100644index 00000000..0acbe4a2--- /dev/null+++ b/test/frame-log.test.ts@@ -0,0 +1,275 @@+import { readFileSync } from 'node:fs'+import { runInNewContext } from 'node:vm'+import { afterEach, describe, expect, it, vi } from 'vitest'++interface FrameLogEntry {+ source: string+ type: string+ level: string+ message: string+}++interface FrameLogHarnessOptions {+ /** 模拟壳层顶层文档:脚本必须整体不工作 */+ topFrame?: boolean+ /** 帧文档路径(脚本用它标注报错来源) */+ pathname?: string+ /** 注入次数(模拟重复注入) */+ injections?: number+}++interface FrameLogHarness {+ /** 宿主(window.parent)真实收到的帧内日志条目 */+ posts: FrameLogEntry[]+ /** 注入前的 console 原始方法被调用次数 */+ calls: { warn: number, error: number }+ /** 帧内 console(注入后即被本脚本劫持的那一份) */+ console: { warn: (...args: unknown[]) => void, error: (...args: unknown[]) => void }+ /** 宿主那一层 window(window.parent),用于构造「来自上层」的消息 */+ parent: unknown+ fireWindowEvent: (type: string, event: unknown) => void+ fireMessage: (data: unknown, source: unknown) => void+}++const script = readFileSync(+ new URL('../src-tauri/src/desktop/frame_log.js.inc', import.meta.url),+ 'utf8',+)++function createHarness(options: FrameLogHarnessOptions = {}): FrameLogHarness {+ const posts: FrameLogEntry[] = []+ const calls = { warn: 0, error: 0 }+ const listeners = new Map<string, Array<(event: unknown) => void>>()++ const consoleObject: FrameLogHarness['console'] = {+ warn() {+ calls.warn += 1+ },+ error() {+ calls.error += 1+ },+ }++ const parent = {+ postMessage(message: FrameLogEntry) {+ posts.push(message)+ },+ }++ const windowObject: Record<string, unknown> = {+ parent,+ top: {},+ console: consoleObject,+ location: { pathname: options.pathname ?? '/' },+ addEventListener(type: string, listener: (event: unknown) => void) {+ const current = listeners.get(type) ?? []+ current.push(listener)+ listeners.set(type, current)+ },+ removeEventListener(type: string, listener: (event: unknown) => void) {+ const current = listeners.get(type) ?? []+ const index = current.indexOf(listener)+ if (index >= 0)+ current.splice(index, 1)+ },+ }+ if (options.topFrame)+ windowObject.top = windowObject++ for (let index = 0; index < (options.injections ?? 1); index += 1)+ runInNewContext(script, { window: windowObject, Date })++ function emit(type: string, event: unknown) {+ for (const listener of [...(listeners.get(type) ?? [])])+ listener(event)+ }++ return {+ posts,+ calls,+ console: consoleObject,+ parent,+ fireWindowEvent: emit,+ fireMessage(data, source) {+ emit('message', { data, source })+ },+ }+}++afterEach(() => {+ vi.useRealTimers()+})++describe('frame log bridge', () => {+ it('forwards console.error from a frame with the error level and frame path', () => {+ const harness = createHarness({ pathname: '/chat' })++ harness.console.error('boom', 42)++ expect(harness.posts).toEqual([+ {+ source: 'dsh-frame-log-bridge',+ type: 'dsh://frame-log',+ level: 'error',+ message: '/chat boom 42',+ },+ ])+ })++ it('forwards console.warn from a frame with the warn level', () => {+ const harness = createHarness()++ harness.console.warn('careful')++ expect(harness.posts).toEqual([+ {+ source: 'dsh-frame-log-bridge',+ type: 'dsh://frame-log',+ level: 'warn',+ message: 'careful',+ },+ ])+ })++ it('keeps the frame console output after hijacking', () => {+ const harness = createHarness()++ harness.console.error('boom')+ harness.console.warn('careful')++ expect(harness.calls).toEqual({ warn: 1, error: 1 })+ })++ it('stays silent in the top-level document', () => {+ const harness = createHarness({ topFrame: true })++ harness.console.error('boom')+ harness.fireWindowEvent('error', { filename: 'http://127.0.0.1:3080/main.js', error: new Error('boom') })++ expect(harness.posts).toEqual([])+ })++ it('reports an uncaught error with its source location', () => {+ const harness = createHarness({ pathname: '/settings' })++ harness.fireWindowEvent('error', {+ message: 'Uncaught TypeError: x is not a function',+ filename: 'http://127.0.0.1:3080/assets/index.js',+ lineno: 12,+ colno: 3,+ error: new TypeError('x is not a function'),+ })++ expect(harness.posts).toEqual([+ {+ source: 'dsh-frame-log-bridge',+ type: 'dsh://frame-log',+ level: 'error',+ message: expect.stringContaining(+ '/settings [uncaught] http://127.0.0.1:3080/assets/index.js:12:3 TypeError: x is not a function',+ ),+ },+ ])+ })++ it('reports an unhandled promise rejection with its reason', () => {+ const harness = createHarness()++ harness.fireWindowEvent('unhandledrejection', { reason: new Error('nope') })++ expect(harness.posts).toHaveLength(1)+ expect(harness.posts[0].level).toBe('error')+ expect(harness.posts[0].message.startsWith('[unhandledrejection] Error: nope')).toBe(true)+ })++ it('serializes an Error argument with its stack', () => {+ const harness = createHarness()++ harness.console.error(new Error('kaboom'))++ expect(harness.posts[0].message).toContain('Error: kaboom')+ expect(harness.posts[0].message).toContain('frame-log.test.ts')+ })++ it('relays a nested frame entry up to the host window', () => {+ const harness = createHarness()+ const entry: FrameLogEntry = {+ source: 'dsh-frame-log-bridge',+ type: 'dsh://frame-log',+ level: 'error',+ message: '/panel boom',+ }++ harness.fireMessage(entry, {})++ expect(harness.posts).toEqual([entry])+ })++ it('does not relay an entry that already came from the host window', () => {+ const harness = createHarness()++ harness.fireMessage(+ { source: 'dsh-frame-log-bridge', type: 'dsh://frame-log', level: 'error', message: 'echo' },+ harness.parent,+ )++ expect(harness.posts).toEqual([])+ })++ it('limits a console.error storm and reports the suppressed count', () => {+ vi.useFakeTimers()+ const harness = createHarness()++ for (let index = 0; index < 30; index += 1)+ harness.console.error(`storm ${index}`)+ expect(harness.posts).toHaveLength(20)++ vi.advanceTimersByTime(1_000)+ harness.console.error('after storm')++ expect(harness.posts).toHaveLength(22)+ expect(harness.posts[20].message).toBe('10 frame log entries suppressed')+ expect(harness.posts[21].message).toBe('after storm')+ })++ it('truncates an oversized frame log entry and marks it', () => {+ const harness = createHarness()++ harness.console.error('x'.repeat(5_000))++ expect(harness.posts[0].message.length).toBeLessThanOrEqual(2_012)+ expect(harness.posts[0].message.endsWith('…[truncated]')).toBe(true)+ })++ it('taps the frame console only once when the script is injected twice', () => {+ const harness = createHarness({ injections: 2 })++ harness.console.error('once')++ expect(harness.posts).toHaveLength(1)+ expect(harness.calls.error).toBe(1)+ })+})++/**+ * 宿主侧协议契约:注入脚本与 `iframe.tsx` 是两个独立产物,字面量与匹配方式必须锁在一起,+ * 否则「帧内日志」会静默消失(运行日志里重新只剩壳层前台日志)。+ */+describe('frame log host contract', () => {+ const iframe = readFileSync(+ new URL('../src/layout/components/iframe.tsx', import.meta.url),+ 'utf8',+ )++ it('dispatches the bridge type the injected script publishes', () => {+ expect(iframe).toContain(`case 'dsh://frame-log'`)+ })++ it('writes frame entries to the frontdesk log under the iframe target', () => {+ expect(iframe).toContain(`invoke('log_frontend', { level, target: 'iframe'`)+ })++ it('downgrades every frame level except error to warn', () => {+ expect(iframe).toContain(`data.level === 'error' ? 'error' : 'warn'`)+ })+})