agent-orchestrator/backend/internal/storage/sqlite/migrations
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
..
0001_init.sql refactor: simplify session lifecycle and zellij runtime (#62) 2026-06-01 08:42:49 +05:30
0002_remove_activity_source.sql refactor: remove activity source tracking (#62) (#66) 2026-06-01 09:26:18 +05:30
0003_add_session_display_name.sql feat: add light backend CLI commands (#98) 2026-06-03 16:18:00 +05:30
0004_scm_observer_schema.sql feat: add provider-neutral SCM observer (#76) 2026-06-04 22:26:07 +05:30
0005_pr_last_nudge_signature.sql feat(scm): wire observer messenger + RepoOriginURL + persist dedup (#108) (#114) 2026-06-05 23:20:02 +05:30
0006_pr_session_changed_cdc.sql feat: ao session claim-pr + spawn --claim-pr wiring (#101) 2026-06-06 00:01:03 +05:30
0007_allow_implemented_harnesses.sql feat(agents): agent platform — registry, activity hooks, harness allowlist (#119) 2026-06-07 00:52:40 +05:30
0008_add_project_config.sql feat(config): persist per-project agent config and resolve it at spawn (#154) 2026-06-08 21:35:29 +05:30
0009_workspace_projects.sql feat: add workspace project registration foundation (#165) 2026-06-10 16:10:14 +05:30
0010_add_first_signal_at.sql fix(codex): reliable activity signals — session-flag hooks, trust bypass, no_signal watchdog (#170) 2026-06-11 10:36:45 +05:30
0011_notifications.sql feat: add notifications v1 (#181) 2026-06-14 20:02:32 +05:30
0012_add_review_tables.sql feat(review): configurable AO code review backend (V1) (#192) (#197) 2026-06-15 01:17:17 +05:30
0013_review_run_unique_sha.sql fix(review): serialize concurrent triggers per worker to stop reviewer double-spawn (#246) 2026-06-17 00:43:10 +05:30
0014_review_run_retry_failed.sql fix: surface missing reviewer harness (#318) 2026-06-20 10:19:50 +05:30
0015_telemetry_events.sql fix(storage): renumber telemetry migration to 0015 to resolve 0014 version collision (#334) 2026-06-20 11:23:13 +05:30
0016_review_run_github_review_id.sql fix(review): notify worker on changes_requested instead of relying on SCM poll (#337) (#340) 2026-06-21 19:52:46 +05:30
0017_add_session_preview_url.sql feat(frontend): add live browser panel (#375) 2026-06-22 04:14:18 +05:30
0018_review_run_delivered_at.sql Refactoring Reviews feature code and idempotency check (#377) 2026-06-22 15:40:00 +05:30
0019_add_session_preview_revision.sql fix(preview): add clear, reuse defaults, force refresh, local files (#379) (#380) 2026-06-22 16:04:29 +05:30