arbiterdesign 0.1.6 → 0.1.8

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.
@@ -3,70 +3,122 @@
3
3
  <head>
4
4
  <meta charset="utf-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1">
6
- <title>Arbiter review</title>
6
+ <title>Review Board</title>
7
7
  <style>
8
+ /* Geist, as on arbiter.design and the board. Served by `arbiter review` from templates/fonts. */
9
+ @font-face { font-family: "Geist"; src: url(/fonts/Geist-Variable.woff2) format("woff2"); font-weight: 100 900; font-display: swap; }
10
+ @font-face { font-family: "Geist Mono"; src: url(/fonts/GeistMono-Variable.woff2) format("woff2"); font-weight: 100 900; font-display: swap; }
11
+ /* The board's tokens (arbiter.design globals.css): cool, flat greys; colour only when it means something.
12
+ --card is the board's surface, --tag its surface-2. */
8
13
  :root {
9
14
  color-scheme: light dark;
10
- --bg: #fafaf9; --card: #fff; --ink: #1c1917; --muted: #78716c; --line: #e7e5e4;
11
- --accent: #1c1917; --accent-ink: #fff; --ok: #15803d; --warn: #b45309; --bad: #b91c1c;
12
- --tag: #f5f5f4; --shot: #f5f5f4;
15
+ --bg: #ffffff; --card: #fafafa; --tag: #f2f2f2; --shot: #f2f2f2;
16
+ --ink: #171717; --muted: #666666; --faint: #8f8f8f; --line: #ebebeb; --line-strong: #c2c2c2;
17
+ --accent: #171717; --accent-ink: #ffffff;
18
+ --ok: #0f7b3f; --warn: #a15c00; --bad: #d4111f; --info: #0060d0;
19
+ --ok-bg: #e8f5ee; --warn-bg: #fff4e0; --bad-bg: #fdecec;
13
20
  }
14
21
  @media (prefers-color-scheme: dark) {
15
22
  :root {
16
- --bg: #0c0a09; --card: #1c1917; --ink: #fafaf9; --muted: #a8a29e; --line: #292524;
17
- --accent: #fafaf9; --accent-ink: #0c0a09; --ok: #4ade80; --warn: #fbbf24; --bad: #f87171;
18
- --tag: #292524; --shot: #0c0a09;
23
+ --bg: #000000; --card: #0a0a0a; --tag: #141414; --shot: #141414;
24
+ --ink: #ededed; --muted: #a1a1a1; --faint: #6f6f6f; --line: #262626; --line-strong: #454545;
25
+ --accent: #ededed; --accent-ink: #000000;
26
+ --ok: #3ecf8e; --warn: #f5a623; --bad: #ff6166; --info: #52a8ff;
27
+ --ok-bg: #062b1a; --warn-bg: #2a1c00; --bad-bg: #2a0a0d;
19
28
  }
20
29
  }
21
30
  * { box-sizing: border-box; }
31
+ /* Type follows the board: hierarchy from colour and size, not weight. Nothing is uppercase or letter-spaced. */
22
32
  body {
23
33
  margin: 0; background: var(--bg); color: var(--ink);
24
- font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
34
+ font: 14px/1.5 "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
35
+ -webkit-font-smoothing: antialiased;
25
36
  padding: 0 16px 80px;
26
37
  }
38
+ /* The board's top bar: full width, a hairline under it, the lockup, then the project after a faint slash. */
27
39
  header {
28
- max-width: 800px; margin: 0 auto; padding: 28px 0 8px;
29
- display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
40
+ position: sticky; top: 0; z-index: 5; margin: 0 -16px; padding: 0 16px;
41
+ border-bottom: 1px solid var(--line);
42
+ background: var(--bg); background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(8px);
30
43
  }
31
- header h1 { font-size: 17px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
44
+ header .bar { max-width: 800px; height: 48px; margin: 0 auto; display: flex; align-items: center; gap: 12px; font-size: 16px; }
45
+ /* The lockup: the mark and the lowercase wordmark, 8px apart, semibold tight. */
46
+ .lockup { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; letter-spacing: -0.025em; }
47
+ .mark { flex-shrink: 0; }
48
+ .mark rect { fill: currentColor; }
49
+ .mark path { fill: var(--bg); }
50
+ header .slash { color: var(--faint); }
32
51
  header .project { color: var(--muted); }
33
- header .count { color: var(--muted); margin-left: auto; font-variant-numeric: tabular-nums; }
34
- nav { max-width: 800px; margin: 12px auto 0; display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
52
+ @media (max-width: 639px) { header .slash, header .project { display: none; } }
53
+ /* Top right: the team board, or how to publish one. */
54
+ .bar-end { margin-left: auto; position: relative; }
55
+ .pop {
56
+ position: absolute; right: 0; top: calc(100% + 8px); width: 300px; z-index: 6; padding: 12px;
57
+ background: var(--bg); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, .08);
58
+ font-size: 13px; color: var(--muted);
59
+ }
60
+ .pop p { margin: 0 0 10px; }
61
+ .pop .cmd { display: flex; align-items: center; gap: 8px; }
62
+ .pop code { flex: 1; color: var(--ink); padding: 4px 8px; }
63
+ /* PageTitle */
64
+ h1 { max-width: 800px; margin: 32px auto 0; font-size: 22px; font-weight: 600; letter-spacing: -0.025em; }
65
+ /* Lede: one sentence under the title. */
66
+ .page-lede { max-width: 800px; margin: 6px auto 0; font-size: 15px; color: var(--muted); }
67
+ nav { max-width: 800px; margin: 16px auto 0; display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
35
68
  nav button {
36
69
  border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted);
37
- padding: 8px 12px; margin-bottom: -1px; font-weight: 500;
70
+ height: auto; padding: 8px 12px; margin-bottom: -1px; font-size: 14px; font-weight: 400;
38
71
  }
39
- nav button:hover { border-color: var(--line); color: var(--ink); }
40
- nav button.on { color: var(--ink); border-bottom-color: var(--ink); }
72
+ nav button:hover:not(:disabled) { border-color: var(--line); color: var(--ink); }
73
+ nav button.on, nav button.on:hover:not(:disabled) { color: var(--ink); border-bottom-color: var(--ink); font-weight: 500; }
74
+ /* Newest | Oldest, styled like the team board's Cards/List toggle: the chosen one tinted, no weight change. */
75
+ .toolbar { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
76
+ .toolbar + .group { margin-top: 20px; }
77
+ .seg { margin-left: auto; display: flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 6px; }
78
+ .seg button { height: 24px; padding: 0 8px; border: 0; border-radius: 4px; background: transparent; font-size: 13px; font-weight: 400; color: var(--muted); }
79
+ .seg button:hover:not(:disabled) { color: var(--ink); }
80
+ .seg button.on { background: var(--tag); color: var(--ink); }
41
81
  main { max-width: 800px; margin: 0 auto; }
42
- h2 {
43
- font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
44
- color: var(--muted); margin: 32px 0 10px;
45
- }
82
+ /* SectionTitle */
83
+ h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.025em; color: var(--ink); margin: 32px 0 12px; }
46
84
  .card {
47
85
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
48
- padding: 18px 20px 16px; margin-bottom: 12px;
86
+ padding: 16px; margin-bottom: 12px;
49
87
  }
50
- .card.done { opacity: 0.55; padding: 12px 20px; }
51
- .card h3 { font-size: 16px; font-weight: 600; margin: 0 0 8px; letter-spacing: -0.01em; }
52
- .card .why { margin: 0 0 8px; }
53
- .lines { margin: 0 0 10px; display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; }
54
- .lines dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; padding-top: 3px; }
88
+ .card.done { opacity: 0.55; padding: 10px 16px; }
89
+ .card h3 { font-size: 15px; font-weight: 600; margin: 0 0 8px; letter-spacing: -0.025em; }
90
+ /* A decision, as on the board: id and badges on one row, "n of N" at the end, then key/value lines. */
91
+ .top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
92
+ .id { font: 12px "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--muted); }
93
+ .faint { font-size: 12px; color: var(--faint); }
94
+ .top .end { margin-left: auto; }
95
+ /* Badge: title case, always. */
96
+ .badge {
97
+ display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px;
98
+ font-size: 11px; font-weight: 500; line-height: 1; background: var(--tag); color: var(--muted); white-space: nowrap;
99
+ }
100
+ .badge.info { color: var(--info); }
101
+ .badge.ok { background: var(--ok-bg); color: var(--ok); }
102
+ .badge.warn { background: var(--warn-bg); color: var(--warn); }
103
+ .badge.bad { background: var(--bad-bg); color: var(--bad); }
104
+ .card h3 .badge { margin-left: 8px; vertical-align: 2px; }
105
+ /* KeyValues: a fixed label column (Label, 13px muted), values beside it. */
106
+ .lines { margin: 0; display: grid; grid-template-columns: 6rem minmax(0, 1fr); gap: 6px 12px; font-size: 14px; }
107
+ .lines dt { color: var(--muted); font-size: 13px; padding-top: 1px; }
55
108
  .lines dd { margin: 0; }
56
109
  .lines dd.muted { color: var(--muted); }
57
- .level { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--tag); color: var(--muted); vertical-align: 2px; margin-left: 8px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; }
58
- .level.feature { color: var(--ink); }
59
- .group { display: flex; align-items: baseline; gap: 10px; margin: 32px 0 10px; }
60
- .group h2 { margin: 0; text-transform: none; letter-spacing: 0; font-size: 15px; color: var(--ink); }
110
+ .lines dd.change { font-weight: 500; }
111
+ .lines a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
112
+ .lines a:hover { color: var(--ink); }
113
+ .group { display: flex; align-items: baseline; gap: 10px; margin: 32px 0 12px; }
114
+ .group h2 { margin: 0; }
61
115
  .group span { color: var(--muted); font-size: 13px; }
62
- .group .nopic { color: var(--warn); cursor: help; }
63
- .polish { background: var(--card); border: 1px dashed var(--line); border-radius: 12px; padding: 12px 20px; margin-bottom: 12px; }
116
+ .group .nopic { color: var(--warn); cursor: help; } .polish { background: var(--card); border: 1px dashed var(--line); border-radius: 12px; padding: 12px 20px; margin-bottom: 12px; }
64
117
  .polish .row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
65
118
  .polish .row .n { color: var(--muted); flex: 1; }
66
119
  .polish ul { list-style: none; margin: 10px 0 0; padding: 10px 0 0; border-top: 1px solid var(--line); }
67
120
  .polish li { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
68
121
  .polish li span { flex: 1; }
69
- .polish li button { padding: 3px 10px; font-size: 13px; }
70
122
  .card ul { margin: 0 0 10px; padding: 0; list-style: none; }
71
123
  .card ul.rejected li { padding-left: 18px; position: relative; }
72
124
  .card ul.rejected li::before { content: "✗"; position: absolute; left: 0; color: var(--muted); }
@@ -78,19 +130,22 @@
78
130
  }
79
131
  .thumb img { display: block; width: 100%; height: auto; }
80
132
  .thumb .cap { font-size: 12px; color: var(--muted); padding: 4px 8px; border-top: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
81
- .meta { color: var(--muted); font-size: 13px; display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
82
- .meta .tag { background: var(--tag); padding: 1px 8px; border-radius: 4px; cursor: help; }
83
- .meta a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
84
- .meta a:hover { color: var(--ink); }
85
- .actions { display: flex; gap: 8px; flex-wrap: wrap; }
86
- button {
87
- font: inherit; font-size: 14px; border-radius: 8px; border: 1px solid var(--line);
88
- background: var(--card); color: var(--ink); padding: 7px 14px; cursor: pointer;
89
- }
90
- button:hover { border-color: var(--ink); }
133
+ .meta { color: var(--muted); font-size: 13px; display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
134
+ .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
135
+ /* The homepage's Button, size sm: secondary by default, .primary filled, .quiet its ghost. Done is size md. */
136
+ button, .button {
137
+ display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; text-decoration: none;
138
+ font: inherit; font-size: 13px; font-weight: 500; height: 28px; padding: 0 10px; border-radius: 6px;
139
+ border: 1px solid var(--line-strong); background: var(--bg); color: var(--ink); cursor: pointer;
140
+ transition: color .15s, background-color .15s, border-color .15s;
141
+ }
142
+ button:hover:not(:disabled), .button:hover { border-color: var(--ink); }
143
+ button:disabled { cursor: not-allowed; opacity: .5; }
91
144
  button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
92
- button.quiet { color: var(--muted); border-color: transparent; }
93
- button.quiet:hover { border-color: var(--line); }
145
+ button.primary:hover:not(:disabled) { opacity: .9; }
146
+ button.quiet { background: transparent; color: var(--muted); border-color: transparent; }
147
+ button.quiet:hover:not(:disabled) { background: var(--tag); color: var(--ink); border-color: transparent; }
148
+ footer button { height: 32px; padding: 0 12px; font-size: 14px; }
94
149
  textarea {
95
150
  font: inherit; width: 100%; min-height: 64px; border: 1px solid var(--line); border-radius: 8px;
96
151
  background: var(--bg); color: var(--ink); padding: 10px 12px; margin: 10px 0; resize: vertical;
@@ -107,20 +162,25 @@
107
162
  .result .skip { color: var(--muted); }
108
163
  .bad { color: var(--bad); }
109
164
  .empty { text-align: center; color: var(--muted); padding: 80px 0; }
110
- .empty h2 { text-transform: none; letter-spacing: 0; font-size: 18px; color: var(--ink); }
165
+ .empty h2 { margin-bottom: 6px; }
111
166
  /* candidates */
112
167
  .cand { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 18px; }
113
168
  @media (max-width: 640px) { .cand { grid-template-columns: 1fr; } .split { flex-direction: column; } .thumb { max-width: 100%; flex-basis: auto; } }
114
169
  .cand .shot { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--shot); cursor: zoom-in; min-height: 80px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; }
115
170
  .cand .shot img { display: block; width: 100%; height: auto; }
116
- .state { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--tag); color: var(--muted); vertical-align: middle; margin-left: 8px; font-weight: 500; }
117
- .state.approved { color: var(--ok); }
118
- .state.rejected, .state.superseded { color: var(--bad); }
119
- .state.in_review { color: var(--warn); }
120
171
  .cand .decs { margin: 8px 0 12px; padding: 0; list-style: none; font-size: 14px; }
121
172
  .cand .decs li { color: var(--muted); }
122
173
  .cand .decs b { color: var(--ink); font-weight: 500; }
123
- .reason { color: var(--muted); font-style: italic; margin: 0 0 10px; }
174
+ .reason { color: var(--muted); margin: 0 0 10px; }
175
+ /* rules: the board's Standing rules. A divided list per dimension, id in the label column, the rule beside it, its reason under. */
176
+ .lede { margin: 24px 0 0; color: var(--muted); font-size: 13px; }
177
+ .lede.near { color: var(--warn); }
178
+ .rule-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
179
+ .rule-list li { display: grid; grid-template-columns: 4.5rem minmax(0, 1fr); gap: 0 12px; padding: 12px 0; font-size: 14px; }
180
+ .rule-list li + li { border-top: 1px solid var(--line); }
181
+ .rule-list .id { padding-top: 2px; }
182
+ .rule-list .why { margin-top: 2px; font-size: 13px; color: var(--muted); }
183
+ .rule-list .from { margin-top: 4px; font-size: 13px; color: var(--muted); }
124
184
  .comments { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; font-size: 14px; }
125
185
  .comments .ok { color: var(--ok); }
126
186
  .comments p { margin: 4px 0; } .comments b { font-weight: 500; }
@@ -129,7 +189,7 @@
129
189
  .card h3.ask { font-weight: 500; white-space: pre-line; }
130
190
  .card.approved { border-style: dashed; }
131
191
  .card.approved h3.ask { color: var(--muted); }
132
- code { font: 13px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--tag); padding: 1px 5px; border-radius: 4px; }
192
+ code { font: 13px "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--tag); padding: 1px 5px; border-radius: 4px; }
133
193
  #lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: none; align-items: center; justify-content: center; cursor: zoom-out; z-index: 10; padding: 24px; }
134
194
  #lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; }
135
195
  footer {
@@ -140,11 +200,14 @@
140
200
  </style>
141
201
  </head>
142
202
  <body>
143
- <header>
144
- <h1>Arbiter</h1>
203
+ <header><div class="bar">
204
+ <span class="lockup"><svg class="mark" width="18" height="18" viewBox="0 0 64 64" aria-hidden="true"><rect width="64" height="64" rx="8.11884"/><path d="M26.4434 21.5508C32.1562 21.5509 37.1773 24.5124 40.0547 28.9844L40.5361 29.583L53.3994 47.5586V53.8984H45.7041L31.5664 34.2197H31.5645C30.45 32.732 28.6728 31.7695 26.6709 31.7695C23.2967 31.7697 20.5618 34.5047 20.5615 37.8789C20.5615 41.2533 23.2965 43.989 26.6709 43.9893C29.567 43.9893 31.9906 41.974 32.6201 39.2695L38.8975 48.042C35.9308 51.619 31.4536 53.8983 26.4434 53.8984C17.5109 53.8984 10.2697 46.657 10.2695 37.7246C10.2695 28.792 17.5108 21.5508 26.4434 21.5508ZM37.4053 10.4082C43.3357 10.4082 53.3994 14.0025 53.3994 26.2227V43.9814L43.3359 29.9189V25.6836C43.3359 21.0112 38.4835 20.292 37.4053 20.292H18.3564L10.2695 10.4082H37.4053Z"/></svg>arbiter</span>
205
+ <span class="slash">/</span>
145
206
  <span class="project" id="project"></span>
146
- <span class="count" id="count"></span>
147
- </header>
207
+ <div class="bar-end" id="team-board"></div>
208
+ </div></header>
209
+ <h1>Review Board</h1>
210
+ <p class="page-lede">Only you see this page. Nothing here reaches your team until you publish.</p>
148
211
  <nav id="nav"></nav>
149
212
  <main id="main"></main>
150
213
  <div id="lightbox" onclick="this.style.display='none'"><img alt=""></div>
@@ -169,16 +232,65 @@ async function load() {
169
232
 
170
233
  function render() {
171
234
  document.getElementById('project').textContent = state.project;
172
- document.getElementById('count').textContent = `${state.active} of ${state.cap} rules`;
235
+ document.title = `Review Board · ${state.project}`;
236
+ teamBoard();
173
237
  const nav = document.getElementById('nav');
174
238
  nav.innerHTML = '';
175
239
  const asks = state.requests.filter(r => r.status === 'open').length;
176
240
  if (state.requests.length || Object.keys(answered).length) nav.appendChild(tabBtn('requests', `Requests · ${asks}`));
177
241
  nav.appendChild(tabBtn('decisions', `Decisions · ${state.pending.length}`));
178
- nav.appendChild(tabBtn('candidates', `Candidates · ${state.candidates.length}`));
242
+ // The team board's words: candidates are options, rules are design rules.
243
+ nav.appendChild(tabBtn('candidates', `Options · ${state.candidates.length}`));
244
+ nav.appendChild(tabBtn('rules', `Design rules · ${state.active}`));
179
245
  const main = document.getElementById('main');
180
246
  main.innerHTML = '';
181
- ({ requests: renderRequests, decisions: renderDecisions, candidates: renderCandidates })[tab](main);
247
+ ({ requests: renderRequests, decisions: renderDecisions, candidates: renderCandidates, rules: renderRules })[tab](main);
248
+ }
249
+
250
+ /* ── the team board, top right ───────────────────────────────────────── */
251
+ // Published: a link to it. Not yet: the command, not a button that publishes. The first publish
252
+ // creates the board on arbiter.design, which is a step to take on purpose.
253
+ const OUT = '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7 17 17 7"/><path d="M7 7h10v10"/></svg>';
254
+ function teamBoard() {
255
+ const box = document.getElementById('team-board');
256
+ if (box.childElementCount) return;
257
+ if (state.hosted) {
258
+ const a = el('a', 'button', 'Open team board'); a.href = state.hosted; a.target = '_blank'; a.rel = 'noreferrer';
259
+ a.insertAdjacentHTML('beforeend', OUT);
260
+ box.appendChild(a);
261
+ return;
262
+ }
263
+ const pop = el('div', 'pop'); pop.hidden = true;
264
+ pop.appendChild(el('p', null, 'Publish a team board: your team can see each screen and why it is that way, comment, and request changes. Run this in the project:'));
265
+ const row = el('div', 'cmd');
266
+ const code = el('code', null, 'npx arbiter publish');
267
+ row.appendChild(code);
268
+ // Selected either way, so a blocked clipboard still leaves it one keypress from copied.
269
+ const copy = btn('Copy', 'quiet', async () => {
270
+ const range = document.createRange(); range.selectNodeContents(code);
271
+ const sel = getSelection(); sel.removeAllRanges(); sel.addRange(range);
272
+ let ok;
273
+ try { await navigator.clipboard.writeText(code.textContent); ok = true; } catch { ok = document.execCommand('copy'); }
274
+ copy.textContent = ok ? 'Copied' : 'Selected';
275
+ });
276
+ row.appendChild(copy);
277
+ pop.appendChild(row);
278
+ box.append(btn('Share team board', null, () => { pop.hidden = !pop.hidden; copy.textContent = 'Copy'; }), pop);
279
+ document.addEventListener('click', (e) => { if (!box.contains(e.target)) pop.hidden = true; });
280
+ document.addEventListener('keydown', (e) => { if (e.key === 'Escape') pop.hidden = true; });
281
+ }
282
+
283
+ /* Newest or oldest first. Remembered in this browser only; it changes nothing in the record. */
284
+ const SORT_KEY = 'arbiter-review-sort';
285
+ let sort = (() => { try { return localStorage.getItem(SORT_KEY) || 'new'; } catch { return 'new'; } })();
286
+ function sortControl() {
287
+ const seg = el('div', 'seg'); seg.setAttribute('role', 'group'); seg.setAttribute('aria-label', 'Sort');
288
+ for (const [key, label] of [['new', 'Newest'], ['old', 'Oldest']]) {
289
+ const b = btn(label, sort === key ? 'on' : '', () => { sort = key; try { localStorage.setItem(SORT_KEY, key); } catch {} render(); });
290
+ b.setAttribute('aria-pressed', String(sort === key));
291
+ seg.appendChild(b);
292
+ }
293
+ return seg;
182
294
  }
183
295
 
184
296
  function tabBtn(id, label) {
@@ -199,12 +311,16 @@ function refLink(ref) {
199
311
  catch { a.textContent = ref; }
200
312
  return a;
201
313
  }
314
+ // Worded as the board words it.
202
315
  function scopeWords(scope) {
203
316
  if (scope === 'global') return 'Everywhere';
204
317
  const i = scope.indexOf(':'); const kind = scope.slice(0, i), target = scope.slice(i + 1);
205
318
  if (kind === 'file') return target.split('/').pop();
206
- return target.replace(/[-_]+/g, ' ').replace(/^\w/, ch => ch.toUpperCase()) + ' pattern';
319
+ return target.replace(/[-_]+/g, ' ').replace(/^\w/, ch => ch.toUpperCase()) + ', anywhere';
207
320
  }
321
+ function cap(s) { return s ? s.charAt(0).toUpperCase() + s.slice(1) : s; }
322
+ function day(iso) { return new Date(iso).toLocaleDateString('en-GB', { day: 'numeric', month: 'short' }); }
323
+ const STATE_TONE = { approved: 'ok', in_review: 'warn', rejected: 'bad', superseded: 'bad' };
208
324
  function messagePanel(c, text, cls) {
209
325
  clearPanel(c);
210
326
  const p = el('div', 'panel');
@@ -219,17 +335,20 @@ const promoted = {}; // polish id -> shown as a full card
219
335
 
220
336
  function renderDecisions(main) {
221
337
  const done = Object.keys(results).filter(id => !state.pending.some(p => p.id === id)).map(id => results[id].item);
222
- const all = [...state.pending, ...done];
338
+ // Sorted before grouping, so groups follow their newest (or oldest) decision and cards follow within each.
339
+ // ISO dates compare as text; the id breaks ties in queue order.
340
+ const when = d => d.date + d.id;
341
+ const all = [...state.pending, ...done].sort((a, b) => (when(a) < when(b) ? -1 : when(a) > when(b) ? 1 : 0) * (sort === 'new' ? -1 : 1));
223
342
  if (!all.length) {
224
343
  main.innerHTML = '<div class="empty"><h2>All caught up.</h2><p>Nothing pending. The agent queues decisions here when work settles.</p></div>';
225
344
  return;
226
345
  }
227
346
  const polishTotal = state.pending.filter(d => d.level === 'polish').length;
228
- if (polishTotal > 1) {
229
- const bar = el('div', 'actions'); bar.style.margin = '20px 0 0';
230
- bar.appendChild(btn(`Confirm all ${polishTotal} polish`, null, () => sendAll({ as: 'accept', level: 'polish' })));
231
- main.appendChild(bar);
232
- }
347
+ // A toolbar row, as on the team board: Confirm all polish on the left, the sort on the right.
348
+ const bar = el('div', 'toolbar');
349
+ if (polishTotal > 1) bar.appendChild(btn(`Confirm all ${polishTotal} polish`, null, () => sendAll({ as: 'accept', level: 'polish' })));
350
+ if (all.length > 1) bar.appendChild(sortControl());
351
+ if (bar.childElementCount) main.appendChild(bar);
233
352
  for (const g of groupByTrigger(all)) {
234
353
  const items = g.items, polish = g.polish.filter(d => !results[d.id] || promoted[d.id]);
235
354
  const head = el('div', 'group');
@@ -240,7 +359,7 @@ function renderDecisions(main) {
240
359
  const pics = [...new Map(items.filter(d => !results[d.id] && d.picture).map(d => [d.picture.command, d.picture])).values()];
241
360
  if (pics.length) { const p = el('span', 'nopic', '· No picture'); p.title = 'Take one while the screen is open:\n' + pics.map(m => m.command).join('\n'); head.appendChild(p); }
242
361
  main.appendChild(head);
243
- for (const d of items) main.appendChild(results[d.id] ? doneCard(d) : card(d));
362
+ items.forEach((d, i) => main.appendChild(results[d.id] ? doneCard(d) : card(d, i, items.length)));
244
363
  for (const d of g.polish.filter(d => promoted[d.id])) main.appendChild(results[d.id] ? doneCard(d) : card(d));
245
364
  const rest = g.polish.filter(d => !promoted[d.id]);
246
365
  if (rest.length) main.appendChild(polishRow(g.trigger, rest));
@@ -285,26 +404,31 @@ function polishRow(trigger, list) {
285
404
  return box;
286
405
  }
287
406
 
288
- function card(d) {
407
+ // The same shape as a decision on the board: id and badges on top, then Change, Pattern, Rejected,
408
+ // Applies to. Why sits after Rejected here, since it's what you judge by.
409
+ function card(d, i, n) {
289
410
  const c = el('div', 'card'); c.dataset.id = d.id;
290
411
  const split = el('div', 'split');
291
412
  const body = el('div', 'body');
292
- const h = el('h3', null, d.change || d.decision);
293
- h.appendChild(el('span', 'level ' + d.level, d.level));
294
- body.appendChild(h);
413
+ const top = el('div', 'top');
414
+ top.appendChild(el('span', 'id', d.id));
415
+ top.appendChild(el('span', 'badge info', cap(d.level)));
416
+ if (d.dimension) top.appendChild(el('span', 'badge', LABEL[d.dimension] || cap(d.dimension)));
417
+ if (d.verified === false) { const v = el('span', 'badge bad', 'Unverified'); v.title = 'The files did not match this claim when it was queued'; top.appendChild(v); }
418
+ top.appendChild(el('span', 'faint end', `${d.author}, ${day(d.date)}${n ? ` · ${i + 1} of ${n}` : ''}`));
419
+ body.appendChild(top);
295
420
  const dl = el('dl', 'lines');
296
- const line = (k, v, cls) => { dl.appendChild(el('dt', null, k)); dl.appendChild(el('dd', cls, v)); };
297
- if (d.change) line('Pattern', d.decision);
298
- for (const r of d.rejected) line('Rejected', r);
299
- line('Why', d.rationale, 'muted');
421
+ const line = (k, v, cls) => { dl.appendChild(el('dt', null, k)); const dd = el('dd', cls, v); dl.appendChild(dd); return dd; };
422
+ line('Change', d.change || d.decision, 'change');
423
+ if (d.change && d.change !== d.decision) line('Pattern', d.decision, 'muted');
424
+ if (d.rejected.length) { const dd = line('Rejected', null, 'muted'); for (const r of d.rejected) dd.appendChild(el('div', null, r)); }
425
+ if (d.rationale) line('Why', d.rationale, 'muted');
426
+ if (d.againstRule) line('Clashes', `${d.againstRule.id} · ${d.againstRule.decision}`);
427
+ // Applies to names a screen, never a file: a decision about one file is about the change it was made on.
428
+ if (d.scope.startsWith('file:')) line('Applies to', d.candidateName || d.trigger, 'muted');
429
+ else line('Applies to', scopeWords(d.scope), 'muted');
430
+ if (d.ref) line('Ticket', null, 'muted').appendChild(refLink(d.ref));
300
431
  body.appendChild(dl);
301
- const meta = el('div', 'meta');
302
- const tag = el('span', 'tag', scopeWords(d.scope)); tag.title = d.scope; meta.appendChild(tag);
303
- meta.appendChild(el('span', null, d.class));
304
- if (d.verified === false) { const v = el('span', 'bad', '· unverified'); v.title = 'The files did not match this claim when it was queued'; meta.appendChild(v); }
305
- meta.appendChild(el('span', null, '· ' + d.author + ', ' + d.date.slice(0, 10)));
306
- if (d.ref) { meta.appendChild(el('span', null, '·')); meta.appendChild(refLink(d.ref)); }
307
- body.appendChild(meta);
308
432
  body.appendChild(actions(d, c));
309
433
  split.appendChild(body);
310
434
  if (d.snapshotUrl) {
@@ -334,8 +458,18 @@ async function sendRow(d, li, body) {
334
458
 
335
459
  function actions(d, c) {
336
460
  const a = el('div', 'actions');
337
- a.appendChild(btn('Confirm', d.level === 'polish' ? 'primary' : null, () => send(d, c, { as: 'accept' })));
338
- if (d.level !== 'polish') a.appendChild(btn('Make it a rule', 'primary', () => send(d, c, { as: 'rule' })));
461
+ // Goes against a rule: someone has to say which wins. Same three choices as the review in chat.
462
+ const r = d.againstRule;
463
+ if (r) {
464
+ // The page records; it can't change code. Following the rule still needs the agent to do it.
465
+ a.appendChild(btn(`Follow ${r.id}`, 'primary', () => send(d, c, { as: 'fix', to: r.decision }, `Recorded. Ask your agent to change it to match ${r.id}.`)));
466
+ a.appendChild(btn(`Replace ${r.id}`, null, () => send(d, c, { as: 'rule', supersedes: r.id })));
467
+ a.appendChild(btn('Keep as exception', null, () => send(d, c, { as: 'accept' }, `Recorded as an exception to ${r.id}.`)));
468
+ a.appendChild(btn('Skip', 'quiet', () => send(d, c, { as: 'skip' })));
469
+ return a;
470
+ }
471
+ a.appendChild(btn('Confirm', 'primary', () => send(d, c, { as: 'accept' })));
472
+ if (d.level !== 'polish') a.appendChild(btn('Make it a rule', null, () => send(d, c, { as: 'rule' })));
339
473
  a.appendChild(btn('Skip', 'quiet', () => send(d, c, { as: 'skip' })));
340
474
  a.appendChild(btn('Fix', 'quiet', () => fixPanel(d, c)));
341
475
  return a;
@@ -383,7 +517,7 @@ function contradictedPanel(d, c, res) {
383
517
  c.appendChild(p);
384
518
  }
385
519
 
386
- async function send(d, c, body) {
520
+ async function send(d, c, body, done) {
387
521
  c.querySelectorAll('button').forEach(b => b.disabled = true);
388
522
  const res = await (await fetch('/api/judge', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ id: d.id, ...body }) })).json();
389
523
  c.querySelectorAll('button').forEach(b => b.disabled = false);
@@ -392,7 +526,7 @@ async function send(d, c, body) {
392
526
  if (res.exitCode === 4) return contradictedPanel(d, c, res);
393
527
  if (res.exitCode !== 0) return messagePanel(c, (res.errors || ['Something went wrong']).join(' · '), 'bad');
394
528
  results[d.id] = { item: d, kind: res.status === 'skipped' ? 'skip' : 'ok',
395
- text: res.status === 'skipped' ? 'Skipped' : `Recorded ${res.id} as ${res.verdict}${res.supersedes ? ', replacing ' + res.supersedes : ''}` };
529
+ text: res.status === 'skipped' ? 'Skipped' : done ?? `Recorded ${res.id} as ${res.verdict}${res.supersedes ? ', replacing ' + res.supersedes : ''}` };
396
530
  await load();
397
531
  }
398
532
 
@@ -415,7 +549,7 @@ function renderRequests(main) {
415
549
  const approved = state.requests.filter(r => r.status === 'approved');
416
550
  const declined = Object.values(answered);
417
551
  if (!open.length && !approved.length && !declined.length) {
418
- main.innerHTML = '<div class="empty"><h2>No requests.</h2><p>When someone presses Request change on the board, it lands here after <code>npx arbiter pull</code>.</p></div>';
552
+ main.innerHTML = '<div class="empty"><h2>No requests.</h2><p>When someone presses Request change on the team board, it lands here after <code>npx arbiter pull</code>.</p></div>';
419
553
  return;
420
554
  }
421
555
  if (open.length || declined.length) {
@@ -443,7 +577,7 @@ function requestCard(r) {
443
577
  meta.appendChild(el('span', null, r.screenName ? `on ${r.screenName}` : `on ${r.screen}`));
444
578
  if (r.decision) meta.appendChild(el('span', null, `· about ${r.decision}`));
445
579
  meta.appendChild(el('span', null, '· ' + r.date.slice(0, 10)));
446
- if (r.earlierVersion) { const s = el('span', null, '· earlier version'); s.title = 'Asked about a version of the board that has since been republished'; meta.appendChild(s); }
580
+ if (r.earlierVersion) { const s = el('span', null, '· earlier version'); s.title = 'Asked about a version of the team board that has since been republished'; meta.appendChild(s); }
447
581
  meta.appendChild(el('span', null, '· ' + r.id));
448
582
  body.appendChild(meta);
449
583
  if (r.status === 'approved') {
@@ -483,7 +617,7 @@ function insteadPanel(r, c) {
483
617
  function declinePanel(r, c) {
484
618
  clearPanel(c);
485
619
  const p = el('div', 'panel');
486
- p.appendChild(el('p', null, `Why not? ${r.author} reads this on the board.`));
620
+ p.appendChild(el('p', null, `Why not? ${r.author} reads this on the team board.`));
487
621
  const ta = el('textarea'); ta.placeholder = 'One line'; p.appendChild(ta);
488
622
  const row = el('div', 'actions');
489
623
  row.appendChild(btn('Decline', 'primary', () => { if (ta.value.trim()) sendRequest(r, c, { as: 'decline', why: ta.value.trim() }); else ta.focus(); }));
@@ -505,7 +639,7 @@ async function sendRequest(r, c, body) {
505
639
  function renderCandidates(main) {
506
640
  const all = state.candidates;
507
641
  if (!all.length) {
508
- main.innerHTML = '<div class="empty"><h2>No candidates yet.</h2><p>When the agent explores several directions for one feature, each one shows up here with its picture, its decisions, and — once you pick — why the others lost.</p></div>';
642
+ main.innerHTML = '<div class="empty"><h2>No options yet.</h2><p>When the agent tries several options for one thing, each one shows up here with its picture and its decisions. Once you pick one, it keeps why the others lost.</p></div>';
509
643
  return;
510
644
  }
511
645
  const features = [...new Set(all.map(c => c.feature || '—'))];
@@ -520,7 +654,7 @@ function candCard(c) {
520
654
  const grid = el('div', 'cand');
521
655
  const body = el('div');
522
656
  const h = el('h3', null, `${c.name}`);
523
- const st = el('span', 'state ' + c.state, STATE_LABEL[c.state] + (c.state === 'superseded' && c.supersededBy ? ` → ${c.supersededBy}` : ''));
657
+ const st = el('span', 'badge ' + (STATE_TONE[c.state] || ''), STATE_LABEL[c.state] + (c.state === 'superseded' && c.supersededBy ? ` → ${c.supersededBy}` : ''));
524
658
  h.appendChild(st); body.appendChild(h);
525
659
  if (c.reason) body.appendChild(el('p', 'reason', '“' + c.reason + '”'));
526
660
  const decs = el('ul', 'decs');
@@ -578,6 +712,40 @@ async function sendCand(card, c, body) {
578
712
  await load();
579
713
  }
580
714
 
715
+ /* ── rules tab ───────────────────────────────────────────────────────── */
716
+ // DECISIONS.md, read only: what's already settled, so you can check before making another rule.
717
+ function renderRules(main) {
718
+ const rules = state.rules;
719
+ if (!rules.length) {
720
+ main.innerHTML = `<div class="empty"><h2>No design rules yet.</h2><p>Make it a rule on a decision and it lands here, in DECISIONS.md, which the agent reads before any UI work. It holds ${state.cap} at most.</p></div>`;
721
+ return;
722
+ }
723
+ const full = state.active >= state.cap;
724
+ main.appendChild(el('p', 'lede' + (state.cap - state.active <= 5 ? ' near' : ''),
725
+ // The team board's subline (its rule D-0012), then how full it is.
726
+ `${state.active === 1 ? '1 rule' : `${state.active} rules`} you've saved in DECISIONS.md. Everything new follows ${state.active === 1 ? 'it' : 'them'}. ${full ? 'Full: a new rule has to replace one.' : `It holds ${state.cap} at most.`}`));
727
+ const dims = [...new Set(rules.map(r => r.dimension))].sort((a, b) => DIMS.indexOf(a) - DIMS.indexOf(b));
728
+ for (const dim of dims) {
729
+ const rs = rules.filter(r => r.dimension === dim);
730
+ const head = el('div', 'group');
731
+ head.appendChild(el('h2', null, LABEL[dim] || cap(dim)));
732
+ head.appendChild(el('span', null, String(rs.length)));
733
+ main.appendChild(head);
734
+ const ul = el('ul', 'rule-list');
735
+ for (const r of rs) {
736
+ const li = el('li');
737
+ li.appendChild(el('span', 'id', r.id));
738
+ const body = el('div');
739
+ body.appendChild(el('div', null, r.decision));
740
+ if (r.rationale) body.appendChild(el('div', 'why', r.rationale));
741
+ body.appendChild(el('div', 'from', `Decided on ${r.trigger} · ${r.author}, ${day(r.date)}`));
742
+ li.appendChild(body);
743
+ ul.appendChild(li);
744
+ }
745
+ main.appendChild(ul);
746
+ }
747
+ }
748
+
581
749
  document.getElementById('done').onclick = async () => {
582
750
  await fetch('/api/done', { method: 'POST', headers: { 'content-type': 'application/json' }, body: '{}' });
583
751
  document.body.innerHTML = '<div class="empty"><h2>Review closed.</h2><p>You can close this tab.</p></div>';