hivedesk 1.0.0 → 1.0.2
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/CHANGELOG.md +143 -111
- package/README.md +307 -303
- package/desktop/controller.js +85 -7
- package/desktop/native.js +4 -1
- package/desktop/release-notes/1.0.1.json +12 -0
- package/desktop/release-notes/1.0.2.json +12 -0
- package/desktop/scripts/package.mjs +11 -0
- package/desktop/shell.html +5 -2
- package/desktop/workarea.js +440 -0
- package/i18n/README.pt-BR.md +308 -304
- package/i18n/de.json +247 -4
- package/i18n/en.json +247 -4
- package/i18n/es.json +247 -4
- package/i18n/fr.json +247 -4
- package/i18n/it.json +247 -4
- package/i18n/ja.json +247 -4
- package/i18n/ko.json +247 -4
- package/i18n/parts/downloads.de.json +29 -0
- package/i18n/parts/downloads.en.json +29 -0
- package/i18n/parts/downloads.es.json +29 -0
- package/i18n/parts/downloads.fr.json +29 -0
- package/i18n/parts/downloads.it.json +29 -0
- package/i18n/parts/downloads.ja.json +29 -0
- package/i18n/parts/downloads.ko.json +29 -0
- package/i18n/parts/downloads.pt-BR.json +29 -0
- package/i18n/parts/downloads.ru.json +29 -0
- package/i18n/parts/downloads.zh-CN.json +29 -0
- package/i18n/parts/office.de.json +184 -0
- package/i18n/parts/office.en.json +184 -0
- package/i18n/parts/office.es.json +184 -0
- package/i18n/parts/office.fr.json +184 -0
- package/i18n/parts/office.it.json +184 -0
- package/i18n/parts/office.ja.json +184 -0
- package/i18n/parts/office.ko.json +184 -0
- package/i18n/parts/office.pt-BR.json +184 -0
- package/i18n/parts/office.ru.json +184 -0
- package/i18n/parts/office.zh-CN.json +184 -0
- package/i18n/pt-BR.json +247 -4
- package/i18n/ru.json +247 -4
- package/i18n/zh-CN.json +247 -4
- package/package.json +3 -2
- package/src/brain/manager.js +23 -7
- package/src/brain/models.js +146 -30
- package/src/brain/runtime.js +61 -13
- package/src/crew/domains/flow.js +2 -1
- package/src/crew/engine.js +172 -22
- package/src/crew/legacy.js +72 -0
- package/src/crew/planner.js +14 -1
- package/src/crew/talk.js +110 -3
- package/src/crew/taskgraph.js +12 -2
- package/src/crew/worker.js +60 -2
- package/src/index.js +4 -1
- package/src/p2p/doctor.js +4 -1
- package/src/phone/hub.js +15 -3
- package/src/phone/port.js +1 -1
- package/src/replay/reduce.js +1 -0
- package/src/tools/check.js +2 -0
- package/src/voice/index.js +1 -1
- package/src/voice/piper.js +10 -4
- package/src/voice/store.js +2 -1
- package/src/voice/whisper.js +63 -25
- package/ui/city/activity.js +4 -1
- package/ui/city/city.js +5 -5
- package/ui/city/scene.js +2 -1
- package/ui/css/hive.css +20 -0
- package/ui/js/dock.js +2 -2
- package/ui/js/dom.js +23 -18
- package/ui/js/i18n.js +12 -0
- package/ui/js/main.js +43 -3
- package/ui/js/md.js +130 -0
- package/ui/js/net.js +6 -0
- package/ui/js/palette.js +2 -2
- package/ui/js/store.js +20 -2
- package/ui/js/topbar.js +2 -2
- package/ui/js/voice/index.js +3 -2
- package/ui/js/widgets/brief.js +28 -10
- package/ui/js/widgets/chat.js +16 -4
- package/ui/js/widgets/files.js +3 -3
- package/ui/js/widgets/memory.js +3 -3
- package/ui/js/widgets/replay.js +3 -3
- package/ui/js/widgets/settings.js +2 -2
- package/ui/js/widgets/timeline.js +2 -2
- package/ui/js/widgets/worker.js +17 -6
- package/ui/models/index.js +3 -2
- package/ui/models/window.js +2 -2
- package/ui/office/office.js +145 -106
- package/ui/office/popout.js +4 -3
- package/ui/office/scene.js +47 -28
- package/ui/phone/core/client.js +11 -5
- package/ui/phone/desktop.js +2 -1
- package/ui/widget.html +8 -8
- package/ui/widget.js +35 -20
- package/ui/workbench/searchview.js +3 -3
package/ui/office/scene.js
CHANGED
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
import { beeSvg } from '/js/bees.js';
|
|
8
8
|
import { hub } from '/city/hub.js';
|
|
9
9
|
import { artTokens, worldPalette, statusColor, tone, mixHex, alpha, shade, rgb } from '/js/art.js';
|
|
10
|
+
import { t, L } from '/js/i18n.js';
|
|
11
|
+
import { roleName } from '/js/store.js';
|
|
12
|
+
import { mdLine } from '/js/md.js';
|
|
10
13
|
|
|
11
14
|
const FONT = '"Inter","Segoe UI Variable Text","Segoe UI",system-ui,-apple-system,sans-serif';
|
|
12
15
|
const MONO = '"JetBrains Mono","Cascadia Mono","Cascadia Code",ui-monospace,Consolas,monospace';
|
|
@@ -26,7 +29,7 @@ const MEL_HOME = { x: 4.05, y: 1.35, z: 1.5 };
|
|
|
26
29
|
const DOOR = { x: 12.45, y: 0.35, z: 1.0 };
|
|
27
30
|
const BOARD = { u0: 0.9, u1: 6.9, t0: 0.2, t1: 2.32 };
|
|
28
31
|
const NOTE_H = 0.3;
|
|
29
|
-
const COLS = ['
|
|
32
|
+
const COLS = ['todo', 'doing', 'done']; // office.board.*
|
|
30
33
|
const COL_OF = { pending: 0, ready: 0, blocked: 0, running: 1, review: 1, failed: 1, done: 2, skipped: 2 };
|
|
31
34
|
const ACTIVE = new Set(['refining', 'awaiting_brief', 'planning', 'running']);
|
|
32
35
|
|
|
@@ -36,7 +39,27 @@ const lerp = (a, b, t) => a + (b - a) * t;
|
|
|
36
39
|
const easeInOut = (t) => (t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2);
|
|
37
40
|
const easeOut = (t) => 1 - Math.pow(1 - t, 3);
|
|
38
41
|
const rnd = (a, b) => a + Math.random() * (b - a);
|
|
39
|
-
|
|
42
|
+
|
|
43
|
+
/* ---------- texts ---------- */
|
|
44
|
+
// Fixed texts drawn every frame: read once per language, then from the cache.
|
|
45
|
+
const txCache = new Map();
|
|
46
|
+
let txV = -1;
|
|
47
|
+
function tc(key) {
|
|
48
|
+
if (L.v !== txV) { txCache.clear(); txV = L.v; }
|
|
49
|
+
let v = txCache.get(key);
|
|
50
|
+
if (v === undefined) { v = t(key); txCache.set(key, v); }
|
|
51
|
+
return v;
|
|
52
|
+
}
|
|
53
|
+
/** A task title as plain text for the canvas (markdown marks gone), cached since it is drawn every frame. */
|
|
54
|
+
const plainCache = new Map();
|
|
55
|
+
function plain(text, max = 0) {
|
|
56
|
+
const k = `${max}|${text}`;
|
|
57
|
+
let v = plainCache.get(k);
|
|
58
|
+
if (v === undefined) { v = mdLine(text, max); if (plainCache.size > 400) plainCache.clear(); plainCache.set(k, v); }
|
|
59
|
+
return v;
|
|
60
|
+
}
|
|
61
|
+
/** One of Mel's lines, in the current language: office.bubble.<base>1..n */
|
|
62
|
+
const melLine = (base, n) => t(`office.bubble.${base}${1 + ((Math.random() * n) | 0)}`);
|
|
40
63
|
|
|
41
64
|
/* ---------- day and night ---------- */
|
|
42
65
|
/** 0 at noon, 1 at night. */
|
|
@@ -51,11 +74,11 @@ function goldenFactor(h) {
|
|
|
51
74
|
return clamp(1 - d / 1.6);
|
|
52
75
|
}
|
|
53
76
|
export function dayPhase(h) {
|
|
54
|
-
if (h >= 5 && h < 8) return '
|
|
55
|
-
if (h >= 8 && h < 12) return '
|
|
56
|
-
if (h >= 12 && h < 17) return '
|
|
57
|
-
if (h >= 17 && h < 20) return '
|
|
58
|
-
return '
|
|
77
|
+
if (h >= 5 && h < 8) return t('office.shift.morning');
|
|
78
|
+
if (h >= 8 && h < 12) return t('office.shift.day');
|
|
79
|
+
if (h >= 12 && h < 17) return t('office.shift.afternoon');
|
|
80
|
+
if (h >= 17 && h < 20) return t('office.shift.evening');
|
|
81
|
+
return t('office.shift.night');
|
|
59
82
|
}
|
|
60
83
|
|
|
61
84
|
export class OfficeScene {
|
|
@@ -233,7 +256,7 @@ export class OfficeScene {
|
|
|
233
256
|
this.briefWrite = null;
|
|
234
257
|
this.briefWait = ev.jobId || true;
|
|
235
258
|
const mel = this.actors.get('mel');
|
|
236
|
-
if (mel) { mel.bubble = { text: '
|
|
259
|
+
if (mel) { mel.bubble = { text: t('office.bubble.briefReady'), at: this.now, until: this.now + 6 }; this.sound('stuck'); }
|
|
237
260
|
break;
|
|
238
261
|
}
|
|
239
262
|
case 'brief.approved': {
|
|
@@ -246,7 +269,7 @@ export class OfficeScene {
|
|
|
246
269
|
case 'job.planning': {
|
|
247
270
|
this.briefWait = null; this.briefWrite = null;
|
|
248
271
|
const mel = this.actors.get('mel');
|
|
249
|
-
if (mel) mel.bubble = { text: '
|
|
272
|
+
if (mel) mel.bubble = { text: t('office.bubble.planning'), at: this.now, until: this.now + 2.5 };
|
|
250
273
|
break;
|
|
251
274
|
}
|
|
252
275
|
case 'job.planned':
|
|
@@ -365,9 +388,9 @@ export class OfficeScene {
|
|
|
365
388
|
const mel = this.actors.get('mel');
|
|
366
389
|
if (!mel) return;
|
|
367
390
|
mel.react = { kind, at: this.now };
|
|
368
|
-
if (kind === 'nod') mel.bubble = { text:
|
|
369
|
-
if (kind === 'curious') mel.bubble = { text:
|
|
370
|
-
if (kind === 'shake') mel.bubble = { text: '
|
|
391
|
+
if (kind === 'nod') mel.bubble = { text: melLine('nod', 3), at: this.now, until: this.now + 2.6 };
|
|
392
|
+
if (kind === 'curious') mel.bubble = { text: melLine('curious', 2), at: this.now, until: this.now + 2.8 };
|
|
393
|
+
if (kind === 'shake') mel.bubble = { text: t('office.bubble.skip'), at: this.now, until: this.now + 2.6 };
|
|
371
394
|
mel.idleSince = this.now;
|
|
372
395
|
}
|
|
373
396
|
|
|
@@ -530,10 +553,8 @@ export class OfficeScene {
|
|
|
530
553
|
if (mel && !jobRunning && !this.mini && !mel.seg && !mel.bubble) {
|
|
531
554
|
if (!this.nextIdleTalk) this.nextIdleTalk = now + 6;
|
|
532
555
|
if (now > this.nextIdleTalk) {
|
|
533
|
-
const
|
|
534
|
-
|
|
535
|
-
: ['Type a request in the box above.', 'The crew is ready when you are.', 'A landing page or a small app: just ask.'];
|
|
536
|
-
mel.bubble = { text: pick(lines), at: now, until: now + 4 };
|
|
556
|
+
const said = (s.jobs || []).length ? melLine('idleDone', 3) : melLine('idleNew', 3);
|
|
557
|
+
mel.bubble = { text: said, at: now, until: now + 4 };
|
|
537
558
|
mel.idleSince = now;
|
|
538
559
|
this.nextIdleTalk = now + rnd(28, 40);
|
|
539
560
|
}
|
|
@@ -906,7 +927,7 @@ export class OfficeScene {
|
|
|
906
927
|
ctx.fillStyle = T.ok; ctx.fillRect(u0, t0, 0.03, t1 - t0);
|
|
907
928
|
this.rightT(100);
|
|
908
929
|
ctx.fillStyle = alpha(T.text, 0.5); ctx.font = `600 11px ${FONT}`;
|
|
909
|
-
ctx.fillText('
|
|
930
|
+
ctx.fillText(tc('office.board.tasksDone').toLocaleUpperCase(), (u0 + 0.14) * 100, (t0 + 0.24) * 100);
|
|
910
931
|
ctx.fillStyle = T.text; ctx.font = `600 40px ${MONO}`;
|
|
911
932
|
ctx.fillText(String(done), (u0 + 0.12) * 100, (t1 - 0.18) * 100);
|
|
912
933
|
this.base();
|
|
@@ -938,7 +959,7 @@ export class OfficeScene {
|
|
|
938
959
|
ctx.fillStyle = [T.muted, T.accent, T.ok][c];
|
|
939
960
|
ctx.fillRect(x, (t0 + 0.2) * 100 - 4, 8, 8);
|
|
940
961
|
ctx.fillStyle = alpha(T.text, 0.7);
|
|
941
|
-
ctx.fillText(name.
|
|
962
|
+
ctx.fillText(tc(`office.board.${name}`).toLocaleUpperCase(), x + 14, (t0 + 0.2) * 100);
|
|
942
963
|
ctx.fillStyle = alpha(T.text, 0.4);
|
|
943
964
|
ctx.font = `500 ${this.mini ? 18 : 13}px ${MONO}`;
|
|
944
965
|
ctx.textAlign = 'right';
|
|
@@ -954,9 +975,9 @@ export class OfficeScene {
|
|
|
954
975
|
const cu = (u0 + u1) / 2; const ct = (t0 + t1) / 2 + 0.15;
|
|
955
976
|
ctx.textAlign = 'center';
|
|
956
977
|
ctx.fillStyle = alpha(T.text, 0.62); ctx.font = `600 17px ${FONT}`;
|
|
957
|
-
ctx.fillText('
|
|
978
|
+
ctx.fillText(tc('office.board.empty'), cu * 100, (ct - 0.06) * 100);
|
|
958
979
|
ctx.fillStyle = alpha(T.text, 0.38); ctx.font = `400 13px ${FONT}`;
|
|
959
|
-
ctx.fillText('
|
|
980
|
+
ctx.fillText(tc('office.board.emptyHint'), cu * 100, (ct + 0.16) * 100);
|
|
960
981
|
ctx.textAlign = 'left';
|
|
961
982
|
}
|
|
962
983
|
// the notes
|
|
@@ -991,7 +1012,7 @@ export class OfficeScene {
|
|
|
991
1012
|
ctx.fillStyle = t.status === 'done' ? alpha(T.text, 0.6) : T.text;
|
|
992
1013
|
ctx.font = `500 14px ${FONT}`;
|
|
993
1014
|
const right = t.status === 'done' || failed ? 0.2 : 0.06;
|
|
994
|
-
const line = wrap(ctx, t.title || '', (w - 0.14 - right) * 100, 1)[0] || '';
|
|
1015
|
+
const line = wrap(ctx, plain(t.title || ''), (w - 0.14 - right) * 100, 1)[0] || '';
|
|
995
1016
|
ctx.fillText(line, (-w / 2 + 0.09) * 100, 0.05 * 100);
|
|
996
1017
|
if (t.status === 'done') { ctx.strokeStyle = T.ok; ctx.lineWidth = 2.4; ctx.lineCap = 'round'; ctx.beginPath(); ctx.moveTo((w / 2 - 0.17) * 100, 0); ctx.lineTo((w / 2 - 0.13) * 100, 4); ctx.lineTo((w / 2 - 0.06) * 100, -4); ctx.stroke(); ctx.lineCap = 'butt'; }
|
|
997
1018
|
if (failed) { ctx.fillStyle = T.bad; ctx.font = `700 15px ${FONT}`; ctx.fillText('!', (w / 2 - 0.11) * 100, 0.06 * 100); }
|
|
@@ -1229,7 +1250,7 @@ export class OfficeScene {
|
|
|
1229
1250
|
const on = this.highlight === a.id;
|
|
1230
1251
|
const t = a.taskId && s.tasks?.[a.taskId];
|
|
1231
1252
|
drawNameTag(ctx, at[0], at[1] + 6, a.w.name, levelOf(s, a.id), a.w.color, on, Math.max(10.5, Math.min(12, this.a * 0.2)),
|
|
1232
|
-
{ status: statusColor(a.seg ? 'idle' : a.mode, T), role: a.w
|
|
1253
|
+
{ status: statusColor(a.seg ? 'idle' : a.mode, T), role: roleName(a.w), task: plain(t?.title || '', 80) });
|
|
1233
1254
|
}
|
|
1234
1255
|
}
|
|
1235
1256
|
for (const a of this.actors.values()) {
|
|
@@ -1238,7 +1259,7 @@ export class OfficeScene {
|
|
|
1238
1259
|
ctx.globalAlpha = a.alpha;
|
|
1239
1260
|
if (m === 'stuck' && !this.mini) {
|
|
1240
1261
|
// waiting for the user: a calm warn chip over the unit
|
|
1241
|
-
drawPill(ctx, a.sx, headY - 4, a.isMel ? '
|
|
1262
|
+
drawPill(ctx, a.sx, headY - 4, a.isMel ? tc('office.pill.brief') : tc('office.pill.ok'), T.warn, Math.max(10.5, Math.min(12, this.a * 0.19)));
|
|
1242
1263
|
} else if (m === 'error') iconBang(ctx, a.sx + 20 * k, headY + 6 * k, Math.max(12, Math.min(18, this.a * 0.3)));
|
|
1243
1264
|
if (a.badge) {
|
|
1244
1265
|
const age = now - a.badge.at;
|
|
@@ -1309,11 +1330,9 @@ export function doneCount(s) {
|
|
|
1309
1330
|
return n;
|
|
1310
1331
|
}
|
|
1311
1332
|
|
|
1333
|
+
/** A chat line as a plain bubble: markdown gone, one line, cut at 88 characters. */
|
|
1312
1334
|
function cleanText(text) {
|
|
1313
|
-
|
|
1314
|
-
t = t.replace(/^Plan: /, '');
|
|
1315
|
-
if (t.length > 88) t = `${t.slice(0, 85).replace(/\s+\S*$/, '')}...`;
|
|
1316
|
-
return t;
|
|
1335
|
+
return mdLine(String(text || '').trim().replace(/^Plan: /, ''), 88);
|
|
1317
1336
|
}
|
|
1318
1337
|
|
|
1319
1338
|
function wrap(ctx, text, maxW, maxLines) {
|
|
@@ -1372,7 +1391,7 @@ function hexScreen(ctx, cx, cy, r) {
|
|
|
1372
1391
|
*/
|
|
1373
1392
|
function drawNameTag(ctx, x, y, name, level, color, on, fs, more) {
|
|
1374
1393
|
const T = artTokens();
|
|
1375
|
-
const lv = level != null ?
|
|
1394
|
+
const lv = level != null ? t('office.level', { level }) : '';
|
|
1376
1395
|
ctx.font = `600 ${fs}px ${FONT}`;
|
|
1377
1396
|
const nw = ctx.measureText(name).width;
|
|
1378
1397
|
ctx.font = `500 ${fs * 0.82}px ${MONO}`;
|
package/ui/phone/core/client.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// 'state' (snapshot), 'feed' (items), 'notice' (body), 'grants' (list), 'remote' (msg), 'close' (reason)
|
|
8
8
|
|
|
9
9
|
import { Emitter } from '../../lend/core/emitter.js';
|
|
10
|
-
import { PairGuest, KnownGuest, PhoneHandshakeError, failMessage, parseHs } from './handshake.js';
|
|
10
|
+
import { PairGuest, KnownGuest, PhoneHandshakeError, failMessage, parseHs, cleanName } from './handshake.js';
|
|
11
11
|
import { FrameSession } from './session.js';
|
|
12
12
|
|
|
13
13
|
export const PING_MS = 10_000;
|
|
@@ -15,6 +15,12 @@ export const SILENCE_MS = 35_000;
|
|
|
15
15
|
export const CMD_TIMEOUT_MS = 20_000;
|
|
16
16
|
const HS_MS = 20_000;
|
|
17
17
|
|
|
18
|
+
/** The computer as the desktop names it, never without a printable name. */
|
|
19
|
+
const hostOf = (v) => {
|
|
20
|
+
const o = v && typeof v === 'object' ? v : {};
|
|
21
|
+
return { ...o, name: cleanName(o.name, 'hivedesk') };
|
|
22
|
+
};
|
|
23
|
+
|
|
18
24
|
/** Turns a link's callbacks into "wait for the next text". */
|
|
19
25
|
class Inbox {
|
|
20
26
|
constructor(link) {
|
|
@@ -150,8 +156,8 @@ export class PhoneClient extends Emitter {
|
|
|
150
156
|
this.accepted = true;
|
|
151
157
|
this.grants = Array.isArray(m.body.grants) ? m.body.grants.map(String) : [];
|
|
152
158
|
this.deviceId = typeof m.body.deviceId === 'string' ? m.body.deviceId : this.deviceId;
|
|
153
|
-
this._decide?.({ accepted: true, grants: this.grants, host: m.body.host });
|
|
154
|
-
this.emit('paired', { deviceId: this.deviceId, grants: this.grants, host: m.body.host });
|
|
159
|
+
this._decide?.({ accepted: true, grants: this.grants, host: hostOf(m.body.host) });
|
|
160
|
+
this.emit('paired', { deviceId: this.deviceId, grants: this.grants, host: hostOf(m.body.host) });
|
|
155
161
|
return undefined;
|
|
156
162
|
case 'pair.refuse':
|
|
157
163
|
this._decide?.({ accepted: false, reason: m.body.reason });
|
|
@@ -160,8 +166,8 @@ export class PhoneClient extends Emitter {
|
|
|
160
166
|
case 'welcome':
|
|
161
167
|
this.accepted = true;
|
|
162
168
|
this.grants = Array.isArray(m.body.grants) ? m.body.grants.map(String) : [];
|
|
163
|
-
this.welcome = m.body;
|
|
164
|
-
return this.emit('welcome',
|
|
169
|
+
this.welcome = { ...m.body, name: cleanName(m.body.name), host: hostOf(m.body.host) };
|
|
170
|
+
return this.emit('welcome', this.welcome);
|
|
165
171
|
case 'grants':
|
|
166
172
|
this.grants = Array.isArray(m.body.grants) ? m.body.grants.map(String) : [];
|
|
167
173
|
return this.emit('grants', this.grants);
|
package/ui/phone/desktop.js
CHANGED
|
@@ -201,7 +201,8 @@ wm.register('phone', {
|
|
|
201
201
|
const phones = s.phones || [];
|
|
202
202
|
list.replaceChildren(
|
|
203
203
|
h('h3', { class: 'ph-h', text: tr('phone.list.title') }),
|
|
204
|
-
|
|
204
|
+
// No null here: replaceChildren would show it as the text "null" above the first phone.
|
|
205
|
+
...(phones.length ? [] : [h('div', { class: 'small muted', text: tr('phone.list.empty') })]),
|
|
205
206
|
...phones.map((p) => h('div', { class: 'ph-item', attrs: { 'data-device': p.deviceId } },
|
|
206
207
|
h('div', { class: 'ph-item-h' },
|
|
207
208
|
h('span', { class: `ph-dot ${p.online ? 'on' : ''}`, 'aria-hidden': 'true' }),
|
package/ui/widget.html
CHANGED
|
@@ -14,22 +14,22 @@
|
|
|
14
14
|
<script type="module" src="/widget.js"></script>
|
|
15
15
|
</head>
|
|
16
16
|
<body>
|
|
17
|
-
<main class="wg" aria-label="hivedesk mini widget">
|
|
17
|
+
<main class="wg" aria-label="hivedesk mini widget" data-ta="office.widget.aria">
|
|
18
18
|
<header class="wg-top">
|
|
19
19
|
<span class="wg-brand"><svg viewBox="0 0 64 64" aria-hidden="true"><defs><clipPath id="wg-c"><path d="M32 4 56.2 18v28L32 60 7.8 46V18z"/></clipPath></defs><path d="M32 4 56.2 18v28L32 60 7.8 46V18z" fill="#F2A93B"/><g clip-path="url(#wg-c)" fill="#14171B"><rect x="0" y="24.5" width="64" height="5.5"/><rect x="0" y="36" width="64" height="5.5"/></g></svg>hivedesk</span>
|
|
20
|
-
<span class="wg-demo" hidden title="No model is running. The crew follows a script.">Demo</span>
|
|
20
|
+
<span class="wg-demo" hidden title="No model is running. The crew follows a script." data-tx="office.widget.demo">Demo</span>
|
|
21
21
|
<span class="wg-conn" role="status" aria-live="polite"></span>
|
|
22
|
-
<button type="button" class="wg-ib wg-open" title="Open the full Hive" aria-label="Open the full Hive"><svg viewBox="0 0 24 24"><path d="M14 4h6v6M20 4l-8 8M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5"/></svg></button>
|
|
22
|
+
<button type="button" class="wg-ib wg-open" title="Open the full Hive" aria-label="Open the full Hive" data-ta="office.widget.open"><svg viewBox="0 0 24 24"><path d="M14 4h6v6M20 4l-8 8M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5"/></svg></button>
|
|
23
23
|
</header>
|
|
24
24
|
<div class="wg-stage"><canvas class="wg-canvas" aria-hidden="true"></canvas></div>
|
|
25
|
-
<section class="wg-job" aria-label="Current job">
|
|
25
|
+
<section class="wg-job" aria-label="Current job" data-ta="office.hud.currentJob">
|
|
26
26
|
<div class="wg-req">Connecting...</div>
|
|
27
|
-
<div class="wg-bar" role="progressbar" aria-label="Job progress" aria-valuemin="0" aria-valuemax="100"><i></i></div>
|
|
27
|
+
<div class="wg-bar" role="progressbar" aria-label="Job progress" data-ta="office.hud.progress" aria-valuemin="0" aria-valuemax="100"><i></i></div>
|
|
28
28
|
<div class="wg-sub"></div>
|
|
29
29
|
</section>
|
|
30
|
-
<section class="wg-queue" aria-label="Queue for the model"></section>
|
|
31
|
-
<section class="wg-chat" aria-label="Latest chat line" aria-live="polite"></section>
|
|
32
|
-
<section class="wg-appr" aria-label="Approval" hidden></section>
|
|
30
|
+
<section class="wg-queue" aria-label="Queue for the model" data-ta="office.widget.queueAria"></section>
|
|
31
|
+
<section class="wg-chat" aria-label="Latest chat line" data-ta="office.widget.chatAria" aria-live="polite"></section>
|
|
32
|
+
<section class="wg-appr" aria-label="Approval" data-ta="office.widget.approvalAria" hidden></section>
|
|
33
33
|
<footer class="wg-actions">
|
|
34
34
|
<button type="button" class="wg-btn wg-approve" disabled>Approve</button>
|
|
35
35
|
<button type="button" class="wg-btn wg-pause">Pause crew</button>
|
package/ui/widget.js
CHANGED
|
@@ -7,6 +7,8 @@ import { S, rev, ui, worker, loadHello, applyEvent, applyLive, onEvent, currentJ
|
|
|
7
7
|
import { beeAvatar } from '/js/bees.js';
|
|
8
8
|
import { reducedMotion } from '/js/dom.js';
|
|
9
9
|
import { OfficeScene, doneCount } from '/office/scene.js';
|
|
10
|
+
import { t, init as initI18n, onLocale } from '/js/i18n.js';
|
|
11
|
+
import { mdLine } from '/js/md.js';
|
|
10
12
|
|
|
11
13
|
const V = window.V;
|
|
12
14
|
const $ = (sel) => document.querySelector(sel);
|
|
@@ -29,10 +31,21 @@ function node(tag, props = {}, ...kids) {
|
|
|
29
31
|
const scene = new OfficeScene(el.canvas, { getState: S, mini: true, reduced: reducedMotion });
|
|
30
32
|
new ResizeObserver(() => scene.resize(el.stage.clientWidth, el.stage.clientHeight)).observe(el.stage);
|
|
31
33
|
|
|
34
|
+
// The strings live in i18n/<locale>.json: load them before the first paint.
|
|
35
|
+
try { await initI18n(document.documentElement.dataset.osLocale); } catch { /* the keys stay as they are */ }
|
|
36
|
+
|
|
37
|
+
const CONN = ['open', 'unauthorized', 'offline'];
|
|
32
38
|
function connPaint(c) {
|
|
33
39
|
el.conn.dataset.s = c.state;
|
|
34
|
-
el.conn.textContent =
|
|
40
|
+
el.conn.textContent = t(`office.widget.conn.${CONN.includes(c.state) ? c.state : 'connecting'}`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Titles the HTML cannot translate by itself (data-tx and data-ta cover the rest). */
|
|
44
|
+
function paintStatic() {
|
|
45
|
+
el.demo.title = t('office.widget.demoTitle');
|
|
46
|
+
el.open.title = t('office.widget.open');
|
|
35
47
|
}
|
|
48
|
+
const SUB = ['refining', 'awaiting_brief', 'planning', 'done', 'failed'];
|
|
36
49
|
|
|
37
50
|
function paint() {
|
|
38
51
|
const s = S();
|
|
@@ -41,31 +54,32 @@ function paint() {
|
|
|
41
54
|
const j = [...(s.jobs || [])].reverse().find((x) => ['refining', 'awaiting_brief', 'planning', 'running'].includes(x.status)) || currentJob(s);
|
|
42
55
|
if (j) {
|
|
43
56
|
const tasks = jobTasks(s, j);
|
|
44
|
-
const done = tasks.filter((
|
|
45
|
-
const running = tasks.filter((
|
|
57
|
+
const done = tasks.filter((x) => x.status === 'done' || x.status === 'skipped').length;
|
|
58
|
+
const running = tasks.filter((x) => x.status === 'running').length;
|
|
46
59
|
const pct = j.status === 'done' ? 100 : tasks.length ? Math.round(((done + running * 0.4) / tasks.length) * 100) : 4;
|
|
47
60
|
el.req.textContent = j.request;
|
|
48
61
|
el.req.title = j.request;
|
|
49
62
|
el.fill.style.width = `${pct}%`;
|
|
50
63
|
el.bar.setAttribute('aria-valuenow', String(pct));
|
|
51
64
|
el.sub.replaceChildren(
|
|
52
|
-
node('span', { text: j.status
|
|
53
|
-
node('span', { class: 'wg-honey', text:
|
|
65
|
+
node('span', { text: SUB.includes(j.status) ? t(`office.widget.sub.${j.status}`) : t('office.widget.progress', { done, total: tasks.length }) }),
|
|
66
|
+
node('span', { class: 'wg-honey', text: t('office.widget.tasksDone', { count: doneCount(s) }) }));
|
|
54
67
|
} else {
|
|
55
|
-
el.req.textContent = ui.hello ? '
|
|
68
|
+
el.req.textContent = ui.hello ? t('office.widget.napping') : t('office.widget.connecting');
|
|
69
|
+
el.req.title = '';
|
|
56
70
|
el.fill.style.width = '0%';
|
|
57
|
-
el.sub.replaceChildren(node('span', { text: '
|
|
71
|
+
el.sub.replaceChildren(node('span', { text: t('office.widget.nappingHint') }), node('span', { class: 'wg-honey', text: t('office.widget.tasksDone', { count: doneCount(s) }) }));
|
|
58
72
|
}
|
|
59
73
|
// the queue for the one shared model
|
|
60
74
|
const run = s.queue.running || [];
|
|
61
75
|
const wait = s.queue.waiting || [];
|
|
62
|
-
const q = [node('span', { class: 'wg-k', text: '
|
|
76
|
+
const q = [node('span', { class: 'wg-k', text: t('office.widget.model') })];
|
|
63
77
|
if (run.length) {
|
|
64
78
|
for (const r of run) q.push(beeAvatar(worker(r.workerId), 26, { ring: true, status: 'thinking' }));
|
|
65
|
-
q.push(node('span', { class: 'grow', text: `${worker(run[0].workerId).name}: ${s.tasks[run[0].taskId]?.title || 'thinking'}` }));
|
|
66
|
-
} else q.push(node('span', { class: 'grow muted', text: 'free' }));
|
|
79
|
+
q.push(node('span', { class: 'grow', text: `${worker(run[0].workerId).name}: ${mdLine(s.tasks[run[0].taskId]?.title || '', 80) || t('office.widget.thinking')}` }));
|
|
80
|
+
} else q.push(node('span', { class: 'grow muted', text: t('office.widget.free') }));
|
|
67
81
|
if (wait.length) {
|
|
68
|
-
q.push(node('span', { class: 'wg-k', text: '
|
|
82
|
+
q.push(node('span', { class: 'wg-k', text: t('office.widget.queue') }));
|
|
69
83
|
for (const w of wait.slice(0, 4)) q.push(beeAvatar(worker(w.workerId), 22, { ring: true }));
|
|
70
84
|
}
|
|
71
85
|
el.queue.replaceChildren(...q);
|
|
@@ -79,20 +93,20 @@ function paint() {
|
|
|
79
93
|
break;
|
|
80
94
|
}
|
|
81
95
|
}
|
|
82
|
-
if (last) el.chat.replaceChildren(beeAvatar(worker(last.from), 26, { ring: true }), node('div', { class: 'txt' }, node('b', { text: worker(last.from).name }),
|
|
83
|
-
else el.chat.replaceChildren(node('span', { class: 'muted', text: '
|
|
96
|
+
if (last) el.chat.replaceChildren(beeAvatar(worker(last.from), 26, { ring: true }), node('div', { class: 'txt' }, node('b', { text: worker(last.from).name }), mdLine(last.text, 200)));
|
|
97
|
+
else el.chat.replaceChildren(node('span', { class: 'muted', text: t('office.widget.quiet') }));
|
|
84
98
|
// approval: a tool call, or Mel's brief for a new job
|
|
85
99
|
const a = (s.approvals || [])[0];
|
|
86
100
|
const brief = !a && ((s.jobs || []).find((x) => x.status === 'awaiting_brief') || (scene.briefWait && (s.jobs || []).find((x) => x.id === scene.briefWait)));
|
|
87
101
|
el.appr.hidden = !a && !brief;
|
|
88
|
-
if (a) el.appr.replaceChildren(node('b', { text: `${worker(a.workerId).name}
|
|
89
|
-
else if (brief) el.appr.replaceChildren(node('b', { text: '
|
|
102
|
+
if (a) el.appr.replaceChildren(node('b', { text: `${t('office.widget.needsApproval', { name: worker(a.workerId).name })} ` }), mdLine(a.summary || a.args?.command || a.args?.path || a.tool, 160));
|
|
103
|
+
else if (brief) el.appr.replaceChildren(node('b', { text: `${t('office.widget.briefBy')} ` }), t('office.widget.briefHint'));
|
|
90
104
|
el.approve.disabled = (!a && !brief) || !!ui.replay;
|
|
91
|
-
el.approve.textContent = (s.approvals || []).length > 1 ?
|
|
105
|
+
el.approve.textContent = (s.approvals || []).length > 1 ? t('office.widget.approveN', { count: s.approvals.length }) : t('office.widget.approve');
|
|
92
106
|
// pause
|
|
93
107
|
const crew = (s.crew || []).filter((w) => !w.paused);
|
|
94
108
|
const allPaused = (s.crew || []).length > 0 && !crew.length;
|
|
95
|
-
el.pause.textContent = allPaused ? '
|
|
109
|
+
el.pause.textContent = allPaused ? t('office.widget.resume') : t('office.widget.pause');
|
|
96
110
|
el.pause.setAttribute('aria-pressed', String(allPaused));
|
|
97
111
|
}
|
|
98
112
|
|
|
@@ -108,7 +122,7 @@ el.approve.addEventListener('click', async () => {
|
|
|
108
122
|
try {
|
|
109
123
|
if (a) await net.command('approval.resolve', { approvalId: a.id, approved: true });
|
|
110
124
|
else await net.command('brief.approve', { jobId: brief.id, use: 'refined' });
|
|
111
|
-
} catch (err) { el.appr.hidden = false; el.appr.textContent =
|
|
125
|
+
} catch (err) { el.appr.hidden = false; el.appr.textContent = t('office.widget.approveFailed', { error: err.message }); }
|
|
112
126
|
schedule();
|
|
113
127
|
});
|
|
114
128
|
|
|
@@ -118,7 +132,7 @@ el.pause.addEventListener('click', async () => {
|
|
|
118
132
|
el.pause.disabled = true;
|
|
119
133
|
try {
|
|
120
134
|
for (const w of s.crew) if (!!w.paused === allPaused) await net.command('crew.update', { workerId: w.id, paused: !allPaused });
|
|
121
|
-
} catch (err) { el.chat.textContent =
|
|
135
|
+
} catch (err) { el.chat.textContent = t(allPaused ? 'office.widget.resumeFailed' : 'office.widget.pauseFailed', { error: err.message }); }
|
|
122
136
|
el.pause.disabled = false;
|
|
123
137
|
schedule();
|
|
124
138
|
});
|
|
@@ -137,7 +151,8 @@ V.effect(() => { void [rev.jobs, rev.tasks, rev.queue, rev.chat, rev.approvals,
|
|
|
137
151
|
|
|
138
152
|
document.addEventListener('visibilitychange', () => { if (document.hidden) scene.stop(); else scene.start(); });
|
|
139
153
|
|
|
140
|
-
|
|
154
|
+
onLocale(() => { paintStatic(); connPaint(net.connection); schedule(); });
|
|
155
|
+
paintStatic();
|
|
141
156
|
connPaint(net.connection);
|
|
142
157
|
scene.resize(el.stage.clientWidth, el.stage.clientHeight);
|
|
143
158
|
scene.start();
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// (src/workbench/search.js) and streams results to this window; replace shows a preview of
|
|
3
3
|
// every changed line first and applies only the files you keep checked.
|
|
4
4
|
|
|
5
|
-
import { h, clear } from '/js/dom.js';
|
|
5
|
+
import { h, clear, append } from '/js/dom.js';
|
|
6
6
|
import { badgeOf } from '/editor/languages.js';
|
|
7
7
|
import { wb, onFrame } from './net.js';
|
|
8
8
|
import { tw } from './strings.js';
|
|
@@ -117,11 +117,11 @@ export function createSearch(ctx) {
|
|
|
117
117
|
if (st.searchId && !st.summary) summary.append(h('span', { class: 'wb-spin' }), h('span', { text: tw('wb.se.searching', { hits, files: files.length }) }));
|
|
118
118
|
else if (st.summary) {
|
|
119
119
|
const s = st.summary;
|
|
120
|
-
|
|
120
|
+
append(summary, [h('span', { text: s.hits ? tw('wb.se.found', { hits: s.hits, files: s.files }) : tw('wb.se.none') }),
|
|
121
121
|
s.truncated ? h('span', { class: 'wb-warn', text: tw('wb.se.truncated') }) : null,
|
|
122
122
|
s.timedOut ? h('span', { class: 'wb-warn', text: tw('wb.se.timedOut') }) : null,
|
|
123
123
|
s.skippedLarge ? h('span', { class: 'wb-faint', text: tw('wb.se.skipped', { n: s.skippedLarge }) }) : null,
|
|
124
|
-
h('span', { class: 'wb-faint', text: tw('wb.se.ms', { ms: Math.round(s.ms) }) }));
|
|
124
|
+
h('span', { class: 'wb-faint', text: tw('wb.se.ms', { ms: Math.round(s.ms) }) })]);
|
|
125
125
|
}
|
|
126
126
|
for (const path of files) {
|
|
127
127
|
const hs = st.results.get(path);
|