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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixed-meetings-calendar-role-and-layout.md
Original file line number Diff line number Diff line change
@@ -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.
148 changes: 148 additions & 0 deletions dashboard/test/meetings-calendar-role-race.test.js
Original file line number Diff line number Diff line change
@@ -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, '&amp;').replace(/</g, '&lt;').replace(/"/g, '&quot;'),
refreshSectionCardShell: () => {},
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, /<span class="kc-pill" data-status="error">failed<\/span>/);
assert.match(html, /class="meetings-row-error">The meeting service did not accept this meeting link\./);
assert.match(html, /<summary class="muted-xs">details<\/summary><div class="meetings-row-raw">quorum meeting\.join/);
assert.match(html, /Zoom · /);
});
10 changes: 5 additions & 5 deletions src/pkg/dashboard/dashboard_section_reorder_9062_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
Expand All @@ -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
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion src/pkg/dashboard/static-src/css/calendar.css
Original file line number Diff line number Diff line change
@@ -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); }
Expand Down
19 changes: 13 additions & 6 deletions src/pkg/dashboard/static-src/css/meetings.css
Original file line number Diff line number Diff line change
@@ -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; }
Expand All @@ -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; }
}
Loading
Loading