5 Commits
Author SHA1 Message Date
John CostaandJonathan Kelley cb5abb48dd fix(cli): display user-specified address in serve output (#5481)
* fix(cli): display user-specified address in serve output

When running `dx serve --addr 0.0.0.0`, the CLI was overriding the
displayed address to 127.0.0.1. This was confusing for users who
explicitly chose 0.0.0.0 and expected the output to reflect their
choice. The default (127.0.0.1) is unchanged when no --addr flag is
given.

Fixes #5477

* fix(cli): resolve actual network IP when bound to 0.0.0.0

Instead of showing the unroutable 0.0.0.0, use the UDP socket trick
to resolve the machine's primary network address for a clickable URL.
Falls back to 127.0.0.1 when resolution fails (no network, etc).

* style: apply rustfmt to test function calls

* fit longer urls in tui frame

* space

---------

Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
2026-04-14 16:52:43 -07:00
John Costa 45442af41d fix(server): don't redirect error responses from #[get] server functions (#5429)
The post-handler redirect logic was unconditionally converting responses
to 302 Found when the request had Accept: text/html and a Referer header.
This overwrote error status codes (4xx, 5xx), making it impossible to
return errors from #[get] endpoints accessed via browser navigation.

Add a response.status().is_success() guard so only successful responses
get the Post/Redirect/Get treatment.

Fixes #5428
2026-03-30 18:46:48 -07:00
John CostaandJonathan Kelley e5b9c39f4e fix(autofmt): remove extra whitespace before commas in for-loop tuple patterns (#5384)
* fix(autofmt): remove extra whitespace before commas in for-loop tuple patterns

`dx fmt` was adding spaces before commas in for-loop destructuring
patterns (e.g. `for (index , name , value)`) because `TokenStream::Display`
inserts spaces between every token. Route the pattern through prettyplease
via a new `unparse_pat` helper, following the existing `unparse_expr` pattern.

Fixes #5348

* style: apply rustfmt to writer.rs

---------

Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
2026-03-27 17:15:32 -07:00
John Costa cece12b57e docs: clarify difference between use_context and consume_context (#5406)
* docs: clarify difference between use_context and consume_context

Document the key distinction: use_context is a hook that captures the
context value once on first render and caches it, following the rules
of hooks. consume_context reads directly from the runtime each time
and can be called from anywhere (event handlers, async tasks, etc.).

Fixes #3862

* fix: remove redundant explicit rustdoc link targets

* fix: use plain text for cross-crate use_context reference in rustdoc
2026-03-24 08:10:13 -05:00
John CostaandEvan Almloff b7958d3d17 feat(signals): add WritableResultExt trait (#5338)
* feat(signals): add WritableResultExt trait

Add WritableResultExt mirroring the existing ReadableResultExt,
providing mutable access to signal values holding Result<T, E>.

Methods:
- as_mut(): returns Result<WritableRef<T>, WritableRef<E>>
- unwrap_mut(): returns WritableRef<T>, panics if Err

Closes #5293

* refactor(signals): use descriptive expect messages in WritableResultExt::as_mut

Replace bare .unwrap() calls with .expect() containing a descriptive
message about the failure mode. This gives better diagnostics if the
Result variant changes between the read and write lock acquisitions.

* switch to a single write to avoid race conditions with sync signals

---------

Co-authored-by: Evan Almloff <evanalmloff@gmail.com>
2026-03-09 14:10:15 -07:00