agent-orchestrator/backend/internal/storage/sqlite/gen
Harshit Singh Bhandari 8fa403c480
fix(preview): add clear, reuse defaults, force refresh, local files (#379) (#380)
* fix(preview): add clear, reuse defaults, force refresh, local files (#379)

`ao preview` had four issues that made the desktop browser panel awkward
during sessions. This addresses all four:

1. No way to clear the panel. Adds `ao preview clear` (DELETE
   /sessions/{id}/preview) which empties the stored target; the panel
   loads about:blank and returns to its empty state.

2. Bare `ao preview` always autodetected index.html. It now reuses the
   session's existing preview target (so each agent/context keeps its own
   default), falling back to index.html only when nothing was previewed.

3. Re-running `ao preview <same-url>` never refreshed. The preview_url
   alone could not distinguish a real re-run from a CDC replay of an
   unrelated session update. A new monotonic preview_revision (bumped on
   every set, migration 0018, added to the sessions_cdc_update trigger)
   gives the renderer a per-command identity to key navigation on, so a
   re-run always re-navigates while unrelated updates are ignored.

4. Local files could not be previewed. `ao preview ./dist/index.html`
   (and other workspace-relative paths) now resolve server-side to the
   preview/files proxy URL when the file exists; non-file targets stay
   verbatim.

Backend, CLI, and renderer all covered by tests; OpenAPI spec and the
frontend schema are regenerated for the new DELETE route and field.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix(cdc): include previewRevision in sessions update event payload

The CDC trigger watched preview_revision changes but didn't include it
in the JSON payload, so the frontend couldn't detect same-URL preview
refreshes via SSE events. This broke the core purpose of the feature.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(migration): renumber to 0019 to resolve conflict with main

Main branch now has migration 0018 (review_run_delivered_at), causing
a duplicate version conflict when CI merges the PR branch with main.
Renamed 0018_add_session_preview_revision.sql to 0019.

Also fixed the Down migration to properly restore the CDC trigger state
after migration 0017 (with previewUrl but without previewRevision).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Vaibhaav <user@example.com>
2026-06-22 16:04:29 +05:30
..
changelog.sql.go refactor: simplify session lifecycle and zellij runtime (#62) 2026-06-01 08:42:49 +05:30
db.go feat(backend): SQLite storage layer + CDC pipeline, LCM/reaper wiring 2026-05-30 16:02:07 +05:30
models.go fix(preview): add clear, reuse defaults, force refresh, local files (#379) (#380) 2026-06-22 16:04:29 +05:30
notifications.sql.go feat: add desktop notifications v1 (#262) 2026-06-22 01:14:04 +05:30
pr.sql.go feat(session): support multiple PRs per session (#230) 2026-06-17 17:31:28 +05:30
pr_checks.sql.go feat: add provider-neutral SCM observer (#76) 2026-06-04 22:26:07 +05:30
pr_comment.sql.go feat: add provider-neutral SCM observer (#76) 2026-06-04 22:26:07 +05:30
pr_review_threads.sql.go fix: 7 bugs from discussion #149 smoke walk (envelope, spawn, CDC, observer) (#153) 2026-06-07 07:35:46 +05:30
projects.sql.go feat: add workspace project registration foundation (#165) 2026-06-10 16:10:14 +05:30
review.sql.go Refactoring Reviews feature code and idempotency check (#377) 2026-06-22 15:40:00 +05:30
sessions.sql.go fix(preview): add clear, reuse defaults, force refresh, local files (#379) (#380) 2026-06-22 16:04:29 +05:30
telemetry.sql.go Feat/backend telemetry v0 (#307) 2026-06-18 22:00:25 +05:30
workspace.sql.go feat: add workspace project registration foundation (#165) 2026-06-10 16:10:14 +05:30