Skip to content

feat(dev): mock backend for reviewing the UI in a browser - #780

Merged
EVWorth merged 7 commits into
mainfrom
claude/hopeful-bardeen-1k4d1h
Oct 21, 2026
Merged

EVWorth merged 7 commits into
mainfrom
claude/hopeful-bardeen-1k4d1h

Conversation

@EVWorth

@EVWorth EVWorth commented Oct 21, 2026

Copy link
Copy Markdown
Owner

The browser preview (just dev-web) showed an empty app: outside Tauri, every command throws "Tauri not available". This adds a dev-only mock backend, so the whole UI runs in a browser with realistic data, and a script that screenshots the main screens. Both are for the planned UX/UI review, and for checking UI changes without a desktop build.

Using it

  • just dev-web, then open http://localhost:1420/?mock. There are three starting points:
    • ?mock: four saved connections, nothing connected.
    • ?mock=empty: a first run, with no saved connections.
    • ?mock=connected: "Local dev" connected, starting in the editor.
  • just ui-snapshots saves 12 screens, in dark and light, at 1366×820 and 1024×680, into ui-snapshots/ (gitignored). Set CHROMIUM_PATH if Playwright's own Chromium isn't installed.

How it works

  • One interception point. Every backend call goes through invoke in the generated bindings, so one mockIPC callback from @tauri-apps/api/mocks answers them all.
    • Each command has a handler in src/dev/mock/handlers/.
    • Event mocking is on, so backup/restore progress, connection health and agent sessions all stream.
    • Tauri plugin calls (window, app version, updater) answer too.
  • Dev only. main.tsx installs the mock only when import.meta.env.DEV is true and the URL has ?mock. In a production build that condition is folded to false, so vite build output contains none of the mock (checked).
  • One change to app code: tauri-api.ts checks for Tauri on each call instead of once at import, so the mock can be installed after that module loads.
  • Fixed data. Two databases (shop, analytics) plus the system schemas. Rows are generated from a fixed seed, so screenshots of the same commit match.
  • Scripted behaviour:
    • Errors use MySQL's own codes and messages (missing table 1146, syntax 1064); writes on the read-only production profile are refused.
    • Staging connects slowly; the MariaDB sandbox refuses to connect.
    • SELECT SLEEP(n) really waits and can be cancelled.
    • Backups emit progress events and can be cancelled.
    • The agent session runs a scripted turn with a tool call, a permission prompt and a staged-write approval.
  • Guard test: src/dev/mock/__tests__/coverage.test.ts fails if a bindings command has no handler, or a handler names a command that no longer exists. Without it, a new backend command would break its screen in the preview unnoticed.

Also fixed

  • CLAUDE.md pitfall 6 said the @/ alias is configured in vite.config.ts. It isn't: only vitest and tsconfig define it. App code has to import relatively, and the mock now does.
  • CLAUDE.md: documents how to open the mock, and that a new command needs a mock handler.

Checks

  • Types and lint: tsc --noEmit is clean. ESLint has no errors; its two warnings were already in admin tests. dprint is clean.
  • Tests: vitest over src/dev, src/lib and src/stores, 1,438 passing, including the guard test.
  • Not run here: src/__tests__/main.test.tsx times out in this container on main too, so CI has the final word on it.
  • Production build leaves the mock out.
  • Screenshots: all 12 shots render in both themes and both sizes (48 PNGs).

What it already shows

From the first screenshots and from the code read while writing the handlers:

  • Saved connections have no on-screen entry point. With profiles saved and nothing connected, the sidebar says only "No connection selected". The list sits behind a small + in the tab bar.
  • A failed connection is shown only as truncated red text in the status bar.
  • A multi-statement run shows only the last statement's result.

These and about 60 smaller findings will be filed as issues in the review that follows. They aren't part of this PR.


Generated by Claude Code

The router, the fixture dataset and state, the plugin handlers, the
entry-point switch (`?mock` under `just dev-web`), a test that every
command has a handler, and a screenshot script. The per-area handlers
follow in the next commit; until then this does not build.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WTypK4RjzzdjoFxd3qk14g
All 14 schema reads, with indexes, foreign keys, routines, a trigger, an event and partitions, and SHOW CREATE-style DDL. Unknown objects fail with the backend's wording.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WTypK4RjzzdjoFxd3qk14g
A fake app.db for the SQLite browser; the agent panel's harnesses, endpoint, sharing terms and a scripted session: a read turn with a tool call, a permission prompt for writes, a staged-write approval, and cancel.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WTypK4RjzzdjoFxd3qk14g
Process list and server variables with kills, a fake file system under /tmp/sqlpilot-mock, backup and restore with progress events and cancel, and a seeded query history with filters, facets and export.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WTypK4RjzzdjoFxd3qk14g
- The connection and query handlers' final versions, plus
  keyring_available, which the guard test missed: its pattern did not
  allow for a type argument (`__TAURI_INVOKE<boolean>(...)`).
- `?mock=connected` connects through the app's own store once it has
  rendered: the app never asks the backend which connections are live.
- Relative imports throughout. Vite has no `@/` alias, only vitest and
  tsconfig do, so the dev server could not load the mock; CLAUDE.md said
  otherwise and is corrected.
- ui-snapshots.mjs waits for the server by polling, loads pages on
  "load" rather than "networkidle", takes CHROMIUM_PATH, and stops the
  server if the browser fails to launch.
- CLAUDE.md: how to open the mock, and that a new command needs a
  handler.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WTypK4RjzzdjoFxd3qk14g
@EVWorth
EVWorth merged commit 9f4526c into main Oct 21, 2026
12 checks passed
@EVWorth
EVWorth deleted the claude/hopeful-bardeen-1k4d1h branch October 21, 2026 11:51
EVWorth added a commit that referenced this pull request Oct 23, 2026
* release: 1.4.0

Version bump across the three manifests and the two lockfile entries
that record the app's own version. Minor: features landed.

From the UX review (#783), 34 issues fixed:

Data safety
- A sorted or filtered grid deleted or copied the wrong row (#839)
- Grid edits saved against the editor's current text, not the result's
  table and connection (#840)
- Switching result sets kept pending edits for the wrong rows (#869)
- Restore into production now always asks (#789); Apply in the designer
  previews DROP COLUMN (#791) and is disabled when the table failed to
  load (#796); Delete Profile asks first (#795)
- Non-default themes crashed the app on every launch (#781)

Editor and results
- Results and run state are kept per editor tab; cancelling one tab no
  longer stops another tab's query on the same connection (#842)
- Run, Explain and Explain Analyze use the statement at the cursor (#846)
- Unsaved tabs ask before closing (#843, partial); a user's own cancel
  reads as information, not an error (#850)
- Double-click edits a cell again (#841); row 1 no longer hides under the
  header (#847); the LIMIT box can be cleared and retyped (#848)

Connections
- Run goes to the server the editor tab shows (#788)
- Progress while connecting, with cancel (#799); full connect failures
  with Retry (#804); saved profiles in the sidebar, menu and palette
  (#817); Test Connection gives the same diagnosis as Connect and names
  MariaDB (#809)
- Save failures keep the dialog open (#792); Port and timeouts can be
  retyped (#813)

Schema browser, backup and agents
- View Structure opens the structure panel (#787); DDL opens in a
  read-only editor tab (#800); the filter finds events (#806); FK
  reference columns survive a load error (#810)
- Cancelled or partial restores warn (#793); run dialogs keep focus, ask
  before closing mid-run and keep Cancel on screen (#798, #803, #807);
  the backup bar counts rows (#811)
- Agent approvals queue instead of replacing each other (#790), show the
  full SQL (#786), and the redaction field follows its patterns (#794)

Also: a mock backend for reviewing the UI in a browser (#780), the
agent setup moved from .opencode to Claude (#775), and dependency
updates.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WTypK4RjzzdjoFxd3qk14g

* fix(deps): bump tokio and ctutils for advisories

RUSTSEC-2026-0384: tokio 1.54.0 -> 1.54.1 (race in time::Interval).
RUSTSEC-2026-0385: ctutils 0.4.2 -> 0.4.5 (non-constant-time
comparisons). Lockfile-only; security fixes are exempt from the dep age
gate.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WTypK4RjzzdjoFxd3qk14g

---------

Co-authored-by: Claude <[email protected]>
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