Skip to content

Generate TypeScript types from Rust IPC structs and add command constants#94

Open
an0nn30 wants to merge 1 commit intomainfrom
feat/ts-type-generation
Open

Generate TypeScript types from Rust IPC structs and add command constants#94
an0nn30 wants to merge 1 commit intomainfrom
feat/ts-type-generation

Conversation

@an0nn30
Copy link
Copy Markdown
Owner

@an0nn30 an0nn30 commented Mar 28, 2026

What does this PR do?

Adds compile-time type safety between the Rust backend and JS frontend:

  1. ts-rs v12 added to workspace — #[derive(TS)] #[ts(export)] on 31 IPC-facing structs across conch_remote and conch_tauri
  2. 33 TypeScript files generated in frontend/types/ via cargo test
  3. frontend/commands.js created with all 58 command names (COMMANDS) and 21 event names (EVENTS) as constants

Types exported include: PtyOutputEvent, ThemeColors, TerminalDisplayConfig, VaultStatusResponse, AccountResponse, FileEntry, ServerEntry, TransferProgress, PanelInfo, PluginMenuItem, UpdateInfo, and 20 more.

Type of change

  • New feature

Testing

  • Builds without errors
  • All 223 tests pass (includes auto-generated ts-rs export tests)
  • No regressions

Notes for reviewer

  • TypeScript files are auto-generated by cargo test — they should be committed so frontend devs can import them
  • commands.js is manually maintained — keep in sync when adding new Tauri commands
  • No function signatures or behavior changed

Add ts-rs v12 to workspace dependencies with serde-compat, uuid-impl,
and serde-json-impl features. Derive TS on all Serialize structs and
enums that cross the Rust/frontend IPC boundary:

- conch_remote: FileEntry, ReadFileResult, ServerEntry, ServerFolder,
  SavedTunnel, ExportPayload, TransferKind, TransferStatus,
  TransferProgress, TunnelStatus, TunnelInfo
- conch_tauri: PtyOutputEvent, PtyExitEvent, ThemeColors,
  TerminalDisplayConfig, KeyboardShortcuts, SavedLayout,
  MenuActionEvent, SaveSettingsResult, VaultStatusResponse,
  AccountResponse, KeyGenResponse, GeneratedKeyResponse,
  UpdateInfo, DownloadProgress, PanelInfo, PluginMenuItem,
  DiscoveredPlugin, ServerListResponse, ActiveSession,
  TunnelWithStatus

Configure TS_RS_EXPORT_DIR in .cargo/config.toml to output generated
.ts files to crates/conch_tauri/frontend/types/ when running cargo test.

Add frontend/commands.js with COMMANDS and EVENTS constants mapping all
tauri::command function names and event string literals.
Copy link
Copy Markdown

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

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: 9f6590d949

ℹ️ 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".

import type { TransferKind } from "./TransferKind";
import type { TransferStatus } from "./TransferStatus";

export type TransferProgress = { transfer_id: string, kind: TransferKind, status: TransferStatus, bytes_transferred: bigint, total_bytes: bigint, file_name: string, error: string | null, };
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Use number for IPC byte counters in generated TS types

The generated IPC type uses bigint for transfer counters, but the frontend currently treats these payload fields as JavaScript numbers (for example, files-panel.js does Math.round((p.bytes_transferred / p.total_bytes) * 100) and other Number arithmetic). If consumers start importing this type, TypeScript will push bigint-based handling that does not match the existing runtime shape and can trigger runtime errors when mixed with Number APIs. Please align these exported fields with the actual IPC representation (e.g., map to number consistently, or stringify explicitly end-to-end).

Useful? React with 👍 / 👎.

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