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-settings-section.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Settings → Inbox section to edit the default RFC repository, dibs URL and auto-routing rules from the dashboard Settings dialog.
1 change: 1 addition & 0 deletions src/docs/dashboard-sections/workflow-and-agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ Voice recordings and dictations waiting for you to file them as an RFC, send to
- The sidebar count and the summary count items with no destination yet and not marked "Knowledge only".
- Each item shows one pill per destination it was sent to: queued, running, filed (with a link) or failed.
- Auto-routing rules run once per new item after a sync; the first matching rule wins.
- The default RFC repository, dibs URL and rules can also be edited under Settings → Inbox.

**What it is good for.** Record an idea on your recorder, then turn it into an RFC with child issues (→ RFC), a dibs idea (→ dibs), or just keep it searchable (Knowledge only) without leaving the dashboard. See [Inbox and voice sources](../inbox-voice-sources.md).

Expand Down
3 changes: 2 additions & 1 deletion src/docs/inbox-voice-sources.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ see the issue linked from the changelog entry.
- **Auto-routing rules** (⚙ Auto-routing in the Inbox, or `inbox.rules`):
`source?`, `title_prefix` or `tag`, `destination`, `repo?`. Rules run once
for each item that arrives after a connector sync; the first match wins;
items already in the Inbox are never re-routed.
items already in the Inbox are never re-routed. The same editor, with the
default RFC repository and dibs URL, is under Settings → Inbox.

## Configuration

Expand Down
34 changes: 34 additions & 0 deletions src/pkg/dashboard/inbox_settings_section_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package dashboard

import (
"strings"
"testing"
)

func TestSettingsInboxSectionWiring(t *testing.T) {
raw, err := staticFS.ReadFile("static/index.html")
if err != nil {
t.Fatal(err)
}
page := string(raw)
for _, want := range []string{
"'Knowledge', 'Inbox', 'Project Observability'",
"case 'Inbox': return renderGovInbox();",
"function renderGovInbox",
"function loadInboxSettingsInline",
"loadInboxSettingsInline();",
"inbox-settings-inline",
"yamlHint('inbox.spek.repo')",
"yamlHint('inbox.dibs.url')",
"yamlHint('inbox.rules')",
"Default RFC repository",
"data-inbox-field=\"dibs-url\"",
"function inboxSettingsRoot",
"data-inbox-form=",
"key: 'inbox.spek.repo'",
} {
if !strings.Contains(page, want) {
t.Errorf("Settings → Inbox wiring missing %q", want)
}
}
}
3 changes: 2 additions & 1 deletion src/pkg/dashboard/static-src/js/config-state.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/pkg/dashboard/static-src/js/config-tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
// The Features tab's Linear Agent panel loads install/session state
// from its own endpoint (owner-only; the render is a static shell).
if (tabId === 'Features') loadLinearAgentStatus();
if (tabId === 'Inbox') loadInboxSettingsInline();
// The same tab carries the upstream-watch editor and divergence view
// (#9969, #11211); it loads from its own endpoint.
if (tabId === 'Features') loadUpstreamWatch();
Expand Down Expand Up @@ -265,6 +266,7 @@
case 'Access': return renderGovSecurity(d.security || {});
case 'Features': return renderGovFeatures(d.features || {}, d.auto_merge || {}, d.review || {});
case 'Knowledge': return renderGovKnowledgeSharing();
case 'Inbox': return renderGovInbox();
case 'Project Observability': return renderGovProjectObservability(d.project_observability || {});
case 'Advisory': return renderGovAdvisory(d.advisory || {});
case 'Work Source': return renderGovWorkSource(d.work_source || {});
Expand Down
84 changes: 65 additions & 19 deletions src/pkg/dashboard/static-src/js/inbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,33 +210,77 @@
'<input class="kb-search-box" data-rule-field="repo" placeholder="owner/repo (RFC only)" value="' + escapeHtml(rule.repo || '') + '" aria-label="Repository">' +
'<button type="button" class="hv-btn btn-icon btn-sm" data-action="inboxRemoveRule" data-arg0="' + i + '" aria-label="Remove rule">✕</button></div>';
}
function inboxReadRules() {
return Array.from(document.querySelectorAll('#inbox-settings-rules .inbox-rule')).map(row => {
// The same form renders in the Inbox page modal and inline under
// Settings → Inbox, and both can sit in the DOM at once (the settings
// tab stays mounted; the closed modal keeps its last body). Every read
// and write therefore goes through the active form root: the modal
// while it is open, otherwise the inline section.
function inboxSettingsRoot() {
const overlay = document.getElementById('kb-modal-overlay');
if (overlay && overlay.style.display !== 'none') {
const modal = overlay.querySelector('.inbox-settings-form');
if (modal) return modal;
}
return document.querySelector('#inbox-settings-inline .inbox-settings-form');
}
function inboxSettingsField(root, name) {
return root ? root.querySelector('[data-inbox-field="' + name + '"]') : null;
}
function inboxReadRules(root) {
root = root || inboxSettingsRoot();
if (!root) return [];
return Array.from(root.querySelectorAll('.inbox-settings-rules .inbox-rule')).map(row => {
const v = f => { const el = row.querySelector('[data-rule-field="' + f + '"]'); return el ? el.value.trim() : ''; };
return { source: v('source'), title_prefix: v('title_prefix'), tag: v('tag'), destination: v('destination'), repo: v('repo') };
});
}
function inboxRenderRules() {
const host = document.getElementById('inbox-settings-rules');
function inboxRenderRules(root) {
root = root || inboxSettingsRoot();
const host = root ? root.querySelector('.inbox-settings-rules') : null;
if (!host) return;
host.innerHTML = _inboxDraftRules.length ? _inboxDraftRules.map(inboxRuleRowHtml).join('') : '<p class="muted-xs">No rules — every item waits here for manual triage.</p>';
}
function inboxOpenSettings() {
const settings = (_inboxCache || {}).settings || {};
_inboxDraftRules = (settings.rules || []).map(r => Object.assign({}, r));
const body = '<p class="muted-note m-0">New items are checked against these rules in order after every connector sync; the first match routes the item automatically. Items that arrived before a rule existed are never re-routed.</p>' +
function inboxSettingsFormHtml(settings, inline) {
const buttons = inline
? '<div class="hive-dialog-buttons"><button type="button" class="hv-btn btn-primary hive-dialog-btn primary" data-action="inboxSaveSettings">Save</button></div>'
: '<div class="hive-dialog-buttons"><button type="button" class="hv-btn btn-secondary hive-dialog-btn" data-action="kbCloseModal">Cancel</button>' +
'<button type="button" class="hv-btn btn-primary hive-dialog-btn primary" data-action="inboxSaveSettings">Save</button></div>';
return '<div class="inbox-settings-form" data-inbox-form="' + (inline ? 'inline' : 'modal') + '"><p class="muted-note m-0">New items are checked against these rules in order after every connector sync; the first match routes the item automatically. Items that arrived before a rule existed are never re-routed.</p>' +
'<div class="inbox-settings-grid">' +
'<label class="muted-note inbox-field">Default RFC repository<input class="kb-search-box mt-2" type="text" id="inbox-settings-spek-repo" placeholder="owner/repo" autocomplete="off" value="' + escapeHtml(settings.spek_repo || '') + '"></label>' +
'<label class="muted-note inbox-field">dibs URL<input class="kb-search-box mt-2" type="text" id="inbox-settings-dibs-url" placeholder="https://dibs.example.org" autocomplete="off" value="' + escapeHtml(settings.dibs_url || '') + '"></label></div>' +
'<label class="muted-note inbox-field">Default RFC repository<input class="kb-search-box mt-2" type="text" data-inbox-field="spek-repo" placeholder="owner/repo" autocomplete="off" value="' + escapeHtml(settings.spek_repo || '') + '"></label>' +
'<label class="muted-note inbox-field">dibs URL<input class="kb-search-box mt-2" type="text" data-inbox-field="dibs-url" placeholder="https://dibs.example.org" autocomplete="off" value="' + escapeHtml(settings.dibs_url || '') + '"></label></div>' +
'<p class="muted-xs">The dibs token is read from the environment variable named by <code>inbox.dibs.token_env</code>' + (settings.dibs_token_set ? ' (set)' : ' (not set)') + '.</p>' +
'<div class="row-between mt-4 mb-2"><div class="section-label m-0">Rules</div><button type="button" class="hv-btn btn-secondary btn-sm" data-action="inboxAddRule">Add rule</button></div>' +
'<div id="inbox-settings-rules"></div>' +
'<div class="hive-dialog-error" role="alert" id="inbox-settings-error"></div>' +
'<div class="hive-dialog-buttons"><button type="button" class="hv-btn btn-secondary hive-dialog-btn" data-action="kbCloseModal">Cancel</button>' +
'<button type="button" class="hv-btn btn-primary hive-dialog-btn primary" data-action="inboxSaveSettings">Save</button></div>';
kbShowModal('⚙ Inbox auto-routing', body, { width: '720px' });
'<div class="inbox-settings-rules"></div>' +
'<div class="hive-dialog-error" role="alert" data-inbox-field="error"></div>' + buttons + '</div>';
}
function inboxOpenSettings() {
const settings = (_inboxCache || {}).settings || {};
_inboxDraftRules = (settings.rules || []).map(r => Object.assign({}, r));
kbShowModal('⚙ Inbox auto-routing', inboxSettingsFormHtml(settings, false), { width: '720px' });
inboxRenderRules();
}
// Settings → Inbox: the same form inline, loaded from /api/inbox/settings.
function renderGovInbox() {
return '<div class="config-section" data-config-section="Inbox"><h3>Inbox</h3>' +
'<p class="text-muted fs-base">Default RFC repository, dibs URL and auto-routing rules for voice recordings. ' + yamlHint('inbox.spek.repo') + ' ' + yamlHint('inbox.dibs.url') + ' ' + yamlHint('inbox.rules') + '</p>' +
'<div id="inbox-settings-inline"><p class="muted-xs">Loading…</p></div></div>';
}
async function loadInboxSettingsInline() {
const host = document.getElementById('inbox-settings-inline');
if (!host) return;
try {
const r = await fetch('/api/inbox/settings');
const data = await r.json().catch(() => ({}));
if (!r.ok) throw new Error(data.error || ('HTTP ' + r.status));
_inboxCache = Object.assign({}, _inboxCache, { settings: data });
_inboxDraftRules = (data.rules || []).map(x => Object.assign({}, x));
host.innerHTML = inboxSettingsFormHtml(data, true);
inboxRenderRules(host.querySelector('.inbox-settings-form'));
} catch (e) {
host.innerHTML = '<p class="kc-error muted-xs">Inbox settings unavailable: ' + escapeHtml(e.message) + '</p>';
}
}
function inboxAddRule() {
_inboxDraftRules = inboxReadRules();
_inboxDraftRules.push({ source: '', title_prefix: 'RFC:', tag: '', destination: 'spek_rfc', repo: '' });
Expand All @@ -248,14 +292,16 @@
inboxRenderRules();
}
async function inboxSaveSettings() {
const errEl = document.getElementById('inbox-settings-error');
const rules = inboxReadRules().map(r => { const o = {}; for (const k of Object.keys(r)) if (r[k]) o[k] = r[k]; return o; });
const payload = { rules, spek_repo: (document.getElementById('inbox-settings-spek-repo') || {}).value || '', dibs_url: (document.getElementById('inbox-settings-dibs-url') || {}).value || '' };
const root = inboxSettingsRoot();
if (!root) return;
const errEl = inboxSettingsField(root, 'error');
const rules = inboxReadRules(root).map(r => { const o = {}; for (const k of Object.keys(r)) if (r[k]) o[k] = r[k]; return o; });
const payload = { rules, spek_repo: (inboxSettingsField(root, 'spek-repo') || {}).value || '', dibs_url: (inboxSettingsField(root, 'dibs-url') || {}).value || '' };
try {
const r = await fetch('/api/inbox/settings', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload) });
const data = await r.json().catch(() => ({}));
if (!r.ok) throw new Error(data.error || ('HTTP ' + r.status));
kbCloseModal();
if (root.dataset.inboxForm !== 'inline') kbCloseModal();
showToast('Inbox settings saved', 'success');
await fetchInbox();
} catch (e) {
Expand Down
Loading
Loading