Skip to content

fix(desktop): fix connection screen IPC on Windows + add uninstall button#3000

Merged
houko merged 1 commit into
mainfrom
fix/desktop-connection-screen-ipc
Apr 23, 2026
Merged

fix(desktop): fix connection screen IPC on Windows + add uninstall button#3000
houko merged 1 commit into
mainfrom
fix/desktop-connection-screen-ipc

Conversation

@houko

@houko houko commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • TDZ crash on Windows: The connection screen is injected via about:blank + document.write(). The top-level const { invoke } = window.__TAURI__.core triggered a Temporal Dead Zone error on WebView2 because Tauri v2 initializes its IPC asynchronously. Fixed by moving the access into a lazy tauriInvoke() wrapper.
  • Test Connection / Connect buttons silently broken: withGlobalTauri defaults to false in Tauri v2, so window.__TAURI__.core is never populated. Fixed by enabling withGlobalTauri: true in tauri.conf.json, plus a waitForTauri() polling guard (8 s timeout) to handle any remaining async-init races.
  • Uninstall button: Added an "Uninstall LibreFang" button to the connection screen with per-platform handling:
    • Windows — reads UninstallString from the NSIS registry key via reg query and runs it
    • macOS — walks up to the .app bundle and moves it to Trash via osascript + Finder
    • Linux / AppImage — detects the APPIMAGE env var and deletes the binary directly
    • Linux / system package — returns the appropriate package manager uninstall command as a hint

Changed files

  • crates/librefang-desktop/tauri.conf.json — enable withGlobalTauri: true
  • crates/librefang-desktop/src/connection.rs — lazy IPC wrapper, waitForTauri polling, uninstall button HTML/JS
  • crates/librefang-desktop/src/commands.rsuninstall_app Tauri command (all three platforms)
  • crates/librefang-desktop/src/lib.rs — register uninstall_app in the invoke handler

Test plan

  • Windows: connection screen loads; Test Connection and Connect work with a custom URL
  • Windows: Start Local Server no longer crashes with a TDZ / ReferenceError
  • Windows: Uninstall button shows a confirm dialog then launches the NSIS uninstaller
  • macOS: Uninstall button moves the .app bundle to Trash
  • Linux AppImage: Uninstall button removes the AppImage binary

…tton

Three issues fixed in the connection screen:

1. **TDZ crash on Start Local Server (Windows)**
   Top-level `const { invoke } = window.__TAURI__.core` in the injected
   about:blank page hit a Temporal Dead Zone error because Tauri v2 IPC
   initializes asynchronously on WebView2. Fixed by moving invoke access
   into a lazy `tauriInvoke()` wrapper.

2. **Test Connection / Connect buttons silently broken**
   Root cause: `withGlobalTauri` defaults to `false` in Tauri v2, so
   `window.__TAURI__.core` is never populated. Fixed by enabling
   `withGlobalTauri: true` in tauri.conf.json. Also added a polling
   `waitForTauri()` guard (8 s timeout) to survive any remaining
   async-init races on about:blank pages.

3. **Uninstall button**
   Added "Uninstall LibreFang" button to the connection screen:
   - Windows: reads UninstallString from NSIS registry via `reg query`
   - macOS: moves .app bundle to Trash via osascript + Finder
   - Linux/AppImage: deletes the AppImage binary directly
   - Linux/system package: returns the distro-specific uninstall hint
@github-actions github-actions Bot added size/M 50-249 lines changed ready-for-review PR is ready for maintainer review labels Apr 23, 2026
@houko
houko merged commit 8e4c6a7 into main Apr 23, 2026
19 of 23 checks passed
@houko
houko deleted the fix/desktop-connection-screen-ipc branch April 23, 2026 01:55
@github-actions github-actions Bot removed the ready-for-review PR is ready for maintainer review label Apr 23, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7ca52712fc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

"identifier": "ai.librefang.desktop",
"build": {},
"app": {
"withGlobalTauri": true,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep global Tauri API disabled for remote dashboards

Enabling withGlobalTauri here injects window.__TAURI__ into pages loaded in the main webview, including remote URLs reached through connect_remote (crates/librefang-desktop/src/connection.rs). This crate only defines capabilities/default.json and no app-command ACL manifest, so Tauri does not enforce app-command ACL for those commands; a remote/compromised dashboard can invoke desktop commands like start_local, install_update, and the new uninstall_app. This is a privilege boundary regression for remote mode and should be fixed by keeping global injection off (or adding explicit app ACL + remote-origin restrictions and a safer bridge just for the connection screen).

Useful? React with 👍 / 👎.

houko added a commit that referenced this pull request Apr 26, 2026
PR review caught 1 stale-doc contradiction + 7 undocumented behaviour
changes from the fix-PR cohort.

- #3114 — configuration/core: 'api_key empty = unauthenticated' was
  stale; now documents the loopback-only policy (non-loopback bypass
  was closed)
- #3170 — features/observability: auto_start is opt-in; home_dir-
  scoped Docker labels; RAII cleanup
- #2989 — api/agents POST /message: per-request session_id override
- #3048 — Interrupting a Running Agent Turn: /stop cascades into
  agent_send subagents (recursive)
- #3056 + #3000 — desktop: dedicated Connection screen via custom
  URI scheme with retry / open-in-browser / uninstall
- #2952 — triggers: response routes to agent's home channel
- #2955 — triggers: task_posted assignee_match = 'self' | 'any'
- #3069 — providers/local: 60-second reprobe + manual 'Test
  connection' refresh

All sections mirrored in docs/src/app/zh/.
houko added a commit that referenced this pull request Apr 26, 2026
…pi / observability (#3189)

* docs(providers): add Novita / SearXHG / Bedrock entries

* docs(config): document [parallel_tools] section + max_history_messages

* docs(scheduler): cron multi-delivery + pre_script + silent_marker

* docs: live context.md, chat attachments, CLI slash commands

Salvages three of the six items from the (quota-killed) misc-features
agent run. Each is a focused append, no rewrite of existing content.

- agent/templates: live Live Context section explains the per-turn
  re-read of `context.md` (#3115), the .identity/ vs root path lookup,
  the 32 KB cap with stale-cache fallback, and the cache_context opt-out.
- integrations/api/agents: attachment-resolution table (image / PDF /
  text+code) covering the supported MIME / extension list and the
  200 KB truncation, plus a note about adjacent-text coalescing for
  small chat-tuned local models (#3094).
- integrations/cli/commands: 'Slash Commands in Chat' section listing
  the registry-backed CLI commands (/model /status /help /clear /kill
  /exit) and pointing at channel-side commands for the broader set
  (#3122 #3123).

* docs: tool invoke API, trajectory export, doctor audit, CLI default-pick, SDK codegen

Picks up the items the second misc-features agent didn't get to before
hitting the org quota.

- integrations/api/system: POST /api/tools/{name}/invoke (#3025) — fail-
  closed allowlist, agent_id requirement for approval-gated tools.
- integrations/api/agents: GET /sessions/{id}/trajectory (#3097) —
  json/jsonl formats, redactor pipeline, audit use case.
- operations/troubleshooting: 'Audit checks' subsection enumerating the
  three registered AuditChecks (#3082) — VaultKey, ApiListenAddr,
  ConfigTomlSchema — with what each asserts and how to extend.
- configuration/providers/tools: 'CLI logins as first-class default
  providers' section (#3061) — detection priority claude-code > codex-
  cli > gemini-cli > qwen-code, override via [default_model] in
  config.toml.
- integrations/sdk: 'Auto-generated from openapi.json' section (#3046) —
  scripts/codegen-sdks.py, pre-commit hook, openai-tag skip rule.

* docs(zh): mirror providers / config-core / cron / features-index sections

* docs(zh): mirror agent / api / cli / providers-tools / troubleshooting / sdk additions

Round 2 of the zh translation pass — picks up the seven mid-priority
files that the first commit didn't cover. All sections mirror the EN
content from #3189 but read naturally as Chinese (terms like agent /
session / fallback / NoEntry left in English where they're API
surface, prose translated to 中文).

- agent/templates: Live Context section, .identity/ vs root fallback,
  cache_context = true opt-out.
- api/agents: attachment-resolution table + trajectory export endpoint
  (#3025 / #3094 / #3097).
- api/system: POST /api/tools/{name}/invoke endpoint + fail-closed
  allowlist explanation.
- cli/commands: 'Slash Commands in Chat' section listing CLI registry
  commands and pointing at channel commands.
- providers/tools: 'CLI logins as first-class default providers'
  detection priority and override.
- troubleshooting: 'Audit checks' subsection + table.
- sdk: 'Auto-generated from openapi.json' section.

* docs: refresh /new slash-command semantics (#3071 review fix)

PR review on #3189 (houko) caught two stale references describing the
pre-#3071 behavior of /new ('wipe the session' / 'clear history'). The
new semantics fork off a fresh session while the previous one stays
resumable on the same channel — phrasing updated in 4 places (en + zh
× 2 files), plus a one-line clarifier in the slash-command roster
section so the cross-reference doesn't silently inherit the old
mental model:

- configuration/channels: 'wipe the session' → 'fork off into a new
  session (the prior conversation stays resumable on the channel)'
- integrations/api/realtime: '(clear history)' → 'forks into a fresh
  session — the prior session is preserved and remains resumable'
- integrations/cli/commands roster paragraph: explicit note that /new
  is a fork, not a wipe.

Same wording mirrored to docs/src/app/zh/.

* docs(channels): 9 channel-related Apr 22-25 PRs (en + zh)

Covers the channel + bridge feature wave:
- #3020 per-agent ChannelOverrides — fixes the contradicting 'without
  modifying the agent manifest' phrasing in both en and zh.
- #3077 prefix_agent_name + Signal plain-text default
- #3009 Slack reactions_enabled + #3005 Feishu @mention preservation
  consolidated into a 'Reactions and Processing State' section
- #3008 Signal media attachments
- #3012 WhatsApp send_voice + dm_policy / group_policy
- #3011 Webhook deliver_only mode
- #2972 channel file downloads (file_download_dir / max_bytes config)

* docs(config-core): provider timeout / browser CDP / cron session caps (en + zh)

Three new `config.toml` sections that landed Apr 22-23:
- #3004 `[provider_request_timeout_secs]` map
- #2993 / #2991 `[browser].cdp_endpoint` + `cdp_auth_token_env`
- #2994 `[kernel].cron_session_max_tokens` / `cron_session_max_messages`

* docs(api): GET /attach + Owner Notice envelope (en + zh)

- #3078 SSE attach endpoint for multi-client co-watching — describes
  the per-session SessionStreamHub fan-out, attacher behaviour, and
  the curl example.
- #2965 ReplyEnvelope.owner_notice + notify_owner tool — message body
  field, StreamEvent variant, WhatsApp OWNER_JIDS fan-out.

* docs(observability + ops): Tempo stack, cache_hit_ratio metric, daemon log tee (en + zh)

- #3064 + #3149 — bundled observability stack (otel-collector / Tempo
  / Grafana), bring-up commands, [telemetry] config, business spans,
  cache_hit_ratio metric formula and where it surfaces
- #3022 — `librefang start --foreground` now tees logs to
  ~/.librefang/logs/daemon-YYYY-MM-DD.log; same-day append; 7-day
  rotation pruned on daemon start

* docs: hooks transform / lazy tools / mcp taint / capability detection / providers extras

Final batch of catch-up docs covering the remaining Apr 22-25 user-facing
features:

- agent/hooks: transform_tool_result hook contract (#3003)
- agent/templates: tool_search / tool_load lazy loading + lazy_tools
  opt-out (#3047)
- integrations/mcp-a2a: TaintRuleId enum + per-tool skip_rules policy
  (#2999)
- configuration/features: compaction summaries in user's conversation
  language (#3007)
- configuration/providers/local: embedding auto-detection priority
  list (#3099) + Ollama capability detection (Modality / metadata
  pipeline, #3074 / #3133 / #3134 / #3140)
- configuration/providers/management: custom image-gen provider via
  generic OpenAI-compat driver (#2998) + Moonshot file-upload helper
  via /v1/files (#2966)

All sections mirrored to docs/src/app/zh/.

* docs: address houko fix-PR audit (8 items, en + zh)

PR review caught 1 stale-doc contradiction + 7 undocumented behaviour
changes from the fix-PR cohort.

- #3114 — configuration/core: 'api_key empty = unauthenticated' was
  stale; now documents the loopback-only policy (non-loopback bypass
  was closed)
- #3170 — features/observability: auto_start is opt-in; home_dir-
  scoped Docker labels; RAII cleanup
- #2989 — api/agents POST /message: per-request session_id override
- #3048 — Interrupting a Running Agent Turn: /stop cascades into
  agent_send subagents (recursive)
- #3056 + #3000 — desktop: dedicated Connection screen via custom
  URI scheme with retry / open-in-browser / uninstall
- #2952 — triggers: response routes to agent's home channel
- #2955 — triggers: task_posted assignee_match = 'self' | 'any'
- #3069 — providers/local: 60-second reprobe + manual 'Test
  connection' refresh

All sections mirrored in docs/src/app/zh/.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M 50-249 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant