Skip to content

feat: unify native/web app core and split runtime adapters#41

Merged
ushkinaz merged 3 commits into
mainfrom
feat/new-web
Feb 22, 2026
Merged

feat: unify native/web app core and split runtime adapters#41
ushkinaz merged 3 commits into
mainfrom
feat/new-web

Conversation

@ushkinaz

Copy link
Copy Markdown
Owner

Summary

  • extract shared application logic into src/app_core (state, reducer, input model, indexing helpers)
  • move runtime-specific code into src/runtime/native and src/runtime/web
  • rename web binary to cbn-web and update trunk data-bin wiring
  • add shared model module and update matcher/search/index/ui usage to consume shared types
  • add web mouse coordinate helper + tests (app_core::web_mouse)
  • add docs/skills/web-native-parity/SKILL.md and runtime-priority note in AGENTS.md

Why

This minimizes divergence between TUI and web by keeping behavior in shared code and leaving runtime files as thin adapters.

Validation

  • cargo fmt --all
  • cargo test --offline
  • cargo check --offline --features web --bin cbn-web --target wasm32-unknown-unknown

@coderabbitai

coderabbitai Bot commented Feb 21, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • WebAssembly-based web UI available in-browser alongside the native terminal app; includes a version picker and responsive input/mouse support.
    • Native TUI preserved as a dedicated runtime with progressive data loading and indexing feedback.
  • Documentation

    • Detailed web setup, runtime parity guidelines, and usage notes added.
  • Chores

    • Added /dist/ to .gitignore.

Walkthrough

Behold: the monolithal TUI was split into a shared app_core and two runtimes (native TUI and wasm/web). Models and indexing/search were centralized, platform-specific binaries and deps added, and documentation plus a web entrypoint (index.html) introduced. No hidden opinions.

Changes

Cohort / File(s) Summary
Manifest & Docs
Cargo.toml, .gitignore, AGENTS.md, README.md
New binaries (cbn-tui, cbn-web), autobins/default-run, platform-specific dependency blocks, web feature, lto profile tweak, added /dist/ to .gitignore, and docs describing web workflow and runtime priority.
Library Surface
src/lib.rs, src/ui.rs
Exported new public modules; updated ProgressStage import and IndexedItem test paths in UI.
Shared App Core
src/app_core/mod.rs, src/app_core/state.rs, src/app_core/reducer.rs, src/app_core/input.rs, src/app_core/indexing.rs, src/app_core/web_mouse.rs
New runtime-agnostic core: AppState, reducer, input/event types, indexing helpers, progress math, and browser pixel→cell translation with tests.
Model & Search
src/model.rs, src/matcher.rs, src/search_index.rs
Centralized data model (BuildInfo, Root, IndexedItem), custom BuildInfo deserialization, switched imports to crate::model::IndexedItem, added SearchIndex::index_item.
Native Runtime
src/runtime/native/mod.rs, src/runtime/native/data.rs, src/runtime/native/main.rs
Native runtime reworked: re-exported model types, streamlined data loading/parsing, new native main binary implementing TUI event loop, adapters, history persistence, and progress-aware loading.
Web Runtime & Entry
src/runtime/web/mod.rs, src/runtime/web/data.rs, src/runtime/web/main.rs, index.html
WASM/web runtime added: async fetch of Root from CDN, web adapters (keys/mouse), browser sizing, async indexing with progress, and an HTML mountpoint linking cbn-web.
Removed Monolith
src/main.rs
Deleted the previous monolithic TUI entry and its embedded state/types/tests; functionality moved into app_core and runtime-specific binaries.
Docs: Parity Skill
docs/skills/web-native-parity/SKILL.md
New guidelines for maintaining behavior parity between native and web runtimes.
Misc tests/format
src/matcher.rs, src/search_index.rs, src/ui.rs
Adjusted imports/type paths and factored indexing logic into index_item; minor formatting and test updates.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Browser as Browser (DOM)
    participant Wasm as Ratzilla (WASM)
    participant Reducer as Input Reducer (app_core)
    participant AppState as AppState (Shared)
    participant Fetcher as Data Loader (web/native)
    participant Renderer as UI Renderer (Terminal/DOM)

    Browser->>Wasm: DOM Key/Mouse Event
    Wasm->>Reducer: AppKeyEvent / AppMouseEvent
    Reducer->>AppState: mutate(state) (focus, filter, select)
    AppState->>AppState: update caches & display
    alt dataset action
        AppState->>Fetcher: request(version/reload)
        Fetcher->>AppState: Root JSON (with progress updates)
        AppState->>AppState: build_index (progress)
    end
    AppState->>Renderer: render frame
    Renderer->>Browser: DOM/Terminal update
Loading
sequenceDiagram
    autonumber
    participant User as User
    participant Native as Native Runtime (cbn-tui)
    participant Core as Shared Core (app_core)
    participant Data as Data Service / CDN
    participant Term as Terminal

    User->>Native: CLI args / events
    Native->>Core: AppState::new(...)
    Native->>Data: fetch_root / load local
    Data->>Core: Root -> index items (with index_item calls)
    Core->>Term: render progress & frames
    User->>Native: keyboard/mouse
    Native->>Core: handle_key_event / handle_mouse_event
    Core->>Term: redraw
Loading

Possibly related PRs

Poem

Hear the Machine-Spirit hum: two pathways forged,
Native steel and web-wrought glyphs now sing in chord,
Shared core the cogitator feeds with timeless lore,
Ratzilla and terminal march where unity swore. ⚙️🦾

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main architectural change: extracting shared app core and splitting runtime-specific adapters into separate modules.
Description check ✅ Passed The description clearly explains the refactoring objectives, implementation approach, and validation steps performed before submission.
Docstring Coverage ✅ Passed Docstring coverage is 91.56% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/new-web

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Cargo.toml`:
- Around line 17-39: The ratatui feature "layout-cache" in the
[target.'cfg(target_arch = "wasm32")'.dependencies] block may require std and
thus may be inappropriate for no_std wasm builds; inspect the ratatui = {
version = "0.30.0", default-features = false, features = ["all-widgets",
"layout-cache"] } entry and either remove "layout-cache" or enable std (or
switch to a wasm target that supports std, e.g., wasm32-wasi) depending on
whether your wasm target supports std; update the features for the ratatui
dependency accordingly to avoid pulling in std-only functionality when targeting
no_std wasm.

In `@index.html`:
- Around line 7-10: The external Fira Code stylesheet link (the <link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/fira_code.min.css"
/> tag) relies on Cloudflare CDN and may fail offline; update the HTML to
provide resilience by adding a local fallback: include a local `@font-face` (or
local stylesheet) for Fira Code in your assets and alter the document to prefer
the local file when available (or add a <link rel="preload"> plus a small inline
CSS font-family fallback stack that includes monospace), and ensure the
font-family usages reference the fallback stack so the page degrades gracefully
if the CDN resource is unavailable.
- Around line 33-46: The `#grid` rule contains duplicated width and height
declarations—remove the earlier redundant width: 100% and height: 100% entries
so only the intended final values remain (retain one width declaration and
height: 100vh); locate the CSS rule for the selector `#grid` and delete the
duplicate lines to avoid dead code and clarify intent.

In `@src/app_core/reducer.rs`:
- Around line 372-415: Ctrl-click currently sets app.filter_text =
format!("i:{}", final_val) which filters by id only; change it to include the
item type to avoid collisions by building a type token (prefer the matched
span's type metadata if available, e.g., span.span_type or
span.span.entity_type; if not present, derive a type from target_path's first
segment) and then set app.filter_text = format!("t:{} i:{}", type_token,
final_val); keep updating app.filter_cursor, call app.update_filter() and
app.focus_pane(FocusPane::Details) as before.

In `@src/model.rs`:
- Around line 61-100: The deserializer requires Proxy.build_number as String
which will fail if the root JSON omits it; change Proxy.build_number to
Option<String>, treat missing value as empty string by using unwrap_or_default()
when initializing build_number and tag_name (e.g., let build_number =
proxy.build_number.unwrap_or_default(); let mut tag_name =
build_number.clone();), and then construct BuildInfo with that build_number
value so deserialization succeeds on missing fields; update all references in
the impl Deserialize for BuildInfo to use proxy.build_number.unwrap_or_default()
(and replace proxy.build_number.clone() uses) accordingly.

Comment thread Cargo.toml
Comment thread index.html
Comment thread index.html
Comment thread src/app_core/reducer.rs
Comment thread src/model.rs
Comment thread index.html

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@index.html`:
- Around line 7-10: Add a short explanatory HTML comment immediately before the
<link> tag (the element with href
"https://cdnjs.cloudflare.com/ajax/libs/juliamono/0.061/juliamono-regular.css")
that documents why the font is loaded from Cloudflare CDN and the trade-offs
(e.g., improved load performance and caching vs. external
request/privacy/availability risks and fallback considerations), so future
maintainers understand the decision and can change to a self-hosted or
alternative approach if needed.

Comment thread index.html
@ushkinaz ushkinaz merged commit 38d38ed into main Feb 22, 2026
3 checks passed
@ushkinaz ushkinaz deleted the feat/new-web branch February 22, 2026 11:08
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.

1 participant