Skip to content

DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.

Revert "fix(shell): expose recovery state and iframe watchdog diagnostics (#1…" (#1089)

Hairy8119ec2b174a
diff --git a/src/i18n/locales/en-US.json b/src/i18n/locales/en-US.json
index 99bbdd94..3b1952ab 100644
--- a/src/i18n/locales/en-US.json
+++ b/src/i18n/locales/en-US.json
@@ -15,9 +15,6 @@
"status.loading_internal": "Loading internal plugins…",
"status.loading_process": "Starting Harness…",
"status.loading_client_modules": "Waiting for Harness…",
- "status.service_restarting": "Restarting the Harness service; waiting for readiness…",
- "status.service_waiting": "The Harness service is not ready yet…",
- "status.document_waiting": "The service passed its readiness check; waiting for the embedded page to respond…",
"status.internal_waiting": "Waiting to check internal plugins.",
"status.internal_checking": "Checking {{total}} internal plugins.",
"status.internal_installing": "Installing {{total}} internal plugins.",
diff --git a/src/i18n/locales/zh-CN.json b/src/i18n/locales/zh-CN.json
index 03eb6768..4d658abb 100644
--- a/src/i18n/locales/zh-CN.json
+++ b/src/i18n/locales/zh-CN.json
@@ -15,9 +15,6 @@
"status.loading_internal": "Loading internal plugins…",
"status.loading_process": "Starting Harness…",
"status.loading_client_modules": "Waiting for Harness…",
- "status.service_restarting": "正在重启 Harness 服务,等待就绪…",
- "status.service_waiting": "Harness 服务尚未就绪…",
- "status.document_waiting": "服务已通过就绪检查,等待内嵌页面响应…",
"status.internal_waiting": "Waiting for internal plugins…",
"status.internal_checking": "Checking {{total}} internal plugins…",
"status.internal_installing": "Installing {{total}} internal plugins…",
diff --git a/src/layout/components/iframe.test.tsx b/src/layout/components/iframe.test.tsx
deleted file mode 100644
index 6948ced0..00000000
--- a/src/layout/components/iframe.test.tsx
+++ /dev/null
@@ -1,104 +0,0 @@
-// @vitest-environment jsdom
-import { act, cleanup, render, screen } from '@testing-library/react'
-import { createRef } from 'react'
-import { afterEach, beforeEach, expect, it, vi } from 'vitest'
-import { store } from '@/store'
-import { Iframe } from './iframe'
-
-vi.mock('@choochmeque/tauri-plugin-notifications-api', () => ({}))
-vi.mock('@overlastic/react', () => ({ useOverlay: () => vi.fn() }))
-vi.mock('@/ui/dialog/config', () => ({ ConfigDialog: () => null }))
-vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key: string) => key }) }))
-vi.mock('@/hooks/use-dsh-style', () => ({ useDshStyle: () => [{}, vi.fn()] }))
-vi.mock('@/hooks/use-invoke-iframe', () => ({ useInvokeIframe: vi.fn() }))
-vi.mock('@/hooks/use-notification-action', () => ({ useNotificationAction: vi.fn() }))
-vi.mock('@/hooks/use-notification-clicked', () => ({ useNotificationClicked: vi.fn() }))
-vi.mock('@/hooks/use-sync-visibility', () => ({ useSyncVisibility: vi.fn() }))
-vi.mock('@/hooks/use-zoom-factor', () => ({ useZoomFactor: vi.fn() }))
-
-beforeEach(() => {
- vi.useFakeTimers()
- vi.spyOn(console, 'warn').mockImplementation(() => {})
- Object.assign(store.harness, {
- status: 'ready',
- serviceHealthy: false,
- serviceRunning: true,
- busyAction: 'restart',
- iframeKey: 1077,
- iframeAliveKey: null,
- iframeLoaded: false,
- iframeError: false,
- iframeSrc: 'http://127.0.0.1:3081/?token=secret',
- })
-})
-
-afterEach(async () => {
- cleanup()
- store.harness.serviceHealthy = false
- await vi.advanceTimersByTimeAsync(0)
- vi.useRealTimers()
- vi.restoreAllMocks()
-})
-
-it('distinguishes service restart, unhealthy service and embedded document waiting on the existing fallback', async () => {
- const view = render(<Iframe iframeRef={createRef()} />)
- expect(screen.getByRole('status').textContent).toBe('status.service_restarting')
- expect(screen.queryByTestId('dsh-shell-iframe')).toBeNull()
- expect(console.warn).toHaveBeenCalledWith('[Iframe] view', expect.objectContaining({
- branch: 'service-wait',
- serviceHealthy: false,
- serviceRunning: true,
- iframeKey: 1077,
- }))
- view.rerender(<Iframe iframeRef={createRef()} />)
- expect(vi.mocked(console.warn).mock.calls.filter(([tag]) => tag === '[Iframe] view')).toHaveLength(1)
-
- await act(async () => {
- store.harness.busyAction = null
- })
- expect(screen.getByRole('status').textContent).toBe('status.service_waiting')
- await act(async () => {
- store.harness.serviceHealthy = true
- })
- const frame = screen.getByTestId<HTMLIFrameElement>('dsh-shell-iframe')
- expect(screen.getByRole('status').textContent).toBe('status.document_waiting')
- expect(console.warn).toHaveBeenCalledWith('[Iframe] view', expect.objectContaining({ branch: 'document-wait', iframeAlive: false }))
-
- await act(async () => {
- store.harness.markIframeAlive()
- })
- expect(screen.queryByRole('status')).toBeNull()
- expect(screen.getByTestId('dsh-shell-iframe')).toBe(frame)
- await act(async () => {
- store.harness.markIframeError()
- })
- expect(screen.getByText('ui.iframe_error')).not.toBeNull()
- expect(console.warn).toHaveBeenCalledWith('[Iframe] view', expect.objectContaining({ branch: 'iframe-error', iframeError: true }))
- expect(JSON.stringify(vi.mocked(console.warn).mock.calls)).not.toContain('secret')
-})
-
-it('diagnoses remote frame visibility across local health and error transitions without changing it', async () => {
- render(<Iframe iframeRef={createRef()} srcOverride="https://example.test/?token=secret" />)
- expect(screen.getByTestId('dsh-shell-iframe').getAttribute('src')).toBe('https://example.test/?token=secret')
- expect(screen.queryByRole('status')).toBeNull()
- expect(console.warn).toHaveBeenCalledWith('[Iframe] view', expect.objectContaining({ branch: 'remote-loading', remoteMode: true, serviceHealthy: false, iframeHidden: true }))
- const frame = screen.getByTestId<HTMLIFrameElement>('dsh-shell-iframe')
- await act(async () => {
- frame.dispatchEvent(new Event('load'))
- })
- expect(frame.style.visibility).toBe('visible')
- expect(console.warn).toHaveBeenCalledWith('[Iframe] view', expect.objectContaining({ branch: 'remote-frame', iframeHidden: false }))
- await act(async () => {
- store.harness.serviceHealthy = true
- store.harness.markIframeError()
- })
- expect(frame.style.visibility).toBe('hidden')
- expect(screen.queryByText('ui.iframe_error')).toBeNull()
- expect(console.warn).toHaveBeenLastCalledWith('[Iframe] view', expect.objectContaining({
- branch: 'remote-frame',
- serviceHealthy: true,
- iframeError: true,
- iframeHidden: true,
- }))
- expect(JSON.stringify(vi.mocked(console.warn).mock.calls)).not.toContain('secret')
-})
diff --git a/src/layout/components/iframe.tsx b/src/layout/components/iframe.tsx
index 15df842d..006d674c 100644
--- a/src/layout/components/iframe.tsx
+++ b/src/layout/components/iframe.tsx
@@ -227,30 +227,6 @@ export function Iframe({ iframeRef, srcOverride = null, borderTint = null }: Ifr
const post = useIframePost(iframeRef)
// 握手兜底:帧内接收器异常时不能让 iframe 永久藏住,超时后按「未确认」直接揭开。
const appearancePending = translucent && bootFrame !== frameKey
- const iframeHidden = appearancePending || remoteLoading || harness.showIframeError
- const mounted = remoteMode || harness.serviceHealthy
- const showIframeError = !remoteMode && harness.showIframeError
- const documentWaiting = !remoteMode && mounted && !harness.iframeAlive && !showIframeError && !appearancePending
- const serviceStatusKey = harness.busyAction === 'restart' ? 'status.service_restarting' : 'status.service_waiting'
- const branch = !mounted ? 'service-wait' : showIframeError ? 'iframe-error' : remoteLoading ? 'remote-loading' : appearancePending ? 'appearance-wait' : documentWaiting ? 'document-wait' : remoteMode ? 'remote-frame' : 'local-frame'
- useWatch([branch, harness.status, remoteMode, harness.serviceHealthy, harness.serviceRunning, harness.iframeKey, harness.iframeLoaded, harness.iframeAlive, harness.iframeError, harness.startupPhase, harness.busyAction, appearancePending, documentWaiting, iframeHidden], () => {
- console.warn('[Iframe] view', {
- branch,
- status: harness.status,
- remoteMode,
- serviceHealthy: harness.serviceHealthy,
- serviceRunning: harness.serviceRunning,
- iframeKey: harness.iframeKey,
- iframeLoaded: harness.iframeLoaded,
- iframeAlive: harness.iframeAlive,
- iframeError: harness.iframeError,
- startupPhase: harness.startupPhase,
- busyAction: harness.busyAction,
- appearancePending,
- documentWaiting,
- iframeHidden,
- })
- }, { immediate: true })
const { start: armAppearanceFallback, stop: stopAppearanceFallback } = useTimeoutFn(
() => setBootFrame(frameKey),
APPEARANCE_HANDSHAKE_TIMEOUT,
@@ -605,12 +581,8 @@ export function Iframe({ iframeRef, srcOverride = null, borderTint = null }: Ifr
return (
<div className="relative min-h-0 flex-1">
<If
- cond={mounted}
- else={(
- <Loadable subtitle={t(harness.startupStatusKey)}>
- <p role="status" className="text-xs leading-[18px] text-load-muted">{t(serviceStatusKey)}</p>
- </Loadable>
- )}
+ cond={remoteMode || harness.serviceHealthy}
+ else={<Loadable subtitle={t(harness.startupStatusKey)} />}
>
<iframe
key={remoteMode ? `remote-${srcOverride}` : harness.iframeKey}
@@ -620,7 +592,7 @@ export function Iframe({ iframeRef, srcOverride = null, borderTint = null }: Ifr
// 未确认收到启动期外观前先藏起来:帧内 boot 页(HARNESS + Loading plugins…)
// 会先按不透明画一帧,露出那一下比等待更刺眼。上面的 Loadable 与之逐项同构,
// 揭开时视觉无跳变,且有 4s 兜底不会永久藏住。
- style={{ visibility: iframeHidden ? 'hidden' : 'visible' }}
+ style={{ visibility: appearancePending || remoteLoading || harness.showIframeError ? 'hidden' : 'visible' }}
src={remoteMode ? srcOverride : harness.iframeSrc}
allow="accelerometer; ambient-light-sensor; autoplay; battery; camera; clipboard-read; clipboard-write; display-capture; document-domain; encrypted-media; fullscreen; gamepad; geolocation; gyroscope; hid; idle-detection; keyboard-map; magnetometer; microphone; midi; payment; picture-in-picture; publickey-credentials-get; screen-wake-lock; serial; speaker-selection; usb; web-share; xr-spatial-tracking"
sandbox="allow-same-origin allow-scripts allow-popups allow-forms allow-modals allow-downloads allow-storage-access-by-user-activation"
@@ -634,12 +606,6 @@ export function Iframe({ iframeRef, srcOverride = null, borderTint = null }: Ifr
/>
</If>
- <If cond={documentWaiting}>
- <p role="status" className="absolute bottom-4 inset-x-4 text-center text-xs leading-[18px] text-load-muted pointer-events-none">
- {t('status.document_waiting')}
- </p>
- </If>
-
{/* 远端机器勾选「边框着色」时,用标识色给内容区描边:当前处于远端一眼可辨 */}
<If cond={borderTint !== null}>
<div
diff --git a/src/layout/components/webview.test.tsx b/src/layout/components/webview.test.tsx
index aaf368a9..39b1bfaa 100644
--- a/src/layout/components/webview.test.tsx
+++ b/src/layout/components/webview.test.tsx
@@ -9,15 +9,13 @@ const mocks = vi.hoisted(() => ({
navbar: vi.fn<(props: NavbarProps) => void>(),
shortcuts: { rows: [] },
setShortcuts: vi.fn(),
- harness: { status: 'ready', serviceHealthy: true, serviceRunning: true, iframeKey: 0, iframeLoaded: false, iframeAlive: false, iframeError: false, startupPhase: 'process-boot', busyAction: null },
- recovery: { recovery: { required: false } },
}))
vi.mock('@tauri-apps/api/window', () => ({ getCurrentWindow: () => ({ label: 'window-2' }) }))
vi.mock('@tauri-apps/plugin-os', () => ({ type: () => 'windows' }))
vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key: string) => key }) }))
vi.mock('valtio-define', () => ({ useStore: (value: unknown) => value }))
-vi.mock('@/store', () => ({ store: { harness: mocks.harness, recovery: mocks.recovery } }))
+vi.mock('@/store', () => ({ store: { harness: { status: 'ready', serviceHealthy: true }, recovery: {} } }))
vi.mock('@/hooks/use-appearance', () => ({ useAppearance: () => '' }))
vi.mock('@/hooks/use-dsh-style', () => ({ useDshStyle: () => [{}] }))
vi.mock('@/hooks/use-dsh-shortcuts', () => ({
@@ -42,39 +40,6 @@ vi.mock('./iframe', () => ({
}))
vi.mock('./loadable', () => ({ Loadable: () => <div data-testid="session-pending" /> }))
-it('logs the selected shell branch and deduplicates unrelated rerenders without exposing remote URLs', () => {
- window.location.hash = ''
- const view = render(<Webview />)
- expect(console.warn).toHaveBeenLastCalledWith('[Webview] shell view', expect.objectContaining({
- branch: 'iframe',
- status: 'ready',
- remoteMode: false,
- serviceHealthy: true,
- iframeKey: 0,
- iframeLoaded: false,
- iframeAlive: false,
- iframeError: false,
- }))
- view.rerender(<Webview />)
- expect(console.warn).toHaveBeenCalledTimes(1)
- mocks.harness.status = 'error'
- view.rerender(<Webview />)
- expect(console.warn).toHaveBeenLastCalledWith('[Webview] shell view', expect.objectContaining({ branch: 'setup' }))
- mocks.recovery.recovery.required = true
- view.rerender(<Webview />)
- expect(console.warn).toHaveBeenLastCalledWith('[Webview] shell view', expect.objectContaining({ branch: 'recovery' }))
- mocks.harness.status = 'preinstall'
- view.rerender(<Webview />)
- expect(console.warn).toHaveBeenLastCalledWith('[Webview] shell view', expect.objectContaining({ branch: 'preinstall' }))
- mocks.harness.status = 'ready'
- mocks.harness.serviceHealthy = false
- view.rerender(<Webview />)
- act(() => navbar().onRemoteChange('https://example.test/?token=secret', null))
- expect(console.warn).toHaveBeenLastCalledWith('[Webview] shell view', expect.objectContaining({ branch: 'iframe', remoteMode: true, serviceHealthy: false }))
- expect(JSON.stringify(vi.mocked(console.warn).mock.calls)).not.toContain('secret')
- expect(console.warn).toHaveBeenCalledTimes(6)
-})
-
function navbar() {
return mocks.navbar.mock.lastCall![0]
}
@@ -92,9 +57,6 @@ function acknowledge(frame: HTMLIFrameElement, sessionId: string) {
beforeEach(() => {
vi.useFakeTimers()
window.location.hash = new URLSearchParams({ sessionId: 'target', iframeUrl: 'http://127.0.0.1:4001/' }).toString()
- Object.assign(mocks.harness, { status: 'ready', serviceHealthy: true })
- mocks.recovery.recovery.required = false
- vi.spyOn(console, 'warn').mockImplementation(() => {})
mocks.navbar.mockClear()
mocks.setShortcuts.mockClear()
})
diff --git a/src/layout/components/webview.tsx b/src/layout/components/webview.tsx
index 56c7f4ab..ead921af 100644
--- a/src/layout/components/webview.tsx
+++ b/src/layout/components/webview.tsx
@@ -49,7 +49,7 @@ export function Webview() {
const [dshStyle] = useDshStyle()
const [{ rows: shortcutRows }, setDshShortcuts] = useDshShortcuts()
- const { status, serviceHealthy, serviceRunning, iframeKey, iframeLoaded, iframeAlive, iframeError, startupPhase, busyAction } = useStore(store.harness)
+ const { status, serviceHealthy } = useStore(store.harness)
const { recovery } = useStore(store.recovery)
const [remoteView, setRemoteView] = useState({ url: '', tint: null as string | null })
const [sessionSource, setSessionSource] = useState(sessionTarget?.url ?? '')
@@ -57,24 +57,6 @@ export function Webview() {
const borderTint = remoteView.tint
const remoteMode = activeTunnelUrl !== ''
const live = status === 'ready' && (remoteMode || serviceHealthy)
- const branch = status === 'ready' ? 'iframe' : status === 'preinstall' ? 'preinstall' : status === 'error' && recovery.required ? 'recovery' : 'setup'
- useWatch([branch, status, remoteMode, serviceHealthy, serviceRunning, iframeKey, iframeLoaded, iframeAlive, iframeError, startupPhase, busyAction, sessionPending, Boolean(sessionError)], () => {
- console.warn('[Webview] shell view', {
- branch,
- status,
- remoteMode,
- serviceHealthy,
- serviceRunning,
- iframeKey,
- iframeLoaded,
- iframeAlive,
- iframeError,
- startupPhase,
- busyAction,
- sessionPending,
- sessionError: Boolean(sessionError),
- })
- }, { immediate: true })
function syncViewMenu() {
if (type() !== 'macos')
diff --git a/src/store/modules/harness/store.ts b/src/store/modules/harness/store.ts
index ca540a77..cc282f09 100644
--- a/src/store/modules/harness/store.ts
+++ b/src/store/modules/harness/store.ts
@@ -939,18 +939,8 @@ let iframeWatch: { loaded: boolean, timer: ReturnType<typeof setTimeout> } | nul
harness.$subscribe(() => {
const { status, serviceHealthy, iframeLoaded, iframeError } = harness.$state
const watching = status === 'ready' && serviceHealthy && !harness.iframeAlive && !iframeError
- const context = {
- status,
- serviceHealthy,
- serviceRunning: harness.serviceRunning,
- iframeKey: harness.iframeKey,
- iframeLoaded,
- iframeAlive: harness.iframeAlive,
- iframeError,
- }
if (!watching) {
if (iframeWatch) {
- console.warn('[Harness] iframe watchdog cancelled', context)
clearTimeout(iframeWatch.timer)
iframeWatch = null
}
@@ -963,24 +953,13 @@ harness.$subscribe(() => {
if (iframeWatch) {
clearTimeout(iframeWatch.timer)
}
- const timeoutMs = iframeLoaded ? IFRAME_FRAME_GRACE_TIMEOUT : IFRAME_LOAD_TIMEOUT
- console.warn('[Harness] iframe watchdog armed', { ...context, timeoutMs })
iframeWatch = {
loaded: iframeLoaded,
timer: setTimeout(() => {
iframeWatch = null
- console.warn('[Harness] iframe watchdog expired', {
- status: harness.status,
- serviceHealthy: harness.serviceHealthy,
- serviceRunning: harness.serviceRunning,
- iframeKey: harness.iframeKey,
- iframeLoaded: harness.iframeLoaded,
- iframeAlive: harness.iframeAlive,
- iframeError: harness.iframeError,
- timeoutMs,
- })
+ console.warn('[Harness] iframe never confirmed a dsh document, showing retryable error')
harness.iframeLoaded = false
harness.iframeError = true
- }, timeoutMs),
+ }, iframeLoaded ? IFRAME_FRAME_GRACE_TIMEOUT : IFRAME_LOAD_TIMEOUT),
}
})
diff --git a/test/iframe-watchdog.test.ts b/test/iframe-watchdog.test.ts
index 79a5bdc7..ab3bd051 100644
--- a/test/iframe-watchdog.test.ts
+++ b/test/iframe-watchdog.test.ts
@@ -54,63 +54,11 @@ beforeEach(async () => {
await mountIframe({ serviceHealthy: false, iframeLoaded: true, iframeError: true })
})
-afterEach(async () => {
- harness.serviceHealthy = false
- await vi.advanceTimersByTimeAsync(0)
+afterEach(() => {
vi.useRealTimers()
- vi.restoreAllMocks()
})
describe('iframe dsh document watchdog', () => {
- it('logs arm, load rearm and expiry once with the current recovery flags', async () => {
- const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
- await mountIframe({ iframeKey: 1077 })
- const context = {
- status: 'ready',
- serviceRunning: true,
- serviceHealthy: true,
- iframeKey: 1077,
- iframeAlive: false,
- iframeLoaded: false,
- iframeError: false,
- }
- expect(warn).toHaveBeenCalledWith('[Harness] iframe watchdog armed', { ...context, timeoutMs: 20000 })
- harness.startupReason = 'unrelated activity'
- await vi.advanceTimersByTimeAsync(0)
- expect(warn).toHaveBeenCalledTimes(1)
-
- harness.markIframeLoaded()
- await vi.advanceTimersByTimeAsync(0)
- expect(warn).toHaveBeenLastCalledWith('[Harness] iframe watchdog armed', { ...context, iframeLoaded: true, timeoutMs: 5000 })
- expect(warn).toHaveBeenCalledTimes(2)
- await vi.advanceTimersByTimeAsync(4999)
- expect(harness.iframeError).toBe(false)
- await vi.advanceTimersByTimeAsync(1)
- expect(warn).toHaveBeenLastCalledWith('[Harness] iframe watchdog expired', { ...context, iframeLoaded: true, timeoutMs: 5000 })
- expect(harness.showIframeError).toBe(true)
- expect(warn).toHaveBeenCalledTimes(3)
- })
-
- it.each(['alive', 'unhealthy', 'error'] as const)('logs cancellation when the frame becomes %s without changing the deadline', async (reason) => {
- const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
- await mountIframe()
- if (reason === 'alive')
- harness.markIframeAlive()
- else if (reason === 'unhealthy')
- harness.serviceHealthy = false
- else
- harness.fail('startup failure', undefined, undefined, undefined, true)
- await vi.advanceTimersByTimeAsync(0)
- expect(warn).toHaveBeenLastCalledWith('[Harness] iframe watchdog cancelled', expect.objectContaining({
- status: reason === 'error' ? 'error' : 'ready',
- serviceHealthy: reason !== 'unhealthy',
- iframeAlive: reason === 'alive',
- }))
- expect(warn).toHaveBeenCalledTimes(2)
- await vi.advanceTimersByTimeAsync(20000)
- expect(harness.iframeError).toBe(false)
- })
-
// issue #705:浏览器内部错误页(代理拦截、DNS 失败等)同样触发 iframe 的 load,
// 只按 load 判定就会把它当成加载成功,用户看不到任何重试入口。
it('shows the retryable error screen when the frame commits a document but never reports a dsh page', async () => {
@@ -218,15 +166,6 @@ describe('iframe dsh document watchdog', () => {
})
describe('iframe unreachable i18n contract', () => {
- it('defines distinct service and document waiting messages in both locales', () => {
- for (const file of ['zh-CN.json', 'en-US.json'] as const) {
- const messages = locale(file)
- const values = ['status.service_restarting', 'status.service_waiting', 'status.document_waiting'].map(key => messages[key])
- expect(values.every(value => typeof value === 'string' && value.length > 0)).toBe(true)
- expect(new Set(values).size).toBe(3)
- }
- })
-
it('defines the unreachable hint in both locales', () => {
expect(locale('zh-CN.json')['ui.iframe_unreachable_hint']).toBeTypeOf('string')
expect(locale('en-US.json')['ui.iframe_unreachable_hint']).toBeTypeOf('string')