arbiterdesign 0.1.8 → 0.1.9
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/README.md +18 -37
- package/dist/area-names.js +120 -0
- package/dist/areas.js +131 -0
- package/dist/board-types.js +9 -0
- package/dist/candidates.js +7 -1
- package/dist/commands/areas.js +153 -0
- package/dist/commands/candidate.js +4 -2
- package/dist/commands/decision.js +100 -0
- package/dist/commands/export.js +88 -125
- package/dist/commands/init.js +12 -1
- package/dist/commands/record.js +129 -4
- package/dist/commands/rename.js +24 -10
- package/dist/commands/review.js +455 -78
- package/dist/commands/rules.js +5 -0
- package/dist/commands/setup.js +1 -0
- package/dist/commands/snapshot.js +24 -2
- package/dist/commands/sweep.js +1 -1
- package/dist/comments.js +24 -0
- package/dist/handoff.js +283 -0
- package/dist/hook.js +80 -0
- package/dist/hosted.js +11 -16
- package/dist/index.js +57 -21
- package/dist/localboard.js +219 -0
- package/dist/lock.js +134 -0
- package/dist/overlap.js +16 -0
- package/dist/pictures.js +4 -0
- package/dist/settings.js +107 -0
- package/dist/store.js +5 -4
- package/dist/verify.js +4 -2
- package/dist/work.js +110 -1
- package/package.json +3 -2
- package/templates/SKILL.md +110 -31
- package/templates/board/board.css +2 -0
- package/templates/board/board.js +25 -0
- package/templates/board/index.html +15 -0
- package/templates/fonts/OFL.txt +92 -92
- package/templates/hooks/arbiter-board.cjs +50 -0
- package/templates/review.html +0 -757
package/templates/review.html
DELETED
|
@@ -1,757 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
-
<title>Review Board</title>
|
|
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. */
|
|
13
|
-
:root {
|
|
14
|
-
color-scheme: light dark;
|
|
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;
|
|
20
|
-
}
|
|
21
|
-
@media (prefers-color-scheme: dark) {
|
|
22
|
-
:root {
|
|
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;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
* { box-sizing: border-box; }
|
|
31
|
-
/* Type follows the board: hierarchy from colour and size, not weight. Nothing is uppercase or letter-spaced. */
|
|
32
|
-
body {
|
|
33
|
-
margin: 0; background: var(--bg); color: var(--ink);
|
|
34
|
-
font: 14px/1.5 "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
|
|
35
|
-
-webkit-font-smoothing: antialiased;
|
|
36
|
-
padding: 0 16px 80px;
|
|
37
|
-
}
|
|
38
|
-
/* The board's top bar: full width, a hairline under it, the lockup, then the project after a faint slash. */
|
|
39
|
-
header {
|
|
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);
|
|
43
|
-
}
|
|
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); }
|
|
51
|
-
header .project { color: var(--muted); }
|
|
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); }
|
|
68
|
-
nav button {
|
|
69
|
-
border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted);
|
|
70
|
-
height: auto; padding: 8px 12px; margin-bottom: -1px; font-size: 14px; font-weight: 400;
|
|
71
|
-
}
|
|
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); }
|
|
81
|
-
main { max-width: 800px; margin: 0 auto; }
|
|
82
|
-
/* SectionTitle */
|
|
83
|
-
h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.025em; color: var(--ink); margin: 32px 0 12px; }
|
|
84
|
-
.card {
|
|
85
|
-
background: var(--card); border: 1px solid var(--line); border-radius: 12px;
|
|
86
|
-
padding: 16px; margin-bottom: 12px;
|
|
87
|
-
}
|
|
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; }
|
|
108
|
-
.lines dd { margin: 0; }
|
|
109
|
-
.lines dd.muted { color: var(--muted); }
|
|
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; }
|
|
115
|
-
.group span { color: var(--muted); font-size: 13px; }
|
|
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; }
|
|
117
|
-
.polish .row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
|
|
118
|
-
.polish .row .n { color: var(--muted); flex: 1; }
|
|
119
|
-
.polish ul { list-style: none; margin: 10px 0 0; padding: 10px 0 0; border-top: 1px solid var(--line); }
|
|
120
|
-
.polish li { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
|
|
121
|
-
.polish li span { flex: 1; }
|
|
122
|
-
.card ul { margin: 0 0 10px; padding: 0; list-style: none; }
|
|
123
|
-
.card ul.rejected li { padding-left: 18px; position: relative; }
|
|
124
|
-
.card ul.rejected li::before { content: "✗"; position: absolute; left: 0; color: var(--muted); }
|
|
125
|
-
.split { display: flex; gap: 18px; align-items: flex-start; }
|
|
126
|
-
.split .body { flex: 1; min-width: 0; }
|
|
127
|
-
.thumb {
|
|
128
|
-
flex: 0 0 180px; max-width: 40%; border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
|
|
129
|
-
background: var(--shot); cursor: zoom-in;
|
|
130
|
-
}
|
|
131
|
-
.thumb img { display: block; width: 100%; height: auto; }
|
|
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; }
|
|
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; }
|
|
144
|
-
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
|
|
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; }
|
|
149
|
-
textarea {
|
|
150
|
-
font: inherit; width: 100%; min-height: 64px; border: 1px solid var(--line); border-radius: 8px;
|
|
151
|
-
background: var(--bg); color: var(--ink); padding: 10px 12px; margin: 10px 0; resize: vertical;
|
|
152
|
-
}
|
|
153
|
-
.panel { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px; }
|
|
154
|
-
.panel p { margin: 0 0 10px; }
|
|
155
|
-
.panel .rule { padding: 10px 12px; background: var(--tag); border-radius: 8px; margin-bottom: 10px; }
|
|
156
|
-
.panel .rule b { display: block; }
|
|
157
|
-
.conf { font-size: 12px; padding: 1px 6px; border-radius: 4px; background: var(--tag); color: var(--muted); }
|
|
158
|
-
.conf.exact { color: var(--ok); }
|
|
159
|
-
.conf.possible { color: var(--warn); }
|
|
160
|
-
.result { display: flex; align-items: center; gap: 10px; }
|
|
161
|
-
.result .ok { color: var(--ok); }
|
|
162
|
-
.result .skip { color: var(--muted); }
|
|
163
|
-
.bad { color: var(--bad); }
|
|
164
|
-
.empty { text-align: center; color: var(--muted); padding: 80px 0; }
|
|
165
|
-
.empty h2 { margin-bottom: 6px; }
|
|
166
|
-
/* candidates */
|
|
167
|
-
.cand { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 18px; }
|
|
168
|
-
@media (max-width: 640px) { .cand { grid-template-columns: 1fr; } .split { flex-direction: column; } .thumb { max-width: 100%; flex-basis: auto; } }
|
|
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; }
|
|
170
|
-
.cand .shot img { display: block; width: 100%; height: auto; }
|
|
171
|
-
.cand .decs { margin: 8px 0 12px; padding: 0; list-style: none; font-size: 14px; }
|
|
172
|
-
.cand .decs li { color: var(--muted); }
|
|
173
|
-
.cand .decs b { color: var(--ink); font-weight: 500; }
|
|
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); }
|
|
184
|
-
.comments { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; font-size: 14px; }
|
|
185
|
-
.comments .ok { color: var(--ok); }
|
|
186
|
-
.comments p { margin: 4px 0; } .comments b { font-weight: 500; }
|
|
187
|
-
/* requests */
|
|
188
|
-
.card .asker { margin: 0 0 4px; color: var(--muted); font-size: 13px; }
|
|
189
|
-
.card h3.ask { font-weight: 500; white-space: pre-line; }
|
|
190
|
-
.card.approved { border-style: dashed; }
|
|
191
|
-
.card.approved h3.ask { color: var(--muted); }
|
|
192
|
-
code { font: 13px "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--tag); padding: 1px 5px; border-radius: 4px; }
|
|
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; }
|
|
194
|
-
#lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; }
|
|
195
|
-
footer {
|
|
196
|
-
position: fixed; bottom: 0; left: 0; right: 0; background: var(--bg);
|
|
197
|
-
border-top: 1px solid var(--line); padding: 12px 16px;
|
|
198
|
-
}
|
|
199
|
-
footer div { max-width: 800px; margin: 0 auto; display: flex; justify-content: flex-end; }
|
|
200
|
-
</style>
|
|
201
|
-
</head>
|
|
202
|
-
<body>
|
|
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>
|
|
206
|
-
<span class="project" id="project"></span>
|
|
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>
|
|
211
|
-
<nav id="nav"></nav>
|
|
212
|
-
<main id="main"></main>
|
|
213
|
-
<div id="lightbox" onclick="this.style.display='none'"><img alt=""></div>
|
|
214
|
-
<footer><div><button id="done" class="primary">Done</button></div></footer>
|
|
215
|
-
|
|
216
|
-
<script>
|
|
217
|
-
const DIMS = ['structure','interaction','states','content','visual','motion','access'];
|
|
218
|
-
const LABEL = { structure:'Structure', interaction:'Interaction', states:'States', content:'Content', visual:'Visual', motion:'Motion', access:'Accessibility' };
|
|
219
|
-
const STATE_LABEL = { generated:'Draft', in_review:'In review', approved:'Approved', rejected:'Rejected', superseded:'Replaced' };
|
|
220
|
-
const results = {}; // pending id -> {item, kind, text}
|
|
221
|
-
let state = null;
|
|
222
|
-
let tab = 'decisions';
|
|
223
|
-
|
|
224
|
-
let first = true;
|
|
225
|
-
async function load() {
|
|
226
|
-
state = await (await fetch('/api/state')).json();
|
|
227
|
-
// Someone is waiting on an answer: open there.
|
|
228
|
-
if (first && state.requests.some(r => r.status === 'open')) tab = 'requests';
|
|
229
|
-
first = false;
|
|
230
|
-
render();
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
function render() {
|
|
234
|
-
document.getElementById('project').textContent = state.project;
|
|
235
|
-
document.title = `Review Board · ${state.project}`;
|
|
236
|
-
teamBoard();
|
|
237
|
-
const nav = document.getElementById('nav');
|
|
238
|
-
nav.innerHTML = '';
|
|
239
|
-
const asks = state.requests.filter(r => r.status === 'open').length;
|
|
240
|
-
if (state.requests.length || Object.keys(answered).length) nav.appendChild(tabBtn('requests', `Requests · ${asks}`));
|
|
241
|
-
nav.appendChild(tabBtn('decisions', `Decisions · ${state.pending.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}`));
|
|
245
|
-
const main = document.getElementById('main');
|
|
246
|
-
main.innerHTML = '';
|
|
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;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
function tabBtn(id, label) {
|
|
297
|
-
const b = btn(label, tab === id ? 'on' : '', () => { tab = id; render(); });
|
|
298
|
-
return b;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
/* ── helpers ─────────────────────────────────────────────────────────── */
|
|
302
|
-
function el(tag, cls, text) { const e = document.createElement(tag); if (cls) e.className = cls; if (text != null) e.textContent = text; return e; }
|
|
303
|
-
function btn(label, cls, onClick) { const b = el('button', cls, label); b.onclick = onClick; return b; }
|
|
304
|
-
function clearPanel(c) { c.querySelectorAll('.panel').forEach(p => p.remove()); }
|
|
305
|
-
function zoom(src) { const lb = document.getElementById('lightbox'); lb.querySelector('img').src = src; lb.style.display = 'flex'; }
|
|
306
|
-
/* A ticket ref: a link when it's a URL (labelled host · last path segment), plain text for a bare key like ENG-123. */
|
|
307
|
-
function refLink(ref) {
|
|
308
|
-
if (!/^https?:\/\//i.test(ref)) return el('span', null, ref);
|
|
309
|
-
const a = el('a'); a.href = ref; a.target = '_blank'; a.rel = 'noreferrer'; a.title = ref;
|
|
310
|
-
try { const u = new URL(ref); const last = u.pathname.split('/').filter(Boolean).pop(); a.textContent = u.hostname.replace(/^www\./, '') + (last ? ' · ' + last : ''); }
|
|
311
|
-
catch { a.textContent = ref; }
|
|
312
|
-
return a;
|
|
313
|
-
}
|
|
314
|
-
// Worded as the board words it.
|
|
315
|
-
function scopeWords(scope) {
|
|
316
|
-
if (scope === 'global') return 'Everywhere';
|
|
317
|
-
const i = scope.indexOf(':'); const kind = scope.slice(0, i), target = scope.slice(i + 1);
|
|
318
|
-
if (kind === 'file') return target.split('/').pop();
|
|
319
|
-
return target.replace(/[-_]+/g, ' ').replace(/^\w/, ch => ch.toUpperCase()) + ', anywhere';
|
|
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' };
|
|
324
|
-
function messagePanel(c, text, cls) {
|
|
325
|
-
clearPanel(c);
|
|
326
|
-
const p = el('div', 'panel');
|
|
327
|
-
p.appendChild(el('p', cls, text));
|
|
328
|
-
p.appendChild(btn('OK', 'quiet', () => clearPanel(c)));
|
|
329
|
-
c.appendChild(p);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
/* ── decisions tab ───────────────────────────────────────────────────── */
|
|
333
|
-
const open = {}; // trigger -> polish list expanded
|
|
334
|
-
const promoted = {}; // polish id -> shown as a full card
|
|
335
|
-
|
|
336
|
-
function renderDecisions(main) {
|
|
337
|
-
const done = Object.keys(results).filter(id => !state.pending.some(p => p.id === id)).map(id => results[id].item);
|
|
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));
|
|
342
|
-
if (!all.length) {
|
|
343
|
-
main.innerHTML = '<div class="empty"><h2>All caught up.</h2><p>Nothing pending. The agent queues decisions here when work settles.</p></div>';
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
const polishTotal = state.pending.filter(d => d.level === 'polish').length;
|
|
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);
|
|
352
|
-
for (const g of groupByTrigger(all)) {
|
|
353
|
-
const items = g.items, polish = g.polish.filter(d => !results[d.id] || promoted[d.id]);
|
|
354
|
-
const head = el('div', 'group');
|
|
355
|
-
head.appendChild(el('h2', null, g.trigger));
|
|
356
|
-
const n = items.filter(d => !results[d.id]).length;
|
|
357
|
-
head.appendChild(el('span', null, `${n} decision${n === 1 ? '' : 's'}${polish.length ? ` · +${polish.length} polish` : ''}`));
|
|
358
|
-
// The board shows an icon where a picture is missing, so this is the place to notice.
|
|
359
|
-
const pics = [...new Map(items.filter(d => !results[d.id] && d.picture).map(d => [d.picture.command, d.picture])).values()];
|
|
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); }
|
|
361
|
-
main.appendChild(head);
|
|
362
|
-
items.forEach((d, i) => main.appendChild(results[d.id] ? doneCard(d) : card(d, i, items.length)));
|
|
363
|
-
for (const d of g.polish.filter(d => promoted[d.id])) main.appendChild(results[d.id] ? doneCard(d) : card(d));
|
|
364
|
-
const rest = g.polish.filter(d => !promoted[d.id]);
|
|
365
|
-
if (rest.length) main.appendChild(polishRow(g.trigger, rest));
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
function groupByTrigger(list) {
|
|
370
|
-
const out = [];
|
|
371
|
-
for (const d of list) {
|
|
372
|
-
let g = out.find(x => x.trigger === d.trigger);
|
|
373
|
-
if (!g) { g = { trigger: d.trigger, items: [], polish: [] }; out.push(g); }
|
|
374
|
-
(d.level === 'polish' ? g.polish : g.items).push(d);
|
|
375
|
-
}
|
|
376
|
-
return out;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
function polishRow(trigger, list) {
|
|
380
|
-
const pending = list.filter(d => !results[d.id]);
|
|
381
|
-
const box = el('div', 'polish');
|
|
382
|
-
const row = el('div', 'row');
|
|
383
|
-
row.appendChild(el('span', 'n', pending.length ? `${pending.length} polish — one-off fixes, no rules come from these` : 'Polish confirmed'));
|
|
384
|
-
if (pending.length) {
|
|
385
|
-
row.appendChild(btn('Confirm all', 'primary', () => sendAll({ as: 'accept', level: 'polish', trigger })));
|
|
386
|
-
row.appendChild(btn(open[trigger] ? 'Hide' : 'Show', 'quiet', () => { open[trigger] = !open[trigger]; render(); }));
|
|
387
|
-
}
|
|
388
|
-
box.appendChild(row);
|
|
389
|
-
if (open[trigger] || !pending.length) {
|
|
390
|
-
const ul = el('ul');
|
|
391
|
-
for (const d of list) {
|
|
392
|
-
const li = el('li');
|
|
393
|
-
const r = results[d.id];
|
|
394
|
-
li.appendChild(el('span', r ? 'muted' : '', (r ? (r.kind === 'ok' ? '✓ ' : '— ') : '') + (d.change || d.decision)));
|
|
395
|
-
if (!r) {
|
|
396
|
-
li.appendChild(btn('Confirm', 'quiet', () => sendRow(d, li, { as: 'accept' })));
|
|
397
|
-
li.appendChild(btn('Skip', 'quiet', () => sendRow(d, li, { as: 'skip' })));
|
|
398
|
-
li.appendChild(btn('More', 'quiet', () => { promoted[d.id] = true; render(); }));
|
|
399
|
-
}
|
|
400
|
-
ul.appendChild(li);
|
|
401
|
-
}
|
|
402
|
-
box.appendChild(ul);
|
|
403
|
-
}
|
|
404
|
-
return box;
|
|
405
|
-
}
|
|
406
|
-
|
|
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) {
|
|
410
|
-
const c = el('div', 'card'); c.dataset.id = d.id;
|
|
411
|
-
const split = el('div', 'split');
|
|
412
|
-
const body = el('div', 'body');
|
|
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);
|
|
420
|
-
const dl = el('dl', 'lines');
|
|
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));
|
|
431
|
-
body.appendChild(dl);
|
|
432
|
-
body.appendChild(actions(d, c));
|
|
433
|
-
split.appendChild(body);
|
|
434
|
-
if (d.snapshotUrl) {
|
|
435
|
-
const t = el('div', 'thumb'); t.onclick = () => zoom(d.snapshotUrl);
|
|
436
|
-
const img = el('img'); img.src = d.snapshotUrl; img.alt = d.candidateName || d.candidate; t.appendChild(img);
|
|
437
|
-
t.appendChild(el('div', 'cap', `${d.candidate} · ${d.candidateName || ''}`));
|
|
438
|
-
split.appendChild(t);
|
|
439
|
-
}
|
|
440
|
-
c.appendChild(split);
|
|
441
|
-
return c;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
async function sendAll(body) {
|
|
445
|
-
const res = await (await fetch('/api/judge-all', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) })).json();
|
|
446
|
-
const targets = state.pending.filter(d => (!body.level || d.level === body.level) && (!body.trigger || d.trigger === body.trigger));
|
|
447
|
-
for (const d of targets) if (!(res.failed || []).some(f => f.id === d.id)) results[d.id] = { item: d, kind: body.as === 'skip' ? 'skip' : 'ok', text: body.as === 'skip' ? 'Skipped' : 'Confirmed' };
|
|
448
|
-
await load();
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
async function sendRow(d, li, body) {
|
|
452
|
-
li.querySelectorAll('button').forEach(b => b.disabled = true);
|
|
453
|
-
const res = await (await fetch('/api/judge', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ id: d.id, ...body }) })).json();
|
|
454
|
-
if (res.exitCode !== 0) { li.querySelectorAll('button').forEach(b => b.disabled = false); return; }
|
|
455
|
-
results[d.id] = { item: d, kind: res.status === 'skipped' ? 'skip' : 'ok', text: res.status === 'skipped' ? 'Skipped' : `Recorded ${res.id}` };
|
|
456
|
-
await load();
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
function actions(d, c) {
|
|
460
|
-
const a = el('div', 'actions');
|
|
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' })));
|
|
473
|
-
a.appendChild(btn('Skip', 'quiet', () => send(d, c, { as: 'skip' })));
|
|
474
|
-
a.appendChild(btn('Fix', 'quiet', () => fixPanel(d, c)));
|
|
475
|
-
return a;
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
function fixPanel(d, c) {
|
|
479
|
-
clearPanel(c);
|
|
480
|
-
const p = el('div', 'panel');
|
|
481
|
-
p.appendChild(el('p', null, 'What should it be instead?'));
|
|
482
|
-
const ta = el('textarea'); ta.placeholder = d.decision; p.appendChild(ta);
|
|
483
|
-
const row = el('div', 'actions');
|
|
484
|
-
row.appendChild(btn('Save fix', 'primary', () => { if (ta.value.trim()) send(d, c, { as: 'fix', to: ta.value.trim() }); }));
|
|
485
|
-
row.appendChild(btn('Cancel', 'quiet', () => clearPanel(c)));
|
|
486
|
-
p.appendChild(row);
|
|
487
|
-
c.appendChild(p); ta.focus();
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
function overlapPanel(d, c, res, body) {
|
|
491
|
-
clearPanel(c);
|
|
492
|
-
const p = el('div', 'panel');
|
|
493
|
-
p.appendChild(el('p', null, `Overlaps ${res.overlaps.length} active rule${res.overlaps.length === 1 ? '' : 's'}:`));
|
|
494
|
-
for (const o of res.overlaps) {
|
|
495
|
-
const r = el('div', 'rule');
|
|
496
|
-
r.appendChild(el('b', null, `${o.id} · ${o.decision}`));
|
|
497
|
-
r.appendChild(el('span', 'conf ' + o.confidence, (o.confidence === 'exact' ? 'exact — ' : 'possible — ') + o.reason));
|
|
498
|
-
p.appendChild(r);
|
|
499
|
-
}
|
|
500
|
-
const row = el('div', 'actions');
|
|
501
|
-
for (const o of res.overlaps) row.appendChild(btn(`Replace ${o.id}`, 'primary', () => send(d, c, { ...body, supersedes: o.id })));
|
|
502
|
-
row.appendChild(btn('Keep both', null, () => send(d, c, { ...body, keepBoth: true })));
|
|
503
|
-
row.appendChild(btn('Cancel', 'quiet', () => clearPanel(c)));
|
|
504
|
-
p.appendChild(row);
|
|
505
|
-
c.appendChild(p);
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
function contradictedPanel(d, c, res) {
|
|
509
|
-
clearPanel(c);
|
|
510
|
-
const p = el('div', 'panel');
|
|
511
|
-
p.appendChild(el('p', 'bad', 'The files don\'t match this claim:'));
|
|
512
|
-
const ul = el('ul', 'rejected');
|
|
513
|
-
for (const f of res.failed) ul.appendChild(el('li', null, `${f.kind}${f.needle ? ` "${f.needle}"` : ''} — ${f.file}${f.detail ? ` (${f.detail})` : ''}`));
|
|
514
|
-
p.appendChild(ul);
|
|
515
|
-
p.appendChild(el('p', null, 'Ask the agent to fix the code, or confirm it as an exception instead.'));
|
|
516
|
-
p.appendChild(btn('OK', 'quiet', () => clearPanel(c)));
|
|
517
|
-
c.appendChild(p);
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
async function send(d, c, body, done) {
|
|
521
|
-
c.querySelectorAll('button').forEach(b => b.disabled = true);
|
|
522
|
-
const res = await (await fetch('/api/judge', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ id: d.id, ...body }) })).json();
|
|
523
|
-
c.querySelectorAll('button').forEach(b => b.disabled = false);
|
|
524
|
-
if (res.exitCode === 2) return overlapPanel(d, c, res, body);
|
|
525
|
-
if (res.exitCode === 3) return messagePanel(c, res.message, 'bad');
|
|
526
|
-
if (res.exitCode === 4) return contradictedPanel(d, c, res);
|
|
527
|
-
if (res.exitCode !== 0) return messagePanel(c, (res.errors || ['Something went wrong']).join(' · '), 'bad');
|
|
528
|
-
results[d.id] = { item: d, kind: res.status === 'skipped' ? 'skip' : 'ok',
|
|
529
|
-
text: res.status === 'skipped' ? 'Skipped' : done ?? `Recorded ${res.id} as ${res.verdict}${res.supersedes ? ', replacing ' + res.supersedes : ''}` };
|
|
530
|
-
await load();
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
function doneCard(d) {
|
|
534
|
-
const r = results[d.id];
|
|
535
|
-
const c = el('div', 'card done');
|
|
536
|
-
const row = el('div', 'result');
|
|
537
|
-
row.appendChild(el('span', r.kind, r.kind === 'ok' ? '✓' : '—'));
|
|
538
|
-
row.appendChild(el('span', null, d.change || d.decision));
|
|
539
|
-
row.appendChild(el('span', 'meta', r.text));
|
|
540
|
-
c.appendChild(row);
|
|
541
|
-
return c;
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
/* ── requests tab ────────────────────────────────────────────────────── */
|
|
545
|
-
const answered = {}; // request id -> {item, text} once declined here
|
|
546
|
-
|
|
547
|
-
function renderRequests(main) {
|
|
548
|
-
const open = state.requests.filter(r => r.status === 'open');
|
|
549
|
-
const approved = state.requests.filter(r => r.status === 'approved');
|
|
550
|
-
const declined = Object.values(answered);
|
|
551
|
-
if (!open.length && !approved.length && !declined.length) {
|
|
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>';
|
|
553
|
-
return;
|
|
554
|
-
}
|
|
555
|
-
if (open.length || declined.length) {
|
|
556
|
-
main.appendChild(el('h2', null, 'To answer'));
|
|
557
|
-
for (const r of open) main.appendChild(requestCard(r));
|
|
558
|
-
for (const a of declined) {
|
|
559
|
-
const c = el('div', 'card done'); const row = el('div', 'result');
|
|
560
|
-
row.appendChild(el('span', 'skip', '—')); row.appendChild(el('span', null, a.item.body)); row.appendChild(el('span', 'meta', a.text));
|
|
561
|
-
c.appendChild(row); main.appendChild(c);
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
if (approved.length) {
|
|
565
|
-
main.appendChild(el('h2', null, 'Approved — the agent makes these at your next /arbiter'));
|
|
566
|
-
for (const r of approved) main.appendChild(requestCard(r));
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
function requestCard(r) {
|
|
571
|
-
const c = el('div', 'card' + (r.status === 'approved' ? ' approved' : '')); c.dataset.id = r.id;
|
|
572
|
-
const split = el('div', 'split');
|
|
573
|
-
const body = el('div', 'body');
|
|
574
|
-
body.appendChild(el('p', 'asker', `${r.author} asks`));
|
|
575
|
-
body.appendChild(el('h3', 'ask', r.body));
|
|
576
|
-
const meta = el('div', 'meta');
|
|
577
|
-
meta.appendChild(el('span', null, r.screenName ? `on ${r.screenName}` : `on ${r.screen}`));
|
|
578
|
-
if (r.decision) meta.appendChild(el('span', null, `· about ${r.decision}`));
|
|
579
|
-
meta.appendChild(el('span', null, '· ' + r.date.slice(0, 10)));
|
|
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); }
|
|
581
|
-
meta.appendChild(el('span', null, '· ' + r.id));
|
|
582
|
-
body.appendChild(meta);
|
|
583
|
-
if (r.status === 'approved') {
|
|
584
|
-
const dl = el('dl', 'lines');
|
|
585
|
-
dl.appendChild(el('dt', null, 'Doing')); dl.appendChild(el('dd', null, r.instead ? r.instead : 'As asked'));
|
|
586
|
-
body.appendChild(dl);
|
|
587
|
-
} else {
|
|
588
|
-
const a = el('div', 'actions');
|
|
589
|
-
a.appendChild(btn('Apply', 'primary', () => sendRequest(r, c, { as: 'apply' })));
|
|
590
|
-
a.appendChild(btn('Apply, but…', null, () => insteadPanel(r, c)));
|
|
591
|
-
a.appendChild(btn('Decline', 'quiet', () => declinePanel(r, c)));
|
|
592
|
-
body.appendChild(a);
|
|
593
|
-
}
|
|
594
|
-
split.appendChild(body);
|
|
595
|
-
if (r.snapshotUrl) {
|
|
596
|
-
const t = el('div', 'thumb'); t.onclick = () => zoom(r.snapshotUrl);
|
|
597
|
-
const img = el('img'); img.src = r.snapshotUrl; img.alt = r.screenName || r.screen; t.appendChild(img);
|
|
598
|
-
t.appendChild(el('div', 'cap', r.screenName || r.screen));
|
|
599
|
-
split.appendChild(t);
|
|
600
|
-
}
|
|
601
|
-
c.appendChild(split);
|
|
602
|
-
return c;
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
function insteadPanel(r, c) {
|
|
606
|
-
clearPanel(c);
|
|
607
|
-
const p = el('div', 'panel');
|
|
608
|
-
p.appendChild(el('p', null, `What should happen instead? ${r.author} sees what was actually done.`));
|
|
609
|
-
const ta = el('textarea'); ta.placeholder = 'e.g. keep it where it is, make the button red'; p.appendChild(ta);
|
|
610
|
-
const row = el('div', 'actions');
|
|
611
|
-
row.appendChild(btn('Apply this instead', 'primary', () => { if (ta.value.trim()) sendRequest(r, c, { as: 'apply', to: ta.value.trim() }); }));
|
|
612
|
-
row.appendChild(btn('Cancel', 'quiet', () => clearPanel(c)));
|
|
613
|
-
p.appendChild(row);
|
|
614
|
-
c.appendChild(p); ta.focus();
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
function declinePanel(r, c) {
|
|
618
|
-
clearPanel(c);
|
|
619
|
-
const p = el('div', 'panel');
|
|
620
|
-
p.appendChild(el('p', null, `Why not? ${r.author} reads this on the team board.`));
|
|
621
|
-
const ta = el('textarea'); ta.placeholder = 'One line'; p.appendChild(ta);
|
|
622
|
-
const row = el('div', 'actions');
|
|
623
|
-
row.appendChild(btn('Decline', 'primary', () => { if (ta.value.trim()) sendRequest(r, c, { as: 'decline', why: ta.value.trim() }); else ta.focus(); }));
|
|
624
|
-
row.appendChild(btn('Cancel', 'quiet', () => clearPanel(c)));
|
|
625
|
-
p.appendChild(row);
|
|
626
|
-
c.appendChild(p); ta.focus();
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
async function sendRequest(r, c, body) {
|
|
630
|
-
c.querySelectorAll('button').forEach(b => b.disabled = true);
|
|
631
|
-
const res = await (await fetch('/api/request', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ id: r.id, ...body }) })).json();
|
|
632
|
-
c.querySelectorAll('button').forEach(b => b.disabled = false);
|
|
633
|
-
if (res.exitCode !== 0) return messagePanel(c, (res.errors || ['Something went wrong']).join(' · '), 'bad');
|
|
634
|
-
if (res.status === 'declined') answered[r.id] = { item: r, text: `Declined — ${res.reason}` };
|
|
635
|
-
await load();
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
/* ── candidates tab ──────────────────────────────────────────────────── */
|
|
639
|
-
function renderCandidates(main) {
|
|
640
|
-
const all = state.candidates;
|
|
641
|
-
if (!all.length) {
|
|
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>';
|
|
643
|
-
return;
|
|
644
|
-
}
|
|
645
|
-
const features = [...new Set(all.map(c => c.feature || '—'))];
|
|
646
|
-
for (const f of features) {
|
|
647
|
-
main.appendChild(el('h2', null, f));
|
|
648
|
-
for (const c of all.filter(c => (c.feature || '—') === f)) main.appendChild(candCard(c));
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
function candCard(c) {
|
|
653
|
-
const card = el('div', 'card'); card.dataset.id = c.id;
|
|
654
|
-
const grid = el('div', 'cand');
|
|
655
|
-
const body = el('div');
|
|
656
|
-
const h = el('h3', null, `${c.name}`);
|
|
657
|
-
const st = el('span', 'badge ' + (STATE_TONE[c.state] || ''), STATE_LABEL[c.state] + (c.state === 'superseded' && c.supersededBy ? ` → ${c.supersededBy}` : ''));
|
|
658
|
-
h.appendChild(st); body.appendChild(h);
|
|
659
|
-
if (c.reason) body.appendChild(el('p', 'reason', '“' + c.reason + '”'));
|
|
660
|
-
const decs = el('ul', 'decs');
|
|
661
|
-
if (!c.decisions.length) decs.appendChild(el('li', null, 'No decisions linked yet.'));
|
|
662
|
-
for (const d of c.decisions) { const li = el('li'); li.appendChild(el('b', null, d.decision)); li.appendChild(document.createTextNode(` · ${d.id} · ${d.verdict}`)); decs.appendChild(li); }
|
|
663
|
-
body.appendChild(decs);
|
|
664
|
-
const meta = el('div', 'meta');
|
|
665
|
-
meta.appendChild(el('span', null, c.id));
|
|
666
|
-
meta.appendChild(el('span', null, '· ' + c.author + ', ' + c.date.slice(0, 10)));
|
|
667
|
-
if (c.commit) meta.appendChild(el('span', null, '· ' + c.commit));
|
|
668
|
-
body.appendChild(meta);
|
|
669
|
-
if (c.comments && c.comments.length) {
|
|
670
|
-
const box = el('div', 'comments');
|
|
671
|
-
const stale = x => !!(x.board_version && state.boardVersion && x.board_version !== state.boardVersion);
|
|
672
|
-
const approvals = c.comments.filter(x => x.kind === 'approve' && !stale(x));
|
|
673
|
-
const earlier = c.comments.filter(x => x.kind === 'approve' && stale(x));
|
|
674
|
-
if (approvals.length) box.appendChild(el('p', 'ok', '✓ Looks good to ' + approvals.map(a => a.author_name).join(', ')));
|
|
675
|
-
if (earlier.length) box.appendChild(el('p', 'muted', 'Looked good to ' + earlier.map(a => a.author_name).join(', ') + ' on an earlier version'));
|
|
676
|
-
for (const x of c.comments.filter(x => x.kind === 'comment')) { const p = el('p'); p.appendChild(el('b', null, x.author_name + (x.decision_id ? ' on ' + x.decision_id : '') + ' ')); p.appendChild(document.createTextNode(x.body + (stale(x) ? ' (earlier version)' : ''))); box.appendChild(p); }
|
|
677
|
-
body.appendChild(box);
|
|
678
|
-
}
|
|
679
|
-
if (c.state === 'generated' || c.state === 'in_review') {
|
|
680
|
-
const a = el('div', 'actions');
|
|
681
|
-
a.appendChild(btn('Approve', 'primary', () => whyPanel(card, c, 'approved', 'Why this one? (kept on the directions it replaces)')));
|
|
682
|
-
a.appendChild(btn('Reject', null, () => whyPanel(card, c, 'rejected', 'Why not?')));
|
|
683
|
-
if (c.state === 'generated') a.appendChild(btn('In review', 'quiet', () => sendCand(card, c, { state: 'in_review' })));
|
|
684
|
-
body.appendChild(a);
|
|
685
|
-
}
|
|
686
|
-
grid.appendChild(body);
|
|
687
|
-
const shot = el('div', 'shot');
|
|
688
|
-
if (c.snapshotUrl) { const img = el('img'); img.src = c.snapshotUrl; img.alt = c.name; shot.appendChild(img); shot.onclick = () => zoom(c.snapshotUrl); }
|
|
689
|
-
else { shot.textContent = 'No picture'; shot.style.cursor = 'default'; shot.title = `npx arbiter candidate ${c.id} --snapshot shot.png`; }
|
|
690
|
-
grid.appendChild(shot);
|
|
691
|
-
card.appendChild(grid);
|
|
692
|
-
return card;
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
function whyPanel(card, c, newState, prompt) {
|
|
696
|
-
clearPanel(card);
|
|
697
|
-
const p = el('div', 'panel');
|
|
698
|
-
p.appendChild(el('p', null, prompt));
|
|
699
|
-
const ta = el('textarea'); ta.placeholder = 'One line'; p.appendChild(ta);
|
|
700
|
-
const row = el('div', 'actions');
|
|
701
|
-
row.appendChild(btn(newState === 'approved' ? 'Approve' : 'Reject', 'primary', () => sendCand(card, c, { state: newState, why: ta.value.trim() || undefined })));
|
|
702
|
-
row.appendChild(btn('Cancel', 'quiet', () => clearPanel(card)));
|
|
703
|
-
p.appendChild(row);
|
|
704
|
-
card.appendChild(p); ta.focus();
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
async function sendCand(card, c, body) {
|
|
708
|
-
card.querySelectorAll('button').forEach(b => b.disabled = true);
|
|
709
|
-
const res = await (await fetch('/api/candidate', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ id: c.id, ...body }) })).json();
|
|
710
|
-
card.querySelectorAll('button').forEach(b => b.disabled = false);
|
|
711
|
-
if (res.exitCode !== 0) return messagePanel(card, (res.errors || ['Something went wrong']).join(' · '), 'bad');
|
|
712
|
-
await load();
|
|
713
|
-
}
|
|
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
|
-
|
|
749
|
-
document.getElementById('done').onclick = async () => {
|
|
750
|
-
await fetch('/api/done', { method: 'POST', headers: { 'content-type': 'application/json' }, body: '{}' });
|
|
751
|
-
document.body.innerHTML = '<div class="empty"><h2>Review closed.</h2><p>You can close this tab.</p></div>';
|
|
752
|
-
};
|
|
753
|
-
|
|
754
|
-
load();
|
|
755
|
-
</script>
|
|
756
|
-
</body>
|
|
757
|
-
</html>
|