@unson/brainbase-mcp 0.50.2 → 0.50.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unson/brainbase-mcp",
3
- "version": "0.50.2",
3
+ "version": "0.50.4",
4
4
  "description": "Local-first Brainbase judgment OS that lets supported AI agents reuse a user's approved goals, priorities, decisions, and judgment criteria.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -644,5 +644,5 @@
644
644
  "url": "https://github.com/Unson-LLC/brainbase/issues"
645
645
  },
646
646
  "homepage": "https://github.com/Unson-LLC/brainbase#readme",
647
- "gitHead": "b7649210b7d3e3c27ac61780abe0ad2cc13b5d05"
647
+ "gitHead": "60790aaf6b20e360ca472f86dbc11f4fd67c1978"
648
648
  }
@@ -89,6 +89,21 @@
89
89
  --bb-font-weight-body: 400;
90
90
  --bb-font-weight-medium: 500;
91
91
  --bb-color-mint: #6fc4b5;
92
+ /* Approved compact Inbox presentation; scoped by the opt-in cards layout. */
93
+ --bb-inbox-approval-stripe: #d97706;
94
+ --bb-inbox-task-stripe: #2563eb;
95
+ --bb-inbox-border-subtle: #ebf0f2;
96
+ --bb-inbox-tab-hover: rgb(255 255 255 / 50%);
97
+ --bb-inbox-card-hover-border: #c4d0d5;
98
+ --bb-inbox-meta-label: var(--bb-color-muted);
99
+ --bb-inbox-badge-border: #bce4dc;
100
+ --bb-inbox-urgent-ink: #b91c1c;
101
+ --bb-inbox-urgent-surface: #fef2f2;
102
+ --bb-inbox-urgent-border: #fecaca;
103
+ --bb-inbox-context-surface: #edf1f7;
104
+ --bb-inbox-card-shadow: 0 1px 2px rgb(15 23 42 / 4%);
105
+ --bb-inbox-card-hover-shadow: 0 4px 12px rgb(15 23 42 / 7%), 0 1px 3px rgb(15 23 42 / 5%);
106
+ --bb-inbox-action-shadow: 0 1px 2px rgb(36 50 75 / 20%);
92
107
  --bb-color-mint-strong: #4fa999;
93
108
  --bb-color-interaction-hover: #eaf6f3;
94
109
  --bb-font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
@@ -133,7 +148,13 @@
133
148
  --bb-search-band-chevron-width: 10px;
134
149
  --bb-search-band-chevron-height: 6px;
135
150
  --bb-search-band-chevron-stroke: 1.2;
136
- --bb-search-band-header-height: 44px;
151
+ --bb-page-title-font-size: 20px;
152
+ --bb-page-title-line-height: 28px;
153
+ --bb-page-title-font-weight: 600;
154
+ --bb-page-header-padding-top: var(--bb-space-3);
155
+ --bb-page-header-padding-bottom: var(--bb-space-4);
156
+ --bb-page-header-height: calc(var(--bb-page-title-line-height) + var(--bb-page-header-padding-top) + var(--bb-page-header-padding-bottom));
157
+ --bb-search-band-header-height: var(--bb-page-header-height);
137
158
  --bb-search-band-scope-padding: 13px;
138
159
  --bb-search-band-scope-viewport-reserve: 192px;
139
160
  --bb-search-band-scope-popup-width: 260px;
package/ui/inbox.css CHANGED
@@ -273,3 +273,102 @@ a.bb-inbox-title:focus-visible {
273
273
  }
274
274
 
275
275
  .bb-inbox-tabs { margin: 0 0 var(--bb-space-4); }
276
+
277
+ /* Opt-in compact cards. Business state and actions still belong to the host port. */
278
+ .bb-inbox.is-cards { min-width: 0; }
279
+ .bb-inbox.is-cards .bb-inbox-card-toolbar { position: sticky; top: var(--bb-page-header-height); z-index: 17; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--bb-space-2) var(--bb-space-4); margin-bottom: 20px; background: var(--bb-color-canvas); border-bottom: 1px solid var(--bb-color-border); }
280
+ .bb-inbox.is-cards .bb-inbox-tabs { min-width: 0; margin: 0; flex-shrink: 0; }
281
+ .bb-inbox-card-filters { display: flex; flex-wrap: wrap; gap: var(--bb-space-1); padding-bottom: var(--bb-space-1); }
282
+ .bb-inbox-card-filters .bb-ws-button { min-height: var(--bb-control-small-height); padding: var(--bb-space-1) var(--bb-space-2); border: 1px solid var(--bb-color-border); border-radius: var(--bb-radius-pill); background: var(--bb-color-panel); font-size: 12px; }
283
+ .bb-inbox-card-filters .bb-ws-button[aria-pressed="true"] { background: var(--bb-color-accent); color: var(--bb-color-action-text); border-color: var(--bb-color-accent); }
284
+ .bb-inbox-card-group-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; padding-bottom: 6px; }
285
+ .bb-inbox.is-cards .bb-inbox-group-title { margin: 0; font-size: 15px; font-weight: 700; color: var(--bb-color-accent); }
286
+ .bb-inbox-group-count { font-size: 12.5px; font-weight: 500; color: var(--bb-color-muted); }
287
+ .bb-inbox.is-cards .bb-inbox-list { display: grid; gap: var(--bb-space-3); }
288
+ .bb-inbox-card { position: relative; min-width: 0; padding: 16px 20px; background: var(--bb-color-panel); border: 1px solid var(--bb-color-border); border-radius: 12px; box-shadow: var(--bb-inbox-card-shadow); }
289
+ .bb-inbox-card-summary { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
290
+ .bb-inbox-card .bb-inbox-row-main { flex: 1; min-width: 0; }
291
+ .bb-inbox-card-heading { margin: 0 0 6px; font-size: 14.5px; line-height: 1.45; letter-spacing: -0.2px; }
292
+ .bb-inbox-card-title { margin: 0; padding: 0; border: 0; background: transparent; color: var(--bb-color-ink); font: inherit; font-weight: 600; text-align: left; cursor: pointer; overflow-wrap: anywhere; }
293
+ .bb-inbox-card :is(.bb-inbox-facts, .bb-inbox-meta) { margin: 0; }
294
+ .bb-inbox-card .bb-inbox-row-actions { flex-wrap: wrap; justify-content: flex-end; flex-shrink: 0; gap: 8px; padding-top: 2px; }
295
+ .bb-inbox-card .bb-ws-button { min-height: 32px; height: 32px; padding: 0 13px; border-radius: 6px; font-size: 12.5px; font-weight: 500; line-height: normal; white-space: nowrap; }
296
+ .bb-inbox-card .bb-inbox-card-detail { margin-top: 16px; padding: 16px; border: 1px solid var(--bb-color-border); border-radius: 8px; background: var(--bb-color-canvas); }
297
+ .bb-inbox-card-detail[hidden] { display: none; }
298
+ .bb-inbox-card-detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--bb-space-3); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--bb-color-border); }
299
+ .bb-inbox-card-detail-head h4 { margin: 0; font-size: 13px; font-weight: 600; color: var(--bb-color-accent); }
300
+ .bb-inbox-card-detail p { font-size: 12.5px; line-height: 1.6; overflow-wrap: anywhere; }
301
+ .bb-inbox-card-detail-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--bb-color-border); }
302
+ .bb-inbox-source-link { color: var(--bb-color-action); font-size: 12px; text-underline-offset: 3px; margin-right: auto; }
303
+ .bb-inbox-card :is(.bb-inbox-fact dd, .bb-inbox-meta) { overflow-wrap: anywhere; }
304
+ .bb-inbox-card .bb-inbox-confirm { margin: 0; flex: 1; min-width: 0; }
305
+ .bb-inbox-card .bb-inbox-later-menu { display: flex; flex-wrap: wrap; gap: var(--bb-space-2); margin-top: var(--bb-space-3); }
306
+ .bb-inbox.is-cards .bb-inbox-group { scroll-margin-top: calc(var(--bb-page-header-height) + var(--bb-tab-height)); }
307
+ .bb-inbox-card :is(button, a):focus-visible { outline: 2px solid var(--bb-color-focus); outline-offset: 3px; }
308
+ @media (max-width: 900px) {
309
+ .bb-inbox.is-cards .bb-inbox-card-toolbar { gap: var(--bb-space-2); }
310
+ .bb-inbox.is-cards .bb-inbox-tabs { flex-shrink: 1; width: 100%; }
311
+ .bb-inbox-card-summary { flex-direction: column; align-items: stretch; gap: 14px; }
312
+ .bb-inbox-card-summary > .bb-inbox-row-actions { justify-content: flex-start; width: 100%; border-top: 1px solid var(--bb-inbox-border-subtle); padding-top: 12px; }
313
+ .bb-inbox-card-detail-footer .bb-inbox-row-actions { justify-content: flex-end; margin-left: auto; }
314
+ }
315
+ @media (prefers-reduced-motion: reduce) {
316
+ .bb-inbox.is-cards *, .bb-inbox.is-cards *::after { transition: none; animation: none; }
317
+ }
318
+ .bb-inbox.is-cards .bb-inbox-list { border: 0; border-radius: 0; overflow: visible; background: transparent; }
319
+ .bb-inbox-card .bb-inbox-facts { display: flex; flex-wrap: wrap; gap: var(--bb-space-2) var(--bb-space-4); }
320
+ .bb-inbox-card .bb-inbox-fact { display: flex; align-items: baseline; gap: 5px; }
321
+ .bb-inbox-card .bb-inbox-fact :is(dt, dd) { margin: 0; font-size: 12px; }
322
+ .bb-inbox-card .bb-inbox-meta { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: center; }
323
+ .bb-inbox-card-detail-footer > .bb-inbox-row-actions { width: auto; flex: 0 1 auto; }
324
+ .bb-inbox.is-cards :is(.bb-inbox-card, button, a, [tabindex]) { scroll-margin-top: calc(var(--bb-page-header-height) + var(--bb-inbox-toolbar-height, var(--bb-tab-height)) + var(--bb-space-2)); }
325
+
326
+ /* Preserve the adopted reference's visual hierarchy within cards only. */
327
+ .bb-inbox.is-cards .bb-inbox-group { margin-bottom: 28px; }
328
+ .bb-inbox-card:hover { border-color: var(--bb-inbox-card-hover-border); box-shadow: var(--bb-inbox-card-hover-shadow); }
329
+ .bb-inbox-card::before { content: ""; position: absolute; top: 12px; bottom: 12px; left: 0; width: 3.5px; border-radius: 0 3px 3px 0; background: var(--bb-color-border); }
330
+ .bb-inbox-card[data-group="approve"]::before { background: var(--bb-inbox-approval-stripe); }
331
+ .bb-inbox-card[data-group="answer"]::before { background: var(--bb-color-accent); }
332
+ .bb-inbox-card[data-group="triage"]::before { background: var(--bb-color-mint); }
333
+ .bb-inbox-card[data-group="task"]::before { background: var(--bb-inbox-task-stripe); }
334
+ .bb-inbox-card-badge { display: inline-flex; align-items: center; margin-bottom: 6px; padding: 2px 7px; border: 1px solid var(--bb-inbox-badge-border); border-radius: 4px; color: var(--bb-color-accent); background: var(--bb-color-accent-soft); font-size: 11px; font-weight: 700; line-height: 1.5; }
335
+ .bb-inbox-card-badge.is-urgent { color: var(--bb-inbox-urgent-ink); background: var(--bb-inbox-urgent-surface); border-color: var(--bb-inbox-urgent-border); }
336
+ .bb-inbox-card-metadata { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 16px; }
337
+ .bb-inbox-card .bb-inbox-fact dt { color: var(--bb-inbox-meta-label); font-size: 11.5px; }
338
+ .bb-inbox-card .bb-inbox-fact dd { font-weight: 500; }
339
+ .bb-inbox-card .bb-inbox-fact[data-fact-label="対象"] dd { padding: 1px 7px; border-radius: 6px; font-size: 11px; background: var(--bb-inbox-context-surface); color: var(--bb-color-accent); }
340
+ .bb-inbox-card .bb-ws-button.is-primary { box-shadow: var(--bb-inbox-action-shadow); }
341
+ .bb-inbox-card .bb-ws-button.is-danger { background: var(--bb-color-panel); color: var(--bb-inbox-urgent-ink); border-color: var(--bb-inbox-urgent-border); }
342
+ .bb-inbox.is-cards .bb-inbox-tabs { gap: 4px; }
343
+ .bb-inbox.is-cards .bb-inbox-tab { gap: 8px; height: 43px; min-height: 43px; padding: 10px 16px; font-size: 14px; font-weight: 500; }
344
+ .bb-inbox.is-cards .bb-inbox-tab.is-selected { font-weight: 600; color: var(--bb-color-accent); }
345
+ .bb-inbox.is-cards .bb-inbox-count { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 6px; border-radius: var(--bb-radius-pill); line-height: 18px; font-size: 11px; font-weight: 600; background: var(--bb-color-border); }
346
+ .bb-inbox.is-cards .bb-inbox-tab.is-selected .bb-inbox-count { background: var(--bb-color-mint); color: var(--bb-color-accent); }
347
+ .bb-inbox-card-filters { gap: 6px; padding-bottom: 6px; }
348
+ .bb-inbox-card-filters .bb-ws-button { gap: 0; min-height: 28px; height: 28px; padding: 0 10px; font-weight: 500; color: var(--bb-color-muted); }
349
+ .bb-inbox-card-filters .bb-ws-button[aria-pressed="true"] { color: var(--bb-color-action-text); }
350
+
351
+ /* The approved inline preview shares its container with the summary. */
352
+ .bb-inbox-card-detail .bb-inbox-facts { display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: 8px 12px; margin-bottom: 14px; }
353
+ .bb-inbox-card-detail .bb-inbox-fact { display: contents; }
354
+ .bb-inbox-card-detail .bb-inbox-fact dt { color: var(--bb-color-muted); font-size: 12px; }
355
+ .bb-inbox-card-detail .bb-inbox-fact dd { font-size: 12.5px; }
356
+ .bb-inbox-card-detail .bb-inbox-fact[data-fact-label="対象"] dd { padding: 0; border-radius: 0; background: transparent; color: var(--bb-color-ink); font-size: 12.5px; }
357
+ .bb-inbox-card-metadata { font-size: 12px; line-height: 1.5; }
358
+ .bb-inbox-card-metadata > .bb-inbox-meta { display: contents; }
359
+ .bb-inbox-card[data-kind="memory_candidates"] .bb-inbox-card-summary .is-primary { background: var(--bb-color-mint); border-color: var(--bb-color-mint); color: var(--bb-color-accent); font-weight: 600; box-shadow: none; }
360
+ .bb-inbox.is-cards .bb-inbox-tabs { min-height: 43px; margin-bottom: -1px; box-shadow: none; }
361
+ .bb-inbox.is-cards .bb-inbox-tabs::after { background: var(--bb-color-accent); height: 2px; }
362
+ .bb-inbox.is-cards .bb-inbox-tab:hover { color: var(--bb-color-accent); background: var(--bb-inbox-tab-hover); }
363
+ .bb-inbox.is-cards .bb-inbox-tab[aria-selected="true"] { color: var(--bb-color-accent); }
364
+ .bb-inbox.is-cards .bb-inbox-count { color: var(--bb-color-ink); }
365
+ @media (min-width: 1251px) {
366
+ .bb-inbox.is-cards .bb-inbox-card-toolbar { flex-wrap: nowrap; }
367
+ }
368
+ @media (max-width: 768px) {
369
+ .bb-inbox-card { padding-inline: 14px; }
370
+ .bb-inbox.is-cards .bb-inbox-tabs { gap: 0; flex-wrap: wrap; overflow: visible; width: auto; }
371
+ .bb-inbox.is-cards .bb-inbox-tab { padding-inline: 10px; gap: 5px; }
372
+ .bb-inbox.is-cards .bb-inbox-tabs.is-indicator-ready::after { display: none; }
373
+ .bb-inbox.is-cards .bb-inbox-tabs > .bb-inbox-tab[aria-selected="true"] { box-shadow: inset 0 -2px 0 var(--bb-color-accent); }
374
+ }
package/ui/inbox.js CHANGED
@@ -34,6 +34,7 @@ export const INBOX_GROUP_LABELS = Object.freeze({
34
34
  const GROUPS = Object.keys(INBOX_GROUP_LABELS);
35
35
  const TABS = ['waiting', 'notices'];
36
36
  const VIEWS = ['waiting', 'later', 'cleared'];
37
+ let inboxInstance = 0;
37
38
 
38
39
  /** The three sections of the 今日決めること layout, in order. */
39
40
  export const INBOX_TODAY_SECTIONS = Object.freeze([
@@ -309,7 +310,9 @@ export function createInboxUI({
309
310
  if (!doc || typeof doc.createElement !== 'function') throw new Error('document_unavailable');
310
311
  const crumbs = Array.isArray(page?.crumbs) ? page.crumbs : ['受信箱'];
311
312
  const readNow = () => (typeof now === 'function' ? now() : now);
312
- const layout = layoutOption === 'today' ? 'today' : 'tabs';
313
+ const layout = ['today', 'cards'].includes(layoutOption) ? layoutOption : 'tabs';
314
+ const cards = layout === 'cards';
315
+ const instanceId = `bb-inbox-${++inboxInstance}`;
313
316
  const undoWindowMs = Number.isFinite(undoWindowMsOption) && undoWindowMsOption > 0 ? undoWindowMsOption : 0;
314
317
  const doneShownMs = Number.isFinite(doneShownMsOption) && doneShownMsOption >= 0 ? doneShownMsOption : 1100;
315
318
  const timers = {
@@ -329,6 +332,9 @@ export function createInboxUI({
329
332
  reason: null,
330
333
  dispositions: new Map(),
331
334
  laterOpen: null,
335
+ expanded: null,
336
+ filter: 'all',
337
+ detailOpener: 'opener',
332
338
  notice: null,
333
339
  noticeOwner: null,
334
340
  notices: null,
@@ -350,6 +356,7 @@ export function createInboxUI({
350
356
  const doneTimers = new Set();
351
357
  // The element to focus once the next render is in place (the confirm band's buttons).
352
358
  let focusTarget = null;
359
+ let toolbarObserver = null;
353
360
  // One live region kept across renders, so a changed count or a result is read out once.
354
361
  const announcer = el(doc, 'p', { className: 'bb-inbox-announcer bb-ws-visually-hidden', attrs: { role: 'status', 'aria-live': 'polite' } });
355
362
  let lastAnnouncedCount = null;
@@ -384,10 +391,11 @@ export function createInboxUI({
384
391
  if (!state.result) return { count: null, unreadable: [] };
385
392
  const current = readNow();
386
393
  const base = countInboxWaiting({ ...state.result, dispositions: [...state.dispositions.values()] }, current);
394
+ if (cards && base.count !== null) base.count = cardItems().filter(item => !activeDisposition(item, state.dispositions, current)).reduce((sum, item) => sum + unitsOf(item), 0);
387
395
  // Rows waiting to be sent, sent, or showing their result are not waiting any more.
388
396
  const gone = new Set([...state.pending.keys(), ...state.sent, ...state.done.keys()]);
389
397
  if (gone.size === 0 || base.count === null) return base;
390
- const rows = new Map(readableItems(state.result).map((item) => [item.id, item]));
398
+ const rows = new Map((cards ? cardItems() : readableItems(state.result)).map((item) => [item.id, item]));
391
399
  let count = base.count;
392
400
  for (const id of gone) {
393
401
  const row = rows.get(id);
@@ -606,7 +614,7 @@ export function createInboxUI({
606
614
  band.append(el(doc, 'p', { className: 'bb-inbox-confirm-text', text: textOf(action.confirm) }));
607
615
  const buttons = el(doc, 'div', { className: 'bb-inbox-row-actions' });
608
616
  const send = workspaceButton(doc, {
609
- text: action.label,
617
+ text: cards ? cardActionLabel(item, action) : action.label,
610
618
  variant: action.tone === 'danger' ? 'danger' : 'primary',
611
619
  onClick: () => {
612
620
  state.confirming = null;
@@ -645,6 +653,214 @@ export function createInboxUI({
645
653
  }
646
654
  }
647
655
 
656
+ function cardActionLabel(item, action) {
657
+ if (action.id === 'deny') return '却下';
658
+ if (action.id === 'publish-suggested') return '公開';
659
+ if (action.id === 'open') return item.group === 'approve' ? '申請へ' : item.kind === 'meeting_triage' ? '振り分けへ' : '本体へ';
660
+ return action.label;
661
+ }
662
+
663
+ function cardItems() {
664
+ const readable = new Set((state.result?.sources ?? []).filter(source => source.status === 'ok').map(source => source.kind));
665
+ return (state.result?.items ?? []).filter(item => readable.has(item.kind));
666
+ }
667
+
668
+ function cardSourceProblem(source) {
669
+ return !['ok', 'not_collected'].includes(source.status);
670
+ }
671
+
672
+ function cardActions(item) {
673
+ return typeof port.runAction === 'function'
674
+ ? (Array.isArray(item.actions) ? item.actions : []).filter(action => textOf(action?.id) && textOf(action?.label))
675
+ : [];
676
+ }
677
+
678
+ function selectCard(item, action = null, opener = 'opener') {
679
+ if (state.running.has(item.id)) return;
680
+ state.expanded = state.expanded === item.id && !action ? null : item.id;
681
+ state.detailOpener = opener;
682
+ state.confirming = action && textOf(action.confirm)
683
+ ? { itemId: item.id, actionId: action.id, revision: item.revision ?? null }
684
+ : null;
685
+ state.focus = { itemId: item.id, target: !state.expanded ? opener : action && textOf(action.confirm) ? 'confirm' : 'detail' };
686
+ render();
687
+ }
688
+
689
+ function renderCardTabs(shown) {
690
+ const bar = el(doc, 'div', { className: 'bb-inbox-card-toolbar' });
691
+ const tablist = el(doc, 'div', { className: 'bb-inbox-tabs', attrs: { role: 'tablist', 'aria-label': '受信箱' } });
692
+ workspaceTabStrip(tablist, { memoryKey: `${instanceId}-tabs` });
693
+ const definitions = [
694
+ ['waiting', '対応待ち', { tab: 'waiting', view: 'waiting' }],
695
+ ['notices', 'お知らせ', { tab: 'notices', view: 'waiting' }],
696
+ ['later', '保留', { tab: 'waiting', view: 'later' }],
697
+ ['cleared', '対応済', { tab: 'waiting', view: 'cleared' }],
698
+ ];
699
+ const selectedId = state.route.tab === 'notices' ? 'notices' : state.route.view;
700
+ for (const [id, label, route] of definitions) {
701
+ const tab = el(doc, 'button', { className: `bb-inbox-tab${id === selectedId ? ' is-selected' : ''}`, text: label,
702
+ attrs: { id: `${instanceId}-tab-${id}`, type: 'button', role: 'tab', 'aria-selected': String(id === selectedId), 'aria-controls': `${instanceId}-panel` } });
703
+ const unreadable = state.result?.sources?.some(cardSourceProblem);
704
+ const count = id === 'notices' ? state.notices?.phase === 'ok' ? state.notices.items.length : null
705
+ : shown ? shown[id].filter(item => !state.done.has(item.id)).reduce((sum, item) => sum + unitsOf(item), 0) : null;
706
+ if (count !== null) tab.append(el(doc, 'span', { className: 'bb-inbox-count bb-ws-tab-count', text: `${count}${id !== 'notices' && unreadable ? '+' : ''}` }));
707
+ tab.addEventListener('click', () => { state.filter = 'all'; state.expanded = null; state.focus = { target: 'tab', id }; go(route); });
708
+ if (state.focus?.target === 'tab' && state.focus.id === id) focusTarget = tab;
709
+ tablist.append(tab);
710
+ }
711
+ bar.append(tablist);
712
+ if (state.route.tab !== 'notices') {
713
+ const filters = el(doc, 'div', { className: 'bb-inbox-card-filters', attrs: { role: 'group', 'aria-label': '種類で絞り込む' } });
714
+ for (const [id, label] of [['all', 'すべて'], ['approve', '承認'], ['answer', '会議振り分け'], ['triage', '記憶・取り込み'], ['task', 'タスク']]) {
715
+ const button = workspaceButton(doc, { text: label, variant: 'quiet', attrs: { 'aria-pressed': String(state.filter === id), 'aria-label': label },
716
+ onClick: () => { state.filter = id; state.expanded = null; state.focus = { target: 'filter', filter: id }; render(); } });
717
+ if (state.focus?.target === 'filter' && state.focus.filter === id) focusTarget = button;
718
+ if (id !== 'all' && shown) {
719
+ const count = shown[state.route.view].filter(item => !state.done.has(item.id) && matchesCardFilter(item, id)).length;
720
+ const incomplete = (state.result?.sources ?? []).some(source => matchesCardFilter(source, id) && cardSourceProblem(source));
721
+ button.setAttribute('aria-label', `${label}、${count}件${incomplete ? '以上、一部取得できません' : ''}`);
722
+ button.append(el(doc, 'span', { className: 'bb-inbox-card-filter-count', text: ` (${count}${incomplete ? '+' : ''})`, attrs: { 'aria-hidden': 'true' } }));
723
+ }
724
+ filters.append(button);
725
+ }
726
+ bar.append(filters);
727
+ }
728
+ return bar;
729
+ }
730
+
731
+ function renderCard(item, view) {
732
+ const running = state.running.has(item.id);
733
+ const done = state.done.get(item.id);
734
+ const expanded = state.expanded === item.id;
735
+ const actions = cardActions(item);
736
+ const card = el(doc, 'article', { className: `bb-inbox-card${expanded ? ' is-expanded' : ''}`, attrs: { role: 'listitem', 'data-inbox-item': item.id, 'data-group': item.group, 'data-kind': item.kind, 'aria-busy': String(running) } });
737
+ const summary = el(doc, 'div', { className: 'bb-inbox-card-summary' });
738
+ const main = el(doc, 'div', { className: 'bb-inbox-row-main' });
739
+ const due = inboxDueLabel(item.dueAt, readNow());
740
+ const category = item.kind === 'meeting_triage' ? item.group === 'answer' ? 'プロジェクト振り分け' : actions.some(action => action.id === 'publish-suggested') ? '会議の一括公開' : '会議の振り分け'
741
+ : ({ agent_connection_requests: '利用申請', memory_candidates: 'ナレッジ蓄積', assigned_task: '個別タスク', waiting_task: '判断待ち' })[item.kind]
742
+ ?? INBOX_GROUP_LABELS[item.group] ?? 'その他';
743
+ const urgent = due && ['expired', 'soon'].includes(due.state);
744
+ main.append(el(doc, 'span', { className: `bb-inbox-card-badge${urgent ? ' is-urgent' : ''}`, text: urgent ? `${category}・${due.state === 'expired' ? '期限切れ' : '期限迫る'}` : category }));
745
+ if (item.blocking) main.append(el(doc, 'span', { className: 'bb-inbox-blocking', text: '対応が必要' }));
746
+ const opener = workspaceButton(doc, { text: item.title, variant: 'quiet', attrs: { class: 'bb-inbox-card-title', 'aria-expanded': String(expanded), 'aria-controls': `${instanceId}-detail-${item.id}` }, onClick: () => selectCard(item) });
747
+ if (state.focus?.itemId === item.id && state.focus.target === 'opener') focusTarget = opener;
748
+ const cardHeading = el(doc, 'h3', { className: 'bb-inbox-card-heading' });
749
+ cardHeading.append(opener); main.append(cardHeading);
750
+ const facts = factsOf(item);
751
+ const metadata = el(doc, 'div', { className: 'bb-inbox-card-metadata' });
752
+ if (facts.length) metadata.append(renderFacts(facts));
753
+ const meta = el(doc, 'div', { className: 'bb-inbox-meta' });
754
+ if (due) meta.append(el(doc, 'span', { className: `bb-inbox-due${due.state === 'later' ? '' : ` is-${due.state}`}`, text: due.text }));
755
+ const received = relativeTime(item.receivedAt, readNow());
756
+ if (received) meta.append(el(doc, 'span', { text: received }));
757
+ const disposition = state.dispositions.get(item.id);
758
+ if (view === 'later' && disposition?.until) meta.append(el(doc, 'span', { text: `${formatShort(disposition.until)}まで保留` }));
759
+ if (meta.children.length) metadata.append(meta);
760
+ if (metadata.children.length) main.append(metadata);
761
+ summary.append(main);
762
+ const controls = el(doc, 'div', { className: 'bb-inbox-row-actions' });
763
+ if (done) controls.append(el(doc, 'span', { className: 'bb-inbox-done', text: done }));
764
+ else {
765
+ const primaryButton = workspaceButton(doc, { text: '確認', variant: 'primary', disabled: running,
766
+ attrs: { 'aria-expanded': String(expanded), 'aria-controls': `${instanceId}-detail-${item.id}` }, onClick: () => selectCard(item, null, 'row-primary') });
767
+ if (state.focus?.itemId === item.id && state.focus.target === 'row-primary') focusTarget = primaryButton;
768
+ controls.append(primaryButton);
769
+ if (view === 'waiting') {
770
+ const deny = actions.find(action => action.id === 'deny');
771
+ if (deny) {
772
+ const denyButton = workspaceButton(doc, { text: '却下', variant: 'danger', disabled: running, onClick: () => selectCard(item, deny, 'row-deny') });
773
+ if (state.focus?.itemId === item.id && state.focus.target === 'row-deny') focusTarget = denyButton;
774
+ controls.append(denyButton);
775
+ }
776
+ const laterButton = workspaceButton(doc, { text: '保留', variant: 'quiet', disabled: running, attrs: { 'aria-expanded': String(state.laterOpen === item.id) }, onClick: () => { state.laterOpen = state.laterOpen === item.id ? null : item.id; state.focus = { itemId: item.id, target: 'row-later' }; render(); } });
777
+ if (state.focus?.itemId === item.id && state.focus.target === 'row-later') focusTarget = laterButton;
778
+ controls.append(laterButton,
779
+ workspaceButton(doc, { text: '対応済', variant: 'quiet', disabled: running, onClick: () => void dispose(item, { state: 'cleared', revision: item.revision ?? null }, '対応済にできませんでした') }));
780
+ } else controls.append(workspaceButton(doc, { text: '再開', variant: 'quiet', onClick: () => void dispose(item, { state: 'open' }, '対応待ちに戻せませんでした') }));
781
+ }
782
+ summary.append(controls); card.append(summary);
783
+ if (state.laterOpen === item.id && !running) card.append(renderLaterMenu(item));
784
+ const detail = el(doc, 'section', { className: 'bb-inbox-card-detail', attrs: { id: `${instanceId}-detail-${item.id}`, 'aria-label': '内容の確認', hidden: !expanded } });
785
+ if (expanded) {
786
+ const closeDetail = () => { state.expanded = null; state.confirming = null; state.focus = { itemId: item.id, target: state.detailOpener }; render(); };
787
+ detail.addEventListener('keydown', event => { if (event.key === 'Escape') { event.preventDefault(); closeDetail(); } });
788
+ const head = el(doc, 'div', { className: 'bb-inbox-card-detail-head' });
789
+ const heading = el(doc, 'h4', { text: '内容の確認', attrs: { tabindex: '-1' } });
790
+ if (state.focus?.itemId === item.id && state.focus.target === 'detail') focusTarget = heading;
791
+ head.append(heading, workspaceButton(doc, { text: '閉じる', variant: 'quiet', onClick: closeDetail })); detail.append(head);
792
+ if (textOf(item.detail)) detail.append(el(doc, 'p', { text: item.detail }));
793
+ if (facts.length) detail.append(renderFacts(facts));
794
+ const footer = el(doc, 'div', { className: 'bb-inbox-card-detail-footer' });
795
+ const href = textOf(item.href);
796
+ if (href) {
797
+ const source = el(doc, 'a', { className: 'bb-inbox-source-link', text: '本体を開く', attrs: { href } });
798
+ source.addEventListener('click', event => openItem(item, event)); footer.append(source);
799
+ }
800
+ const confirming = confirmingAction(item, actions);
801
+ if (confirming) footer.append(renderConfirm(item, confirming));
802
+ else if (view === 'waiting' && !done) {
803
+ const buttons = el(doc, 'div', { className: 'bb-inbox-row-actions' });
804
+ for (const action of actions) {
805
+ const button = workspaceButton(doc, { text: cardActionLabel(item, action), disabled: running, variant: action.tone === 'danger' ? 'danger' : 'primary', onClick: () => pressFromRow(item, action) });
806
+ if (state.focus?.itemId === item.id && state.focus.target === 'action' && state.focus.actionId === action.id) focusTarget = button;
807
+ buttons.append(button);
808
+ }
809
+ footer.append(buttons);
810
+ }
811
+ detail.append(footer);
812
+ }
813
+ card.append(detail);
814
+ return card;
815
+ }
816
+
817
+ function matchesCardFilter(item, filter = state.filter) {
818
+ if (filter === 'all') return true;
819
+ if (filter === 'approve') return item.group === 'approve';
820
+ if (filter === 'answer') return item.kind === 'meeting_triage';
821
+ if (filter === 'triage') return item.kind === 'memory_candidates';
822
+ return ['assigned_task', 'waiting_task'].includes(item.kind);
823
+ }
824
+
825
+ function renderCards(shown) {
826
+ const panel = el(doc, 'div', { className: 'bb-inbox-card-panel', attrs: { id: `${instanceId}-panel`, role: 'tabpanel', 'aria-labelledby': `${instanceId}-tab-${state.route.tab === 'notices' ? 'notices' : state.route.view}` } });
827
+ if (state.route.tab === 'notices') { panel.append(renderNotices()); return panel; }
828
+ const which = state.route.view;
829
+ let any = false;
830
+ const groups = ['approve', ...GROUPS.filter(group => group !== 'approve')];
831
+ for (const group of groups) {
832
+ const rows = sortInboxItems(shown[which].filter(item => item.group === group && matchesCardFilter(item)));
833
+ const problems = (state.result.sources ?? []).filter(source => source.group === group && matchesCardFilter(source) && cardSourceProblem(source));
834
+ if (!rows.length && !problems.length) continue;
835
+ any = true;
836
+ const section = el(doc, 'section', { className: 'bb-inbox-group', attrs: { 'aria-label': INBOX_GROUP_LABELS[group] } });
837
+ const heading = el(doc, 'div', { className: 'bb-inbox-card-group-head' });
838
+ heading.append(el(doc, 'h2', { className: 'bb-inbox-group-title', text: INBOX_GROUP_LABELS[group] }), el(doc, 'span', { className: 'bb-inbox-group-count', text: `${rows.length}件` }));
839
+ section.append(heading);
840
+ const list = el(doc, 'div', { className: 'bb-inbox-list', attrs: { role: 'list' } });
841
+ rows.forEach(item => list.append(renderCard(item, which))); section.append(list);
842
+ problems.forEach(source => section.append(sourceLine(source))); panel.append(section);
843
+ }
844
+ if (state.filter === 'all') {
845
+ const unknown = shown[which].filter(item => !GROUPS.includes(item.group));
846
+ const problems = (state.result.sources ?? []).filter(source => !GROUPS.includes(source.group) && cardSourceProblem(source));
847
+ if (unknown.length || problems.length) {
848
+ any = true;
849
+ const section = el(doc, 'section', { className: 'bb-inbox-group', attrs: { 'aria-label': 'その他' } });
850
+ section.append(el(doc, 'h2', { className: 'bb-inbox-group-title', text: 'その他' }));
851
+ const list = el(doc, 'div', { className: 'bb-inbox-list', attrs: { role: 'list' } });
852
+ unknown.forEach(item => list.append(renderCard(item, which))); section.append(list);
853
+ problems.forEach(source => section.append(sourceLine(source))); panel.append(section);
854
+ }
855
+ }
856
+ if (!any) panel.append(el(doc, 'p', { className: 'bb-inbox-empty', text: state.filter !== 'all' ? '該当する項目はありません。' : which === 'later' ? '保留した項目はありません。' : which === 'cleared' ? '対応済の項目はありません。' : '待っているものはありません。' }));
857
+ if (which === 'waiting') {
858
+ const uncollected = (state.result.uncollected ?? []).filter(textOf);
859
+ if (uncollected.length) panel.append(el(doc, 'p', { className: 'bb-inbox-uncollected', text: `まだ集めていない種類があります(${uncollected.join('・')})。件数には入っていません。` }));
860
+ }
861
+ return panel;
862
+ }
863
+
648
864
  function renderTabs(waitingCount) {
649
865
  const bar = el(doc, 'div', { className: 'bb-inbox-tabs', attrs: { role: 'tablist', 'aria-label': '受信箱' } });
650
866
  workspaceTabStrip(bar, { memoryKey: 'inbox-tabs' });
@@ -679,7 +895,7 @@ export function createInboxUI({
679
895
  function renderFacts(facts) {
680
896
  const list = el(doc, 'dl', { className: 'bb-inbox-facts' });
681
897
  for (const fact of facts) {
682
- const pair = el(doc, 'div', { className: 'bb-inbox-fact' });
898
+ const pair = el(doc, 'div', { className: 'bb-inbox-fact', attrs: { 'data-fact-label': fact.label } });
683
899
  pair.append(el(doc, 'dt', { text: fact.label }), el(doc, 'dd', { text: fact.value }));
684
900
  list.append(pair);
685
901
  }
@@ -788,7 +1004,7 @@ export function createInboxUI({
788
1004
 
789
1005
  function partition(now) {
790
1006
  const shown = { waiting: [], later: [], cleared: [] };
791
- for (const item of readableItems(state.result)) {
1007
+ for (const item of cards ? cardItems() : readableItems(state.result)) {
792
1008
  if (state.pending.has(item.id) || state.sent.has(item.id)) continue;
793
1009
  const disposition = activeDisposition(item, state.dispositions, now);
794
1010
  shown[disposition ? disposition.state : 'waiting'].push(item);
@@ -915,11 +1131,12 @@ export function createInboxUI({
915
1131
  const waitingCount = shown ? shown.waiting.filter(stillWaiting).reduce((sum, item) => sum + unitsOf(item), 0) : null;
916
1132
  const isToday = layout === 'today';
917
1133
  const view = el(doc, 'div', {
918
- className: `bb-inbox${isToday ? ' is-today' : ''}`,
1134
+ className: `bb-inbox${isToday ? ' is-today' : ''}${cards ? ' is-cards' : ''}`,
919
1135
  attrs: { 'data-contract-version': INBOX_UI_CONTRACT_VERSION },
920
1136
  });
921
- view.append(workspacePageHeader(doc, { crumbs, title: '受信箱', source: page?.source ?? undefined }));
922
- if (!isToday) view.append(renderTabs(waitingCount));
1137
+ if (!cards) view.append(workspacePageHeader(doc, { crumbs, title: '受信箱', source: page?.source ?? undefined }));
1138
+ if (cards) view.append(renderCardTabs(shown));
1139
+ else if (!isToday) view.append(renderTabs(waitingCount));
923
1140
  if (isToday && shown) {
924
1141
  const decideGroups = INBOX_TODAY_SECTIONS[0].groups;
925
1142
  const decideCount = shown.waiting
@@ -944,7 +1161,9 @@ export function createInboxUI({
944
1161
  const undoBand = renderUndoBand();
945
1162
  if (undoBand) view.append(undoBand);
946
1163
  if (state.notice) view.append(workspaceNotice(doc, { label: 'できませんでした', text: state.notice, tone: 'warning', role: 'alert' }));
947
- if (!isToday && state.route.tab === 'notices') {
1164
+ if (cards && shown) {
1165
+ view.append(renderCards(shown));
1166
+ } else if (!isToday && state.route.tab === 'notices') {
948
1167
  view.append(renderNotices());
949
1168
  } else if (state.phase === 'error' && !shown) {
950
1169
  view.append(workspaceErrorCard(doc, { title: '受信箱を読めませんでした', message: `理由: ${reasonText(state.reason)}。0件ではありません。`, onRetry: () => void load(), open: true }));
@@ -952,9 +1171,19 @@ export function createInboxUI({
952
1171
  if (isToday) view.append(state.route.view === 'waiting' ? renderTodayWaiting(shown) : renderSet(shown, state.route.view));
953
1172
  else view.append(state.route.view === 'waiting' ? renderWaiting(shown) : renderSet(shown, state.route.view));
954
1173
  }
1174
+ toolbarObserver?.disconnect();
955
1175
  root.replaceChildren(view, announcer);
1176
+ if (cards) {
1177
+ const toolbar = view.querySelector?.('.bb-inbox-card-toolbar');
1178
+ const measure = () => {
1179
+ if (toolbar && root.style) root.style.setProperty('--bb-inbox-toolbar-height', `${toolbar.getBoundingClientRect().height}px`);
1180
+ };
1181
+ measure();
1182
+ if (toolbar && typeof globalThis.ResizeObserver === 'function') { toolbarObserver = new globalThis.ResizeObserver(measure); toolbarObserver.observe(toolbar); }
1183
+ }
956
1184
  if (state.focus) {
957
1185
  focusTarget?.focus?.({ preventScroll: true });
1186
+ if (cards) focusTarget?.scrollIntoView?.({ block: 'nearest' });
958
1187
  state.focus = null;
959
1188
  }
960
1189
  }
@@ -967,6 +1196,7 @@ export function createInboxUI({
967
1196
  },
968
1197
  destroy() {
969
1198
  state.destroyed = true;
1199
+ toolbarObserver?.disconnect();
970
1200
  generation += 1;
971
1201
  for (const timerId of doneTimers) timers.clear(timerId);
972
1202
  doneTimers.clear();
@@ -674,9 +674,9 @@
674
674
  @media (prefers-reduced-motion:reduce) { .bb-ws-combobox-popup { animation: none; } }
675
675
 
676
676
  /* Shared page chrome and on-demand inspectors. Page actions remain in the body. */
677
- .bb-ws-topbar { position: sticky; top: 0; z-index: 18; display: flex; align-items: center; height: 44px; min-height: 44px; flex: 0 0 44px; box-sizing: border-box; padding: 0 16px; background: var(--bb-color-panel); border-bottom: 1px solid var(--bb-color-border); }
677
+ .bb-ws-topbar { position: sticky; top: 0; z-index: 18; display: flex; align-items: center; min-height: var(--bb-page-header-height); flex: 0 0 auto; box-sizing: border-box; padding: var(--bb-page-header-padding-top) var(--bb-space-6) var(--bb-page-header-padding-bottom); background: var(--bb-color-canvas); border: 0; }
678
678
  .bb-ws-topbar[hidden] { display: none; }
679
- .bb-ws-topbar h1 { margin: 0; font: 500 14px/20px var(--bb-font-sans); color: var(--bb-color-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
679
+ .bb-ws-topbar h1 { margin: 0; font: var(--bb-page-title-font-weight) var(--bb-page-title-font-size)/var(--bb-page-title-line-height) var(--bb-font-sans); color: var(--bb-color-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
680
680
  .bb-ws-visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
681
681
  .bb-ws-detail-drawer { padding: 0; }
682
682
  .bb-ws-detail-drawer:not([open]) { display: none; }