Skip to content

feat(core): add unified API layer with Tauri invoke for desktop tools#26

Merged
YueMiyuki merged 6 commits intomainfrom
dev
Jan 20, 2026
Merged

feat(core): add unified API layer with Tauri invoke for desktop tools#26
YueMiyuki merged 6 commits intomainfrom
dev

Conversation

@YueMiyuki
Copy link
Owner

@YueMiyuki YueMiyuki commented Jan 20, 2026


Summary by cubic

Adds a unified API layer that uses Tauri commands in the desktop app and a fetch fallback in web preview. Network tools now use native sockets via Tauri, fixing CORS issues and enabling reliable TCP/UDP, port scanning, and certificate checks.

  • New Features

    • Unified API layer (lib/api.ts, lib/tauri.ts) with Tauri invoke routing.
    • New Tauri commands: cert_check, http_proxy, whistle; removed Next.js /api/whistle.
    • Tools updated to use the unified API: TCP/UDP Whistle, Port Detective, SSL Toothbrush, Curl Converter.
    • Desktop-only guard with an AlertDialog when not running in Tauri.
    • Graceful app termination using @tauri-apps/plugin-process.
    • Added AlertDialog UI component and i18n strings; expanded Tauri capabilities and config.
  • Migration

    • Run pnpm install to add new deps (@radix-ui/react-alert-dialog, @tauri-apps/plugin-process).
    • Rebuild the Tauri app; tools that use sockets (Whistle, Port Detective) work only in the desktop app.
    • Update any code referencing /api/whistle to use lib/api.whistle().

Written for commit d42531d. Summary will update on new commits.

Summary by CodeRabbit

  • New Features

    • Desktop-only: certificate inspector, HTTP proxy, and TCP/UDP tooling available in the desktop app; web preview shows a notice and disables those actions.
    • App termination uses the native exit path in desktop builds.
  • New Components

    • Reusable alert dialog added; button variants exported for consistent UI.
  • Refactor

    • Frontend unified API layer for cert/proxy/whistle interactions across runtimes.
  • Chores

    • Version bump, dependency/script updates, capability and build config updates, and new multilingual desktop-only notices with an OK label.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link

vercel bot commented Jan 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
devutils Ready Ready Preview, Comment Jan 20, 2026 0:49am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 20, 2026

Caution

Review failed

The pull request is closed.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Moves proxy/whistle/cert-check logic from Next.js routes into Tauri native commands, adds a runtime-aware frontend API shim, introduces desktop-only guards and AlertDialog UI, removes the Next.js whistle route, and updates frontend components, deps, and Tauri config accordingly.

Changes

Cohort / File(s) Summary
Tauri native commands & Rust impl
src-tauri/src/lib.rs
Adds cert_check, http_proxy, whistle commands with TLS/certificate parsing, HTTP proxying, and TCP/UDP whistle implementations; large new logic and data structures.
Tauri config & deps
src-tauri/Cargo.toml, src-tauri/tauri.conf.json, src-tauri/capabilities/*
Adds many Rust deps (reqwest, x509-parser, tls libs, etc.), updates capabilities (adds main.json, removes default.json), adjusts CSP and permissions.
Frontend runtime API shim
lib/api.ts, lib/tauri.ts
New environment-aware APIs: certCheck, httpProxy, whistle, plus isTauri and invokeCommand helpers; delegates to Tauri invoke or web fallbacks.
Removed Next.js route
app/api/whistle/route.ts
Full removal of the whistle route (functionality migrated to Tauri).
Frontend components & usage updates
components/tools/tcp-udp-whistle.tsx, components/tools/ssl-toothbrush.tsx, components/tools/curl-converter.tsx, app/page.tsx
Replace direct fetch calls with lib/api functions, refactor listen loop and send flows, use Tauri plugin for exit in app/page.tsx, adjust types and control flow.
Desktop-only guards & dialogs
components/tools/port-detective.tsx, components/tools/tcp-udp-whistle.tsx
Add isTauri checks, useEffect to show AlertDialog when not desktop, disable/guard desktop-only actions and early-return on non-desktop.
New UI primitive & button export
components/ui/alert-dialog.tsx, components/ui/button.tsx
New Radix-based AlertDialog composite component and re-export of buttonVariants.
I18n updates
messages/en.json, messages/zh.json, messages/zh-TW.json
Add desktopOnly warning strings for impacted tools and common.ok label.
Build/editor & CI tweaks
.vscode/settings.json, package.json, .prettierignore, .github/workflows/tauri-build.yml
Add TS SDK path, bump version, add clean script, add deps (@radix-ui/react-alert-dialog, @tauri-apps/plugin-process), update prettier ignore and CI caching steps.

Sequence Diagram(s)

sequenceDiagram
    participant UI as Frontend Component
    participant API as lib/api.ts
    participant Env as lib/tauri.ts
    participant Tauri as Tauri Runtime
    participant Web as Web API Route

    UI->>API: certCheck({host, port, cert_pem})
    API->>Env: isTauri()
    Env-->>API: boolean
    alt Tauri environment
        API->>Tauri: invokeCommand("cert_check", args)
        Tauri-->>API: CertificatePayload
    else Web environment
        API->>Web: POST /api/cert-check
        Web-->>API: CertificatePayload
    end
    API-->>UI: CertificatePayload
Loading
sequenceDiagram
    participant UI as Frontend Component
    participant API as lib/api.ts
    participant Env as lib/tauri.ts
    participant Tauri as Tauri Runtime
    participant Web as Web API Route

    UI->>API: httpProxy({InputUrl, method, headers, body})
    API->>Env: isTauri()
    Env-->>API: boolean
    alt Tauri environment
        API->>Tauri: invokeCommand("http_proxy", request)
        Tauri-->>API: ProxyResponse
    else Web environment
        API->>Web: POST /api/proxy
        Web-->>API: ProxyResponse
    end
    API-->>UI: ProxyResponse
Loading
sequenceDiagram
    participant UI as Frontend Component
    participant API as lib/api.ts
    participant Env as lib/tauri.ts
    participant Tauri as Tauri Runtime
    participant Cmd as Tauri whistle command

    UI->>API: whistle({mode, host, port, payload...})
    API->>Env: isTauri()
    Env-->>API: boolean
    alt Tauri environment
        API->>Tauri: invokeCommand("whistle", request)
        Tauri->>Cmd: whistle handler (tcp/udp send/listen)
        Cmd-->>API: WhistleResponse
    else
        API-->>UI: throw "not available"
    end
    API-->>UI: WhistleResponse
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~65 minutes

Possibly related PRs

Poem

🐰 I hopped from route to native land,
I learned to call the Tauri hand.
When web can't whisper, dialogs say nay,
Sockets, certs, and proxies find a new way.
Thump-thump — the rabbit celebrates today!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.89% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat(core): add unified API layer with Tauri invoke for desktop tools' accurately describes the main change: introducing a unified API abstraction that uses Tauri invoke for desktop environments while maintaining web fallbacks.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot]

This comment was marked as resolved.

cubic-dev-ai[bot]

This comment was marked as resolved.

cubic-dev-ai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

@YueMiyuki YueMiyuki merged commit 5face1d into main Jan 20, 2026
11 of 12 checks passed
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