Skip to content

fix: prevent stale markdown preview cache in app://md-preview protoco…#2387

Draft
dushyant-hada-90 wants to merge 5 commits into
AgentWrapper:mainfrom
dushyant-hada-90:fix/markdown-preview-cache
Draft

fix: prevent stale markdown preview cache in app://md-preview protoco…#2387
dushyant-hada-90 wants to merge 5 commits into
AgentWrapper:mainfrom
dushyant-hada-90:fix/markdown-preview-cache

Conversation

@dushyant-hada-90

Copy link
Copy Markdown
Contributor

…l handler

Add Cache-Control: no-cache, no-store, must-revalidate headers to the app://md-preview protocol handler response so Chromium does not cache the rendered HTML. When the file-backed markdown changes, the chokidar watcher updates the cached HTML in MarkdownHost and emits md:fileChanged; the renderer calls reload(), which re-requests the URL. Without cache prevention headers, Chromium served the stale cached copy instead of re-invoking the protocol handler for the updated HTML.

…l handler

Add Cache-Control: no-cache, no-store, must-revalidate headers to the
app://md-preview protocol handler response so Chromium does not cache
the rendered HTML. When the file-backed markdown changes, the chokidar
watcher updates the cached HTML in MarkdownHost and emits md:fileChanged;
the renderer calls reload(), which re-requests the URL. Without cache
prevention headers, Chromium served the stale cached copy instead of
re-invoking the protocol handler for the updated HTML.
…mon proxy URL file watching

The markdown auto-refresh failed for daemon-proxied URLs because:
1. Chromium cached the app://md-preview response (Cache-Control fix already deployed)
2. Daemon proxy URLs (http://host/api/v1/sessions/<id>/preview/files/<entry>)
   bypassed chokidar watchers since resolveLocalPath() only handled file://

Fix:
- Backend: sessionView() populates WorkspacePath from SessionMetadata
- API: SessionView DTO + regenerated OpenAPI spec + TypeScript types
- Frontend: workspacePath flows SessionView → BrowserPanel → useBrowserView
  → preload → markdownHost.render() → resolveLocalPath()
- markdown-host.ts: parseDaemonProxyEntry() extracts entry from proxy URL and
  resolves it against workspacePath with directory traversal guard
- Test: removed negative assertion for workspacePath leak (now curated field)
…roaden BrowserPanel path normalization

- Replace httpFetch() with native fetch() — simpler, standard, no extra deps
- Add tryLocalFile() fallback for UNC/drive-letter paths that fail fileURLToPath
- Guard file:// URLs from reaching fetch() to avoid ERR_INVALID_PROTOCOL
- Broaden BrowserPanel path normalization to handle UNC (\\host) and
  Windows drive-letter (C:\) paths
- Remove md_implementation.md from git tracking (internal reference doc,
  not intended for remote)
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