Generate TypeScript types from Rust IPC structs and add command constants#94
Generate TypeScript types from Rust IPC structs and add command constants#94
Conversation
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.
There was a problem hiding this comment.
💡 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, }; |
There was a problem hiding this comment.
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 👍 / 👎.
What does this PR do?
Adds compile-time type safety between the Rust backend and JS frontend:
#[derive(TS)] #[ts(export)]on 31 IPC-facing structs across conch_remote and conch_taurifrontend/types/viacargo testfrontend/commands.jscreated with all 58 command names (COMMANDS) and 21 event names (EVENTS) as constantsTypes exported include:
PtyOutputEvent,ThemeColors,TerminalDisplayConfig,VaultStatusResponse,AccountResponse,FileEntry,ServerEntry,TransferProgress,PanelInfo,PluginMenuItem,UpdateInfo, and 20 more.Type of change
Testing
Notes for reviewer
cargo test— they should be committed so frontend devs can import themcommands.jsis manually maintained — keep in sync when adding new Tauri commands