feat: drawer significance review panel (T98.2)
This commit is contained in:
@@ -456,6 +456,52 @@
|
||||
</details>
|
||||
</section>
|
||||
|
||||
<section class="drawer-section">
|
||||
<h3>Significance review</h3>
|
||||
{% set total_mem = significance_distribution.values()|sum %}
|
||||
{% if total_mem %}
|
||||
<ul class="significance-distribution">
|
||||
{% for level in [0, 1, 2, 3] %}
|
||||
{% set count = significance_distribution[level] %}
|
||||
{% set marker = ['·','•','★','★★'][level] %}
|
||||
{% set pct = (100 * count / total_mem)|round(0, 'floor')|int if total_mem else 0 %}
|
||||
<li class="sig-bar sig-{{ level }}">
|
||||
<span class="sig-label">{{ marker }} ({{ level }})</span>
|
||||
<span class="sig-bar-fill" style="width: {{ pct }}%"></span>
|
||||
<span class="sig-count">{{ count }}</span>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<p class="muted">No memories yet.</p>
|
||||
{% endif %}
|
||||
{% if recent_memories %}
|
||||
<details>
|
||||
<summary>Edit significance (recent memories)</summary>
|
||||
<ul class="significance-edit-list">
|
||||
{% for m in recent_memories %}
|
||||
<li>
|
||||
<span class="sig sig-{{ m.significance }}">{{ ['·','•','★','★★'][m.significance|default(0)] }}</span>
|
||||
{{ m.pov_summary[:80] }}{% if m.pov_summary|length > 80 %}…{% endif %}
|
||||
<form class="inline-edit"
|
||||
hx-post="/chats/{{ chat.id }}/drawer/memory/{{ m.id }}/significance"
|
||||
hx-target="#drawer" hx-swap="innerHTML">
|
||||
<label>
|
||||
Significance:
|
||||
<input type="range" name="significance" min="0" max="3"
|
||||
value="{{ m.significance|default(0) }}"
|
||||
oninput="this.nextElementSibling.value = this.value">
|
||||
<output>{{ m.significance|default(0) }}</output>
|
||||
</label>
|
||||
<button type="submit">Save</button>
|
||||
</form>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</details>
|
||||
{% endif %}
|
||||
</section>
|
||||
|
||||
<section class="drawer-section">
|
||||
<h3>Pinned memories ({{ pinned|length }} / {{ pin_cap }})</h3>
|
||||
{% if pinned %}
|
||||
|
||||
@@ -181,6 +181,21 @@ async def drawer(chat_id: str, request: Request, conn=Depends(get_conn)):
|
||||
# returns both flavours and the template highlights the active one).
|
||||
branches = list_branches_with_metadata(conn, chat_id)
|
||||
|
||||
# T98.2: significance distribution across this chat's memories. Powers
|
||||
# the "Significance review" panel — a small histogram letting authors
|
||||
# spot lopsided buckets (e.g. nothing significant=3 yet) and triage by
|
||||
# editing individual memory significance values.
|
||||
sig_rows = conn.execute(
|
||||
"SELECT significance, COUNT(*) FROM memories "
|
||||
"WHERE chat_id = ? GROUP BY significance ORDER BY significance",
|
||||
(chat_id,),
|
||||
).fetchall()
|
||||
significance_distribution = {int(r[0]): int(r[1]) for r in sig_rows}
|
||||
# Ensure every bucket 0..3 is present so the bar-chart template can
|
||||
# render a stable axis even when a level has zero rows.
|
||||
for level in (0, 1, 2, 3):
|
||||
significance_distribution.setdefault(level, 0)
|
||||
|
||||
return TEMPLATES.TemplateResponse(
|
||||
request,
|
||||
"_drawer.html",
|
||||
@@ -209,6 +224,7 @@ async def drawer(chat_id: str, request: Request, conn=Depends(get_conn)):
|
||||
"active_events": active_events,
|
||||
"open_threads": open_threads,
|
||||
"branches": branches,
|
||||
"significance_distribution": significance_distribution,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user