From 909a9ae6d9ca841e50a86685c2a8cabb49105834 Mon Sep 17 00:00:00 2001 From: Sandro Date: Wed, 22 Jul 2026 00:43:24 +0100 Subject: [PATCH 1/4] =?UTF-8?q?feat(accounts):=20Finding=20=E2=86=92=20Fix?= =?UTF-8?q?=20with=20scope/intent=20preview=20(Story=205.1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a `fix it` affordance on actionable found-issues findings in the Feed and the Queue. It opens a scope/intent preview (repo/ref scope + the finding intent + the untrusted fix_prompt as inert, auto-escaped text — no generated diff) and, only on an explicit confirm POST, launches exactly one change session via submit_batch_runs(trigger_type=UI_JOB). Render paths and the preview GET perform zero writes and enqueue zero runs; the confirm re-validates the live envelope server-side (shared still_actionable + FIX + non-empty fix_prompt), owner-scopes the run, gates can_run, builds RepoTarget from the originating run's ref, and swaps the item to a calm "fix started" state without decrementing the "you have N" count. The preview + POST-only enqueue is the human-in-the-loop security gate over classifier-authored, untrusted run prose. --- daiv/accounts/locale/pt/LC_MESSAGES/django.po | 50 ++++ .../templates/accounts/_feed_item.html | 27 +- .../templates/accounts/_fix_notice.html | 9 + .../templates/accounts/_fix_preview.html | 128 ++++++++ .../templates/accounts/_fix_started.html | 27 ++ .../templates/accounts/_queue_item.html | 28 +- .../templates/accounts/dashboard.html | 10 + daiv/accounts/urls/dashboard.py | 10 +- daiv/accounts/views.py | 185 ++++++++++++ .../accounts/test_dashboard_console.py | 181 ++++++++++++ tests/unit_tests/accounts/test_views.py | 279 +++++++++++++++++- tests/unit_tests/conftest.py | 1 + 12 files changed, 927 insertions(+), 8 deletions(-) create mode 100644 daiv/accounts/templates/accounts/_fix_notice.html create mode 100644 daiv/accounts/templates/accounts/_fix_preview.html create mode 100644 daiv/accounts/templates/accounts/_fix_started.html diff --git a/daiv/accounts/locale/pt/LC_MESSAGES/django.po b/daiv/accounts/locale/pt/LC_MESSAGES/django.po index 09a1979b2..cf8f15f52 100644 --- a/daiv/accounts/locale/pt/LC_MESSAGES/django.po +++ b/daiv/accounts/locale/pt/LC_MESSAGES/django.po @@ -518,6 +518,56 @@ msgid_plural "checked %(counter)s runs" msgstr[0] "verificada %(counter)s execução" msgstr[1] "verificadas %(counter)s execuções" + +# Story 5.1 — Finding -> Fix scope/intent preview +msgid "Fix it" +msgstr "Corrigir" + +msgid "Start a fix" +msgstr "Iniciar uma correção" + +msgid "Review what will run before starting it. Nothing happens until you confirm." +msgstr "Reveja o que será executado antes de iniciar. Nada acontece até confirmar." + +msgid "Close" +msgstr "Fechar" + +msgid "Scope" +msgstr "Âmbito" + +msgid "default branch" +msgstr "ramo predefinido" + +msgid "What will be attempted" +msgstr "O que será tentado" + +msgid "Instruction" +msgstr "Instrução" + +msgid "Cancel" +msgstr "Cancelar" + +msgid "This finding is no longer actionable — nothing to start." +msgstr "Esta deteção já não é acionável — nada para iniciar." + +msgid "Fix started" +msgstr "Correção iniciada" + +msgid "Started, but some repositories could not be queued — check your sessions." +msgstr "Iniciada, mas alguns repositórios não puderam ser colocados em fila — verifique as suas sessões." + +msgid "A change session is on its way." +msgstr "Uma sessão de alteração está a caminho." + +msgid "View session" +msgstr "Ver sessão" + +msgid "This finding is no longer actionable — nothing was started." +msgstr "Esta deteção já não é acionável — nada foi iniciado." + +msgid "Could not start the fix. Please try again in a moment." +msgstr "Não foi possível iniciar a correção. Tente novamente daqui a instantes." + #~ msgid "stale" #~ msgstr "parado" diff --git a/daiv/accounts/templates/accounts/_feed_item.html b/daiv/accounts/templates/accounts/_feed_item.html index 6ffa5f6b8..8e019a492 100644 --- a/daiv/accounts/templates/accounts/_feed_item.html +++ b/daiv/accounts/templates/accounts/_feed_item.html @@ -11,8 +11,14 @@ Story 2.4 adds a per-user seen/unread layer keyed on ``item.read_at`` (NULL = unread), orthogonal to ``data-status``: an unread neutral wash + SR-labelled dot, the drill-through marks-seen, and a -resolved-only dismiss control. Neutral tokens ONLY — never a status/teal/violet color. Still NO Epic -5 action button (fix/review/retry). +resolved-only dismiss control. Neutral tokens ONLY — never a status/teal/violet color. + +Story 5.1 adds the ONE Epic-5 action button: a ``fix it`` affordance on a still-actionable +found-issues item that carries a fix-able finding (``item.fixable`` — computed server-side via the +``offered_action == FIX`` + ``still_actionable`` + non-empty ``fix_prompt`` gate). It sits OUTSIDE +the card ```` and ``hx-get``s the scope/intent preview into ``#fix-preview-mount`` — it NEVER +POSTs / launches; only the preview's explicit confirm does. Inline amber, byte-identical to the +Queue's. No ``review``/``retry`` here (Story 5.2). {% endcomment %}