Skip to content

refactor(ui): split app.ts into 7 small files#13

Merged
samir1498 merged 1 commit into
mainfrom
refactor/ui-split
May 13, 2026
Merged

refactor(ui): split app.ts into 7 small files#13
samir1498 merged 1 commit into
mainfrom
refactor/ui-split

Conversation

@samir1498
Copy link
Copy Markdown
Collaborator

Summary

src/ui/app.ts went from 362 lines doing everything to a 30-line entry that just bootstraps modules.

File Lines Responsibility
types.ts ~25 Shared TS types (Monitor, RunLite, MonType, ...)
helpers.ts ~30 `$`, `$$`, `esc`, `fmtAge`, `statusClass`
`api.ts` ~35 Typed fetch wrappers
`list.ts` ~90 renderList + rowFor + tab/click handlers
`detail.ts` ~75 renderDetail + sparkline
`dialogs.ts` ~90 Add monitor + Import JSON wiring
`app.ts` ~30 Router + setInterval + bootstrap

No behavior change. Same selectors, same handlers, same render output. The only deduplication is `statusClass()` — the inline status→CSS-class switch that appeared in both `rowFor` and the detail executions row is now one helper.

Verification

  • Built a docker image from this branch (`docker build -t oo-workers:refactor-test .`)
  • Ran the new image as a sidecar on port 3011 (so the published-image stack on 3010 stayed running)
  • All 11 UI e2e specs passed against the refactored bundle (15.9s)
  • 4 fast CI gates clean (typecheck, format, lint, knip)
  • Pre-push integration suite: 7/7 passed

What this PR does NOT do

Per agreement: client-side pagination, search, emoji-to-dot cleanup on detail Status card — all coming in the next PR.

Bundle size

11.34 KB (was ~10 KB single-file). The ~1 KB growth is module boilerplate / extra exports.

🤖 Generated with Claude Code

src/ui/app.ts went from 362 lines doing everything to a 30-line
entry that just bootstraps modules. No behavior change — same
selectors, same handlers, same render output. Verified by running
all 11 UI e2e specs against a docker image built from this branch.

  types.ts      shared TS types (Monitor, RunLite, MonType, ...)
  helpers.ts    $, $$, esc, fmtAge, statusClass (deduped from
                inline switches in rowFor + detail executions)
  api.ts        typed fetch wrappers (getMonitors, runMonitor,
                createMonitor, importJson, ...)
  list.ts       renderList + rowFor + tab/click handlers
  detail.ts     renderDetail + sparkline svg
  dialogs.ts    Add monitor + Import JSON wiring
  app.ts        router + setInterval + bootstrap

Also: gitignore the public/ build output (was untracked but not
ignored; the docker image regenerates it via `bun run build:ui`).
@samir1498 samir1498 merged commit 932ede1 into main May 13, 2026
5 checks passed
@samir1498 samir1498 deleted the refactor/ui-split branch May 13, 2026 09:19
samir1498 added a commit that referenced this pull request May 26, 2026
…onsistency (#88)

Three small UX fixes batched together.

1. Settings → API keys: clicking "I've copied it" used to be a visual
   no-op. The reveal-panel host's innerHTML was populated when oneTimeKey
   was set but never cleared on the next render. Add an explicit
   `if (!oneTimeKey && host) host.innerHTML = '';` so the panel goes
   away when dismissed.

2. Import JSON dialog: drop the `www.` from the observeone.com/cli link.
   Aligns with README (which already uses bare apex) so every operator-
   facing URL in the repo points at the same canonical host.

3. Heartbeat detail page back-link reads "← back" instead of
   "← All monitors", matching the other 7 monitor types' detail pages.

Test: tests/ui/api-key-dismiss.e2e.spec.ts creates a key, asserts the
reveal panel is visible, clicks dismiss, asserts the cleartext element
is hidden afterward.

Closes friction #13, #31, #32.

Co-authored-by: Claude Sonnet 4.6 <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.

1 participant