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/added-inbox-share-history.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Inbox items now show a pill for every share (RFC, spek, Knowledge, DIBS) recording what was shared, by whom, when and the status, linked to the RFC, dibs item, fact or spek session; the latest per destination shows and +N expands the history.
13 changes: 12 additions & 1 deletion dashboard/test/inbox-item.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ function makeContext(role) {
INBOX_DEST_LABELS: { spek_rfc: 'RFC', dibs: 'dibs' },
INBOX_INTENT_LABELS: { spek_rfc: 'RFC', dismiss: 'Knowledge', spek: 'spek' },
INBOX_SUMMARY_COLLAPSE_CHARS: 280,
INBOX_SHARE_LABELS: { rfc: 'RFC', dibs: 'DIBS', knowledge: 'Knowledge', spek: 'spek' },
_inboxHistoryOpen: new Set(),
_inboxSelected: new Set(),
_inboxExpanded: new Set(),
_inboxTranscriptOpen: new Set(),
Expand All @@ -49,7 +51,7 @@ function makeContext(role) {
Array,
};
vm.createContext(ctx);
for (const fn of ['inboxCanShare', 'inboxIntentLabel', 'inboxIntentThen', 'inboxSourceIcon', 'inboxItemHasAudio', 'inboxItemKey', 'inboxViewerCanPlay', 'inboxApiPath', 'inboxFmtDuration', 'inboxStatePill', 'inboxSummaryHtml', 'inboxTranscriptHtml', 'inboxTxUnavailableText', 'inboxTxEtaText', 'inboxTxElapsedText', 'inboxTxProgressHtml', 'inboxTranscriptionHtml', 'inboxItemHtml']) {
for (const fn of ['inboxSharePillText', 'inboxShareTargetHref', 'inboxSharePillHtml', 'inboxSharePillsHtml', 'inboxCanShare', 'inboxIntentLabel', 'inboxIntentThen', 'inboxSourceIcon', 'inboxItemHasAudio', 'inboxItemKey', 'inboxViewerCanPlay', 'inboxApiPath', 'inboxFmtDuration', 'inboxStatePill', 'inboxSummaryHtml', 'inboxTranscriptHtml', 'inboxTxUnavailableText', 'inboxTxEtaText', 'inboxTxElapsedText', 'inboxTxProgressHtml', 'inboxTranscriptionHtml', 'inboxItemHtml']) {
vm.runInContext(extractFunction(fn), ctx);
}
return ctx;
Expand Down Expand Up @@ -173,3 +175,12 @@ test('an uploaded document shows where it came from and who added it, its text,
// Uploaded audio keeps the player.
assert.match(vm.runInContext('inboxItemHtml(' + JSON.stringify(Object.assign({}, doc, { upload_kind: 'audio' })) + ')', ctx), /data-action="inboxPlay"/);
});

test('share history pills sit with the other pills and read users get no link', () => {
const withHistory = Object.assign({}, readyItem, { share_history: [{ id: 'sh-1', destination: 'rfc', actor: 'andy', status: 'done', started_at: '2026-11-16T10:00:00Z', ref: { number: 18412, url: 'https://github.com/o/r/issues/18412' } }] });
let html = vm.runInContext('inboxItemHtml(' + JSON.stringify(withHistory) + ')', makeContext('owner'));
assert.match(html, /<a class="kc-pill inbox-share-pill"[^>]*href="https:\/\/github\.com\/o\/r\/issues\/18412"[^>]*>→ RFC #18412 · andy · 2h ago</);
html = vm.runInContext('inboxItemHtml(' + JSON.stringify(withHistory) + ')', makeContext('read-only'));
assert.match(html, /<span class="kc-pill inbox-share-pill"[^>]*>→ RFC #18412/);
assert.doesNotMatch(html, /href="https:\/\/github/);
});
29 changes: 29 additions & 0 deletions src/cmd/hive/boot_inbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ const inboxSweepTimeout = 2 * time.Minute
// audio past inbox.recording.retention_days is deleted.
const inboxRecordingSweepInterval = 10 * time.Minute

// inboxRFCCheckInterval is how often delegated RFC shares are checked for
// their published issue.
const inboxRFCCheckInterval = 10 * time.Minute

// bootInbox builds the Inbox service. Sources are the configured knowledge
// connectors whose type is a voice source (inbox.sources, default
// plaud/wisprflow); with none configured the service still exists and lists
Expand Down Expand Up @@ -72,6 +76,31 @@ func (b *boot) bootInbox(baseDir string) {
})
b.inboxSvc = svc
b.startInboxRecordingSweep(svc)
// A delegated RFC share completes when its issue (carrying the item's
// provenance reference) shows up on the target repo; the finder reads
// b.ghClient at call time because that client is installed after boot.
svc.SetRFCFinder(func(ctx context.Context, repo, marker string) (string, error) {
if b.ghClient == nil {
return "", nil
}
return b.ghClient.FindIssueByBody(ctx, repo, marker)
})
if b.ctx != nil {
go func() {
t := time.NewTicker(inboxRFCCheckInterval)
defer t.Stop()
for {
select {
case <-b.ctx.Done():
return
case <-t.C:
ctx, cancel := context.WithTimeout(b.ctx, inboxSweepTimeout)
svc.CheckRFCPublications(ctx)
cancel()
}
}
}()
}
b.logger.Info("inbox started", "sources", len(srcs), "rules", len(b.cfg.Inbox.Rules))
if tx := b.cfg.Inbox.Transcription; tx.Enabled {
// Transcription reaches the provider from the hive process itself,
Expand Down
19 changes: 19 additions & 0 deletions src/docs/inbox-voice-sources.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,25 @@ see the issue linked from the changelog entry.
as a private draft idea (Bearer token from `inbox.dibs.token_env`).
- **Knowledge only** (`dismiss`): leaves the fact where it is and drops the
item from the unprocessed count.
- **Share history pills.** Every share of an item (🔗 Share → Hive, the bulk
Hive menu, an auto-routing rule or a spek session) appends a record to the
item's history and shows a pill next to the status pills, in the form
`→ RFC #18412 · andy · 2m ago`, `→ spek: nate-v2 · …`, `→ DIBS · …` or
`→ Knowledge · …`. A record carries the destination, the acting user
(`inbox-auto` for auto-routing), start and finish times, a status (`queued`,
`transcribing`, `in_progress`, `done`, `failed`, with the reason in the
pill's tooltip) and the target: the RFC issue or PR URL and number once the
agent's publish creates it, the dibs item, the Knowledge fact, or the spek
session. A pill links to its target for owners and read-write users; read
users see the same pills without links. Only the latest record per
destination shows; **+N** expands the full history. A delegated RFC stays in progress until the hive finds
the issue: after each sync and every 10 minutes it searches the target
repository for an issue whose body carries the item's `Reference:` line
(the agent prompt asks for it) and then fills the URL and number. If none
appears within 6 hours the share fails with that reason and the Share menu
offers a retry. The records never hold
item text or secrets and are stored with the item state. The list is the
`share_history` array of each item in `GET /api/inbox`.
- **State** per item per destination: `queued → running → filed | failed`
(`delegated` for → RFC, with a `note` naming the agent), with the RFC/idea
URL and child issue URLs, and the `error` text on `failed`. Stored in `connector-state/_inbox.json`.
Expand Down
4 changes: 2 additions & 2 deletions src/pkg/dashboard/api_inbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ func (s *Server) handleInboxRoute(w http.ResponseWriter, r *http.Request) {
waiting := false
if req.Destination == inbox.DestDibs {
// DIBS sends straight away, audio-only items included.
st, err = svc.Route(ctx, it, inbox.Request{Destination: req.Destination, Repo: req.Repo})
st, err = svc.Route(ctx, it, inbox.Request{Destination: req.Destination, Repo: req.Repo, Actor: actor})
} else {
var out inbox.ShareOutcome
out, err = svc.ShareWhenReady(ctx, it, inbox.ShareIntent{Destination: req.Destination, Actor: actor, Repo: req.Repo, Params: req.Params}, s.inboxTranscribeOptions(actor))
Expand Down Expand Up @@ -576,7 +576,7 @@ func (s *Server) handleInboxDismiss(w http.ResponseWriter, r *http.Request) {
}
}
}
if err := svc.Dismiss(it.Source, it.ItemID, !req.Undo); err != nil {
if err := svc.DismissBy(actor, it.Source, it.ItemID, !req.Undo); err != nil {
jsonError(w, "dismiss failed: "+err.Error(), http.StatusInternalServerError)
return
}
Expand Down
47 changes: 44 additions & 3 deletions src/pkg/dashboard/api_sessions_seed.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ type sessionSeedFile struct {
name string
rel string
data []byte
// shareID is the share-history record of a transcribe-first share
// (ShareIntent.RecordID); empty for items that had text already.
shareID string
}

// sessionSeed is a prepared seed: who sent it, the files to write and the
Expand Down Expand Up @@ -259,11 +262,43 @@ func (s *Server) deliverSessionSeedFiles(rt SessionRuntime, st *sessionStore, id
if err := svc.MarkSession(f.item, rec.ID, rec.Name); err != nil && s.logger != nil {
s.logger.Warn("sessions: marking inbox item routed failed", "item", f.item.Key(), "session", rec.ID, "error", err)
}
s.recordSpekShare(svc, f, seed.user, rec.ID, rec.Name)
}
}
return sessionSeedResult{Files: seed.rels(), Instruction: text, QueueID: item.ID, Position: pos}, nil
}

// recordSpekShare records the share of one seeded item in its history: a
// finished record carrying the session id and name as its target. A
// transcribe-first share continues the record made when it was queued.
func (s *Server) recordSpekShare(svc *inbox.Service, f sessionSeedFile, actor, sessionID, sessionName string) {
ref := &inbox.ShareRef{ID: sessionID, Name: sessionName}
var err error
if f.shareID != "" {
err = svc.FinishShare(f.item.Key(), f.shareID, inbox.ShareDone, "", ref)
} else {
now := time.Now().UTC()
_, err = svc.RecordShare(f.item.Key(), inbox.ShareRecord{Destination: inbox.ShareDestSpek, Actor: actor, Status: inbox.ShareDone, FinishedAt: &now, Ref: ref})
}
if err != nil && s.logger != nil {
s.logger.Warn("sessions: recording the inbox share failed", "item", f.item.Key(), "session", sessionID, "error", err)
}
}

// failSpekShares marks the transcribe-first records of a parked seed failed
// when the session never started.
func (s *Server) failSpekShares(seed *sessionSeed, reason string) {
svc := s.deps.Inbox
if svc == nil {
return
}
for _, f := range seed.files {
if f.shareID != "" {
_ = svc.FinishShare(f.item.Key(), f.shareID, inbox.ShareFailed, reason, nil)
}
}
}

// handleSessionSeed is POST /api/sessions/{id}/seed: send Inbox items into a
// running session the caller may type into (owner, or read-write on their
// own or a shared session; the read role only watches).
Expand Down Expand Up @@ -401,7 +436,9 @@ func (s *Server) runSpekIntent(ctx context.Context, it inbox.Item, in inbox.Shar
if err := inbox.CheckSessionText(it, c); err != nil {
return err
}
seed := &sessionSeed{user: in.Actor, files: []sessionSeedFile{s.renderSessionSeedFile(it, c, in.Actor, time.Now().UTC())}}
file := s.renderSessionSeedFile(it, c, in.Actor, time.Now().UTC())
file.shareID = in.RecordID
seed := &sessionSeed{user: in.Actor, files: []sessionSeedFile{file}}
s.sessionsMu.Lock()
if rec, found := st.get(id); found && rec.Status == sessionStatusPreparing && s.sessionsPreparing[id] {
if prev := s.sessionSeeds[id]; prev != nil {
Expand Down Expand Up @@ -443,9 +480,13 @@ func (s *Server) deliverPendingSessionSeed(rt SessionRuntime, st *sessionStore,
}
if startErr != nil {
s.auditSession(seed.user, auditInboxToSession, auditDetail("session", id, "items", seed.keys(), "files", "0", "error", "the session did not start", "outcome", sessionSeedOutcomeFailed))
s.failSpekShares(seed, "the session did not start")
return
}
if _, err := s.deliverSessionSeed(rt, st, id, seed); err != nil && s.logger != nil {
s.logger.Warn("sessions: seeding a new session from the Inbox failed", "id", id, "error", err)
if _, err := s.deliverSessionSeed(rt, st, id, seed); err != nil {
s.failSpekShares(seed, err.Error())
if s.logger != nil {
s.logger.Warn("sessions: seeding a new session from the Inbox failed", "id", id, "error", err)
}
}
}
19 changes: 18 additions & 1 deletion src/pkg/dashboard/api_sessions_seed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,15 @@ func TestSessionSeedAuditAndRoutedMark(t *testing.T) {
if r == nil || r.Session != id || r.Status != inbox.StatusDelegated || r.Note != "session/"+id+" (named one)" {
t.Errorf("%s route = %+v", it.ID, r)
}
// The share is in the item's history with the session as its target.
if len(it.ShareHistory) != 1 {
t.Errorf("%s history = %+v", it.ID, it.ShareHistory)
continue
}
h := it.ShareHistory[0]
if h.Destination != inbox.ShareDestSpek || h.Status != inbox.ShareDone || h.Actor != callerOwner.user || h.FinishedAt == nil || h.Ref == nil || h.Ref.ID != id || h.Ref.Name != "named one" {
t.Errorf("%s share record = %+v %+v", it.ID, h, h.Ref)
}
}
}

Expand Down Expand Up @@ -367,9 +376,17 @@ func TestSpekIntentRunnerSeedsRunningSession(t *testing.T) {
// The transcript arrived: the content now has text.
src.contents["rec-3"] = inbox.Content{Title: "audio only", Transcript: "machine words", TranscriptLabel: "Transcript (machine: whisper/base.en)", Provenance: "plaud://recordings/rec-3"}
it := inbox.Item{Source: "plaud", ID: "rec-3", Title: "audio only"}
if err := e.s.runSpekIntent(context.Background(), it, inbox.ShareIntent{Destination: inboxSpekIntentDest, Actor: callerOwner.user, Params: map[string]string{sessionSeedParamSession: id}}); err != nil {
// A transcribe-first share arrives with its history record.
recID, err := e.s.deps.Inbox.RecordShare(it.Key(), inbox.ShareRecord{Destination: inbox.ShareDestSpek, Actor: callerOwner.user, Status: inbox.ShareTranscribing})
if err != nil {
t.Fatal(err)
}
if err := e.s.runSpekIntent(context.Background(), it, inbox.ShareIntent{Destination: inboxSpekIntentDest, Actor: callerOwner.user, RecordID: recID, Params: map[string]string{sessionSeedParamSession: id}}); err != nil {
t.Fatal(err)
}
if h := e.s.deps.Inbox.Store.History(it.Key()); len(h) != 1 || h[0].ID != recID || h[0].Status != inbox.ShareDone || h[0].Ref == nil || h[0].Ref.ID != id {
t.Fatalf("transcribe-first record = %+v", h)
}
files := e.rt.storedInboxFiles()
if len(files) != 1 || files[0].name != "plaud-rec-3.md" || !strings.Contains(string(files[0].data), "machine words") {
t.Fatalf("files = %+v", files)
Expand Down
88 changes: 88 additions & 0 deletions src/pkg/dashboard/inbox_share_pills_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package dashboard

import (
"strings"
"testing"
)

// Share history pills: one per record, latest per destination with a +N
// expander, links only for viewers who can open them. Helpers run under node.
func TestInboxSharePills(t *testing.T) {
html := indexHTML(t)
script := "(function () {\n" + strings.Join([]string{
"const assert = require('assert');",
"function escapeHtml(s) { return String(s == null ? '' : s).replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/\"/g,'&quot;'); }",
"var window = { _hiveRole: 'owner' }; var rendered = 0;",
"function relativeTimeShort() { return '2m ago'; } function formatDashboardDateTime(s) { return 'at ' + s; } function renderInbox() { rendered++; }",
jsConstLine(t, html, "_inboxHistoryOpen"),
jsConstLine(t, html, "INBOX_SHARE_LABELS"),
jsFunc(t, html, "inboxViewerCanPlay"),
jsFunc(t, html, "inboxSharePillText"),
jsFunc(t, html, "inboxShareTargetHref"),
jsFunc(t, html, "inboxSharePillHtml"),
jsFunc(t, html, "inboxSharePillsHtml"),
jsFunc(t, html, "inboxToggleHistory"),
`
const rec = (o) => Object.assign({ destination: 'rfc', actor: 'clubanderson', started_at: '2026-11-16T10:00:00Z', status: 'done' }, o);
const item = (hist) => ({ source: 'plaud', id: 'r1', fact_slug: 'plaud-r1', layer: 'personal', share_history: hist });
assert.strictEqual(inboxSharePillsHtml({ source: 'plaud', id: 'r1' }, 'plaud/r1'), '');
// Per destination and status.
let h = inboxSharePillsHtml(item([rec({ ref: { number: 18412, url: 'https://github.com/o/r/issues/18412' } })]), 'plaud/r1');
assert(h.includes('→ RFC #18412 · clubanderson · 2m ago') && h.includes('data-status="ok"'));
assert(h.includes('<a ') && h.includes('href="https://github.com/o/r/issues/18412"') && h.includes('noopener') && !h.includes('<button'));
h = inboxSharePillsHtml(item([rec({ destination: 'spek', status: 'in_progress', actor: 'andy', ref: { id: 'sess-1', name: 'nate-v2' } })]), 'plaud/r1');
assert(h.includes('→ spek: nate-v2 … · andy') && h.includes('data-status="syncing"') && h.includes('inbox-tx-spinner') && h.includes('href="#section-sessions-section?session=sess-1"'));
h = inboxSharePillsHtml(item([rec({ destination: 'dibs', ref: { url: 'https://dibs.example/i/7', id: '7' } })]), 'plaud/r1');
assert(h.includes('→ DIBS · ') && h.includes('href="https://dibs.example/i/7"'));
h = inboxSharePillsHtml(item([rec({ destination: 'knowledge', actor: 'inbox-auto', ref: { id: 'plaud-r1' } })]), 'plaud/r1');
assert(h.includes('→ Knowledge · inbox-auto') && h.includes('data-action="inboxOpenFact"'));
h = inboxSharePillsHtml(item([rec({ status: 'transcribing' })]), 'plaud/r1');
assert(h.includes('→ RFC (transcribing) · ') && h.includes('inbox-tx-spinner'));
// Failed: danger status, reason in the title, no link.
h = inboxSharePillsHtml(item([rec({ destination: 'dibs', status: 'failed', reason: 'dibs: 502 bad "gateway"' })]), 'plaud/r1');
assert(h.includes('data-status="error"') && h.includes('→ DIBS failed · ') && h.includes('title="dibs: 502 bad &quot;gateway&quot; · ') && h.includes('<span ') && !h.includes('href='));
// Read role: same pills, no links.
window._hiveRole = 'read';
h = inboxSharePillsHtml(item([rec({ ref: { number: 1, url: 'https://github.com/o/r/issues/1' } }), rec({ destination: 'knowledge', ref: { id: 'x' } })]), 'plaud/r1');
assert(h.includes('→ RFC #1') && h.includes('→ Knowledge') && !h.includes('href=') && !h.includes('<a '));
window._hiveRole = 'read-write';
assert(inboxSharePillsHtml(item([rec({ ref: { url: 'https://github.com/o/r/issues/1' } })]), 'plaud/r1').includes('href='));
window._hiveRole = 'owner';
// Collapse to the latest record per destination, "+N" expands the history.
const hist = [rec({ status: 'failed', reason: 'x', started_at: '2026-11-16T09:00:00Z' }), rec({ ref: { number: 5 } }), rec({ destination: 'dibs' })];
h = inboxSharePillsHtml(item(hist), 'plaud/r1');
assert.strictEqual((h.match(/inbox-share-pill/g) || []).length, 2, 'latest per destination only');
assert(h.includes('>+1<') && h.includes('data-action="inboxToggleHistory"') && !h.includes('failed'));
inboxToggleHistory('plaud', 'r1'); assert.strictEqual(rendered, 1);
h = inboxSharePillsHtml(item(hist), 'plaud/r1');
assert.strictEqual((h.match(/inbox-share-pill/g) || []).length, 3, 'full history when expanded');
assert(h.includes('>less<') && h.includes('failed'));
inboxToggleHistory('plaud', 'r1');
assert(!_inboxHistoryOpen.has('plaud/r1'));
`,
}, "\n") + "\n})();"
runStageTrackerRowActionsScript(t, script)
}

// The spek pill's deep link opens the Inception section and selects the
// session's tab: the hash is parsed once and claimed when the session exists.
func TestSessionsFocusDeepLink(t *testing.T) {
html := indexHTML(t)
script := "(function () {\n" + strings.Join([]string{
"const assert = require('assert');",
jsConstLine(t, html, "SESSIONS_FOCUS_HASH"),
jsFunc(t, html, "sessionsFocusIdFromHash"),
jsFunc(t, html, "sessionsClaimFocus"),
`
assert.strictEqual(sessionsFocusIdFromHash('#section-sessions-section?session=ab%2Fc'), 'ab/c');
assert.strictEqual(sessionsFocusIdFromHash('#section-sessions-section'), '');
assert.strictEqual(sessionsFocusIdFromHash('#section-inbox-section?item=x'), '');
assert.strictEqual(sessionsFocusIdFromHash('#section-sessions-section?session=%E0%A4%A'), '', 'malformed escape is ignored');
var _sessionsFocusId = sessionsFocusIdFromHash('https://h.example/#section-sessions-section?session=s2');
assert.strictEqual(sessionsClaimFocus([{ id: 's1' }]), '', 'unknown session: keep waiting');
assert.strictEqual(sessionsClaimFocus([{ id: 's1' }, { id: 's2' }]), 's2');
assert.strictEqual(sessionsClaimFocus([{ id: 's2' }]), '', 'claimed once');
`,
}, "\n") + "\n})();"
runStageTrackerRowActionsScript(t, script)
}
5 changes: 5 additions & 0 deletions src/pkg/dashboard/static-src/css/inbox.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,8 @@
@media (max-width: 720px) {
.inbox-settings-grid, .inbox-rule { grid-template-columns: 1fr; }
}
/* Share history pills: status links, not buttons. */
a.inbox-share-pill { text-decoration: none; color: inherit; cursor: pointer; }
a.inbox-share-pill:hover, a.inbox-share-pill:focus-visible { text-decoration: underline; }
.inbox-share-more { text-decoration: none; color: var(--text-faint); }
.inbox-share-more:hover, .inbox-share-more:focus-visible { text-decoration: underline; }
Loading
Loading