Open in browser regression coverage and shell-safe serve launch
Problem
The March 16, 2026 openInBrowser() fix corrected the broken port and project-dir behavior, but it still left two quality gaps. First, the tests only cover buildServeUrl() as a pure helper, so the actual openInBrowser() flow can regress without test failures if terminal launch, workspace-folder resolution, or delayed browser open behavior changes. Second, the terminal command still depends on shell interpolation for the project directory path, which is avoidable and makes path handling more fragile than necessary. Both gaps sit directly on the IDE extension's preview-to-browser workflow, so they should be closed with a narrow follow-up patch and regression coverage.
Context
apps/ide/vscode-extension/src/preview/preview-manager.tsowns theopenInBrowser()behavior for launchingdft serveand opening the rendered dashboard URL.apps/ide/vscode-extension/src/preview/preview-manager.test.tsalready uses Vitest and mocks the VS Code surface, so it is the right place to extend coverage to the real browser-open flow.dft servedefaults to port9876, and the correct usage for this extension is to serve a project root and open the dashboard route derived from the current document path.- VS Code terminal creation supports passing
cwdvia terminal options, which lets the extension avoid embedding the project directory path directly in the shell command string.
Possible Solutions
- Keep testing only
buildServeUrl()and leave shell interpolation in place. This is the smallest change, but it does not cover the actual regression surface and leaves brittle command construction untouched. - Add a helper for quoting shell arguments and keep passing
projectDirinside the command string. This improves quoting somewhat, but it still relies on shell parsing and is more complex than necessary across terminal environments. - Recommended: update
openInBrowser()to create the terminal withcwd: projectDirand rundft serve --project-dir ., then add end-to-end unit tests that verify terminal creation, command text, workspace fallback behavior, and delayed browser open. This removes the avoidableprojectDirshell interpolation risk while testing the real behavior that matters.
Plan
- Patch
openInBrowser()inapps/ide/vscode-extension/src/preview/preview-manager.tsto use terminalcwdinstead of interpolatingprojectDirinto the command string. - Extend
apps/ide/vscode-extension/src/preview/preview-manager.test.tswith focused tests that exercise the fullopenInBrowser()flow using mocked VS Code APIs and fake timers. - Run the extension unit tests for
preview-manager.test.ts, then update this task with implementation notes and validation results.
Implementation Progress
- Created follow-up task after reviewing merged commit
b3e0e2adade7d97dfaba305059ab71eabb408bf0/ PR#594. - Confirmed the original fix is valid and that the two remaining gaps are test coverage scope and avoidable shell interpolation of
projectDir. - Updated
openInBrowser()to set the terminalcwdto the resolved project directory and launchdft serve --project-dir .. - Added regression tests that verify terminal creation options, command text, browser URL opening, and fallback behavior when no workspace folder exists.
just task validate tasks/workstreams/ide-extension/tasks/open-in-browser-regression-coverage-and-shell-safe-serve-launch.mdpassed.npm run test:unit -- src/preview/preview-manager.test.tsandnpm run compileare currently blocked by the local Homebrew Node installation missinglibsimdjson.29.dylib, so TypeScript and Vitest could not be executed in this environment.- Rebased the follow-up branch onto
origin/mainand resolved the expected conflict with merged PR#594by keeping the upstream URL helper changes and retaining the safer terminalcwdlaunch plus the newopenInBrowser()tests. scripts/pr-validate prenow gets through rebase and repo CI startup, but fails in an unrelated docs check:tests/docs/test_tasks_build.py::test_tasks_mkdocs_builds_in_strict_modedue toTemplateNotFound: 'chat/_suggestions.html'intasks/workstreams/mcp-analyst-agent/tasks/chat-first-home-page-conversational-ai-interface-for-dataface-cloud.md.- Fixed the unrelated docs blocker by replacing the live Jinja include snippet in
tasks/workstreams/mcp-analyst-agent/tasks/chat-first-home-page-conversational-ai-interface-for-dataface-cloud.mdwith plain prose, then reranscripts/pr-validate presuccessfully. uv run --project libs/cbox cbox reviewapproved the branch with one low-severity recommendation to add a null-CLI-path test, but no blocking issues.
Review Feedback
-
uv run --project libs/cbox cbox reviewapproved the branch. Notes: low-severity recommendation to add an explicitcliPath === nulltest; not required for approval. -
[x] Review cleared