Skip to content

Speakr is a personal, self-hosted web application designed for transcribing audio recordings

Python

fix: inquire citation pills derive the timestamp from the link's ?t= seek param and strip any raw-seconds '@ 1317' tail from titles, so pills always show a formatted time and Sources stay clean

Murtaza Nasird73247e8dd2a
diff --git a/src/services/inquire_agent.py b/src/services/inquire_agent.py
index b52a0c64..f37eeb5f 100644
--- a/src/services/inquire_agent.py
+++ b/src/services/inquire_agent.py
@@ -569,7 +569,8 @@ Never invent content that is not in the tool results; say clearly when something
{tool_mode_prompt_block}When you give your final answer:
- Use clear markdown (headings per recording where it helps, bullets, **bold** speaker names).
- Cite sources inline as markdown links. When the supporting search result has a time and \
-seek_seconds, link directly to that moment using the result's `time` value verbatim: \
+seek_seconds, link directly to that moment using the result's `time` value verbatim (the colon \
+form like 12:34 — never the raw seek_seconds number): \
[Title @ time](/recordings/<recording_id>?t=<seek_seconds>) — for example \
[Weekly Sync @ 12:34](/recordings/73?t=754) or [Board Meeting @ 1:31:03](/recordings/80?t=5463). \
Without a timestamp, link the recording: \
diff --git a/templates/inquire.html b/templates/inquire.html
index ab92d14e..9a53b9ab 100644
--- a/templates/inquire.html
+++ b/templates/inquire.html
@@ -963,20 +963,40 @@
tpl.innerHTML = html;
const links = [...tpl.content.querySelectorAll('a[href^="/recordings/"]')];
if (!links.length) return html;
+ const fmtSeconds = (s) => {
+ s = Math.max(0, Math.floor(s));
+ const h = Math.floor(s / 3600), m = Math.floor((s % 3600) / 60), sec = s % 60;
+ return h > 0
+ ? h + ':' + String(m).padStart(2, '0') + ':' + String(sec).padStart(2, '0')
+ : m + ':' + String(sec).padStart(2, '0');
+ };
const refs = new Map(); // recording id -> {n, title, href}
for (const a of links) {
- const m = (a.getAttribute('href') || '').match(/^\/recordings\/(\d+)/);
+ const href = a.getAttribute('href') || '';
+ const m = href.match(/^\/recordings\/(\d+)/);
if (!m) continue;
const recId = m[1];
const raw = (a.textContent || '').trim();
- const tm = raw.match(/@\s*(\d+:\d{2}(?::\d{2})?)\s*$/);
+ // Timestamp truth is the href's seek param; the
+ // link text is only a fallback (the model
+ // sometimes writes raw seconds like "@ 1317"
+ // instead of the formatted time).
+ const tm = raw.match(/@\s*(\d+(?::\d{1,2}){0,2})\s*$/);
+ let seconds = null;
+ const th = href.match(/[?&]t=(\d+)/);
+ if (th) {
+ seconds = parseInt(th[1], 10);
+ } else if (tm) {
+ const parts = tm[1].split(':').map(Number);
+ seconds = parts.reduce((acc, p) => acc * 60 + p, 0);
+ }
const title = (tm ? raw.slice(0, tm.index) : raw).trim() || ('Recording ' + recId);
if (!refs.has(recId)) {
refs.set(recId, { n: refs.size + 1, title: title, href: '/recordings/' + recId });
}
const entry = refs.get(recId);
if (title.length > entry.title.length) entry.title = title;
- a.textContent = tm ? (entry.n + ' @ ' + tm[1]) : String(entry.n);
+ a.textContent = seconds !== null ? (entry.n + ' @ ' + fmtSeconds(seconds)) : String(entry.n);
a.setAttribute('title', entry.title);
}
if (message) {