diff --git a/changelog.d/fixed-meetings-calendar-role-and-layout.md b/changelog.d/fixed-meetings-calendar-role-and-layout.md new file mode 100644 index 0000000000..9650ff046b --- /dev/null +++ b/changelog.d/fixed-meetings-calendar-role-and-layout.md @@ -0,0 +1 @@ +- Dashboard: the Meetings and Calendar panels wait for the viewer's role instead of telling the owner they are not allowed, say when the hive is unreachable instead of staying on "Loading meetings…", sit inside the dashboard like other sections (they had lost their card padding), and lay out the join form, meeting rows (status pill, platform, time, a plain-language error with the raw one under details) and empty states like the rest of the dashboard. diff --git a/dashboard/test/meetings-calendar-role-race.test.js b/dashboard/test/meetings-calendar-role-race.test.js new file mode 100644 index 0000000000..b2caab7f22 --- /dev/null +++ b/dashboard/test/meetings-calendar-role-race.test.js @@ -0,0 +1,148 @@ +'use strict'; + +// The Meetings and Calendar panels must not show their "not allowed" notice +// while /api/role is unresolved, and must fetch and render the moment the +// role arrives (same race the Inbox fixed in #18442). They must also sit in +// the dashboard layout template, or layout.js leaves them outside +// #hive-dashboard-root and the card loses its padding tokens. Functions are +// extracted from the generated dashboard page. +const { test } = require('node:test'); +const assert = require('node:assert/strict'); +const fs = require('node:fs'); +const path = require('node:path'); +const vm = require('node:vm'); + +const indexHtml = fs.readFileSync(path.join(__dirname, '..', '..', 'src', 'pkg', 'dashboard', 'static', 'index.html'), 'utf8'); + +function extractFunction(name) { + const start = indexHtml.indexOf('function ' + name + '('); + assert.notEqual(start, -1, `${name} function exists`); + const brace = indexHtml.indexOf('{', start); + let depth = 0; + for (let i = brace; i < indexHtml.length; i++) { + const ch = indexHtml[i]; + if (ch === '{') depth++; + if (ch === '}') depth--; + if (depth === 0) return (indexHtml.slice(start - 6, start) === 'async ' ? 'async ' : '') + indexHtml.slice(start, i + 1); + } + throw new Error(`unterminated ${name}`); +} + +function extractConst(name) { + const m = new RegExp('const ' + name + ' = [^;]+;').exec(indexHtml); + assert.ok(m, `${name} const exists`); + return m[0]; +} + +const GH_AUTH = ['hiveRoleSettled']; +const MEETINGS = ['meetingsIsOwner', 'meetingsRoleKnown', 'meetingsOnRoleReady', 'fetchMeetings', 'renderMeetings', 'meetingsJoinFormHtml', + 'meetingsRowHtml', 'meetingsFormatTime', 'meetingsFriendlyReason', 'meetingsReasonHtml', 'meetingsLabel']; +const CALENDAR = ['calendarRoleKnown', 'calendarOnRoleReady', 'calendarCanView', 'calendarIsOwner', 'fetchCalendar', 'calendarRefreshMeetings', + 'fetchMeetingDrafts', 'renderCalendar', 'renderMeetingDrafts', 'meetingDraftsSplit', 'calendarFormHtml', 'calendarViewerTimeZone', + 'calendarRowHtml', 'calendarFormatTime', 'calendarPlatformLabel', 'calendarMeetingLink', 'calendarActionButtons', 'renderCalendarIndicator', + 'calendarIndicatorState', 'calendarBadgeCount', 'calendarMeetingList']; + +function makeSandbox(opts) { + const els = {}; + const el = (id) => (els[id] = els[id] || { id, innerHTML: '', dataset: {}, querySelector: () => null, setAttribute() {} }); + const calls = []; + const sb = { + window: { _hiveRoleListeners: [] }, + document: { getElementById: (id) => el(id), querySelector: () => null }, + els, + calls, + escapeHtml: (s) => String(s).replace(/&/g, '&').replace(/ {}, + setSectionSummary: () => {}, + setSidebarCountBadge: () => {}, + renderMeetingsLive: () => {}, + dashboardRoleAtLeast: (role, min) => ['read', 'read-write', 'owner'].indexOf(role) >= ['read', 'read-write', 'owner'].indexOf(min), + fetch: async (url) => { + calls.push(url); + if (opts && opts.fetch) return opts.fetch(url); + if (url === '/api/meetings') return { ok: true, status: 200, json: async () => ({ meetings: (opts && opts.meetings) || [] }) }; + if (url === '/api/meetings/schedule') return { ok: true, status: 200, json: async () => ({ upcoming: [], recent: [] }) }; + if (url === '/api/meetings/actions') return { ok: true, status: 200, json: async () => ({ drafts: [] }) }; + return { ok: true, status: 200, json: async () => ({}) }; + }, + _meetingsList: null, _meetingsError: '', _meetingsOpen: null, + _calendarData: null, _calendarError: '', _calendarMeetings: {}, + _meetingDrafts: null, _meetingDraftsError: '', _meetingDraftRepos: ['o/r'], + console, Math, Number, Array, Error, Promise, String, Object, Date, Intl, isNaN, + }; + vm.createContext(sb); + const consts = ['MEETINGS_ERROR_INLINE_CHARS', 'MEETINGS_PLATFORM_LABELS', 'MEETINGS_PILL_STATUS', 'MEETINGS_LIVE_STATES', + 'CALENDAR_ACTIVE_STATES', 'CALENDAR_DEFAULT_NAME', 'CALENDAR_PLATFORM_LABELS', 'CALENDAR_PLATFORM_ICONS', 'CALENDAR_SOURCE_LABELS', + 'CALENDAR_STATUS_LABELS', 'CALENDAR_PILL_STATUS'].map(extractConst); + // const declarations stay script-scoped in a vm context; re-declare the + // mutable module state with var so the extracted functions share it. + vm.runInContext(consts.join('\n') + '\n' + GH_AUTH.concat(MEETINGS, CALENDAR).map(extractFunction).join('\n'), sb); + // Same registrations meetings.js and calendar.js perform at load. + sb.window._hiveRoleListeners.push(sb.meetingsOnRoleReady, sb.calendarOnRoleReady); + return sb; +} + +const settle = () => new Promise((r) => setImmediate(r)); + +test('meetings and calendar are in the dashboard layout template', () => { + const m = /var DASHBOARD_LAYOUT_TEMPLATE=\{main:\[([^\]]+)\]\}/.exec(indexHtml); + assert.ok(m, 'layout template found'); + assert.match(m[1], /'inbox-section','calendar-section','meetings-section'/); +}); + +test('while the role is unknown both panels show loading, not the not-allowed notice, and fetch nothing', async () => { + const sb = makeSandbox({}); + await sb.fetchMeetings(); + await sb.fetchCalendar(); + assert.match(sb.els['meetings-panel'].innerHTML, /Loading meetings/); + assert.match(sb.els['calendar-panel'].innerHTML, /Loading calendar/); + assert.doesNotMatch(sb.els['meetings-panel'].innerHTML + sb.els['calendar-panel'].innerHTML, /visible to the hive owner/); + assert.deepEqual(sb.calls, []); +}); + +test('role arriving as owner fetches and renders the join form and the calendar', async () => { + const sb = makeSandbox({}); + await sb.fetchMeetings(); + await sb.fetchCalendar(); + sb.window._hiveRole = 'owner'; + sb.hiveRoleSettled(false); + await settle(); + await settle(); + assert.ok(sb.calls.includes('/api/meetings')); + assert.ok(sb.calls.includes('/api/meetings/schedule')); + assert.match(sb.els['meetings-panel'].innerHTML, /data-action="meetingsJoin"/); + assert.match(sb.els['meetings-panel'].innerHTML, /No meetings yet/); + assert.match(sb.els['calendar-panel'].innerHTML, /Nothing scheduled/); + assert.match(sb.els['meeting-drafts-panel'].innerHTML, /No drafts waiting/); + assert.doesNotMatch(sb.els['meetings-panel'].innerHTML, /visible to the hive owner/); +}); + +test('role arriving as read shows the not-allowed notices', async () => { + const sb = makeSandbox({}); + sb.window._hiveRole = 'read'; + sb.hiveRoleSettled(false); + await settle(); + assert.match(sb.els['meetings-panel'].innerHTML, /visible to the hive owner only/); + assert.match(sb.els['calendar-panel'].innerHTML, /visible to the hive owner and read-write users/); + assert.equal(sb.calls.length, 0); +}); + +test('a network failure says so instead of staying on Loading meetings', async () => { + const sb = makeSandbox({ fetch: async () => { throw new Error('network'); } }); + sb.window._hiveRole = 'owner'; + await sb.fetchMeetings(); + assert.doesNotMatch(sb.els['meetings-panel'].innerHTML, /Loading meetings/); + assert.match(sb.els['meetings-panel'].innerHTML, /unreachable right now/); +}); + +test('a failed meeting row shows a pill, a friendly line and the raw error under details', async () => { + const raw = 'quorum meeting.join: invalid_argument: Vexa POST /bots answered 422: unsupported platform \'zoom\' without a meeting_url'; + const sb = makeSandbox({ meetings: [{ id: 'm1', title: 'Live test', platform: 'zoom', state: 'failed', state_reason: raw, created_at: '2026-11-16T15:00:00Z' }] }); + sb.window._hiveRole = 'owner'; + await sb.fetchMeetings(); + const html = sb.els['meetings-panel'].innerHTML; + assert.match(html, /failed<\/span>/); + assert.match(html, /class="meetings-row-error">The meeting service did not accept this meeting link\./); + assert.match(html, /details<\/summary>
quorum meeting\.join/); + assert.match(html, /Zoom · /); +}); diff --git a/src/pkg/dashboard/dashboard_section_reorder_9062_test.go b/src/pkg/dashboard/dashboard_section_reorder_9062_test.go index 4e2e8c170e..dd494ef897 100644 --- a/src/pkg/dashboard/dashboard_section_reorder_9062_test.go +++ b/src/pkg/dashboard/dashboard_section_reorder_9062_test.go @@ -9,14 +9,14 @@ import ( ) var dashboardLayoutIDs9062 = []string{ - "overview-section", "governor", "pr-throughput-section", "repos-section", "activity-monitor-section", "knowledge-section", "inbox-section", "review-queue-section", + "overview-section", "governor", "pr-throughput-section", "repos-section", "activity-monitor-section", "knowledge-section", "inbox-section", "calendar-section", "meetings-section", "review-queue-section", "contributors-section", "advisory-section", "token-panel", "cost-panel", "sessions-section", "acmm-eval-section", "debug-section", "audit-section", "approvals-section", "nous-section", "logs-section", "agents-section", "agent-activity-section", "faq-section", } var dashboardDefaultNavOrder9062 = []string{ - "overview-section", "governor", "pr-throughput-section", "repos-section", "activity-monitor-section", "knowledge-section", "inbox-section", "review-queue-section", + "overview-section", "governor", "pr-throughput-section", "repos-section", "activity-monitor-section", "knowledge-section", "inbox-section", "calendar-section", "meetings-section", "review-queue-section", "contributors-section", "advisory-section", "token-panel", "cost-panel", "sessions-section", "acmm-eval-section", "debug-section", "audit-section", "faq-section", } @@ -26,7 +26,7 @@ var dashboardDefaultLayoutOrder9062 = append(append(append([]string{}, dashboard "faq-section", ) -const dashboardDefaultLayoutTemplate9062 = `DASHBOARD_LAYOUT_TEMPLATE={main:['overview-section','governor','pr-throughput-section','repos-section','activity-monitor-section','knowledge-section','inbox-section','review-queue-section','contributors-section','advisory-section','token-panel','cost-panel','sessions-section','acmm-eval-section','debug-section','audit-section','approvals-section','nous-section','logs-section','agents-section','agent-activity-section','faq-section']}` +const dashboardDefaultLayoutTemplate9062 = `DASHBOARD_LAYOUT_TEMPLATE={main:['overview-section','governor','pr-throughput-section','repos-section','activity-monitor-section','knowledge-section','inbox-section','calendar-section','meetings-section','review-queue-section','contributors-section','advisory-section','token-panel','cost-panel','sessions-section','acmm-eval-section','debug-section','audit-section','approvals-section','nous-section','logs-section','agents-section','agent-activity-section','faq-section']}` func jsArray9062(ids []string) string { var b strings.Builder @@ -165,7 +165,7 @@ func TestDashboardLayoutNormalizeFutureUnknownAndMissing(t *testing.T) { html := indexHTML(t) script := dashboardLayoutPreamble9062() + jsFunc(t, html, "dashboardLayoutAllIds") + "\n" + jsFunc(t, html, "dashboardLayoutNormalize") + ` const got = dashboardLayoutNormalize({v:99, main:['faq-section','beads-section','unknown','governor','faq-section']}); -const want = ` + jsArray9062([]string{"faq-section", "overview-section", "governor", "pr-throughput-section", "repos-section", "activity-monitor-section", "knowledge-section", "inbox-section", "review-queue-section", "contributors-section", "advisory-section", "token-panel", "cost-panel", "sessions-section", "acmm-eval-section", "debug-section", "audit-section", "approvals-section", "nous-section", "logs-section", "agents-section", "agent-activity-section"}) + `; +const want = ` + jsArray9062([]string{"faq-section", "overview-section", "governor", "pr-throughput-section", "repos-section", "activity-monitor-section", "knowledge-section", "inbox-section", "calendar-section", "meetings-section", "review-queue-section", "contributors-section", "advisory-section", "token-panel", "cost-panel", "sessions-section", "acmm-eval-section", "debug-section", "audit-section", "approvals-section", "nous-section", "logs-section", "agents-section", "agent-activity-section"}) + `; if (got.v !== 1) throw new Error('version not normalized: '+got.v); if (got.main.includes('beads-section')) throw new Error('legacy beads section survived normalization: '+JSON.stringify(got.main)); if (JSON.stringify(got.main) !== JSON.stringify(want)) throw new Error('normalized order '+JSON.stringify(got.main)); @@ -287,7 +287,7 @@ if (middle !== 'nous-section,logs-section,agents-section,agent-activity-section, if (new Set(got).size !== got.length) throw new Error('duplicate ids: '+JSON.stringify(got)); const moved = dashboardLayoutNormalize({v:1, main:['faq-section','cost-panel','overview-section']}).main; if (moved[0] !== 'faq-section') throw new Error('operator-moved FAQ not respected: '+JSON.stringify(moved)); -if (moved.length !== 22) throw new Error('missing sections not restored: '+moved.length); +if (moved.length !== 24) throw new Error('missing sections not restored: '+moved.length); ` cmd := exec.Command(node, "-e", script) if out, err := cmd.CombinedOutput(); err != nil { diff --git a/src/pkg/dashboard/static-src/css/calendar.css b/src/pkg/dashboard/static-src/css/calendar.css index 4f47b14e68..813c977ec0 100644 --- a/src/pkg/dashboard/static-src/css/calendar.css +++ b/src/pkg/dashboard/static-src/css/calendar.css @@ -1,5 +1,6 @@ /* Calendar: scheduled meetings hive joins (#18394) */ - .calendar-panel { display: flex; flex-direction: column; gap: var(--sp-3); } + .calendar-panel { display: flex; flex-direction: column; gap: var(--sp-5); } + .calendar-subsection { display: flex; flex-direction: column; gap: var(--sp-2); } .calendar-add-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) auto; gap: var(--sp-2); align-items: end; } .calendar-add-grid label { display: flex; flex-direction: column; gap: var(--sp-1); font-size: var(--fs-xs); } .calendar-list { display: flex; flex-direction: column; gap: var(--sp-2); } diff --git a/src/pkg/dashboard/static-src/css/meetings.css b/src/pkg/dashboard/static-src/css/meetings.css index 62dc405c49..16acee2269 100644 --- a/src/pkg/dashboard/static-src/css/meetings.css +++ b/src/pkg/dashboard/static-src/css/meetings.css @@ -1,12 +1,19 @@ /* Meetings: hive as a live meeting participant (Quorum) */ .meetings-panel { display: flex; flex-direction: column; gap: var(--sp-4); } - .meetings-join { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto auto; gap: var(--sp-2); align-items: end; } - .meetings-join-discord { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--sp-2); } - .meetings-join label { display: flex; flex-direction: column; gap: var(--sp-1); font-size: var(--fs-xs); } + .meetings-join { display: flex; flex-direction: column; gap: var(--sp-3); } + .meetings-join-fields { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--sp-3); } + .meetings-field { display: flex; flex-direction: column; gap: var(--sp-1); font-size: var(--fs-xs); color: var(--muted); } + .meetings-join-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); } + .meetings-voice-toggle { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); cursor: pointer; } .meetings-list { display: flex; flex-direction: column; gap: var(--sp-2); } - .meetings-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); padding: var(--sp-2); border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); } + .meetings-row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); } .meetings-row.is-open { border-color: var(--accent); } - .meetings-row-title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } + .meetings-row-main { flex: 1 1 16em; min-width: 0; display: flex; flex-direction: column; gap: var(--sp-1); } + .meetings-row-head { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; } + .meetings-row-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); font-weight: 600; } + .meetings-row-error { font-size: var(--fs-xs); color: var(--red); overflow-wrap: anywhere; } + .meetings-row-raw { margin-top: var(--sp-1); font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; } + .meetings-row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); } .meetings-live { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--sp-4); } .meetings-transcript { max-height: 28em; overflow: auto; font-size: var(--fs-sm); padding: var(--sp-2); border: 1px solid var(--border); border-radius: var(--r); background: var(--bg); } .meetings-line { margin: 0 0 var(--sp-1); white-space: pre-wrap; } @@ -21,5 +28,5 @@ .meetings-effective { font-size: var(--fs-xs); } .meetings-effective td { padding: 0 var(--sp-2) 0 0; vertical-align: top; } @media (max-width: 720px) { - .meetings-join, .meetings-join-discord, .meetings-live, .meetings-settings-grid { grid-template-columns: 1fr; } + .meetings-join-fields, .meetings-live, .meetings-settings-grid { grid-template-columns: 1fr; } } diff --git a/src/pkg/dashboard/static-src/js/calendar.js b/src/pkg/dashboard/static-src/js/calendar.js index c12b06c38d..1ebcc9889d 100644 --- a/src/pkg/dashboard/static-src/js/calendar.js +++ b/src/pkg/dashboard/static-src/js/calendar.js @@ -26,6 +26,19 @@ return typeof dashboardRoleAtLeast === 'function' ? dashboardRoleAtLeast(window._hiveRole || 'read', 'read-write') : window._hiveRole === 'owner'; } function calendarIsOwner() { return window._hiveRole === 'owner'; } + // The role is known once /api/role settled; until then the Calendar + // shows a loading state, never the "not allowed" notice, and re-renders + // when gh-auth.js notifies role listeners (same contract as the Inbox). + function calendarRoleKnown() { return window._hiveRoleSettled === true || window._hiveRole !== undefined; } + function calendarOnRoleReady() { + Promise.all([fetchCalendar(), calendarRefreshMeetings(), fetchMeetingDrafts()]).catch(console.error); + } + (window._hiveRoleListeners = window._hiveRoleListeners || []).push(calendarOnRoleReady); + // Schedule and draft status to the kc-pill status palette. + const CALENDAR_PILL_STATUS = { + live: 'ok', done: 'ok', scheduled: 'syncing', awaiting_approval: 'not loaded', pending: 'not loaded', approving: 'syncing', + failed: 'error', blocked: 'error' + }; function calendarPlatformLabel(p) { return CALENDAR_PLATFORM_LABELS[p] || p || 'meeting'; } @@ -100,6 +113,7 @@ } async function calendarRefreshMeetings() { + if (!calendarRoleKnown()) return; if (!calendarIsOwner()) { _calendarMeetings = {}; renderCalendarIndicator(); return; } try { const r = await fetch('/api/meetings'); @@ -124,8 +138,12 @@ async function fetchCalendar() { const host = document.getElementById('calendar-panel'); + if (!calendarRoleKnown()) { + if (host) host.innerHTML = '

Loading calendar…

'; + return; + } if (!calendarCanView()) { - if (host) host.innerHTML = '

The calendar is visible to the hive owner and read-write users.

'; + if (host) host.innerHTML = '

The calendar is visible to the hive owner and read-write users.

'; return; } try { @@ -133,7 +151,9 @@ const data = await r.json().catch(() => ({})); if (!r.ok) { _calendarData = null; _calendarError = data.error || ('HTTP ' + r.status); } else { _calendarData = data; _calendarError = ''; } - } catch (e) { return; } + } catch (e) { + if (!_calendarData) _calendarError = 'The calendar is unreachable right now; retrying.'; + } renderCalendar(); } dashboardScheduleWork('calendar', () => Promise.all([fetchCalendar(), calendarRefreshMeetings()])).catch(console.error); @@ -179,7 +199,7 @@ const status = e.status || ''; const times = calendarFormatTime(e.start) + (e.end ? ' – ' + calendarFormatTime(e.end) : ''); return '
' + - '' + escapeHtml(CALENDAR_STATUS_LABELS[status] || status) + '' + + '' + escapeHtml(CALENDAR_STATUS_LABELS[status] || status) + '' + '' + (CALENDAR_PLATFORM_ICONS[platform] || '🎙') + ' ' + escapeHtml(calendarPlatformLabel(platform)) + '' + '
' + escapeHtml(e.summary || e.join_url || 'Meeting') + '
' + '
' + escapeHtml(times) + (e.rrule ? ' · repeats' : '') + @@ -204,8 +224,8 @@ const recent = data.recent || []; const pending = upcoming.filter(e => e.status === 'awaiting_approval').length; host.innerHTML = calendarFormHtml() + - '
' + (upcoming.length ? upcoming.map(calendarRowHtml).join('') : '

Nothing scheduled.

') + '
' + - (recent.length ? '
' + recent.map(calendarRowHtml).join('') + '
' : ''); + '
' + (upcoming.length ? upcoming.map(calendarRowHtml).join('') : '

Nothing scheduled.

') + '
' + + (recent.length ? '
' + recent.map(calendarRowHtml).join('') + '
' : ''); setSectionSummary('calendar-section', upcoming.length + ' upcoming' + (pending ? ' · ' + pending + ' awaiting approval' : '')); } @@ -272,7 +292,11 @@ } async function fetchMeetingDrafts() { - if (!calendarCanView()) return; + if (!calendarRoleKnown() || !calendarCanView()) { + const host = document.getElementById('meeting-drafts-panel'); + if (host) host.innerHTML = ''; + return; + } try { const r = await fetch('/api/meetings/actions'); const data = await r.json().catch(() => ({})); @@ -310,7 +334,7 @@ const where = d.type === 'knowledge' ? 'knowledge vault' : (d.repo || 'no repo set'); const result = d.result_url ? ' · ' + escapeHtml(d.result_url) + '' : (d.result_note ? ' · ' + escapeHtml(d.result_note) : ''); return '
' + - '' + escapeHtml(MEETING_DRAFT_STATUS[status] || status) + '' + + '' + escapeHtml(MEETING_DRAFT_STATUS[status] || status) + '' + '' + escapeHtml(MEETING_DRAFT_TYPES[d.type] || d.type || '') + '' + '
' + escapeHtml(d.title || '') + '
' + '
' + escapeHtml(where) + (d.meeting_title ? ' · from ' + escapeHtml(d.meeting_title) : '') + @@ -328,14 +352,14 @@ const host = document.getElementById('meeting-drafts-panel'); if (!host) return; if (_meetingDraftsError) { - host.innerHTML = '

' + escapeHtml(_meetingDraftsError) + '

'; + host.innerHTML = '

' + escapeHtml(_meetingDraftsError) + '

'; return; } const split = meetingDraftsSplit((_meetingDrafts || {}).drafts); - host.innerHTML = '' + + host.innerHTML = '
' + '

Issues, RFCs, Spek sessions and knowledge notes people asked for in a meeting. Nothing is created until you approve it.

' + - '
' + (split.pending.length ? split.pending.map(meetingDraftRowHtml).join('') : '

No drafts waiting.

') + '
' + - (split.decided.length ? '
Recent (' + split.decided.length + ')
' + split.decided.map(meetingDraftRowHtml).join('') + '
' : ''); + '
' + (split.pending.length ? split.pending.map(meetingDraftRowHtml).join('') : '

No drafts waiting.

') + '
' + + (split.decided.length ? '
Recent (' + split.decided.length + ')
' + split.decided.map(meetingDraftRowHtml).join('') + '
' : '') + '
'; } function meetingDraftField(id, name) { return document.querySelector('[data-draft-id="' + CSS.escape(id) + '"][data-draft-field="' + name + '"]'); } diff --git a/src/pkg/dashboard/static-src/js/layout.js b/src/pkg/dashboard/static-src/js/layout.js index d101567d78..2aaaad2d26 100644 --- a/src/pkg/dashboard/static-src/js/layout.js +++ b/src/pkg/dashboard/static-src/js/layout.js @@ -4,7 +4,7 @@ var DASHBOARD_LAYOUT_KEY='hive.dashboard.layout'; var DASHBOARD_LAYOUT_VERSION=1; var DASHBOARD_LAYOUT_REGIONS=['main']; - var DASHBOARD_LAYOUT_TEMPLATE={main:['overview-section','governor','pr-throughput-section','repos-section','activity-monitor-section','knowledge-section','inbox-section','review-queue-section','contributors-section','advisory-section','token-panel','cost-panel','sessions-section','acmm-eval-section','debug-section','audit-section','approvals-section','nous-section','logs-section','agents-section','agent-activity-section','faq-section']}; + var DASHBOARD_LAYOUT_TEMPLATE={main:['overview-section','governor','pr-throughput-section','repos-section','activity-monitor-section','knowledge-section','inbox-section','calendar-section','meetings-section','review-queue-section','contributors-section','advisory-section','token-panel','cost-panel','sessions-section','acmm-eval-section','debug-section','audit-section','approvals-section','nous-section','logs-section','agents-section','agent-activity-section','faq-section']}; var DASHBOARD_LAYOUT_GRIP_SELECTOR='[data-dashboard-grip]'; var DASHBOARD_LAYOUT_CARD_SELECTOR='[data-dashboard-section]'; var DASHBOARD_LAYOUT_ANCHOR_ID='dash-notices'; diff --git a/src/pkg/dashboard/static-src/js/meetings.js b/src/pkg/dashboard/static-src/js/meetings.js index 671e1ff7e2..24ec960ac6 100644 --- a/src/pkg/dashboard/static-src/js/meetings.js +++ b/src/pkg/dashboard/static-src/js/meetings.js @@ -14,7 +14,20 @@ // Ended meetings are inbox items too (source "meeting"). if (typeof INBOX_SOURCE_ICONS === 'object' && !INBOX_SOURCE_ICONS.meeting) INBOX_SOURCE_ICONS.meeting = '🎙'; + // Raw errors longer than this collapse behind a "details" toggle. + const MEETINGS_ERROR_INLINE_CHARS = 140; + const MEETINGS_PLATFORM_LABELS = { google_meet: 'Google Meet', teams: 'Teams', zoom: 'Zoom', discord: 'Discord' }; + // Meeting state to the kc-pill status palette (green, blue, red, muted). + const MEETINGS_PILL_STATUS = { live: 'ok', requested: 'syncing', joining: 'syncing', lobby: 'syncing', failed: 'error', blocked: 'error' }; + function meetingsIsOwner() { return window._hiveRole === 'owner'; } + // The role is known once /api/role settled (answered, or its retries gave + // up). Until then the panel shows a neutral loading state, never the + // owner-only notice, and re-renders when gh-auth.js notifies role + // listeners (same contract as the Inbox, #18442). + function meetingsRoleKnown() { return window._hiveRoleSettled === true || window._hiveRole !== undefined; } + function meetingsOnRoleReady() { fetchMeetings(); } + (window._hiveRoleListeners = window._hiveRoleListeners || []).push(meetingsOnRoleReady); function meetingsLabel(m) { if (m.title) return m.title; if (m.platform === 'discord') return 'Discord ' + (m.channel_id || ''); @@ -24,8 +37,13 @@ async function fetchMeetings() { const host = document.getElementById('meetings-panel'); if (!host) return; + if (!meetingsRoleKnown()) { + host.innerHTML = '

Loading meetings…

'; + return; + } if (!meetingsIsOwner()) { - host.innerHTML = '

Meetings are visible to the hive owner only.

'; + host.innerHTML = '

Meetings are visible to the hive owner only.

' + + (window._hiveRoleFailed && !window._hiveRole ? '

Could not determine your role. It will retry automatically.

' : ''); return; } try { @@ -33,7 +51,11 @@ const data = await r.json().catch(() => ({})); if (!r.ok) { _meetingsList = []; _meetingsError = data.error || ('HTTP ' + r.status); } else { _meetingsList = data.meetings || []; _meetingsError = ''; } - } catch (e) { return; } + } catch (e) { + // Keep the last list; say the hive is unreachable instead of leaving "Loading meetings…". + if (_meetingsList === null) _meetingsList = []; + _meetingsError = 'Meetings are unreachable right now; retrying.'; + } renderMeetings(); } dashboardScheduleWork('meetings', fetchMeetings).catch(console.error); @@ -41,14 +63,48 @@ function meetingsJoinFormHtml() { return '
' + - '' + - '' + - '' + + '
' + + '' + + '
' + + '
Discord voice channel instead
' + + '' + + '
' + + '
' + + '' + '
' + - '
Discord voice channel instead
' + - '' + - '
' + - ''; + '
'; + } + + function meetingsFormatTime(iso) { + if (!iso) return ''; + const d = new Date(iso); + if (isNaN(d.getTime())) return ''; + try { return new Intl.DateTimeFormat(undefined, { month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }).format(d); } + catch (e) { return d.toISOString(); } + } + + // meetingsFriendlyReason is a plain-language line for a meeting's + // state_reason; the raw reason stays available under "details". + function meetingsFriendlyReason(m) { + const raw = String(m.state_reason || ''); + if (!raw) return ''; + if (m.state === 'blocked') return 'The meeting refused a guest bot.'; + if (/lobby_timeout/.test(raw)) return 'Nobody admitted hive from the lobby in time.'; + if (/platform_unavailable/.test(raw)) return 'This meeting platform is not available on this hive right now.'; + if (/invalid_argument/.test(raw)) return 'The meeting service did not accept this meeting link.'; + if (/upstream_error|Vexa|answered 5\d\d/.test(raw)) return 'The meeting service could not start the bot.'; + if (m.state === 'failed') return 'Hive could not join this meeting.'; + return raw.length > MEETINGS_ERROR_INLINE_CHARS ? '' : raw; + } + + function meetingsReasonHtml(m) { + const raw = String(m.state_reason || ''); + if (!raw) return ''; + const friendly = meetingsFriendlyReason(m); + const cls = (m.state === 'failed' || m.state === 'blocked') ? 'meetings-row-error' : 'muted-xs'; + if (friendly === raw) return '
' + escapeHtml(raw) + '
'; + return '
' + escapeHtml(friendly || 'Details') + '
' + + '
details
' + escapeHtml(raw) + '
'; } function meetingsRowHtml(m) { @@ -56,21 +112,29 @@ const open = _meetingsOpen && _meetingsOpen.id === m.id; const request = m.state === 'requested' && m.requested_by; if (request) { - return '
join request' + + return '
' + '' + escapeHtml((m.requested_by.name || m.requested_by.id || 'someone') + ' asked hive into ' + meetingsLabel(m)) + '' + + 'join request
' + + '
' + '' + - '
'; + '
'; } - return '
' + - '' + escapeHtml(m.state || '') + '' + + const state = m.state || ''; + const when = meetingsFormatTime(m.live_at || m.created_at); + const meta = [MEETINGS_PLATFORM_LABELS[m.platform] || m.platform || '', when].filter(Boolean).join(' · '); + return '
' + + '
' + '' + escapeHtml(meetingsLabel(m)) + '' + - (m.state_reason ? '' + escapeHtml(m.state_reason) + '' : '') + - (m.consent_error && !m.consent_posted_at ? 'chat unavailable: consent notice not posted yet' : '') + - (m.voice_enabled && !m.voice_capable ? 'joined without voice; replies go to chat' : '') + + '' + escapeHtml(state) + '
' + + (meta ? '
' + escapeHtml(meta) + '
' : '') + + meetingsReasonHtml(m) + + (m.consent_error && !m.consent_posted_at ? '
chat unavailable: consent notice not posted yet
' : '') + + (m.voice_enabled && !m.voice_capable ? '
joined without voice; replies go to chat
' : '') + + '
' + '' + (active ? '' + '' : '') + - '
'; + '
'; } function renderMeetings() { @@ -83,7 +147,7 @@ html += meetingsJoinFormHtml(); } const list = _meetingsList || []; - html += '
' + (list.length ? list.map(meetingsRowHtml).join('') : (_meetingsError ? '' : '

No meetings yet.

')) + '
'; + html += '
' + (list.length ? list.map(meetingsRowHtml).join('') : (_meetingsError ? '' : '

No meetings yet.

')) + '
'; html += '
'; host.innerHTML = html; const liveCount = list.filter(m => MEETINGS_LIVE_STATES[m.state]).length; diff --git a/src/pkg/dashboard/static-src/js/sections.js b/src/pkg/dashboard/static-src/js/sections.js index eedf74a85f..566af20e97 100644 --- a/src/pkg/dashboard/static-src/js/sections.js +++ b/src/pkg/dashboard/static-src/js/sections.js @@ -10,6 +10,7 @@ // keeps the historical all-expanded default forever) or is new ('v1'). const DASHBOARD_DEFAULT_COLLAPSED_SECTIONS = Object.freeze([ 'pr-throughput-section', 'token-panel', 'cost-panel', 'advisory-section', 'knowledge-section', 'inbox-section', + 'calendar-section', 'meetings-section', 'contributors-section', 'sessions-section', 'acmm-eval-section', 'debug-section', 'audit-section', 'logs-section', 'nous-section', 'faq-section' ]); diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 33ba10bdba..113c7fad39 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -6144,13 +6144,20 @@ .inbox-share-more:hover, .inbox-share-more:focus-visible { text-decoration: underline; } /* Meetings: hive as a live meeting participant (Quorum) */ .meetings-panel { display: flex; flex-direction: column; gap: var(--sp-4); } - .meetings-join { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto auto; gap: var(--sp-2); align-items: end; } - .meetings-join-discord { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--sp-2); } - .meetings-join label { display: flex; flex-direction: column; gap: var(--sp-1); font-size: var(--fs-xs); } + .meetings-join { display: flex; flex-direction: column; gap: var(--sp-3); } + .meetings-join-fields { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--sp-3); } + .meetings-field { display: flex; flex-direction: column; gap: var(--sp-1); font-size: var(--fs-xs); color: var(--muted); } + .meetings-join-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); } + .meetings-voice-toggle { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); cursor: pointer; } .meetings-list { display: flex; flex-direction: column; gap: var(--sp-2); } - .meetings-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); padding: var(--sp-2); border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); } + .meetings-row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); } .meetings-row.is-open { border-color: var(--accent); } - .meetings-row-title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } + .meetings-row-main { flex: 1 1 16em; min-width: 0; display: flex; flex-direction: column; gap: var(--sp-1); } + .meetings-row-head { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; } + .meetings-row-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); font-weight: 600; } + .meetings-row-error { font-size: var(--fs-xs); color: var(--red); overflow-wrap: anywhere; } + .meetings-row-raw { margin-top: var(--sp-1); font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; } + .meetings-row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); } .meetings-live { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--sp-4); } .meetings-transcript { max-height: 28em; overflow: auto; font-size: var(--fs-sm); padding: var(--sp-2); border: 1px solid var(--border); border-radius: var(--r); background: var(--bg); } .meetings-line { margin: 0 0 var(--sp-1); white-space: pre-wrap; } @@ -6165,10 +6172,11 @@ .meetings-effective { font-size: var(--fs-xs); } .meetings-effective td { padding: 0 var(--sp-2) 0 0; vertical-align: top; } @media (max-width: 720px) { - .meetings-join, .meetings-join-discord, .meetings-live, .meetings-settings-grid { grid-template-columns: 1fr; } + .meetings-join-fields, .meetings-live, .meetings-settings-grid { grid-template-columns: 1fr; } } /* Calendar: scheduled meetings hive joins (#18394) */ - .calendar-panel { display: flex; flex-direction: column; gap: var(--sp-3); } + .calendar-panel { display: flex; flex-direction: column; gap: var(--sp-5); } + .calendar-subsection { display: flex; flex-direction: column; gap: var(--sp-2); } .calendar-add-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) auto; gap: var(--sp-2); align-items: end; } .calendar-add-grid label { display: flex; flex-direction: column; gap: var(--sp-1); font-size: var(--fs-xs); } .calendar-list { display: flex; flex-direction: column; gap: var(--sp-2); } @@ -10746,6 +10754,7 @@

Where to get help

// keeps the historical all-expanded default forever) or is new ('v1'). const DASHBOARD_DEFAULT_COLLAPSED_SECTIONS = Object.freeze([ 'pr-throughput-section', 'token-panel', 'cost-panel', 'advisory-section', 'knowledge-section', 'inbox-section', + 'calendar-section', 'meetings-section', 'contributors-section', 'sessions-section', 'acmm-eval-section', 'debug-section', 'audit-section', 'logs-section', 'nous-section', 'faq-section' ]); @@ -12355,7 +12364,7 @@

Where to get help

var DASHBOARD_LAYOUT_KEY='hive.dashboard.layout'; var DASHBOARD_LAYOUT_VERSION=1; var DASHBOARD_LAYOUT_REGIONS=['main']; - var DASHBOARD_LAYOUT_TEMPLATE={main:['overview-section','governor','pr-throughput-section','repos-section','activity-monitor-section','knowledge-section','inbox-section','review-queue-section','contributors-section','advisory-section','token-panel','cost-panel','sessions-section','acmm-eval-section','debug-section','audit-section','approvals-section','nous-section','logs-section','agents-section','agent-activity-section','faq-section']}; + var DASHBOARD_LAYOUT_TEMPLATE={main:['overview-section','governor','pr-throughput-section','repos-section','activity-monitor-section','knowledge-section','inbox-section','calendar-section','meetings-section','review-queue-section','contributors-section','advisory-section','token-panel','cost-panel','sessions-section','acmm-eval-section','debug-section','audit-section','approvals-section','nous-section','logs-section','agents-section','agent-activity-section','faq-section']}; var DASHBOARD_LAYOUT_GRIP_SELECTOR='[data-dashboard-grip]'; var DASHBOARD_LAYOUT_CARD_SELECTOR='[data-dashboard-section]'; var DASHBOARD_LAYOUT_ANCHOR_ID='dash-notices'; @@ -49966,7 +49975,20 @@ // Ended meetings are inbox items too (source "meeting"). if (typeof INBOX_SOURCE_ICONS === 'object' && !INBOX_SOURCE_ICONS.meeting) INBOX_SOURCE_ICONS.meeting = '🎙'; + // Raw errors longer than this collapse behind a "details" toggle. + const MEETINGS_ERROR_INLINE_CHARS = 140; + const MEETINGS_PLATFORM_LABELS = { google_meet: 'Google Meet', teams: 'Teams', zoom: 'Zoom', discord: 'Discord' }; + // Meeting state to the kc-pill status palette (green, blue, red, muted). + const MEETINGS_PILL_STATUS = { live: 'ok', requested: 'syncing', joining: 'syncing', lobby: 'syncing', failed: 'error', blocked: 'error' }; + function meetingsIsOwner() { return window._hiveRole === 'owner'; } + // The role is known once /api/role settled (answered, or its retries gave + // up). Until then the panel shows a neutral loading state, never the + // owner-only notice, and re-renders when gh-auth.js notifies role + // listeners (same contract as the Inbox, #18442). + function meetingsRoleKnown() { return window._hiveRoleSettled === true || window._hiveRole !== undefined; } + function meetingsOnRoleReady() { fetchMeetings(); } + (window._hiveRoleListeners = window._hiveRoleListeners || []).push(meetingsOnRoleReady); function meetingsLabel(m) { if (m.title) return m.title; if (m.platform === 'discord') return 'Discord ' + (m.channel_id || ''); @@ -49976,8 +49998,13 @@ async function fetchMeetings() { const host = document.getElementById('meetings-panel'); if (!host) return; + if (!meetingsRoleKnown()) { + host.innerHTML = '

Loading meetings…

'; + return; + } if (!meetingsIsOwner()) { - host.innerHTML = '

Meetings are visible to the hive owner only.

'; + host.innerHTML = '

Meetings are visible to the hive owner only.

' + + (window._hiveRoleFailed && !window._hiveRole ? '

Could not determine your role. It will retry automatically.

' : ''); return; } try { @@ -49985,7 +50012,11 @@ const data = await r.json().catch(() => ({})); if (!r.ok) { _meetingsList = []; _meetingsError = data.error || ('HTTP ' + r.status); } else { _meetingsList = data.meetings || []; _meetingsError = ''; } - } catch (e) { return; } + } catch (e) { + // Keep the last list; say the hive is unreachable instead of leaving "Loading meetings…". + if (_meetingsList === null) _meetingsList = []; + _meetingsError = 'Meetings are unreachable right now; retrying.'; + } renderMeetings(); } dashboardScheduleWork('meetings', fetchMeetings).catch(console.error); @@ -49993,14 +50024,48 @@ function meetingsJoinFormHtml() { return '
' + - '' + - '' + - '' + + '
' + + '' + + '
' + + '
Discord voice channel instead
' + + '' + + '
' + + '
' + + '' + '
' + - '
Discord voice channel instead
' + - '' + - '
' + - ''; + '
'; + } + + function meetingsFormatTime(iso) { + if (!iso) return ''; + const d = new Date(iso); + if (isNaN(d.getTime())) return ''; + try { return new Intl.DateTimeFormat(undefined, { month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }).format(d); } + catch (e) { return d.toISOString(); } + } + + // meetingsFriendlyReason is a plain-language line for a meeting's + // state_reason; the raw reason stays available under "details". + function meetingsFriendlyReason(m) { + const raw = String(m.state_reason || ''); + if (!raw) return ''; + if (m.state === 'blocked') return 'The meeting refused a guest bot.'; + if (/lobby_timeout/.test(raw)) return 'Nobody admitted hive from the lobby in time.'; + if (/platform_unavailable/.test(raw)) return 'This meeting platform is not available on this hive right now.'; + if (/invalid_argument/.test(raw)) return 'The meeting service did not accept this meeting link.'; + if (/upstream_error|Vexa|answered 5\d\d/.test(raw)) return 'The meeting service could not start the bot.'; + if (m.state === 'failed') return 'Hive could not join this meeting.'; + return raw.length > MEETINGS_ERROR_INLINE_CHARS ? '' : raw; + } + + function meetingsReasonHtml(m) { + const raw = String(m.state_reason || ''); + if (!raw) return ''; + const friendly = meetingsFriendlyReason(m); + const cls = (m.state === 'failed' || m.state === 'blocked') ? 'meetings-row-error' : 'muted-xs'; + if (friendly === raw) return '
' + escapeHtml(raw) + '
'; + return '
' + escapeHtml(friendly || 'Details') + '
' + + '
details
' + escapeHtml(raw) + '
'; } function meetingsRowHtml(m) { @@ -50008,21 +50073,29 @@ const open = _meetingsOpen && _meetingsOpen.id === m.id; const request = m.state === 'requested' && m.requested_by; if (request) { - return '
join request' + + return '
' + '' + escapeHtml((m.requested_by.name || m.requested_by.id || 'someone') + ' asked hive into ' + meetingsLabel(m)) + '' + + 'join request
' + + '
' + '' + - '
'; + '
'; } - return '
' + - '' + escapeHtml(m.state || '') + '' + + const state = m.state || ''; + const when = meetingsFormatTime(m.live_at || m.created_at); + const meta = [MEETINGS_PLATFORM_LABELS[m.platform] || m.platform || '', when].filter(Boolean).join(' · '); + return '
' + + '
' + '' + escapeHtml(meetingsLabel(m)) + '' + - (m.state_reason ? '' + escapeHtml(m.state_reason) + '' : '') + - (m.consent_error && !m.consent_posted_at ? 'chat unavailable: consent notice not posted yet' : '') + - (m.voice_enabled && !m.voice_capable ? 'joined without voice; replies go to chat' : '') + + '' + escapeHtml(state) + '
' + + (meta ? '
' + escapeHtml(meta) + '
' : '') + + meetingsReasonHtml(m) + + (m.consent_error && !m.consent_posted_at ? '
chat unavailable: consent notice not posted yet
' : '') + + (m.voice_enabled && !m.voice_capable ? '
joined without voice; replies go to chat
' : '') + + '
' + '' + (active ? '' + '' : '') + - '
'; + '
'; } function renderMeetings() { @@ -50035,7 +50108,7 @@ html += meetingsJoinFormHtml(); } const list = _meetingsList || []; - html += '
' + (list.length ? list.map(meetingsRowHtml).join('') : (_meetingsError ? '' : '

No meetings yet.

')) + '
'; + html += '
' + (list.length ? list.map(meetingsRowHtml).join('') : (_meetingsError ? '' : '

No meetings yet.

')) + '
'; html += '
'; host.innerHTML = html; const liveCount = list.filter(m => MEETINGS_LIVE_STATES[m.state]).length; @@ -50285,6 +50358,19 @@ return typeof dashboardRoleAtLeast === 'function' ? dashboardRoleAtLeast(window._hiveRole || 'read', 'read-write') : window._hiveRole === 'owner'; } function calendarIsOwner() { return window._hiveRole === 'owner'; } + // The role is known once /api/role settled; until then the Calendar + // shows a loading state, never the "not allowed" notice, and re-renders + // when gh-auth.js notifies role listeners (same contract as the Inbox). + function calendarRoleKnown() { return window._hiveRoleSettled === true || window._hiveRole !== undefined; } + function calendarOnRoleReady() { + Promise.all([fetchCalendar(), calendarRefreshMeetings(), fetchMeetingDrafts()]).catch(console.error); + } + (window._hiveRoleListeners = window._hiveRoleListeners || []).push(calendarOnRoleReady); + // Schedule and draft status to the kc-pill status palette. + const CALENDAR_PILL_STATUS = { + live: 'ok', done: 'ok', scheduled: 'syncing', awaiting_approval: 'not loaded', pending: 'not loaded', approving: 'syncing', + failed: 'error', blocked: 'error' + }; function calendarPlatformLabel(p) { return CALENDAR_PLATFORM_LABELS[p] || p || 'meeting'; } @@ -50359,6 +50445,7 @@ } async function calendarRefreshMeetings() { + if (!calendarRoleKnown()) return; if (!calendarIsOwner()) { _calendarMeetings = {}; renderCalendarIndicator(); return; } try { const r = await fetch('/api/meetings'); @@ -50383,8 +50470,12 @@ async function fetchCalendar() { const host = document.getElementById('calendar-panel'); + if (!calendarRoleKnown()) { + if (host) host.innerHTML = '

Loading calendar…

'; + return; + } if (!calendarCanView()) { - if (host) host.innerHTML = '

The calendar is visible to the hive owner and read-write users.

'; + if (host) host.innerHTML = '

The calendar is visible to the hive owner and read-write users.

'; return; } try { @@ -50392,7 +50483,9 @@ const data = await r.json().catch(() => ({})); if (!r.ok) { _calendarData = null; _calendarError = data.error || ('HTTP ' + r.status); } else { _calendarData = data; _calendarError = ''; } - } catch (e) { return; } + } catch (e) { + if (!_calendarData) _calendarError = 'The calendar is unreachable right now; retrying.'; + } renderCalendar(); } dashboardScheduleWork('calendar', () => Promise.all([fetchCalendar(), calendarRefreshMeetings()])).catch(console.error); @@ -50438,7 +50531,7 @@ const status = e.status || ''; const times = calendarFormatTime(e.start) + (e.end ? ' – ' + calendarFormatTime(e.end) : ''); return '
' + - '' + escapeHtml(CALENDAR_STATUS_LABELS[status] || status) + '' + + '' + escapeHtml(CALENDAR_STATUS_LABELS[status] || status) + '' + '' + (CALENDAR_PLATFORM_ICONS[platform] || '🎙') + ' ' + escapeHtml(calendarPlatformLabel(platform)) + '' + '
' + escapeHtml(e.summary || e.join_url || 'Meeting') + '
' + '
' + escapeHtml(times) + (e.rrule ? ' · repeats' : '') + @@ -50463,8 +50556,8 @@ const recent = data.recent || []; const pending = upcoming.filter(e => e.status === 'awaiting_approval').length; host.innerHTML = calendarFormHtml() + - '
' + (upcoming.length ? upcoming.map(calendarRowHtml).join('') : '

Nothing scheduled.

') + '
' + - (recent.length ? '
' + recent.map(calendarRowHtml).join('') + '
' : ''); + '
' + (upcoming.length ? upcoming.map(calendarRowHtml).join('') : '

Nothing scheduled.

') + '
' + + (recent.length ? '
' + recent.map(calendarRowHtml).join('') + '
' : ''); setSectionSummary('calendar-section', upcoming.length + ' upcoming' + (pending ? ' · ' + pending + ' awaiting approval' : '')); } @@ -50531,7 +50624,11 @@ } async function fetchMeetingDrafts() { - if (!calendarCanView()) return; + if (!calendarRoleKnown() || !calendarCanView()) { + const host = document.getElementById('meeting-drafts-panel'); + if (host) host.innerHTML = ''; + return; + } try { const r = await fetch('/api/meetings/actions'); const data = await r.json().catch(() => ({})); @@ -50569,7 +50666,7 @@ const where = d.type === 'knowledge' ? 'knowledge vault' : (d.repo || 'no repo set'); const result = d.result_url ? ' · ' + escapeHtml(d.result_url) + '' : (d.result_note ? ' · ' + escapeHtml(d.result_note) : ''); return '
' + - '' + escapeHtml(MEETING_DRAFT_STATUS[status] || status) + '' + + '' + escapeHtml(MEETING_DRAFT_STATUS[status] || status) + '' + '' + escapeHtml(MEETING_DRAFT_TYPES[d.type] || d.type || '') + '' + '
' + escapeHtml(d.title || '') + '
' + '
' + escapeHtml(where) + (d.meeting_title ? ' · from ' + escapeHtml(d.meeting_title) : '') + @@ -50587,14 +50684,14 @@ const host = document.getElementById('meeting-drafts-panel'); if (!host) return; if (_meetingDraftsError) { - host.innerHTML = '

' + escapeHtml(_meetingDraftsError) + '

'; + host.innerHTML = '

' + escapeHtml(_meetingDraftsError) + '

'; return; } const split = meetingDraftsSplit((_meetingDrafts || {}).drafts); - host.innerHTML = '' + + host.innerHTML = '
' + '

Issues, RFCs, Spek sessions and knowledge notes people asked for in a meeting. Nothing is created until you approve it.

' + - '
' + (split.pending.length ? split.pending.map(meetingDraftRowHtml).join('') : '

No drafts waiting.

') + '
' + - (split.decided.length ? '
Recent (' + split.decided.length + ')
' + split.decided.map(meetingDraftRowHtml).join('') + '
' : ''); + '
' + (split.pending.length ? split.pending.map(meetingDraftRowHtml).join('') : '

No drafts waiting.

') + '
' + + (split.decided.length ? '
Recent (' + split.decided.length + ')
' + split.decided.map(meetingDraftRowHtml).join('') + '
' : '') + '
'; } function meetingDraftField(id, name) { return document.querySelector('[data-draft-id="' + CSS.escape(id) + '"][data-draft-field="' + name + '"]'); } diff --git a/src/pkg/dashboard/webstatic/static_index_test.go b/src/pkg/dashboard/webstatic/static_index_test.go index 21ad921679..edd90e7648 100644 --- a/src/pkg/dashboard/webstatic/static_index_test.go +++ b/src/pkg/dashboard/webstatic/static_index_test.go @@ -420,7 +420,7 @@ func TestStaticDashboardDefaultLayoutOrder(t *testing.T) { } html := rec.Body.String() - defaultOrder := "'overview-section','governor','pr-throughput-section','repos-section','activity-monitor-section','knowledge-section','inbox-section','review-queue-section','contributors-section','advisory-section','token-panel','cost-panel','sessions-section','acmm-eval-section','debug-section','audit-section','approvals-section','nous-section','logs-section','agents-section','agent-activity-section','faq-section'" + defaultOrder := "'overview-section','governor','pr-throughput-section','repos-section','activity-monitor-section','knowledge-section','inbox-section','calendar-section','meetings-section','review-queue-section','contributors-section','advisory-section','token-panel','cost-panel','sessions-section','acmm-eval-section','debug-section','audit-section','approvals-section','nous-section','logs-section','agents-section','agent-activity-section','faq-section'" if !strings.Contains(html, defaultOrder) { t.Fatalf("dashboard default layout/reset order no longer matches sidebar nav; missing %q", defaultOrder) }