Phase 3: JEV classification, rules table, editable categories (AUD-69)
Implements FR-3, FR-4, FR-5 and FR-14. - internal/classify: TypeSafe System One (JEV) HTTP client with the confirmed request/response shape, retry with backoff on 429/529/5xx, a plain-text rule engine (first match wins, overrides only the named fields), and bounded orchestration with a per-run cap. - internal/store: migration v3 adds an editable `categories` table (name = JEV Choice option and classifications key; rename cascades, remove reassigns) and seeds a starter rules version once. Classification persistence, coverage, and pending/all message queries. - internal/server: POST /actions/classify and /actions/reclassify, plus the FR-14 category editor (GET /categories and add/rename/remove). The triage list now groups by the live category list and shows action + confidence. - CLI: -classify and -classify-all for n8n. - Docs: docs/phase3-classify.md with the confirmed JEV shape, a live read-only classification, and the DoD evidence. DoD: all 100 stored messages have a non-null category, importance, and suggested action (0 nulls); JEV picked a newly added/renamed category for 6 real messages over HTTP. One live JEV call recorded in the phase doc. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
104
web/templates/categories.html
Normal file
104
web/templates/categories.html
Normal file
@@ -0,0 +1,104 @@
|
||||
<!doctype html>
|
||||
<html lang="en" data-theme="light">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Categories · Email Agent</title>
|
||||
<link rel="stylesheet" href="/static/tokens.css">
|
||||
<link rel="stylesheet" href="/static/app.css">
|
||||
<script>
|
||||
(function () {
|
||||
try {
|
||||
var t = localStorage.getItem("ea-theme");
|
||||
if (!t) t = matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
||||
document.documentElement.setAttribute("data-theme", t);
|
||||
} catch (e) {}
|
||||
})();
|
||||
function eaToggleTheme() {
|
||||
var el = document.documentElement;
|
||||
var next = el.getAttribute("data-theme") === "dark" ? "light" : "dark";
|
||||
el.setAttribute("data-theme", next);
|
||||
try { localStorage.setItem("ea-theme", next); } catch (e) {}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<header class="nav-bar">
|
||||
<span class="wordmark">Email Agent</span>
|
||||
<div class="nav-actions">
|
||||
<a class="btn btn-utility" href="/">Back to inbox</a>
|
||||
<button class="btn btn-utility theme-toggle" type="button" onclick="eaToggleTheme()" aria-label="Toggle dark mode">
|
||||
<span class="icon-light" aria-hidden="true">☾</span>
|
||||
<span class="icon-dark" aria-hidden="true">☀</span>
|
||||
</button>
|
||||
<form method="post" action="/logout">
|
||||
<input type="hidden" name="csrf" value="{{.CSRFToken}}">
|
||||
<button class="btn btn-utility" type="submit">Log out</button>
|
||||
</form>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main class="page">
|
||||
<h1 class="greeting">Categories</h1>
|
||||
|
||||
{{if .Note}}<div class="scan-note" role="status">{{.Note}}</div>{{end}}
|
||||
{{if .Error}}<div class="alert alert-error" role="alert">{{.Error}}</div>{{end}}
|
||||
|
||||
<section class="panel categories-panel" aria-label="Category list">
|
||||
<div class="panel-head">
|
||||
<h2>Category list</h2>
|
||||
<span class="muted">{{.Classified}} of {{.Total}} message(s) classified</span>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<p class="muted categories-help">
|
||||
JEV classifies each message against this list. Renaming a category updates
|
||||
every message already filed under it. Removing one moves those messages to
|
||||
the first remaining category. At least one category is required.
|
||||
</p>
|
||||
|
||||
<form class="category-add" method="post" action="/categories/add">
|
||||
<input type="hidden" name="csrf" value="{{.CSRFToken}}">
|
||||
<div class="field">
|
||||
<label for="new-name">New category</label>
|
||||
<input class="text-input" id="new-name" name="name" maxlength="40" required
|
||||
placeholder="Finance" autocomplete="off">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="new-description">Description (used by JEV)</label>
|
||||
<input class="text-input" id="new-description" name="description" maxlength="200"
|
||||
placeholder="Bills, statements, and payments" autocomplete="off">
|
||||
</div>
|
||||
<button class="btn btn-primary" type="submit">Add category</button>
|
||||
</form>
|
||||
|
||||
<div class="category-list">
|
||||
{{range .Categories}}
|
||||
<div class="category-row">
|
||||
<form class="category-rename" method="post" action="/categories/rename">
|
||||
<input type="hidden" name="csrf" value="{{$.CSRFToken}}">
|
||||
<input type="hidden" name="id" value="{{.ID}}">
|
||||
<div class="field">
|
||||
<label for="name-{{.ID}}">Name</label>
|
||||
<input class="text-input" id="name-{{.ID}}" name="name" value="{{.Name}}" maxlength="40" required>
|
||||
</div>
|
||||
<div class="category-desc">
|
||||
<span class="muted">{{.Description}}</span>
|
||||
</div>
|
||||
<span class="count pill">{{.MessageCount}} message(s)</span>
|
||||
<button class="btn btn-utility" type="submit">Rename</button>
|
||||
</form>
|
||||
<form method="post" action="/categories/remove" class="category-remove"
|
||||
onsubmit="return confirm('Remove this category? Its messages move to the first remaining category.');">
|
||||
<input type="hidden" name="csrf" value="{{$.CSRFToken}}">
|
||||
<input type="hidden" name="id" value="{{.ID}}">
|
||||
<button class="btn btn-utility btn-danger" type="submit">Remove</button>
|
||||
</form>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user