Skip to content

feat(ui): serve the archive UI with sample data under npm run dev - #19

Merged
hsusul merged 1 commit into
mainfrom
p1-2-archive-mock
Oct 26, 2026
Merged

hsusul merged 1 commit into
mainfrom
p1-2-archive-mock

Conversation

@hsusul

@hsusul hsusul commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Why

npm run dev in a plain browser has no Tauri shell. Every invoke and listen call failed. The page showed "Archive unavailable" and console errors like Cannot read properties of undefined (reading 'transformCallback'). This makes the archive UI usable in a browser for review and demos.

What changed

  • src/mock/sample-data.ts holds one fixed sample archive. It has 122 sessions, 4 repositories, 2 folders, patches, git observations, settings, and a backup schedule. Every record is typed with the generated lore-ipc DTOs.
  • src/mock/ipc-mock.ts holds a handler table keyed by command name. It has a handler for every command in src/ipc.ts, plus the dialog plugin's folder picker.
  • Search filters the sample data by the query terms. It wraps matches in \u{e000} and \u{e001}, the markers the real backend uses. It pages with a cursor bound to the query and sort.
  • rescan emits four scan_progress events, then a final one with done: true. After "forget everything", a rescan restores the sample sessions.
  • Settings, the backup schedule, folders, and agent roots persist in memory.
  • src/main.tsx installs the mock only when import.meta.env.DEV is true and __TAURI_INTERNALS__ is absent.
  • The mock keeps its own event bus. The stock mockIPC event mock unlistens on the wrong field and logs a warning on every later emit.
  • src/ipc.test.ts gains tests that derive the command list from ipc.ts and fail when a command has no handler. It also covers highlight markers, the empty result, paging, settings, and rescan events.

Scope

  • Changes only src/mock/, src/main.tsx, and src/ipc.test.ts.
  • No change to src/ipc.ts, vite.config.ts, the Rust crates, or src-tauri.
  • The sample timestamps are fixed offsets from page load, so the list always reads "2h" and "1d" and not a stale date.

Blast Radius

  • npm run tauri dev and the production app are unaffected. The mock is skipped at runtime inside Tauri.
  • npm run build drops the mock. dist/ contains no sample-data string and no mock code.
  • The only change that runs in production is main.tsx rendering after an async function that does nothing when DEV is false.

Verification

  • npm run lint: clean.
  • npm run typecheck: clean.
  • npm test: 13 files, 160 tests pass, including 9 new ones.
  • Removing one handler fails the new coverage test. I checked this by renaming backup_now, then reverted it.
  • npm run build: passes, one JS chunk, no mock chunk.
  • grep -rl over dist/ for acme-storefront, pricing-service, ses-claude-rounding, installIpcMock, and no handler for finds nothing.
  • npm run dev in a fresh browser tab: no console errors, 122 sessions listed.
  • Search for rounding shows highlighted hits. zzyzxnotaword shows the empty state. tests pages across three pages.
  • Opening a session shows its messages, a recorded patch, and the git rail. The 251-message session shows its full count. I did not click through its second message page.
  • The repository sidebar lists 4 repositories and filters sessions.
  • A backup schedule change to Daily persists across closing Settings and switching repositories.
  • Rescan shows 31/122, 62/122, 93/122, 122/122, then "Scan complete".
  • With a fake __TAURI_INTERNALS__ present in a dev page, the app called the fake shell and the mock stayed off.
  • First list paint in dev, five loads on a warm cache: 33 to 55 ms, median 35 ms.
  • Not run: cargo fmt, cargo clippy, and cargo test. No Rust files changed.
  • Known gap: at 375 px wide the fixed three-pane layout is clipped. The page itself does not scroll horizontally. This is existing CSS and the desktop window has a 720 px minimum.

Outside the Tauri shell every invoke and listen call failed, so npm run dev showed Archive unavailable. Answer them from a fixed in-memory sample archive typed with the lore-ipc DTOs. main.tsx installs the mock only when import.meta.env.DEV is true and the page is not inside Tauri, so production builds drop it and tauri dev keeps the real backend. A test derives the commands from ipc.ts and fails when one has no handler.
@hsusul
hsusul merged commit 77c3caa into main Oct 26, 2026
5 checks passed
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