@unson/brainbase-mcp 0.50.2 → 0.50.3

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.3",
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": "824896b5d5764f28f8dba870a683de9b2f78938a"
648
648
  }
@@ -133,7 +133,13 @@
133
133
  --bb-search-band-chevron-width: 10px;
134
134
  --bb-search-band-chevron-height: 6px;
135
135
  --bb-search-band-chevron-stroke: 1.2;
136
- --bb-search-band-header-height: 44px;
136
+ --bb-page-title-font-size: 20px;
137
+ --bb-page-title-line-height: 28px;
138
+ --bb-page-title-font-weight: 600;
139
+ --bb-page-header-padding-top: var(--bb-space-3);
140
+ --bb-page-header-padding-bottom: var(--bb-space-4);
141
+ --bb-page-header-height: calc(var(--bb-page-title-line-height) + var(--bb-page-header-padding-top) + var(--bb-page-header-padding-bottom));
142
+ --bb-search-band-header-height: var(--bb-page-header-height);
137
143
  --bb-search-band-scope-padding: 13px;
138
144
  --bb-search-band-scope-viewport-reserve: 192px;
139
145
  --bb-search-band-scope-popup-width: 260px;
package/ui/inbox.css CHANGED
@@ -273,3 +273,52 @@ 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: var(--bb-space-5); 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: center; justify-content: space-between; margin-bottom: var(--bb-space-3); }
285
+ .bb-inbox.is-cards .bb-inbox-group-title { margin: 0; font-size: 15px; color: var(--bb-color-ink); }
286
+ .bb-inbox-group-count { font-size: 12px; color: var(--bb-color-muted); }
287
+ .bb-inbox.is-cards .bb-inbox-list { display: grid; gap: var(--bb-space-3); }
288
+ .bb-inbox-card { min-width: 0; padding: var(--bb-space-4); background: var(--bb-color-panel); border: 1px solid var(--bb-color-border); border-radius: var(--bb-radius-md); }
289
+ .bb-inbox-card-summary { display: flex; align-items: center; justify-content: space-between; gap: var(--bb-space-4); }
290
+ .bb-inbox-card .bb-inbox-row-main { flex: 1; min-width: 0; }
291
+ .bb-inbox-card-heading { margin: 0 0 var(--bb-space-2); font-size: 15px; }
292
+ .bb-inbox-card-title { margin: 0; padding: 0; border: 0; background: transparent; color: var(--bb-color-ink); font: inherit; font-weight: var(--bb-font-weight-medium); text-align: left; cursor: pointer; overflow-wrap: anywhere; }
293
+ .bb-inbox-card :is(.bb-inbox-facts, .bb-inbox-meta) { margin-top: var(--bb-space-2); }
294
+ .bb-inbox-card .bb-inbox-row-actions { flex-wrap: wrap; justify-content: flex-end; flex-shrink: 0; gap: var(--bb-space-2); }
295
+ .bb-inbox-card .bb-ws-button { min-height: var(--bb-control-compact-height); font-size: 12px; white-space: nowrap; }
296
+ .bb-inbox-card .bb-inbox-card-detail { margin-top: var(--bb-space-4); padding-top: var(--bb-space-4); border-top: 1px solid var(--bb-color-border); }
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: var(--bb-space-3); }
299
+ .bb-inbox-card-detail-head h4 { margin: 0; font-size: 13px; font-weight: var(--bb-font-weight-medium); }
300
+ .bb-inbox-card-detail p { font-size: 13px; overflow-wrap: anywhere; }
301
+ .bb-inbox-card-detail-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--bb-space-3); margin-top: var(--bb-space-4); }
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: 760px) {
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; }
312
+ .bb-inbox-card .bb-inbox-row-actions { justify-content: flex-start; }
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: var(--bb-space-2); }
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: var(--bb-space-3); }
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)); }
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,201 @@ 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) },
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
+ filters.append(button);
719
+ }
720
+ bar.append(filters);
721
+ }
722
+ return bar;
723
+ }
724
+
725
+ function renderCard(item, view) {
726
+ const running = state.running.has(item.id);
727
+ const done = state.done.get(item.id);
728
+ const expanded = state.expanded === item.id;
729
+ const actions = cardActions(item);
730
+ const card = el(doc, 'article', { className: `bb-inbox-card${expanded ? ' is-expanded' : ''}`, attrs: { role: 'listitem', 'data-inbox-item': item.id, 'aria-busy': String(running) } });
731
+ const summary = el(doc, 'div', { className: 'bb-inbox-card-summary' });
732
+ const main = el(doc, 'div', { className: 'bb-inbox-row-main' });
733
+ if (item.blocking) main.append(el(doc, 'span', { className: 'bb-inbox-blocking', text: '対応が必要' }));
734
+ 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) });
735
+ if (state.focus?.itemId === item.id && state.focus.target === 'opener') focusTarget = opener;
736
+ const cardHeading = el(doc, 'h3', { className: 'bb-inbox-card-heading' });
737
+ cardHeading.append(opener); main.append(cardHeading);
738
+ const facts = factsOf(item);
739
+ if (facts.length) main.append(renderFacts(facts));
740
+ const meta = el(doc, 'div', { className: 'bb-inbox-meta' });
741
+ const due = inboxDueLabel(item.dueAt, readNow());
742
+ if (due) meta.append(el(doc, 'span', { className: `bb-inbox-due${due.state === 'later' ? '' : ` is-${due.state}`}`, text: due.text }));
743
+ const received = relativeTime(item.receivedAt, readNow());
744
+ if (received) meta.append(el(doc, 'span', { text: received }));
745
+ const disposition = state.dispositions.get(item.id);
746
+ if (view === 'later' && disposition?.until) meta.append(el(doc, 'span', { text: `${formatShort(disposition.until)}まで保留` }));
747
+ if (meta.children.length) main.append(meta);
748
+ summary.append(main);
749
+ const controls = el(doc, 'div', { className: 'bb-inbox-row-actions' });
750
+ if (done) controls.append(el(doc, 'span', { className: 'bb-inbox-done', text: done }));
751
+ else {
752
+ const primaryButton = workspaceButton(doc, { text: '確認', variant: 'primary', disabled: running,
753
+ attrs: { 'aria-expanded': String(expanded), 'aria-controls': `${instanceId}-detail-${item.id}` }, onClick: () => selectCard(item, null, 'row-primary') });
754
+ if (state.focus?.itemId === item.id && state.focus.target === 'row-primary') focusTarget = primaryButton;
755
+ controls.append(primaryButton);
756
+ if (view === 'waiting') {
757
+ const deny = actions.find(action => action.id === 'deny');
758
+ if (deny) {
759
+ const denyButton = workspaceButton(doc, { text: '却下', variant: 'danger', disabled: running, onClick: () => selectCard(item, deny, 'row-deny') });
760
+ if (state.focus?.itemId === item.id && state.focus.target === 'row-deny') focusTarget = denyButton;
761
+ controls.append(denyButton);
762
+ }
763
+ 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(); } });
764
+ if (state.focus?.itemId === item.id && state.focus.target === 'row-later') focusTarget = laterButton;
765
+ controls.append(laterButton,
766
+ workspaceButton(doc, { text: '対応済', variant: 'quiet', disabled: running, onClick: () => void dispose(item, { state: 'cleared', revision: item.revision ?? null }, '対応済にできませんでした') }));
767
+ } else controls.append(workspaceButton(doc, { text: '再開', variant: 'quiet', onClick: () => void dispose(item, { state: 'open' }, '対応待ちに戻せませんでした') }));
768
+ }
769
+ summary.append(controls); card.append(summary);
770
+ if (state.laterOpen === item.id && !running) card.append(renderLaterMenu(item));
771
+ const detail = el(doc, 'section', { className: 'bb-inbox-card-detail', attrs: { id: `${instanceId}-detail-${item.id}`, 'aria-label': '内容の確認', hidden: !expanded } });
772
+ if (expanded) {
773
+ const closeDetail = () => { state.expanded = null; state.confirming = null; state.focus = { itemId: item.id, target: state.detailOpener }; render(); };
774
+ detail.addEventListener('keydown', event => { if (event.key === 'Escape') { event.preventDefault(); closeDetail(); } });
775
+ const head = el(doc, 'div', { className: 'bb-inbox-card-detail-head' });
776
+ const heading = el(doc, 'h4', { text: '内容の確認', attrs: { tabindex: '-1' } });
777
+ if (state.focus?.itemId === item.id && state.focus.target === 'detail') focusTarget = heading;
778
+ head.append(heading, workspaceButton(doc, { text: '閉じる', variant: 'quiet', onClick: closeDetail })); detail.append(head);
779
+ if (textOf(item.detail)) detail.append(el(doc, 'p', { text: item.detail }));
780
+ if (facts.length) detail.append(renderFacts(facts));
781
+ const footer = el(doc, 'div', { className: 'bb-inbox-card-detail-footer' });
782
+ const href = textOf(item.href);
783
+ if (href) {
784
+ const source = el(doc, 'a', { className: 'bb-inbox-source-link', text: '本体を開く', attrs: { href } });
785
+ source.addEventListener('click', event => openItem(item, event)); footer.append(source);
786
+ }
787
+ const confirming = confirmingAction(item, actions);
788
+ if (confirming) footer.append(renderConfirm(item, confirming));
789
+ else if (view === 'waiting' && !done) {
790
+ const buttons = el(doc, 'div', { className: 'bb-inbox-row-actions' });
791
+ for (const action of actions) {
792
+ const button = workspaceButton(doc, { text: cardActionLabel(item, action), disabled: running, variant: action.tone === 'danger' ? 'danger' : 'primary', onClick: () => pressFromRow(item, action) });
793
+ if (state.focus?.itemId === item.id && state.focus.target === 'action' && state.focus.actionId === action.id) focusTarget = button;
794
+ buttons.append(button);
795
+ }
796
+ footer.append(buttons);
797
+ }
798
+ detail.append(footer);
799
+ }
800
+ card.append(detail);
801
+ return card;
802
+ }
803
+
804
+ function matchesCardFilter(item) {
805
+ if (state.filter === 'all') return true;
806
+ if (state.filter === 'approve') return item.group === 'approve';
807
+ if (state.filter === 'answer') return item.kind === 'meeting_triage';
808
+ if (state.filter === 'triage') return item.kind === 'memory_candidates';
809
+ return ['assigned_task', 'waiting_task'].includes(item.kind);
810
+ }
811
+
812
+ function renderCards(shown) {
813
+ 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}` } });
814
+ if (state.route.tab === 'notices') { panel.append(renderNotices()); return panel; }
815
+ const which = state.route.view;
816
+ let any = false;
817
+ const groups = ['approve', ...GROUPS.filter(group => group !== 'approve')];
818
+ for (const group of groups) {
819
+ const rows = sortInboxItems(shown[which].filter(item => item.group === group && matchesCardFilter(item)));
820
+ const problems = (state.result.sources ?? []).filter(source => source.group === group && matchesCardFilter(source) && cardSourceProblem(source));
821
+ if (!rows.length && !problems.length) continue;
822
+ any = true;
823
+ const section = el(doc, 'section', { className: 'bb-inbox-group', attrs: { 'aria-label': INBOX_GROUP_LABELS[group] } });
824
+ const heading = el(doc, 'div', { className: 'bb-inbox-card-group-head' });
825
+ 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}件` }));
826
+ section.append(heading);
827
+ const list = el(doc, 'div', { className: 'bb-inbox-list', attrs: { role: 'list' } });
828
+ rows.forEach(item => list.append(renderCard(item, which))); section.append(list);
829
+ problems.forEach(source => section.append(sourceLine(source))); panel.append(section);
830
+ }
831
+ if (state.filter === 'all') {
832
+ const unknown = shown[which].filter(item => !GROUPS.includes(item.group));
833
+ const problems = (state.result.sources ?? []).filter(source => !GROUPS.includes(source.group) && cardSourceProblem(source));
834
+ if (unknown.length || problems.length) {
835
+ any = true;
836
+ const section = el(doc, 'section', { className: 'bb-inbox-group', attrs: { 'aria-label': 'その他' } });
837
+ section.append(el(doc, 'h2', { className: 'bb-inbox-group-title', text: 'その他' }));
838
+ const list = el(doc, 'div', { className: 'bb-inbox-list', attrs: { role: 'list' } });
839
+ unknown.forEach(item => list.append(renderCard(item, which))); section.append(list);
840
+ problems.forEach(source => section.append(sourceLine(source))); panel.append(section);
841
+ }
842
+ }
843
+ if (!any) panel.append(el(doc, 'p', { className: 'bb-inbox-empty', text: state.filter !== 'all' ? '該当する項目はありません。' : which === 'later' ? '保留した項目はありません。' : which === 'cleared' ? '対応済の項目はありません。' : '待っているものはありません。' }));
844
+ if (which === 'waiting') {
845
+ const uncollected = (state.result.uncollected ?? []).filter(textOf);
846
+ if (uncollected.length) panel.append(el(doc, 'p', { className: 'bb-inbox-uncollected', text: `まだ集めていない種類があります(${uncollected.join('・')})。件数には入っていません。` }));
847
+ }
848
+ return panel;
849
+ }
850
+
648
851
  function renderTabs(waitingCount) {
649
852
  const bar = el(doc, 'div', { className: 'bb-inbox-tabs', attrs: { role: 'tablist', 'aria-label': '受信箱' } });
650
853
  workspaceTabStrip(bar, { memoryKey: 'inbox-tabs' });
@@ -788,7 +991,7 @@ export function createInboxUI({
788
991
 
789
992
  function partition(now) {
790
993
  const shown = { waiting: [], later: [], cleared: [] };
791
- for (const item of readableItems(state.result)) {
994
+ for (const item of cards ? cardItems() : readableItems(state.result)) {
792
995
  if (state.pending.has(item.id) || state.sent.has(item.id)) continue;
793
996
  const disposition = activeDisposition(item, state.dispositions, now);
794
997
  shown[disposition ? disposition.state : 'waiting'].push(item);
@@ -915,11 +1118,12 @@ export function createInboxUI({
915
1118
  const waitingCount = shown ? shown.waiting.filter(stillWaiting).reduce((sum, item) => sum + unitsOf(item), 0) : null;
916
1119
  const isToday = layout === 'today';
917
1120
  const view = el(doc, 'div', {
918
- className: `bb-inbox${isToday ? ' is-today' : ''}`,
1121
+ className: `bb-inbox${isToday ? ' is-today' : ''}${cards ? ' is-cards' : ''}`,
919
1122
  attrs: { 'data-contract-version': INBOX_UI_CONTRACT_VERSION },
920
1123
  });
921
- view.append(workspacePageHeader(doc, { crumbs, title: '受信箱', source: page?.source ?? undefined }));
922
- if (!isToday) view.append(renderTabs(waitingCount));
1124
+ if (!cards) view.append(workspacePageHeader(doc, { crumbs, title: '受信箱', source: page?.source ?? undefined }));
1125
+ if (cards) view.append(renderCardTabs(shown));
1126
+ else if (!isToday) view.append(renderTabs(waitingCount));
923
1127
  if (isToday && shown) {
924
1128
  const decideGroups = INBOX_TODAY_SECTIONS[0].groups;
925
1129
  const decideCount = shown.waiting
@@ -944,7 +1148,9 @@ export function createInboxUI({
944
1148
  const undoBand = renderUndoBand();
945
1149
  if (undoBand) view.append(undoBand);
946
1150
  if (state.notice) view.append(workspaceNotice(doc, { label: 'できませんでした', text: state.notice, tone: 'warning', role: 'alert' }));
947
- if (!isToday && state.route.tab === 'notices') {
1151
+ if (cards && shown) {
1152
+ view.append(renderCards(shown));
1153
+ } else if (!isToday && state.route.tab === 'notices') {
948
1154
  view.append(renderNotices());
949
1155
  } else if (state.phase === 'error' && !shown) {
950
1156
  view.append(workspaceErrorCard(doc, { title: '受信箱を読めませんでした', message: `理由: ${reasonText(state.reason)}。0件ではありません。`, onRetry: () => void load(), open: true }));
@@ -952,9 +1158,19 @@ export function createInboxUI({
952
1158
  if (isToday) view.append(state.route.view === 'waiting' ? renderTodayWaiting(shown) : renderSet(shown, state.route.view));
953
1159
  else view.append(state.route.view === 'waiting' ? renderWaiting(shown) : renderSet(shown, state.route.view));
954
1160
  }
1161
+ toolbarObserver?.disconnect();
955
1162
  root.replaceChildren(view, announcer);
1163
+ if (cards) {
1164
+ const toolbar = view.querySelector?.('.bb-inbox-card-toolbar');
1165
+ const measure = () => {
1166
+ if (toolbar && root.style) root.style.setProperty('--bb-inbox-toolbar-height', `${toolbar.getBoundingClientRect().height}px`);
1167
+ };
1168
+ measure();
1169
+ if (toolbar && typeof globalThis.ResizeObserver === 'function') { toolbarObserver = new globalThis.ResizeObserver(measure); toolbarObserver.observe(toolbar); }
1170
+ }
956
1171
  if (state.focus) {
957
1172
  focusTarget?.focus?.({ preventScroll: true });
1173
+ if (cards) focusTarget?.scrollIntoView?.({ block: 'nearest' });
958
1174
  state.focus = null;
959
1175
  }
960
1176
  }
@@ -967,6 +1183,7 @@ export function createInboxUI({
967
1183
  },
968
1184
  destroy() {
969
1185
  state.destroyed = true;
1186
+ toolbarObserver?.disconnect();
970
1187
  generation += 1;
971
1188
  for (const timerId of doneTimers) timers.clear(timerId);
972
1189
  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; }