Skip to content

fix: address PR review comments for dev server initialization#36

Open
Jeshua Ben Joseph (Theaxiom) wants to merge 2 commits intomainfrom
feat-dev-server-hmr-17194680974801638956
Open

fix: address PR review comments for dev server initialization#36
Jeshua Ben Joseph (Theaxiom) wants to merge 2 commits intomainfrom
feat-dev-server-hmr-17194680974801638956

Conversation

@Theaxiom
Copy link
Copy Markdown
Member

  • Wrapped filter_map closure in a future returning construct for tokio streams.
  • Explicitly handle serde_json::to_string serialization errors without returning empty payload strings.
  • Replaced the watcher blocking_send logic with non-blocking try_send.
  • Expanded watcher target directories to include app/ and public/ directories from the standard structure scaffold.
  • Bound server configuration host to 127.0.0.1 by default and added CLI argument.
  • Extracted tokio-stream to workspace global dependencies.

- Wrapped `filter_map` closure in a future returning construct for tokio streams.
- Explicitly handle `serde_json::to_string` serialization errors without returning empty payload strings.
- Replaced the watcher `blocking_send` logic with non-blocking `try_send`.
- Expanded watcher target directories to include `app/` and `public/` directories from the standard structure scaffold.
- Bound server configuration host to `127.0.0.1` by default and added CLI argument.
- Extracted `tokio-stream` to workspace global dependencies.

Co-authored-by: Theaxiom <57013+Theaxiom@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 30, 2026 00:44
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves dev server initialization by wiring up a basic file-watching + SSE-based HMR notification path, exposing dev server host configuration through the CLI, and aligning dependencies to support tokio stream wrappers.

Changes:

  • Added an axum SSE endpoint and broadcast-channel-based HMR message plumbing.
  • Implemented dev server startup that watches common source directories and triggers reload events.
  • Added --host CLI argument and moved tokio-stream into workspace dependencies.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
runtime/src/dev/hot_reload.rs Introduces HMR state, message types, and an SSE endpoint/router.
runtime/src/dev/dev_server.rs Implements dev server config + startup, file watching, and runs app/studio servers concurrently.
runtime/Cargo.toml Updates runtime crate dependencies for new HMR/dev server functionality.
foundry/client/src/migrate/analyzer.rs Refactors process.env detection match arms for clarity.
cli/src/commands/dev.rs Adds --host and delegates to forge-runtime dev server with a config object.
Cargo.toml Adds tokio-stream to workspace dependencies.
Cargo.lock Lockfile updates reflecting new/changed dependency resolution.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread runtime/src/dev/hot_reload.rs Outdated
Comment on lines +63 to +67
pub fn hmr_router(state: HmrState) -> Router {
Router::new()
.route("/_forge/hmr", get(hmr_endpoint))
.with_state(state)
}
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

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

hmr_router returns axum::Router without a state type parameter, but the body calls .with_state(state) which produces a Router<HmrState> in axum 0.8. This will not type-check; change the return type to Router<HmrState> (or otherwise ensure the returned router’s state type matches the value passed to with_state).

Copilot uses AI. Check for mistakes.
Comment thread runtime/Cargo.toml Outdated
camino = { workspace = true }
bytes = { workspace = true }
futures = { workspace = true }
futures.workspace = true
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

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

futures.workspace = true uses the dotted workspace-dependency shorthand, but the rest of the workspace consistently uses { workspace = true } in crate Cargo.toml files. For consistency (and to avoid style churn), switch this back to futures = { workspace = true }.

Suggested change
futures.workspace = true
futures = { workspace = true }

Copilot uses AI. Check for mistakes.
Comment thread runtime/Cargo.toml Outdated
uuid = { workspace = true }
deno_core = { workspace = true }
tokio-stream = { workspace = true }
futures-util = "0.3.32"
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

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

futures-util is pinned to a specific version in this crate while most third-party deps are sourced via [workspace.dependencies]. This can introduce duplicate futures-* versions across the workspace. Consider removing this direct dependency (since futures re-exports StreamExt), or add futures-util to [workspace.dependencies] and reference it with { workspace = true } here.

Suggested change
futures-util = "0.3.32"

Copilot uses AI. Check for mistakes.
@Theaxiom
Copy link
Copy Markdown
Member Author

Copilot apply changes based on the comments in this thread and also resolve merge conflicts.

…7194680974801638956

# Conflicts:
#	cli/src/commands/dev.rs
#	foundry/client/src/migrate/analyzer.rs
#	runtime/Cargo.toml
#	runtime/src/dev/dev_server.rs
#	runtime/src/dev/hot_reload.rs

Co-authored-by: Theaxiom <57013+Theaxiom@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 30, 2026

Copilot apply changes based on the comments in this thread and also resolve merge conflicts.

Applied all three review fixes in commit ac196ec and resolved the merge conflicts with main:

  • hot_reload.rs: Changed hmr_router return type from Router to Router<()>. Also pulled in use tokio_stream::StreamExt from main, replacing futures::StreamExt::filter_map(...) with idiomatic method-call syntax while keeping the explicit serialization error handling (no unwrap_or_default).
  • runtime/Cargo.toml: Fixed futures.workspace = truefutures = { workspace = true }. Removed futures-util = "0.3.32" entirely — StreamExt now comes from tokio_stream directly. Changed tokio-stream to a direct pinned dep ({ version = "0.1.18", features = ["sync"] }) matching main's approach after tokio-stream was removed from workspace.
  • Merge conflicts: Resolved in cli/src/commands/dev.rs, runtime/src/dev/dev_server.rs, foundry/client/src/migrate/analyzer.rs. Kept our improvements (host field, try_send, multi-dir watching) while incorporating main's refactors.

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.

3 participants