Skip to content

Restructure project: migrate from web to native desktop app with libp2p networking#1

Merged
intendednull merged 1 commit into
mainfrom
claude/analyze-repo-27dg1
Mar 22, 2026
Merged

Restructure project: migrate from web to native desktop app with libp2p networking#1
intendednull merged 1 commit into
mainfrom
claude/analyze-repo-27dg1

Conversation

@intendednull
Copy link
Copy Markdown
Owner

Summary

This is a major architectural restructuring that pivots Willow from a web-based application to a native desktop client. The project now uses Bevy for the UI, libp2p for P2P networking, and introduces a complete modular crate structure with proper separation of concerns.

Key Changes

Removed

  • Web frontend (crates/web/) — Yew-based web UI and related dependencies
  • Timeline crate (crates/timeline/) — Old state management approach

Added

  • willow-app — New Bevy-based desktop UI with ECS architecture

    • ui.rs — Bevy UI layout (sidebar, message list, peer count)
    • network_bridge.rs — Bridges async tokio networking into Bevy's synchronous ECS
    • main.rs — Application entry point with plugin system
  • willow-network — Complete P2P networking layer built on libp2p

    • node.rs — High-level NetworkNode managing the libp2p swarm
    • behaviour.rs — Composite network behaviour (GossipSub, Kademlia, mDNS, Identify, Relay)
    • config.rs — Network configuration with sensible defaults
    • Supports pub/sub messaging, peer discovery, NAT traversal, and local network mDNS
  • willow-channel — Server/channel/role/permission management (730 lines)

    • Server — Named communities with channels and members
    • Channel — Text/voice conversation spaces
    • Role — Permission bundles assignable to members
    • Invite — Signed tokens for server access with expiration/use limits
    • Permission system (SendMessages, ManageChannels, Administrator, etc.)
  • willow-messaging — Chat messages with Hybrid Logical Clock ordering

    • Message — Supports text, files, reactions, replies, edits, deletes, system events
    • HLC (Hybrid Logical Clock) — Distributed timestamp ordering that works across peers with clock skew
    • MessageStore trait with InMemoryStore implementation
    • Proper message ID and channel ID types

Modified

  • willow-identity — Expanded with comprehensive documentation and API improvements

    • Changed PeerId backing from Rc to Arc for thread safety
    • Added UserProfile for display names and avatars
    • Introduced SignedPayload for cryptographic message signing
    • Added pack() / unpack() functions for serializing signed data
    • Improved error types with IdentityError
  • willow-transport — Enhanced with protocol versioning and message types

    • Added Envelope wrapper with protocol version and message type tags
    • Defined MessageType enum (Chat, Channel, Identity, File, Signal, Presence, Ping)
    • Improved error handling with TransportError
    • Added comprehensive module documentation
  • Cargo.toml — Workspace restructuring

    • Unified workspace dependencies (serde, tokio, libp2p, bevy, chrono, uuid, etc.)
    • Renamed crates to willow-* namespace for clarity
    • Configured workspace resolver and shared package metadata

Documentation

  • Added PLAN.md — High-level vision and architecture overview
  • Added CLAUDE.md — Development guide with build instructions and crate descriptions
  • Comprehensive module-level documentation in all new crates with examples

Notable Implementation Details

  1. Network Architecture — Uses libp2p's modular protocol stack: GossipSub for pub/sub, Kademlia for DHT, mDNS for local discovery, Noise for encryption, and Relay for NAT traversal.

  2. Hybrid Logical Clocks — Implements the Kulkarni et al. (2014) algorithm to establish consistent message ordering across peers despite clock skew, critical for a decentralized chat system.

  3. ECS Bridge — The NetworkBridgeEvent and NetworkBridgeCommand types allow the async tok

https://claude.ai/code/session_019s8X2ZL8SEF9KZok2e5qJV

Replace the original Yew-based timeline app with a full chat platform
architecture. New crate structure:

- willow-transport: Protocol-versioned binary serialization with envelopes
- willow-identity: Modern libp2p Ed25519 identity, Arc-based (Send+Sync),
  user profiles, signed message packaging
- willow-messaging: Chat messages with Hybrid Logical Clock ordering,
  multiple content types (text, file, reaction, reply, edit, delete),
  pluggable message store with in-memory implementation
- willow-channel: Server/channel/role/permission model with invite system
- willow-network: libp2p networking layer with GossipSub, Kademlia, mDNS,
  Relay, and Identify protocols on tokio
- willow-app: Bevy 0.14 desktop client with Discord-style layout and
  async network bridge via std::sync::mpsc channels

All library crates have thorough documentation and tests (60 total).
Removes old timeline and web crates.

https://claude.ai/code/session_019s8X2ZL8SEF9KZok2e5qJV
@intendednull intendednull merged commit 008a1c6 into main Mar 22, 2026
intendednull added a commit that referenced this pull request Mar 25, 2026
- Fix openMemberList/closeMemberList to work on all viewports (Critical #1)
- Scope .action-trigger to target message instead of page.last() (Important #3)
- Add regression comment to messages sync test (Important #7)
- Use beforeEach for mobile skip instead of per-test (Suggestion #10)
- Use startsWith('mobile') consistently (Suggestion #9)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
intendednull added a commit that referenced this pull request Apr 26, 2026
lifecycle, fix IrohBlobStore spec drift, track 4 new follow-ups

Round 2 review (two fresh agents) verified all 15 round-1 fixes
land cleanly with no regressions, then surfaced 8 new findings
(0 critical, 3 medium, 5 low) by widening scope to cross-component
interactions, perf, and API surface.

Fixed inline (trivial doc / spec):

- Add an "Actor coordination signal" row to the spec decision tree
  + CLAUDE.md table covering tokio::sync::watch / oneshot /
  broadcast / Notify, with the explicit rule that
  tokio::sync::Mutex is forbidden for business state on the same
  terms as std/parking_lot Mutex. Closes the spec gap that left
  contributors without guidance on async channels. (round-2 #3)
- Reconcile spec § 184 with the corrected IrohBlobStore comment
  (round-1 fixed the code, missed the spec). The blob store is
  not an iroh-callback boundary — it's an interim stub. The relay-
  status timestamp Mutex stays in the iroh boundary list. (round-2 #4)
- Document the web `_event_loop` drop pattern in `crates/web/src/app.rs`
  so future readers see explicitly that the actor System is process-
  scoped on web (page reload tears everything down) and that any
  actor needing pre-close cleanup must route via `beforeunload`,
  not Drop. (round-2 #8)

Tracked as new follow-ups in spec § Follow-up work:

- F5. SearchActor head-of-line + rebuild-storm fix. Rebuild blocks
  Query in FIFO order; the rebuild Effect has no debounce. Fix is
  chunked-Rebuild + Debounce<Rebuild> wrap. (round-2 #1, #2 — Med)
- F6. Browser-tier coverage for SearchIndexHandle consumers. The
  spawn_local + Effect path has no wasm-pack test. (round-2 #6)
- F7. Sealed ClientSpawner to narrow the system() API surface,
  rather than exposing the full SystemHandle. (round-2 #7)
- F8. Search-query debouncing-flicker fix via generation tag or
  Leptos Resource migration. (round-2 #5)

Each follow-up has a "Trigger:" line naming the dedicated PR title.

`just check` green: clippy zero warnings, 1003+ tests pass, WASM
compile clean. Loop terminates here per the user's two-round cap;
no Critical issues remain.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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