Skip to content

fix: dashboard & backend improvements#94

Merged
MathurAditya724 merged 5 commits into
mainfrom
improvements/dashboard-and-backend-fixes
May 20, 2026
Merged

fix: dashboard & backend improvements#94
MathurAditya724 merged 5 commits into
mainfrom
improvements/dashboard-and-backend-fixes

Conversation

@MathurAditya724
Copy link
Copy Markdown
Member

Summary

  • Data retention: Configurable cleanup (default 30 days) with dashboard Settings UI and manual prune button. Adds retention_days to config schema, metadata table to SQLite, and REST endpoints (GET/PUT /api/retention, POST /api/retention/prune). Runs on startup + every 24h.
  • CORS hardening: Replace wildcard origin: "*" with OPENTOWER_CORS_ORIGIN env var. Same-origin (production) works without config; set the dev server URL during development.
  • Token comparison fix: Replace length-gated timingSafeEqual with HMAC-based constant-time comparison that doesn't leak token length.
  • Form validation: Migrate cron job create form to react-hook-form + zod schema validation (the deps were already in package.json but unused).
  • Dialog accessibility: Replace hand-rolled dialog with Radix-based shadcn dialog -- proper focus trap, escape handling, and aria-modal via @radix-ui/react-dialog.
  • Per-card mutation state: Fix cron page where toggling/deleting/triggering one job showed loading spinners on all cards. Now uses mutation variables to scope pending state.
  • Error boundary: Add ErrorBoundary component wrapping the app to prevent full-page crashes on render errors.
  • Code dedup: Extract shared isValidUrl to lib/validation.ts, replace inline IIFE in dispatches page with existing SessionLink component.
  • Email worker auto-seed: Automatically seed default allowed sender patterns on first email when the D1 table is empty.
  • Structured logging: Add JSON-structured logger to opentower with timestamp, level, message, and context fields. Replaces ad-hoc console.log/warn/error in bootstrap and handler.
  • README fixes: Update stale config schema (remove non-existent retention field, add retention_days, batch_window_ms, OPENTOWER_CORS_ORIGIN).

- Add data retention with configurable cleanup (default 30 days) and
  dashboard settings UI with manual prune button
- Restrict CORS to configured origins (OPENTOWER_CORS_ORIGIN env var)
  instead of wildcard; same-origin works without config
- Fix token comparison timing leak by using HMAC-based constant-time
  compare instead of length-gated timingSafeEqual
- Migrate cron job form to react-hook-form + zod validation
- Replace hand-rolled dialog with Radix-based shadcn dialog (focus
  trap, proper a11y, escape handling)
- Fix per-card mutation state in cron page (toggle/delete/trigger now
  only show loading on the affected card)
- Add ErrorBoundary component wrapping the app
- Extract shared isValidUrl utility, replace inline IIFE in dispatches
  with SessionLink component
- Auto-seed email worker allowlist on first email when table is empty
- Add structured JSON logger to opentower (replaces ad-hoc console
  calls with timestamped, leveled JSON lines)
- Fix stale README config schema (retention field, add CORS env var,
  batch_window_ms)
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 20, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
opencode-email-worker 4c001b9 Commit Preview URL

Branch Preview URL
May 20 2026, 02:15 PM

- Exclude in-flight dispatches (status='started') from retention prune
- Prune orphaned links rows when both sides are deleted
- Fix cron form state by unmounting dialog content when closed
- Skip retention validation when API client is unavailable
- Extract DEFAULT_RETENTION_DAYS to shared constant in storage.ts
- Add HMAC key purpose comment in safeTokenCompare
- Add OPENTOWER_CORS_ORIGIN to .env.example
- Migrate all remaining console.log/warn/error calls to structured
  logger (index.ts, server.ts, pipeline.ts, cron.ts, config.ts,
  bot-identity.ts)
@MathurAditya724 MathurAditya724 marked this pull request as ready for review May 20, 2026 10:35
The /seed endpoint was redundant — POST /senders can do the same thing.
Added clear setup documentation in the file header comment explaining
which patterns to create for GitHub notification emails.
- Extract formatError() helper to logger.ts, replace 15+ inline
  occurrences across all opentower source files
- Wire OPENTOWER_LOG_LEVEL env var to configure log level at startup
- Exclude pending/running cron executions from retention prune
- Include links count in prune total for bootstrap log threshold
- Save retention before pruning in settings dialog so the server
  uses the value the user sees in the input
- Fix cron dialog: use reset() on reopen instead of conditional
  mount (preserves Radix exit animation)
- Settings dialog trigger uses DialogTrigger for proper ARIA attrs
- Normalize prune response to snake_case (cron_executions)
@MathurAditya724 MathurAditya724 merged commit 006b350 into main May 20, 2026
2 checks passed
@MathurAditya724 MathurAditya724 deleted the improvements/dashboard-and-backend-fixes branch May 20, 2026 14:18
@sentry-release-bot sentry-release-bot Bot mentioned this pull request May 22, 2026
4 tasks
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