Skip to content

Commit 0c4e004

Browse files
committed
style: hygiene pass on async seam changes
Behavior-preserving cleanups from a code-hygiene review of the PR + AsyncState refactor: - async_view.rs: drop a needless Option<String> clone in the error arm. - notification_popover.rs: test !groups.is_empty() instead of re-entering the state.loaded() accessor for the same answer. - nodedb_service.rs / app.rs / connection_manager.rs: replace external plan-ID comment narration (SEAM-02, CONN-01..07, "Phase 2") with comments that describe the code's actual behavior. No logic, control flow, or signatures changed.
1 parent b975e8c commit 0c4e004

5 files changed

Lines changed: 12 additions & 15 deletions

File tree

nodedb-studio/src/app.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ pub fn App() -> Element {
3232
// real client can replace the mock without touching consumers.
3333
let service: Rc<dyn ConnectionService> = Rc::new(MockConnectionService);
3434

35-
// Prove the real-client stub is instantiable and object-safe behind the
36-
// seam (SEAM-02). Not the active impl this phase — Phase 2 swaps it in —
37-
// but constructing it here guarantees it compiles against the trait.
35+
// Compile-time check: the real-client stub must be instantiable and
36+
// object-safe behind the seam trait. Not the active impl yet — the mock is.
3837
let _real: Rc<dyn ConnectionService> = Rc::new(NodeDbConnectionService::default());
3938

4039
use_context_provider(|| service.clone());

nodedb-studio/src/components/async_view.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ pub struct AsyncViewProps {
4545
pub empty_message: String,
4646
}
4747

48-
// Consumed by the notification popover (01-04) and later wired views.
48+
// Consumed by the notification popover and later wired views.
4949
#[component]
5050
pub fn AsyncView(props: AsyncViewProps) -> Element {
5151
if props.loading {
5252
return rsx! { div { class: "async-loading", "Loading…" } };
5353
}
54-
if let Some(msg) = props.error.clone() {
54+
if let Some(msg) = props.error {
5555
return rsx! {
5656
div { class: "async-error",
5757
div { class: "async-error-msg", "{msg}" }

nodedb-studio/src/components/popovers/notification_popover.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ pub fn NotificationPopover() -> Element {
120120
on_retry: move |_| feed.restart(),
121121
}
122122
// Loaded -> the existing grouped list markup.
123-
if state.loaded().is_some() {
123+
if !groups.is_empty() {
124124
for (group_name, items) in groups {
125125
div { class: "notif-group-label", "{group_name}" }
126126
for n in items {

nodedb-studio/src/services/nodedb_service.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
//! The real-client-backed seam impl. Phase 1: inert stub.
2-
//!
3-
//! Holds an `Option<NativeClient>` (None until Phase 2 connects). While the
4-
//! client is None, every method returns `StudioError::NotConnected` — never
5-
//! a panic or todo!(). Phase 2 (CONN-01..07) fills the client via
6-
//! ConnectionBuilder; that wiring is explicitly out of scope here.
1+
//! The real-client-backed `ConnectionService` impl. Currently an inert stub:
2+
//! every method returns `StudioError::NotConnected` until a real connection is
3+
//! opened. Holds an `Option<NativeClient>` so the type is forward-compatible
4+
//! with the future `ConnectionBuilder` wiring — no panic or `todo!()` in the interim.
75
86
use async_trait::async_trait;
97
use nodedb_client::NativeClient;
@@ -16,8 +14,8 @@ use crate::state::connections_registry::SavedConnection;
1614

1715
#[derive(Default)]
1816
pub struct NodeDbConnectionService {
19-
/// None until a real connection is opened in Phase 2 (ConnectionBuilder
20-
/// fills this). The field exists now so the seam type is forward-compatible.
17+
/// None until a real connection is opened. Field kept for forward-compatibility
18+
/// with the future `ConnectionBuilder` wiring.
2119
#[allow(dead_code)]
2220
client: Option<NativeClient>,
2321
}

nodedb-studio/src/views/connection_manager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub fn ConnectionManager() -> Element {
5757
if let Ok(session) = service.connect(&name).await {
5858
active.set(Some(session));
5959
}
60-
// Phase 2 / CONN-03 surfaces the Err case as an error state.
60+
// Err case (e.g. offline): surfaced in a later wiring phase.
6161
});
6262
}
6363
},

0 commit comments

Comments
 (0)