read.markets/app/templates/partials/news.html
Giorgio Gilestro 2013bfa8cc news: auto-tag headlines + market-aware cadence + filter UI
- Move news_job from hourly to 3x/hour (cron 10,30,50), with a CadencePolicy
  gate that throttles to active hours (07-21 UTC weekdays at 20 min), off-hours
  (3 h), weekends (6 h). Keeps the daytime feed fresh without spamming RSS
  sources overnight.
- Tag each headline on ingestion via DeepSeek (BATCH_SIZE=25, max_tokens=4000,
  json.JSONDecoder().raw_decode + per-row regex recovery for resilient parsing).
  Vocabulary: 16 tags including new EU / USA / AI / Conflict. NULL tags are
  picked up automatically on the next news_job run, so back-tagging is implicit
  rather than a separate migration step.
- Tag UI: pill bar above the feed with off → include → exclude cycle on click;
  shift-click jumps straight to exclude. State persists in localStorage and is
  injected into /api/news requests via htmx:configRequest. Per-row chips sit to
  the right of the headline (new 5-column grid: age | source | title | tags |
  UTC) so vertical density stays high.
- Strategic log header bug: model was hallucinating "(Updated 21:30 UTC)" in
  future tense. Bumped PROMPT_VERSION 6→7, added explicit ban on time-of-day
  clauses, and supply the actual current UTC time in the user prompt so the
  model has no need to invent one.

Migration 0012 adds headlines.tags (JSON, nullable). Tests cover vocabulary
integrity, validation/normalisation, and the JSON-recovery parser (17 tests).
2026-05-21 23:25:03 +01:00

35 lines
1.4 KiB
HTML

{% if tag_vocabulary %}
<div class="news-tags" data-include="{{ active_include|join(',') }}" data-exclude="{{ active_exclude|join(',') }}">
{% for tag in tag_vocabulary %}
<button type="button" class="news-tag"
data-tag="{{ tag }}"
{% if tag in active_include %}data-state="include"{% elif tag in active_exclude %}data-state="exclude"{% endif %}
title="{{ tag_labels.get(tag, tag) }} — click to include only, shift-click to exclude">
{{ tag_labels.get(tag, tag) }}
</button>
{% endfor %}
{% if active_include or active_exclude %}
<button type="button" class="news-tag news-tag--clear" data-tag="" title="Clear all filters">clear</button>
{% endif %}
</div>
{% endif %}
{% if not headlines %}
<div class="empty">no headlines in window{% if active_include or active_exclude %} (after tag filter){% endif %}</div>
{% else %}
{% for h in headlines %}
<div class="news-row">
<span class="age">{{ h.age }}</span>
<span class="source">{{ h.source }}</span>
<a class="title" href="{{ h.url }}" target="_blank" rel="noopener">{{ h.title }}</a>
<span class="news-row__tags">
{% for t in h.tags or [] %}<span class="tag-chip" data-tag="{{ t }}">{{ tag_labels.get(t, t) }}</span>{% endfor %}
</span>
{% if h.iso %}
<time class="local" datetime="{{ h.iso }}" title="{{ h.iso }}">{{ h.utc_short }}</time>
{% else %}
<span class="local"></span>
{% endif %}
</div>
{% endfor %}
{% endif %}