Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixed-recording-ux-display.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Inbox ● Record: the "Saved to the Inbox" panel now follows the recording's item, says "Transcribed. See the item below." (or why transcription failed or is off) and then closes itself with the toast countdown; the item preview shows the plain transcript text instead of the provenance line and untrusted-data envelope; hive recordings and dropped audio files get a plain "Transcript made by this hive with <provider>/<model> on <date>." line; and the player says how long the audio is kept on this hive instead of "the recording is not stored".
17 changes: 16 additions & 1 deletion src/docs/inbox-recording.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,17 @@ When you stop, the hive transcribes the recording automatically with its
built-in whisper first, so the audio stays on the hive), with the same
progress bar and time-left estimate as any other Inbox transcription. The
transcriber reads the file from the hive's own disk; nothing is fetched over
HTTP. The transcript is written into the recording's Knowledge fact.
HTTP. The transcript is written into the recording's Knowledge fact under the
line `_Transcript made by this hive with whisper/base.en on 2026-11-16._`
(provider, model and day); the
Inbox preview shows the transcript text only.

The **Saved to the Inbox** panel above the Inbox follows the item: it says
**Transcribed. See the item below.** once the transcript lands, or
**Transcription failed:** with the reason (or that transcription is off), and then
closes itself with the same countdown bar and duration as the dashboard's
toasts (hovering or focusing it pauses the countdown). **Close** dismisses it
at once.

- Recording does **not** replace the hive-wide transcription consent: nothing
is transcribed until an owner enables `inbox.transcription` with
Expand All @@ -107,6 +117,11 @@ HTTP. The transcript is written into the recording's Knowledge fact.
| Knowledge fact (personal layer, never published to the hub) | kept |
| Recording metadata (title, who, when, duration, consent version) | kept |

While the audio is kept, the note under the player says **The audio is kept
on this hive until** the day the recording ended plus `retention_days`,
**then deleted; the transcript stays.** Dropped audio files say the same with
the upload retention.

After the audio is deleted the item shows **audio expired (kept 5 days)**
(with the configured number of days) and has no play control; the transcript
and the fact stay readable and shareable. The sweep that deletes audio runs at
Expand Down
37 changes: 37 additions & 0 deletions src/pkg/dashboard/inbox_audio_note.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Inbox player note: audio this hive stores (hive recordings, dropped audio
// files) says how long it is kept; third-party audio is streamed, not stored.
// Run: node --test src/pkg/dashboard/*.test.js
const test = require('node:test');
const assert = require('node:assert');
const fs = require('node:fs');
const path = require('node:path');

const html = fs.readFileSync(path.join(__dirname, 'static', 'index.html'), 'utf8');
const fnSrc = name => {
const start = html.indexOf('function ' + name + '(');
assert.ok(start >= 0, name + ' not found');
let depth = 0;
for (let i = html.indexOf('{', start); i < html.length; i++) {
if (html[i] === '{') depth++;
else if (html[i] === '}' && --depth === 0) return html.slice(start, i + 1);
}
throw new Error('unbalanced ' + name);
};
const inboxAudioNoteText = new Function(fnSrc('inboxAudioNoteText') + '\nreturn inboxAudioNoteText;')();
const fmt = d => 'DAY(' + d + ')';

test('hive-stored audio names the day retention deletes it', () => {
for (const source of ['hive-recording', 'upload']) {
const out = inboxAudioNoteText({ source, audio_expires_at: '2026-11-21T10:00:00Z' }, fmt);
assert.strictEqual(out, 'The audio is kept on this hive until DAY(2026-11-21T10:00:00Z), then deleted; the transcript stays. Click ▶ Play recording again to restart.');
assert.doesNotMatch(out, /not stored/);
}
assert.strictEqual(inboxAudioNoteText({ source: 'upload' }, fmt), 'The audio is kept on this hive. Click ▶ Play recording again to restart.');
assert.strictEqual(inboxAudioNoteText({ source: 'hive-recording', audio_expires_at: '0001-01-01T00:00:00Z' }, fmt), 'The audio is kept on this hive. Click ▶ Play recording again to restart.');
});

test('third-party audio keeps the streaming note', () => {
for (const it of [{ source: 'plaud' }, { source: 'zoom', audio_expires_at: '2026-11-21T10:00:00Z' }, undefined]) {
assert.strictEqual(inboxAudioNoteText(it, fmt), 'Streaming through this hive; the recording is not stored. Click ▶ Play recording again to restart.');
}
});
1 change: 1 addition & 0 deletions src/pkg/dashboard/inbox_audio_stream.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const harness = ({ fetchReply, share, clipboardOK = true } = {}) => {
const items = [{ source: 'plaud', id: 'f_01', title: 'cost considerations' }];
const api = new Function('document', 'fetch', 'navigator', 'location', 'CSS', 'showToast', 'writeClipboardText', 'window', 'renderInbox', 'items',
'function inboxFind(src, id) { return items.find(it => it.source === src && it.id === id); }\n' +
'function formatDashboardDate(d) { return String(d); }\n' + fnSrc('inboxAudioNoteText') + '\n' +
fnSrc('inboxApiPath') + '\n' + fnSrc('inboxStreamURL') + '\n' + fnSrc('inboxAudioErrorReason') + '\n' + fnSrc('inboxPlay') + '\n' +
constSrc('INBOX_SHARE_HASH') + '\n' + fnSrc('inboxShareLink') + '\n' + fnSrc('inboxFocusKeyFromHash') + '\n' + fnSrc('inboxShareCopy') + '\n' + fnSrc('inboxShareNative') + '\n' +
'return { inboxPlay, inboxStreamURL, inboxAudioErrorReason, inboxShareLink, inboxFocusKeyFromHash, inboxShareCopy, inboxShareNative };',
Expand Down
38 changes: 37 additions & 1 deletion src/pkg/dashboard/inbox_recorder.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ const escapeHtml = s => String(s == null ? '' : s).replace(/&/g, '&amp;').replac

const FNS = ['inboxRecSupport', 'inboxRecRoleCanRecord', 'inboxRecAvailable', 'inboxRecFmtClock', 'inboxRecLevel', 'inboxRecSplit',
'inboxRecConsentText', 'inboxRecDefaultTitle', 'inboxRecConsentHtml', 'inboxRecMemoryQueue', 'inboxRecUploader', 'inboxRecorderMachine',
'inboxRecResumePending', 'inboxRecUploadText', 'inboxRecMeterHtml', 'inboxRecPanelHtml', 'inboxRecTabSupport', 'inboxRecSourcesHtml', 'inboxRecCaptureTab'];
'inboxRecResumePending', 'inboxRecUploadText', 'inboxRecMeterHtml', 'inboxRecPanelHtml', 'inboxRecTabSupport', 'inboxRecSourcesHtml', 'inboxRecCaptureTab',
'inboxRecDoneOutcome', 'inboxRecDoneText'];
const lib = new Function('escapeHtml', consts() + '\n' + FNS.map(fnSrc).join('\n') + '\nreturn {' + FNS.join(',') + ', CONSENT: INBOX_REC_CONSENT_VERSION, ACK: INBOX_REC_CONSENT_ACK };')(escapeHtml);

const flush = async (n = 20) => { for (let i = 0; i < n; i++) await new Promise(r => setImmediate(r)); };
Expand Down Expand Up @@ -397,3 +398,38 @@ test('cancelling the tab picker records the microphone only', async () => {
assert.match(m.warning, /No tab was shared/);
assert.strictEqual(hive.start.includes_tab_audio, false);
});

test('the saved panel follows the item: transcribed, failed, off, stalled, waiting', () => {
const o = (it, transcribes = true, why = '', waited = false) => lib.inboxRecDoneOutcome(it, transcribes, why, waited);
assert.deepStrictEqual(o(null), { state: 'waiting', reason: '' });
assert.deepStrictEqual(o(null, false), { state: 'off', reason: '' });
assert.strictEqual(o({ transcription: { status: 'running' } }).state, 'waiting');
assert.strictEqual(o({ transcription: { status: 'done' } }).state, 'transcribed');
assert.strictEqual(o({ fact_state: 'machine' }).state, 'transcribed');
assert.strictEqual(o({ has_transcript: true }, false).state, 'transcribed', 'text wins over transcription being off');
assert.deepStrictEqual(o({ transcription: { status: 'failed', reason: 'whisper crashed' } }), { state: 'failed', reason: 'whisper crashed' });
assert.deepStrictEqual(o({ transcribe_unavailable: 'budget' }, true, 'Monthly budget used'), { state: 'failed', reason: 'Monthly budget used' });
assert.strictEqual(o({ transcribe_unavailable: 'disabled' }).state, 'off');
assert.strictEqual(o({}, true, '', true).state, 'stalled');
assert.strictEqual(o({ transcription: { status: 'queued' } }, true, '', true).state, 'waiting', 'a queued job is still followed');

assert.strictEqual(lib.inboxRecDoneText({ state: 'transcribed' }), 'Transcribed. See the item below.');
assert.match(lib.inboxRecDoneText({ state: 'failed', reason: 'whisper crashed' }), /^Transcription failed: whisper crashed\. The recording is saved/);
assert.match(lib.inboxRecDoneText({ state: 'waiting' }), /transcribing it now/);
assert.match(lib.inboxRecDoneText({ state: 'off' }), /Transcription is off on this hive/);

const done = { state: 'done', title: 'Standup', levels: {}, elapsedMs: () => 4000, outcome: { state: 'transcribed', reason: '' } };
let out = lib.inboxRecPanelHtml(done);
assert.match(out, /data-inbox-rec-outcome="transcribed">Transcribed\. See the item below\.</);
assert.doesNotMatch(out, /transcribing it now/, 'the stale line is gone');
assert.match(out, /data-action="inboxRecClose"/, 'Close stays');
out = lib.inboxRecPanelHtml(Object.assign({}, done, { outcome: { state: 'failed', reason: 'no audio' } }));
assert.match(out, /class="kc-error muted-xs"[^>]*data-inbox-rec-outcome="failed">Transcription failed: no audio\./);
});

test('the saved panel auto-dismisses with the toast countdown, not its own timer', () => {
const src = fnSrc('inboxRecArmDismiss');
assert.match(src, /toastCountdownBar\(panel, TOAST_DURATION_MS,/);
assert.match(fnSrc('inboxRecSyncDone'), /inboxRecArmDismiss\(m\)/);
assert.match(fnSrc('fetchInbox'), /inboxRecSyncDone\(_inboxCache\.items\)/);
});
7 changes: 6 additions & 1 deletion src/pkg/dashboard/static-src/css/inbox.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@
.inbox-add-url { flex: 1 1 16rem; min-width: 0; }
.inbox-upload .kc-error { flex-basis: 100%; }
/* ● Record (inbox-recorder.js): panel, red indicator, level meters */
.inbox-rec-panel { margin-bottom: var(--sp-4); padding: var(--sp-3) var(--sp-4); border: 1px solid var(--border); border-left: 3px solid var(--red); border-radius: var(--r); background: var(--surface); }
.inbox-rec-panel { position: relative; overflow: hidden; margin-bottom: var(--sp-4); padding: var(--sp-3) var(--sp-4); border: 1px solid var(--border); border-left: 3px solid var(--red); border-radius: var(--r); background: var(--surface); }
/* The saved panel auto-dismisses with the toast countdown bar (toastCountdownBar). */
.inbox-rec-panel .toast-bar { background: color-mix(in srgb, var(--green) 40%, transparent); }
.inbox-rec-panel[data-outcome="failed"] .toast-bar { background: color-mix(in srgb, var(--red) 40%, transparent); }
.inbox-rec-panel[data-outcome="stalled"] .toast-bar { background: color-mix(in srgb, var(--status-warn) 40%, transparent); }
.inbox-rec-panel[data-outcome="off"] .toast-bar { background: color-mix(in srgb, var(--blue) 40%, transparent); }
.inbox-rec-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.inbox-rec-dot { color: var(--red); }
.inbox-rec-dot.is-live { animation: inbox-rec-pulse 1.2s ease-in-out infinite; }
Expand Down
87 changes: 83 additions & 4 deletions src/pkg/dashboard/static-src/js/inbox-recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
// A live recorder holds a Web Lock with this prefix, so another tab of
// the same browser never finalizes a recording that is still running.
const INBOX_REC_LOCK_PREFIX = 'hive-inbox-recording-';
// After a recording is saved the panel follows its Inbox item: the
// Inbox is re-read this often while the item shows no transcription
// state yet (a running job is followed by the transcription poll), for
// at most INBOX_REC_DONE_WAIT_MS before the panel stops waiting.
const INBOX_REC_DONE_POLL_MS = 5000;
const INBOX_REC_DONE_WAIT_MS = 120000;

let _inboxRec = null;

Expand Down Expand Up @@ -597,7 +603,10 @@
if (m.uploader) html += '<div class="muted-xs inbox-rec-upload" data-inbox-rec-upload aria-live="polite">' + escapeHtml(inboxRecUploadText(m.uploader.state)) + '</div>';
if (m.warning) html += '<div class="kc-error muted-xs" role="alert">' + escapeHtml(m.warning) + '</div>';
if (m.error) html += '<div class="kc-error muted-xs" role="alert">' + escapeHtml(m.error) + '</div>';
if (m.state === 'done') html += '<div class="muted-xs">' + escapeHtml(m.transcribes ? 'The hive is transcribing it now; follow the progress on the item in the Inbox below.' : 'It appears in the Inbox below. Transcription is off on this hive, so it is not transcribed yet.') + '</div>';
if (m.state === 'done') {
const o = m.outcome || inboxRecDoneOutcome(null, m.transcribes, '', false);
html += '<div class="' + (o.state === 'failed' ? 'kc-error ' : '') + 'muted-xs" role="status" data-inbox-rec-outcome="' + escapeHtml(o.state) + '">' + escapeHtml(inboxRecDoneText(o)) + '</div>';
}
html += '<div class="kc-actions mt-2">';
if (m.state === 'recording') html += '<button type="button" class="hv-btn btn-secondary btn-sm" data-action="inboxRecPause">⏸ Pause</button>';
if (m.state === 'paused') html += '<button type="button" class="hv-btn btn-secondary btn-sm" data-action="inboxRecResume">⏺ Resume</button>';
Expand All @@ -607,6 +616,61 @@
if (m.state === 'done' || m.state === 'error') html += '<button type="button" class="hv-btn btn-secondary btn-sm" data-action="inboxRecClose">Close</button>';
return html + '</div>';
}
// inboxRecDoneOutcome is where a saved recording's Inbox item stands:
// transcribed (the item has text), failed (the job failed or was
// skipped, or the hive cannot transcribe it; reason says why), off
// (transcription is off on this hive), stalled (no job appeared within
// INBOX_REC_DONE_WAIT_MS: waitedOut) or waiting. Every state but waiting
// starts the panel's auto-dismiss countdown.
function inboxRecDoneOutcome(it, transcribes, unavailableText, waitedOut) {
const tx = (it && it.transcription) || null;
if (it && (it.has_transcript || it.fact_state === 'machine' || (tx && tx.status === 'done'))) return { state: 'transcribed', reason: '' };
if (tx && (tx.status === 'failed' || tx.status === 'skipped')) return { state: 'failed', reason: tx.reason || '' };
if (tx && (tx.status === 'queued' || tx.status === 'running')) return { state: 'waiting', reason: '' };
if (!transcribes || (it && it.transcribe_unavailable === 'disabled')) return { state: 'off', reason: '' };
if (it && it.transcribe_unavailable) return { state: 'failed', reason: unavailableText || '' };
if (waitedOut) return { state: 'stalled', reason: '' };
return { state: 'waiting', reason: '' };
}
// inboxRecDoneText is the panel line for an outcome.
function inboxRecDoneText(o) {
switch (o && o.state) {
case 'transcribed': return 'Transcribed. See the item below.';
case 'failed': return 'Transcription failed' + (o.reason ? ': ' + o.reason : '') + '. The recording is saved in the Inbox below; retry the transcription from the item.';
case 'off': return 'It appears in the Inbox below. Transcription is off on this hive, so it is not transcribed yet.';
case 'stalled': return 'Saved in the Inbox below. Transcription has not started yet; follow it on the item.';
default: return 'The hive is transcribing it now; follow the progress on the item in the Inbox below.';
}
}
// inboxRecSyncDone runs after every Inbox read: it finds the saved
// recording's item, updates the panel line, and once the outcome is
// final starts the same auto-dismiss countdown toasts use (bar, duration
// and pause on hover or focus). Close still dismisses at once.
function inboxRecSyncDone(items) {
const m = _inboxRec;
if (!m || m.state !== 'done' || !m.id) return;
if (!m.doneAt) m.doneAt = Date.now();
const it = (items || []).find(x => x && x.source === 'hive-recording' && x.id === m.id) || null;
const waitedOut = Date.now() - m.doneAt >= INBOX_REC_DONE_WAIT_MS;
const why = it && it.transcribe_unavailable && typeof inboxTxUnavailableText === 'function' ? inboxTxUnavailableText(it.transcribe_unavailable) : '';
const o = inboxRecDoneOutcome(it, m.transcribes, why, waitedOut);
const changed = !m.outcome || m.outcome.state !== o.state || m.outcome.reason !== o.reason;
m.outcome = o;
if (changed) inboxRecRender();
clearTimeout(m.donePoll);
m.donePoll = 0;
if (o.state !== 'waiting') { inboxRecArmDismiss(m); return; }
// A running job is followed by the Inbox's own transcription poll.
const busy = it && it.transcription && (it.transcription.status === 'queued' || it.transcription.status === 'running');
if (!busy && typeof fetchInbox === 'function') m.donePoll = setTimeout(() => { if (_inboxRec === m) fetchInbox(); }, INBOX_REC_DONE_POLL_MS);
}
function inboxRecArmDismiss(m) {
const panel = document.getElementById('inbox-rec-panel');
if (!panel || m.dismissArmed || typeof toastCountdownBar !== 'function') return;
m.dismissArmed = true;
if (m.outcome) panel.dataset.outcome = m.outcome.state;
toastCountdownBar(panel, TOAST_DURATION_MS, () => { if (_inboxRec === m) inboxRecClose(); });
}
// The timer and meters redraw on a dashboard interval (paused while the
// page is hidden); the length limit has its own timeout so it holds in
// the background too.
Expand All @@ -624,12 +688,27 @@
const m = _inboxRec;
const panel = document.getElementById('inbox-rec-panel');
const html = inboxRecPanelHtml(m);
if (panel) { panel.hidden = !html; panel.innerHTML = html; }
if (panel) {
// A countdown belongs to the saved recording it was armed for.
if (panel._countdown && !(m && m.state === 'done' && m.dismissArmed) && typeof toastCountdownCancel === 'function') toastCountdownCancel(panel);
panel.hidden = !html;
if (m && m.outcome) panel.dataset.outcome = m.outcome.state; else delete panel.dataset.outcome;
if (panel._html !== html) {
panel._html = html;
panel.innerHTML = html;
// The rewrite dropped the countdown bar; put it back where it was.
if (panel._countdown && panel._countdown.bar) panel.appendChild(panel._countdown.bar);
}
}
inboxRecIndicator(m);
const live = m && (m.state === 'recording' || m.state === 'paused');
if (live && !_inboxRecTicker) { _inboxRecTicker = true; dashboardSetInterval('inbox-recorder', inboxRecTick, INBOX_REC_TICK_MS); }
if (!live && _inboxRecTicker) { _inboxRecTicker = false; dashboardClearInterval('inbox-recorder'); }
if (m && m.state === 'done' && !m.listed) { m.listed = true; inboxRecWakeLock(false); if (typeof fetchInbox === 'function') fetchInbox(); }
if (m && m.state === 'done' && !m.listed) {
m.listed = true; inboxRecWakeLock(false);
if (!m.transcribes) { m.outcome = inboxRecDoneOutcome(null, false, '', false); inboxRecArmDismiss(m); }
if (typeof fetchInbox === 'function') fetchInbox();
}
if (m && m.state === 'error') inboxRecWakeLock(false);
const btn = document.querySelector('#inbox-panel .inbox-rec-btn');
if (btn) btn.outerHTML = inboxRecordButtonHtml((_inboxCache || {}).settings || {});
Expand Down Expand Up @@ -684,7 +763,7 @@
_inboxRec = null;
inboxRecRender();
}
function inboxRecClose() { _inboxRec = null; inboxRecRender(); }
function inboxRecClose() { if (_inboxRec) clearTimeout(_inboxRec.donePoll); _inboxRec = null; inboxRecRender(); }
// inboxRecFinishEarlier finalizes the user's earlier recording that is
// still open on the hive (another tab or device stopped sending), so a
// new one can start.
Expand Down
Loading
Loading