From 7f41d713041588c3612f2ac7ed10357c0cb4b923 Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Thu, 12 Nov 2026 04:17:50 -0500 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=A8=20dashboard:=20Settings=20?= =?UTF-8?q?=E2=86=92=20Inbox=20section=20for=20default=20repo,=20dibs=20UR?= =?UTF-8?q?L=20and=20rules?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: clubanderson <407614+clubanderson@users.noreply.github.com> #17885 landed inbox.* config, validation, parity allowlist and /api/inbox/settings but no Settings tab section. Add Settings → Inbox reusing the Inbox drawer form and endpoint. Part of #17883. --- changelog.d/added-inbox-settings-section.md | 1 + .../dashboard-sections/workflow-and-agents.md | 1 + src/docs/inbox-voice-sources.md | 3 +- .../dashboard/inbox_settings_section_test.go | 32 ++++++++++++ .../dashboard/static-src/js/config-state.js | 3 +- .../dashboard/static-src/js/config-tabs.js | 2 + src/pkg/dashboard/static-src/js/inbox.js | 44 +++++++++++++---- src/pkg/dashboard/static/index.html | 49 +++++++++++++++---- 8 files changed, 114 insertions(+), 21 deletions(-) create mode 100644 changelog.d/added-inbox-settings-section.md create mode 100644 src/pkg/dashboard/inbox_settings_section_test.go diff --git a/changelog.d/added-inbox-settings-section.md b/changelog.d/added-inbox-settings-section.md new file mode 100644 index 0000000000..7199a8ab60 --- /dev/null +++ b/changelog.d/added-inbox-settings-section.md @@ -0,0 +1 @@ +- Settings → Inbox section to edit the default RFC repository, dibs URL and auto-routing rules from the dashboard Settings dialog. diff --git a/src/docs/dashboard-sections/workflow-and-agents.md b/src/docs/dashboard-sections/workflow-and-agents.md index c49a26bbd1..bb9ec25b24 100644 --- a/src/docs/dashboard-sections/workflow-and-agents.md +++ b/src/docs/dashboard-sections/workflow-and-agents.md @@ -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). diff --git a/src/docs/inbox-voice-sources.md b/src/docs/inbox-voice-sources.md index bb5c95792f..4f689aa9cd 100644 --- a/src/docs/inbox-voice-sources.md +++ b/src/docs/inbox-voice-sources.md @@ -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 diff --git a/src/pkg/dashboard/inbox_settings_section_test.go b/src/pkg/dashboard/inbox_settings_section_test.go new file mode 100644 index 0000000000..7a4f2fa824 --- /dev/null +++ b/src/pkg/dashboard/inbox_settings_section_test.go @@ -0,0 +1,32 @@ +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", + "id=\"inbox-settings-dibs-url\"", + "key: 'inbox.spek.repo'", + } { + if !strings.Contains(page, want) { + t.Errorf("Settings → Inbox wiring missing %q", want) + } + } +} diff --git a/src/pkg/dashboard/static-src/js/config-state.js b/src/pkg/dashboard/static-src/js/config-state.js index 162cf7e258..c3b76f8bfa 100644 --- a/src/pkg/dashboard/static-src/js/config-state.js +++ b/src/pkg/dashboard/static-src/js/config-state.js @@ -23,7 +23,7 @@ // which is read-only hub-synced user/role data. It sits next to Model // Gateways because both are backend configuration. const GOVERNOR_BOB_TAB = 'Bob'; - const GOVERNOR_CONFIG_TABS = ['General', 'Appearance', 'Dashboard', 'Agents', 'Thresholds', 'Labels', 'Repos', 'Workflows', 'Budget', 'Notifications', 'Health', 'Sensing', 'Logging', 'Features', 'Knowledge', 'Project Observability', 'Advisory', 'Work Source', 'Hub', 'Forge App', 'Model Gateways', GOVERNOR_BOB_TAB, 'Variables', 'Security', 'Compliance']; + const GOVERNOR_CONFIG_TABS = ['General', 'Appearance', 'Dashboard', 'Agents', 'Thresholds', 'Labels', 'Repos', 'Workflows', 'Budget', 'Notifications', 'Health', 'Sensing', 'Logging', 'Features', 'Knowledge', 'Inbox', 'Project Observability', 'Advisory', 'Work Source', 'Hub', 'Forge App', 'Model Gateways', GOVERNOR_BOB_TAB, 'Variables', 'Security', 'Compliance']; const PIPELINE_STAGES = ['resolve-beads', 'track-prs', 'stale-check', 'repo-scan', 'coverage-gate', 'prompt-compose', 'budget-check', 'api-collect', 'final-compose']; const PIPELINE_STAGE_TIPS = { 'resolve-beads': 'Fetch and inject knowledge beads (facts, patterns, gotchas) relevant to the agent\'s current task context.', @@ -82,6 +82,7 @@ { tab: 'Labels', section: 'Labels', label: 'Adoption of a maintainer\'s PR', key: 'governor.labels.stage.adoption.maintainer_policy', text: 'adoption maintainer policy adopt ask never maintainer own pr clanker disconnected offline adopt action governor.labels.stage.adoption.maintainer_policy' }, { tab: 'Labels', section: 'Labels', label: 'Contributor nudge', key: 'governor.labels.stage.contributor_nudge.enabled', text: 'contributor nudge returned-to-contributor red ci fix-pr relay interrupt renudge presence window governor.labels.stage.contributor_nudge.enabled governor.labels.stage.contributor_nudge.renudge_interval auto_merge.nudge_repeat_after governor.labels.stage.contributor_nudge.ci_failure_cooldown governor.labels.stage.presence_window' }, { tab: 'Labels', section: 'Labels', label: 'Adopt red contributor PRs', key: 'governor.labels.stage.adoption.enabled', text: 'adoption adopted-by-hive stage 074 red contributor pr grace online offline supersede takeover in place after offline unregistered heartbeat governor.labels.stage.adoption.enabled governor.labels.stage.contributor_grace_online governor.labels.stage.contributor_grace_offline governor.labels.stage.adoption.after_offline governor.labels.stage.adoption.after_unregistered governor.labels.stage.adoption.in_place governor.labels.stage.adoption.strict_attribution strict attribution governor.labels.stage.adoption.auto_merge auto merge adopted head hive authority governor.labels.stage.adoption.supersede.close_first close first superseded reopen copy failed governor.labels.stage.adoption.close_superseded close superseded on adopt on merge clanker authored opt-in label governor.labels.stage.adoption.offline_grace offline grace rebase failed twice fixer resolving conflicts governor.labels.stage.adoption.rebase_attempt_timeout rebase attempt timeout' }, + { tab: 'Inbox', section: 'Inbox', label: 'Inbox routing', key: 'inbox.spek.repo', lazy: true, text: 'inbox voice recordings plaud wispr default rfc repository spek dibs url auto-routing rules inbox.spek.repo inbox.dibs.url inbox.rules' }, { tab: 'Hub', section: 'Contributor Relay', label: 'Fix budget', key: 'contribute.max_parallel_fixes', text: 'fix budget parallel fixes focus window red pr fix-pr preempt spawn contribute.max_parallel_fixes contribute.min_focus_window' }, { tab: 'Logging', section: 'Logging', label: 'Governor logging', key: 'governor.logging.max_size_mb', text: 'governor logging directory level compression max size age backups governor.logging.compress governor.logging.dir governor.logging.level governor.logging.max_age_days governor.logging.max_backups governor.logging.max_size_mb' }, { tab: 'Advisory', section: 'Advisory', label: 'Advisory digest', key: 'governor.advisory.max_findings', text: 'advisory digest max findings show all staleness pr autoclose target linear issue retry backoff update interval rewrite floor changed digest governor.advisory.update_interval_s governor.advisory.digest_min_interval' }, diff --git a/src/pkg/dashboard/static-src/js/config-tabs.js b/src/pkg/dashboard/static-src/js/config-tabs.js index 03d69b03f3..b8ca800a08 100644 --- a/src/pkg/dashboard/static-src/js/config-tabs.js +++ b/src/pkg/dashboard/static-src/js/config-tabs.js @@ -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(); @@ -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 || {}); diff --git a/src/pkg/dashboard/static-src/js/inbox.js b/src/pkg/dashboard/static-src/js/inbox.js index 4f38662937..2ec698a5e6 100644 --- a/src/pkg/dashboard/static-src/js/inbox.js +++ b/src/pkg/dashboard/static-src/js/inbox.js @@ -221,22 +221,47 @@ if (!host) return; host.innerHTML = _inboxDraftRules.length ? _inboxDraftRules.map(inboxRuleRowHtml).join('') : '

No rules — every item waits here for manual triage.

'; } - function inboxOpenSettings() { - const settings = (_inboxCache || {}).settings || {}; - _inboxDraftRules = (settings.rules || []).map(r => Object.assign({}, r)); - const body = '

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.

' + + function inboxSettingsFormHtml(settings, inline) { + const buttons = inline + ? '
' + : '
' + + '
'; + return '

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.

' + '
' + '' + '
' + '

The dibs token is read from the environment variable named by inbox.dibs.token_env' + (settings.dibs_token_set ? ' (set)' : ' (not set)') + '.

' + '
Rules
' + '
' + - '' + - '
' + - '
'; - kbShowModal('⚙ Inbox auto-routing', body, { width: '720px' }); + '' + buttons; + } + 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 '

Inbox

' + + '

Default RFC repository, dibs URL and auto-routing rules for voice recordings. ' + yamlHint('inbox.spek.repo') + ' ' + yamlHint('inbox.dibs.url') + ' ' + yamlHint('inbox.rules') + '

' + + '

Loading…

'; + } + 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(); + } catch (e) { + host.innerHTML = '

Inbox settings unavailable: ' + escapeHtml(e.message) + '

'; + } + } function inboxAddRule() { _inboxDraftRules = inboxReadRules(); _inboxDraftRules.push({ source: '', title_prefix: 'RFC:', tag: '', destination: 'spek_rfc', repo: '' }); @@ -255,7 +280,8 @@ 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(); + const inline = !!document.getElementById('inbox-settings-inline'); + if (!inline) kbCloseModal(); showToast('Inbox settings saved', 'success'); await fetchInbox(); } catch (e) { diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 90af378a72..cee371c608 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -46417,22 +46417,47 @@ if (!host) return; host.innerHTML = _inboxDraftRules.length ? _inboxDraftRules.map(inboxRuleRowHtml).join('') : '

No rules — every item waits here for manual triage.

'; } - function inboxOpenSettings() { - const settings = (_inboxCache || {}).settings || {}; - _inboxDraftRules = (settings.rules || []).map(r => Object.assign({}, r)); - const body = '

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.

' + + function inboxSettingsFormHtml(settings, inline) { + const buttons = inline + ? '
' + : '
' + + '
'; + return '

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.

' + '
' + '' + '
' + '

The dibs token is read from the environment variable named by inbox.dibs.token_env' + (settings.dibs_token_set ? ' (set)' : ' (not set)') + '.

' + '
Rules
' + '
' + - '' + - '
' + - '
'; - kbShowModal('⚙ Inbox auto-routing', body, { width: '720px' }); + '' + buttons; + } + 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 '

Inbox

' + + '

Default RFC repository, dibs URL and auto-routing rules for voice recordings. ' + yamlHint('inbox.spek.repo') + ' ' + yamlHint('inbox.dibs.url') + ' ' + yamlHint('inbox.rules') + '

' + + '

Loading…

'; + } + 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(); + } catch (e) { + host.innerHTML = '

Inbox settings unavailable: ' + escapeHtml(e.message) + '

'; + } + } function inboxAddRule() { _inboxDraftRules = inboxReadRules(); _inboxDraftRules.push({ source: '', title_prefix: 'RFC:', tag: '', destination: 'spek_rfc', repo: '' }); @@ -46451,7 +46476,8 @@ 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(); + const inline = !!document.getElementById('inbox-settings-inline'); + if (!inline) kbCloseModal(); showToast('Inbox settings saved', 'success'); await fetchInbox(); } catch (e) { @@ -55233,7 +55259,7 @@

Configure LiteLLM

// which is read-only hub-synced user/role data. It sits next to Model // Gateways because both are backend configuration. const GOVERNOR_BOB_TAB = 'Bob'; - const GOVERNOR_CONFIG_TABS = ['General', 'Appearance', 'Dashboard', 'Agents', 'Thresholds', 'Labels', 'Repos', 'Workflows', 'Budget', 'Notifications', 'Health', 'Sensing', 'Logging', 'Features', 'Knowledge', 'Project Observability', 'Advisory', 'Work Source', 'Hub', 'Forge App', 'Model Gateways', GOVERNOR_BOB_TAB, 'Variables', 'Security', 'Compliance']; + const GOVERNOR_CONFIG_TABS = ['General', 'Appearance', 'Dashboard', 'Agents', 'Thresholds', 'Labels', 'Repos', 'Workflows', 'Budget', 'Notifications', 'Health', 'Sensing', 'Logging', 'Features', 'Knowledge', 'Inbox', 'Project Observability', 'Advisory', 'Work Source', 'Hub', 'Forge App', 'Model Gateways', GOVERNOR_BOB_TAB, 'Variables', 'Security', 'Compliance']; const PIPELINE_STAGES = ['resolve-beads', 'track-prs', 'stale-check', 'repo-scan', 'coverage-gate', 'prompt-compose', 'budget-check', 'api-collect', 'final-compose']; const PIPELINE_STAGE_TIPS = { 'resolve-beads': 'Fetch and inject knowledge beads (facts, patterns, gotchas) relevant to the agent\'s current task context.', @@ -55292,6 +55318,7 @@

Configure LiteLLM

{ tab: 'Labels', section: 'Labels', label: 'Adoption of a maintainer\'s PR', key: 'governor.labels.stage.adoption.maintainer_policy', text: 'adoption maintainer policy adopt ask never maintainer own pr clanker disconnected offline adopt action governor.labels.stage.adoption.maintainer_policy' }, { tab: 'Labels', section: 'Labels', label: 'Contributor nudge', key: 'governor.labels.stage.contributor_nudge.enabled', text: 'contributor nudge returned-to-contributor red ci fix-pr relay interrupt renudge presence window governor.labels.stage.contributor_nudge.enabled governor.labels.stage.contributor_nudge.renudge_interval auto_merge.nudge_repeat_after governor.labels.stage.contributor_nudge.ci_failure_cooldown governor.labels.stage.presence_window' }, { tab: 'Labels', section: 'Labels', label: 'Adopt red contributor PRs', key: 'governor.labels.stage.adoption.enabled', text: 'adoption adopted-by-hive stage 074 red contributor pr grace online offline supersede takeover in place after offline unregistered heartbeat governor.labels.stage.adoption.enabled governor.labels.stage.contributor_grace_online governor.labels.stage.contributor_grace_offline governor.labels.stage.adoption.after_offline governor.labels.stage.adoption.after_unregistered governor.labels.stage.adoption.in_place governor.labels.stage.adoption.strict_attribution strict attribution governor.labels.stage.adoption.auto_merge auto merge adopted head hive authority governor.labels.stage.adoption.supersede.close_first close first superseded reopen copy failed governor.labels.stage.adoption.close_superseded close superseded on adopt on merge clanker authored opt-in label governor.labels.stage.adoption.offline_grace offline grace rebase failed twice fixer resolving conflicts governor.labels.stage.adoption.rebase_attempt_timeout rebase attempt timeout' }, + { tab: 'Inbox', section: 'Inbox', label: 'Inbox routing', key: 'inbox.spek.repo', lazy: true, text: 'inbox voice recordings plaud wispr default rfc repository spek dibs url auto-routing rules inbox.spek.repo inbox.dibs.url inbox.rules' }, { tab: 'Hub', section: 'Contributor Relay', label: 'Fix budget', key: 'contribute.max_parallel_fixes', text: 'fix budget parallel fixes focus window red pr fix-pr preempt spawn contribute.max_parallel_fixes contribute.min_focus_window' }, { tab: 'Logging', section: 'Logging', label: 'Governor logging', key: 'governor.logging.max_size_mb', text: 'governor logging directory level compression max size age backups governor.logging.compress governor.logging.dir governor.logging.level governor.logging.max_age_days governor.logging.max_backups governor.logging.max_size_mb' }, { tab: 'Advisory', section: 'Advisory', label: 'Advisory digest', key: 'governor.advisory.max_findings', text: 'advisory digest max findings show all staleness pr autoclose target linear issue retry backoff update interval rewrite floor changed digest governor.advisory.update_interval_s governor.advisory.digest_min_interval' }, @@ -56383,6 +56410,7 @@

Configure LiteLLM

// 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(); @@ -56595,6 +56623,7 @@

Configure LiteLLM

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 || {}); From 085b33e8343be8d8d83e9b3aac6776ff9f82d3d1 Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Thu, 12 Nov 2026 04:46:48 -0500 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9B=20dashboard:=20scope=20the=20I?= =?UTF-8?q?nbox=20settings=20form=20to=20its=20active=20root?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Inbox settings form renders twice — in the Inbox page modal and inline under Settings → Inbox — and both can be mounted at once: the settings tab stays in the DOM and the closed modal keeps its last body. inboxReadRules collected .inbox-rule rows from every #inbox-settings-rules, the repo/dibs inputs were read via getElementById (first in document) and the inline sniff kept the modal open on save, so saving from the modal after visiting Settings → Inbox posted the inline form's values and left the dialog up. Wrap the form in .inbox-settings-form[data-inbox-form=inline|modal], replace the duplicated ids with data-inbox-field attributes, and resolve one active root per operation (the modal while open, otherwise the inline section). Read, render, save and the close-modal decision all go through that root. Hive-Fix-Attempt: 1/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- .../dashboard/inbox_settings_section_test.go | 4 +- src/pkg/dashboard/static-src/js/inbox.js | 50 +++++++++++++------ src/pkg/dashboard/static/index.html | 50 +++++++++++++------ 3 files changed, 73 insertions(+), 31 deletions(-) diff --git a/src/pkg/dashboard/inbox_settings_section_test.go b/src/pkg/dashboard/inbox_settings_section_test.go index 7a4f2fa824..147803693d 100644 --- a/src/pkg/dashboard/inbox_settings_section_test.go +++ b/src/pkg/dashboard/inbox_settings_section_test.go @@ -22,7 +22,9 @@ func TestSettingsInboxSectionWiring(t *testing.T) { "yamlHint('inbox.dibs.url')", "yamlHint('inbox.rules')", "Default RFC repository", - "id=\"inbox-settings-dibs-url\"", + "data-inbox-field=\"dibs-url\"", + "function inboxSettingsRoot", + "data-inbox-form=", "key: 'inbox.spek.repo'", } { if !strings.Contains(page, want) { diff --git a/src/pkg/dashboard/static-src/js/inbox.js b/src/pkg/dashboard/static-src/js/inbox.js index 2ec698a5e6..9d2233d788 100644 --- a/src/pkg/dashboard/static-src/js/inbox.js +++ b/src/pkg/dashboard/static-src/js/inbox.js @@ -210,14 +210,33 @@ '' + ''; } - 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('') : '

No rules — every item waits here for manual triage.

'; } @@ -226,14 +245,14 @@ ? '
' : '
' + '
'; - return '

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.

' + + return '

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.

' + '
' + - '' + - '
' + + '' + + '
' + '

The dibs token is read from the environment variable named by inbox.dibs.token_env' + (settings.dibs_token_set ? ' (set)' : ' (not set)') + '.

' + '
Rules
' + - '
' + - '' + buttons; + '
' + + '' + buttons + ''; } function inboxOpenSettings() { const settings = (_inboxCache || {}).settings || {}; @@ -257,7 +276,7 @@ _inboxCache = Object.assign({}, _inboxCache, { settings: data }); _inboxDraftRules = (data.rules || []).map(x => Object.assign({}, x)); host.innerHTML = inboxSettingsFormHtml(data, true); - inboxRenderRules(); + inboxRenderRules(host.querySelector('.inbox-settings-form')); } catch (e) { host.innerHTML = '

Inbox settings unavailable: ' + escapeHtml(e.message) + '

'; } @@ -273,15 +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)); - const inline = !!document.getElementById('inbox-settings-inline'); - if (!inline) kbCloseModal(); + if (root.dataset.inboxForm !== 'inline') kbCloseModal(); showToast('Inbox settings saved', 'success'); await fetchInbox(); } catch (e) { diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index cee371c608..de4565d3a5 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -46406,14 +46406,33 @@ '' + ''; } - 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('') : '

No rules — every item waits here for manual triage.

'; } @@ -46422,14 +46441,14 @@ ? '
' : '
' + '
'; - return '

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.

' + + return '

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.

' + '
' + - '' + - '
' + + '' + + '
' + '

The dibs token is read from the environment variable named by inbox.dibs.token_env' + (settings.dibs_token_set ? ' (set)' : ' (not set)') + '.

' + '
Rules
' + - '
' + - '' + buttons; + '
' + + '' + buttons + ''; } function inboxOpenSettings() { const settings = (_inboxCache || {}).settings || {}; @@ -46453,7 +46472,7 @@ _inboxCache = Object.assign({}, _inboxCache, { settings: data }); _inboxDraftRules = (data.rules || []).map(x => Object.assign({}, x)); host.innerHTML = inboxSettingsFormHtml(data, true); - inboxRenderRules(); + inboxRenderRules(host.querySelector('.inbox-settings-form')); } catch (e) { host.innerHTML = '

Inbox settings unavailable: ' + escapeHtml(e.message) + '

'; } @@ -46469,15 +46488,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)); - const inline = !!document.getElementById('inbox-settings-inline'); - if (!inline) kbCloseModal(); + if (root.dataset.inboxForm !== 'inline') kbCloseModal(); showToast('Inbox settings saved', 'success'); await fetchInbox(); } catch (e) {