Skip to content

refactor: small cleanups extracted from #96 prep work#124

Merged
pgherveou merged 7 commits into
mainfrom
refactor/extract-cleanup-from-issue-96
May 27, 2026
Merged

refactor: small cleanups extracted from #96 prep work#124
pgherveou merged 7 commits into
mainfrom
refactor/extract-cleanup-from-issue-96

Conversation

@pgherveou
Copy link
Copy Markdown
Collaborator

@pgherveou pgherveou commented May 20, 2026

No description provided.

pgherveou added 4 commits May 20, 2026 21:21
Three independently-mergeable cleanups identified while preparing the
Rust core runtime port (#96):

- `truapi/transport.ts`: extract a module-level `toError(unknown): Error`
  helper and use it at the three sites that hand-rolled the same
  `error instanceof Error ? error : new Error(String(error))` coercion.

- `truapi-codegen::MethodKind`: derive `Clone` and `Copy` so the enum
  can be passed through helpers without re-matching. Trivial additive
  change; the variants are bare.

- `rust/crates/truapi/README.md`: drop the spurious `v02` mention from
  the bulleted module list. The table below it (and the rest of the
  document) only mentions `v01`; the prose was out of date.
- Don't introduce typealias chains that just rename a type from another
  crate; use the canonical name directly. A typealias should capture a
  real abstraction, not just a rename.
- After any code change, update README.md (and CLAUDE.md if the layout
  changed) so the top-level docs match the repo. Stale docs are a
  regression.
- In codegen emitters, prefer indoc::writedoc! / formatdoc! over chains
  of writeln!. Multi-line raw strings keep the emitted shape visible in
  source instead of fragmenting it.
- In PR descriptions, issue comments, and other artifacts that outlive
  the conversation, describe the resulting state, not the transition
  between commits. "Previously X, now Y" framing reads as ephemeral
  history once the PR is squash-merged.
Permission request enums are surfaced to host UIs through the prompt
flow, where they need human-readable rendering. The versioned wrappers
and the inner v01 enums now implement Display through `derive_more`:

- `v01::HostDevicePermissionRequest` formats each variant with a short
  label ("camera", "open URL", "NFC", ...).
- `v01::RemotePermission` formats `Remote { domains }` as
  "access to <comma-separated sorted list>" and each named variant with
  its own phrase ("submit chain transactions", "WebRTC connections",
  ...).
- `v01::RemotePermissionRequest` formats the `permissions` vec joined
  with "; ".
- The versioned wrappers `HostDevicePermissionRequest` and
  `RemotePermissionRequest` forward through `{_0}` so callers can format
  either layer.

Internal `DisplayDomains` and `DisplayPermissions` adapters write
straight into the `Formatter`, avoiding the intermediate `Vec<String>` +
`join` allocations a `format_*` helper would incur.

The `versioned_type!` macro is extended to thread outer enum and inner
variant `#[meta]` attributes so the `derive(Display)` lands on the
generated code.
Drop the DisplayDomains helper and call domains.join(", ") directly
from the #[display] template.
@socket-security
Copy link
Copy Markdown

socket-security Bot commented May 25, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedcargo/​derive_more@​2.1.110010093100100

View full report

@pgherveou pgherveou marked this pull request as ready for review May 26, 2026 15:44
@pgherveou pgherveou requested a review from a team May 26, 2026 15:44
Copy link
Copy Markdown
Collaborator

@filvecchiato filvecchiato left a comment

Choose a reason for hiding this comment

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

LGTM

@pgherveou pgherveou merged commit 99f7d6b into main May 27, 2026
10 checks passed
@pgherveou pgherveou deleted the refactor/extract-cleanup-from-issue-96 branch May 27, 2026 07:47
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.

2 participants