Show loading state when VIP link is unavailable and fix error handling#122
Conversation
Co-authored-by: Yashb404 <139128977+Yashb404@users.noreply.github.com>
Co-authored-by: Yashb404 <139128977+Yashb404@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR improves the “Share / Embed” modal UX by showing a helpful loading/message state when the VIP link (embed_key) hasn’t been generated yet, instead of rendering an empty input. It also includes broad formatting/import reordering changes across the client UI.
Changes:
- Add conditional rendering in the VIP link section to show a “being generated” message when
vip_linkis empty. - Reformat/reorder imports and adjust whitespace across many Leptos page/component files (rustfmt-style cleanup).
- Minor request/closure formatting changes in several pages/components touched by the formatting sweep.
Reviewed changes
Copilot reviewed 15 out of 18 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| client/src/types.rs | Formatting cleanup only. |
| client/src/pages/view.rs | Import/formatting cleanup; still sets vip_link empty when embed_key missing. |
| client/src/pages/policy.rs | Import/formatting cleanup. |
| client/src/pages/home.rs | Import/formatting cleanup. |
| client/src/pages/embed.rs | Import/formatting cleanup. |
| client/src/pages/docs.rs | Import/formatting cleanup. |
| client/src/pages/dashboard.rs | Formatting + touched auth/projects loading logic (see comments). |
| client/src/pages/create.rs | Formatting; spawn error handling currently overloads container_id (see comments). |
| client/src/pages/blogs.rs | Import/formatting cleanup. |
| client/src/pages/analytics.rs | Import/formatting cleanup. |
| client/src/pages/admin.rs | Import/formatting cleanup. |
| client/src/lib.rs | Module ordering/formatting cleanup. |
| client/src/components/terminal.rs | Import/formatting cleanup. |
| client/src/components/protected.rs | Import/formatting cleanup. |
| client/src/components/modal.rs | Functional change: VIP link empty state now shows a centered message instead of empty input. |
| client/src/components/limit.rs | Formatting cleanup. |
| client/src/app.rs | Import formatting cleanup. |
| client/src/api.rs | Comment whitespace cleanup. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if resp.ok() { | ||
| if let Ok(u) = resp.json::<User>().await { | ||
| // user authenticated | ||
| set_user.set(Some(u.clone())); | ||
|
|
||
| let proj_url = format!("{}/api/my-projects", api_base()); | ||
| let projects_req = Request::get(&proj_url) | ||
| .credentials(RequestCredentials::Include) | ||
| .send() | ||
| .await; | ||
| let proj_url = format!("{}/api/my-projects", api_base()); |
There was a problem hiding this comment.
In the auth resource, if resp.ok() is true but resp.json::<User>().await fails, set_loading is never set to false and no error is surfaced, leaving the dashboard stuck on the spinner. Handle the JSON parse failure explicitly (set an error message and set loading to false) so the UI can exit the loading state.
There was a problem hiding this comment.
Fixed in commit f149003. Now explicitly handles JSON parse failure with a match statement, setting loading to false and displaying "Failed to parse user data" error message to prevent stuck spinner.
| {move || { | ||
| let link = vip_link.get(); | ||
| let vip_link_for_input = vip_link.clone(); | ||
| let vip_link_for_button = vip_link_for_click.clone(); | ||
| if link.is_empty() { | ||
| view! { | ||
| <div style="background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 8px; padding: 16px; text-align: center;"> | ||
| <p style="color: var(--text-muted); font-size: 0.85rem; margin: 0;"> |
There was a problem hiding this comment.
The PR description says only client/src/components/modal.rs was modified, but this PR also includes widespread formatting/import reordering across many client/src/pages/* files. Please update the PR description to reflect the additional scope or split the formatting-only changes into a separate PR to keep the behavioral change reviewable.
There was a problem hiding this comment.
Updated the PR description to accurately reflect all changes including the formatting/import reordering that was applied via cargo fmt, along with the error handling improvements added based on code review feedback.
| } else { | ||
| let status = spawn_resp.status(); | ||
| let text = spawn_resp.text().await.unwrap_or_default(); | ||
| set_container_id.set(format!("ERROR {}: {}", status, text)); | ||
| } | ||
| } else { | ||
| let status = spawn_resp.status(); | ||
| let text = spawn_resp.text().await.unwrap_or_default(); | ||
| set_container_id.set(format!("ERROR {}: {}", status, text)); | ||
| } | ||
| } | ||
| Err(e) => { | ||
| set_container_id.set(format!("NETWORK_FAIL: {}", e)); | ||
| Err(e) => { | ||
| set_container_id.set(format!("NETWORK_FAIL: {}", e)); | ||
| } |
There was a problem hiding this comment.
container_id is used to decide when to render TerminalView, but on spawn failures it is set to strings like "ERROR ..." / "NETWORK_FAIL ...". That makes the UI attempt to open a WebSocket for an invalid session id, obscuring the real spawn error. Keep container_id as an actual id (or Option<String>) and track spawn errors in a separate signal so you can render an explicit error state instead of TerminalView.
There was a problem hiding this comment.
Fixed in commits f149003 and 33a77cb. Added separate spawn_error signal to track spawn failures. Now displays explicit error message instead of attempting WebSocket connection with invalid container ID. Error state shows:
⚠️ Environment Spawn Error
[error details]
This prevents confusing WebSocket errors and clearly communicates spawn failures to users.
|
@copilot apply changes based on the comments in this thread |
- dashboard.rs: Handle JSON parse failure explicitly to prevent stuck loading state - create.rs: Separate spawn error state from container_id to avoid invalid WebSocket connections Co-authored-by: Yashb404 <139128977+Yashb404@users.noreply.github.com>
Co-authored-by: Yashb404 <139128977+Yashb404@users.noreply.github.com>
Co-authored-by: Yashb404 <139128977+Yashb404@users.noreply.github.com>
Applied all changes from the review thread:
All issues identified in the review have been addressed. |
Addresses feedback to replace empty input field with helpful message when
embed_keyis not yet generated, and fixes error handling issues identified in code review.Changes
VIP Link Loading State (Original Scope)
Modified
client/src/components/modal.rs:vip_linkstateError Handling Improvements (Code Review Feedback)
Modified
client/src/pages/dashboard.rs:Modified
client/src/pages/create.rs:spawn_errorsignal to track environment spawn failuresFormatting Changes
Multiple client files:
cargo fmtfor consistent code style across the codebaseImplementation
VIP Link Loading State
Uses Leptos reactive signals to switch between states:
Error Handling
All changes ensure users see clear error messages instead of stuck loading states or cryptic connection failures.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.