Skip to content

fix(webui): native Windows folder picker and rail project refresh - #77

Merged
Fectivnfy112357 merged 3 commits into
mainfrom
fix/windows-native-folder-picker-dsh
Nov 27, 2026
Merged

Fectivnfy112357 merged 3 commits into
mainfrom
fix/windows-native-folder-picker-dsh

Conversation

@July-X

@July-X July-X commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Change

Three WebUI fixes from the Windows desktop flow:

  • Windows folder picker — the installed provider from Fix Windows project folder selection and verify the installed user flow #75 compiled, but it ran as a separate PowerShell/C# helper and did not reliably activate its dialog when the server was started in the background. This replaces it with a short-lived koffi worker that owns the modal IFileOpenDialog, sets per-monitor DPI awareness, and presses Alt immediately before Show so the dialog activates in front. The worker reports over IPC and is killed/awaited on abort. The PowerShell picker is removed.
  • Rail project refresh — the rail reads the visible project list once when it mounts. Creating a session in a new directory refreshed the session catalogue but not the project records, so the new project appeared only after a page reload. The creation completion path now refreshes the project list; a project read failure remains retryable and does not undo the created session.
  • Desktop host grant handoff — WEBUI_DESKTOP_HOST=1 marks a locally hosted page that embeds the WebUI; WEBUI_LAUNCH_URL_FILE=<absolute path> names a private file. Once the listener is up, the launcher writes the page URL with its #nativeDirectoryGrant fragment to that file atomically, with 0600 access on POSIX (Windows keeps the file under the user-profile ACL), and never logs it. The host opens that URL in its own page, so the existing captureNativeDirectoryLaunchGrant pairing completes. Ordinary launches still require an interactive TTY; WEBUI_DESKTOP_HOST=1 is the explicit opt-in for a local embedded launch. WEBUI_OPEN_BROWSER=0 only suppresses the system browser and never disqualifies the picker. SSH, full access and non-loopback binds remain excluded.

The native-directory route is deliberately unchanged: loopback, Host, Origin, Sec-Fetch-Site, cookie, grant and browserKey checks all stay in force. The grant remains one-time and is only useful to the page that opens it; this change does not relax the boundary to token-only. A handoff write failure is logged without the URL, and the host falls back to the printed bare URL. The package declares koffi 3.1.1 (MIT), and the install/acceptance paths include it.

Validation

  • node --test test/source-sync.test.mjs — 75 tests, 72 passed, 3 skipped, 0 failed.
  • pnpm exec vitest run --config vitest.oss.config.mjs packages/webui/test/unit/task-session-workflows.test.ts — 24/24 passed.
  • pnpm --filter @mavis/webui typecheck:client — passed.
  • pnpm build:webui — passed.
  • node scripts/source-inventory.mjs — passed.
  • Manual Windows handoff: started with WEBUI_DESKTOP_HOST=1, WEBUI_LAUNCH_URL_FILE=<absolute path>, WEBUI_OPEN_BROWSER=0 and no TTY. The file was created with no trailing newline and only the URL (token plus #nativeDirectoryGrant); the grant did not appear in stdout or logs, and the URL opened from the file.
  • NOT RUN: the native dialog's cancel and select interactions were not re-driven after the handoff change; they are pending a manual click in the opened page. A fresh end-to-end click-through of the rail refresh is also pending; the refresh path is covered by the focused unit test. Full pnpm verify was not run.
  • Performance: no performance-sensitive path; the automatic basic check applies.

Publication and contribution checks

  • I have permission to contribute these changes under the existing licenses applicable to the changed files/packages; imported material and its provenance are identified and existing notices are preserved.
  • No credentials, account data, real user content, internal source history or private review material is included.
  • Added/removed source files were reviewed before regenerating release/public-source.json; new tests are declared in test/vitest-suites.json where applicable.
  • Shared English/Chinese documentation and capability/verification records are updated where applicable. Mock/offline results are not described as live-service acceptance.

Maintainer handoff

Publication scope or license changes: koffi 3.1.1 (MIT) is added to the WebUI npm package for the Windows dialog.

Shared-source port: not needed.

Replace the PowerShell/C# picker with a short-lived koffi worker that owns the modal IFileOpenDialog. The worker presses Alt immediately before Show so a dialog spawned by a background server still activates in front, and reports the selected path over IPC.

Eligibility no longer depends on a TTY or WEBUI_OPEN_BROWSER: a local desktop loopback launch can create the picker. Add koffi to the package, update the installed-app acceptance driver, tests and install docs, and remove the PowerShell picker.
The rail reads the visible project list once when it mounts. Creating a session in a new directory refreshed the session catalogue but not the project records, so the new project appeared only after a page reload.

Refresh the project list on the creation completion path. A project read failure stays retryable and does not undo the created session.
@July-X July-X added the bug Something isn't working label Nov 27, 2026
The native-directory grant still authorizes only the page that loads its one-time URL. A local desktop host that embeds the page cannot rely on the system browser opening that URL, so the launcher can now write the URL to an owner-only file when WEBUI_DESKTOP_HOST=1 and WEBUI_LAUNCH_URL_FILE is set. The file is written atomically after the listener starts, is never logged, and contains only the URL. A write failure is reported and the host falls back to the printed bare URL.

Eligibility keeps the ordinary TTY requirement; WEBUI_DESKTOP_HOST opts a local embedded launch out of it. WEBUI_OPEN_BROWSER only gates the system browser, never the picker. SSH, full access, and non-loopback binds remain excluded, and the HTTP route's grant/cookie/browserKey checks are unchanged.
@Fectivnfy112357
Fectivnfy112357 merged commit b99bae8 into main Nov 27, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants