Knowledge: each card says when its TRIAGE.md was last updated, with the date, instead of when it's checked

This commit is contained in:
juansebsol committed 2026-10-17 23:09:05 -07:00
1 parent 122ab2eb33
commit d26853bf44
5 files changed
+14 -24

No files matched your search

+3 -3
View File
@@ -1348,9 +1348,9 @@ a.feed-row:focus-visible { outline-offset: -2px; }
.kn-file.is-failed > .ic { color: var(--warn); }
.kn-card-lines { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; }
.kn-card-lines > * { max-width: 100%; }
.kn-changes, .kn-check { display: inline-flex; align-items: flex-start; gap: 6px; min-width: 0; font-size: 12px; line-height: 16px; color: var(--muted); font-variant-numeric: tabular-nums; }
.kn-changes > .ic, .kn-check > .ic { flex: none; margin-top: 1px; }
.kn-changes > span, .kn-check > span { min-width: 0; }
.kn-changes { display: inline-flex; align-items: flex-start; gap: 6px; min-width: 0; font-size: 12px; line-height: 16px; color: var(--muted); font-variant-numeric: tabular-nums; }
.kn-changes > .ic { flex: none; margin-top: 1px; }
.kn-changes > span { min-width: 0; }
.kn-changes.has { color: var(--text); }
.kn-changes.has > .ic { color: var(--accent-text); }
.kn-card-text { flex: 1; font-size: 13px; line-height: 20px; color: var(--muted); }
+3 -6
View File
@@ -16,16 +16,13 @@
// ---- Local times ----------------------------------------------------------------------------
// <time data-local>: in the viewer's own time zone ("today at 2:32 PM", "Oct 15 at 9:10 AM").
// <time data-local>: the date and time in the viewer's own time zone ("Oct 17 at 9:05 PM").
function localTimes(ctx) {
var now = new Date();
var today = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime();
var year = new Date().getFullYear();
$$('time[data-local]', ctx).forEach(function (t) {
var d = new Date(t.getAttribute('datetime'));
if (isNaN(d.getTime())) return;
var days = Math.round((today - new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime()) / 86400000);
var date = days === 0 ? 'today' : days === 1 ? 'yesterday'
: d.toLocaleDateString(undefined, d.getFullYear() === now.getFullYear() ? { month: 'short', day: 'numeric' } : { month: 'short', day: 'numeric', year: 'numeric' });
var date = d.toLocaleDateString(undefined, d.getFullYear() === year ? { month: 'short', day: 'numeric' } : { month: 'short', day: 'numeric', year: 'numeric' });
t.textContent = date + ' at ' + d.toLocaleTimeString(undefined, { hour: 'numeric', minute: '2-digit' });
t.title = d.toLocaleString(undefined, { dateStyle: 'full', timeStyle: 'short' });
});
+2 -10
View File
@@ -93,13 +93,6 @@ function checks(k: AppKnowledge, every: number, now = Date.now()): { quiet: Date
return { quiet, next: ms <= 60_000 ? 'now' : `in ${inTime(ms)}`, soon: ms <= 60_000 };
}
/** "Checked 12 min ago, nothing new · next check in 1 h 48 min", under the TRIAGE.md line of each card. */
function checkLine(k: AppKnowledge | null | undefined, every: number, triageOn: boolean): SafeHtml | '' {
if (!k?.auto_at || stateOf(k) !== 'done') return '';
if (!triageOn) return html`<span class="kn-check">${icon('clock', 14)}<span>Checks start once AI triage is on</span></span>`;
const { quiet, next, soon } = checks(k, every);
return html`<span class="kn-check">${icon('clock', 14)}<span>${quiet ? html`Checked ${ago(quiet)}, nothing new · next ${next}` : soon ? 'Checking now' : `Next check ${next}`}</span></span>`;
}
/** When the merged changes waiting go into an app's TRIAGE.md: at its next update. */
function changesDue(lastAt: Date | null, every: number, now = Date.now()): string {
@@ -119,7 +112,7 @@ const busy = (s: State) => s === 'queued' || s === 'running';
/** Merged changes were added since the last full write. */
const updatedSince = (k: AppKnowledge | null | undefined) => Boolean(k?.auto_at && k.auto_full_at && k.auto_at.getTime() > k.auto_full_at.getTime());
/** "TRIAGE.md · Updated today at 2:32 PM", with the state of the latest write. */
/** "TRIAGE.md · Last updated Oct 17 at 9:05 PM", with the state of the latest write. */
function fileLine(k: AppKnowledge | null | undefined): SafeHtml {
const s = stateOf(k);
const lead = s === 'running' ? icon('loader-circle', 14, 'kn-spin') : s === 'queued' ? icon('clock', 14) : s === 'failed' ? icon('triangle-alert', 14, 'warn') : icon('file-text', 14);
@@ -127,7 +120,7 @@ function fileLine(k: AppKnowledge | null | undefined): SafeHtml {
running: 'Claude is writing it…',
queued: 'Waiting to be written…',
failed: isWritten(k) ? 'Couldn’t update it' : 'Couldn’t write it',
done: k?.auto_at ? html`Updated ${localTime(k.auto_at)}` : '',
done: k?.auto_at ? html`Last updated ${localTime(k.auto_at)}` : '',
none: 'Not written yet',
};
return html`<span class="kn-file is-${s}">${lead}<span class="mono">TRIAGE.md</span><span class="muted">·</span><span class="kn-file-state">${text[s]}</span></span>`;
@@ -248,7 +241,6 @@ export function registerTriageKnowledgeRoutes(app: FastifyInstance, web: Web): v
${q?.fresh ? html`<span class="kn-new" title="Questions Claude asked and hasn’t answered, since your team last saved its notes">${icon('lightbulb', 12)}${plural(q.fresh, 'question')}</span>` : ''}</span>
<span class="kn-card-lines">
${fileLine(k)}
${c.knowledgeAuto ? checkLine(k, intervalMs(c.knowledgeEvery), anyOn) : ''}
${tracking ? (() => {
const ch = changed.get(a.id);
return html`<span class="kn-changes${ch?.today ? ' has' : ''}">${icon('git-merge', 14)}<span>${ch?.today ? `${plural(ch.today, 'change')} merged today${ch.added ? ` · ${n(ch.added)} added to TRIAGE.md` : ''}` : 'Nothing merged today'}${ch?.pending ? ` · ${n(ch.pending)} waiting` : ''}</span></span>`;
+1 -1
View File
@@ -319,7 +319,7 @@ export function formatDate(d: Date | null | undefined): string {
return d.toISOString().replace('T', ' ').slice(0, 16) + ' UTC';
}
/** A date and time each viewer sees in their own time zone ("today at 2:32 PM", see app.js); UTC until then. */
/** A date and time each viewer sees in their own time zone ("Oct 17 at 9:05 PM", see app.js); UTC until then. */
export function localTime(d: Date): SafeHtml {
return html`<time datetime="${d.toISOString()}" data-local title="${formatDate(d)}">${formatDate(d)}</time>`;
}
+5 -4
View File
@@ -183,7 +183,7 @@ describe('Knowledge: Claude writes each app’s TRIAGE.md', () => {
expect((await page('/triage/knowledge?partial=1')).body).toContain('data-live-reload');
const list = (await page('/triage/knowledge')).body;
expect(list).toMatch(/TRIAGE\.md<\/span><span class="muted">·<\/span><span class="kn-file-state">Updated <time datetime="[^"]+" data-local title="[^"]+ UTC">[^<]+ UTC<\/time>/);
expect(list).toMatch(/TRIAGE\.md<\/span><span class="muted">·<\/span><span class="kn-file-state">Last updated <time datetime="[^"]+" data-local title="[^"]+ UTC">[^<]+ UTC<\/time>/);
expect(list).toContain('<span class="tag" >Known issues</span>');
expect(list).toContain('Update all');
expect(list).not.toContain('Write all');
@@ -287,9 +287,9 @@ describe('Knowledge: Claude writes each app’s TRIAGE.md', () => {
// Two days later, nothing changed: nothing to do.
await writtenDaysAgo(2);
expect(await env.triage.engine.knowledge.scheduleUpdates()).toBe(0);
// The look is noted, on the card too: the next one is a day later.
// The look is noted (on the app's page): the next one is a day later.
expect((await knowledgeRow(photo().id)).auto_checked_at).toBeInstanceOf(Date);
expect((await page('/triage/knowledge')).body).toMatch(/<span class="kn-check">.*?<span>Checked <time[^>]*>just now<\/time>, nothing new · next in 24 hours<\/span><\/span>/);
expect((await page(`/triage/knowledge/${photo().id}`)).body).toMatch(/ · checked <time[^>]*>just now<\/time>, nothing new · next check in 24 hours<\/div>/);
// An issue opened in PhotoCraft's repository: at the next look, only PhotoCraft's is rewritten.
repo(0).issues.push({ number: 9, title: 'Crash when printing', body: 'It crashes.', labels: ['bug'], created_at: new Date().toISOString(), user: 'someone' });
@@ -338,7 +338,8 @@ describe('Knowledge: Claude writes each app’s TRIAGE.md', () => {
const one = (await page(`/triage/knowledge/${photo().id}`)).body;
expect(one).toContain('Claude reads it with every PhotoCraft ticket and updates it every 3 hours when something changed.');
expect(one).toContain('next check in 3 hours');
expect((await page('/triage/knowledge')).body).toMatch(/<span class="kn-check">.*?<span>Next check in 3 hours<\/span><\/span>/);
// The cards say when each was last updated, not when it's checked.
expect((await page('/triage/knowledge')).body).not.toContain('kn-check');
// An issue opened two hours later isn't enough yet; after three hours it is.
const hoursAgo = (h: number) => env.db.query('UPDATE app_knowledge SET auto_at = $1, auto_full_at = $1', [new Date(Date.now() - h * 3_600_000)]);