@skillcdn/console 0.6.1 → 0.6.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/README.md +2 -2
- package/dist/agent-page.d.ts.map +1 -1
- package/dist/agent-page.js +38 -28
- package/dist/agent-page.js.map +1 -1
- package/dist/agent-usage.d.ts +9 -6
- package/dist/agent-usage.d.ts.map +1 -1
- package/dist/agent-usage.js +38 -8
- package/dist/agent-usage.js.map +1 -1
- package/dist/api.d.ts +1 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +1 -1
- package/dist/api.js.map +1 -1
- package/dist/cli/cli.d.ts.map +1 -1
- package/dist/cli/cli.js +65 -0
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/help.js +3 -3
- package/dist/cli/help.js.map +1 -1
- package/dist/client.d.ts +7 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +2 -1
- package/dist/client.js.map +1 -1
- package/dist/components/agent-page.d.ts +33 -8
- package/dist/components/agent-page.d.ts.map +1 -1
- package/dist/components/agent-page.js +98 -32
- package/dist/components/agent-page.js.map +1 -1
- package/dist/components/calendar.d.ts +24 -4
- package/dist/components/calendar.d.ts.map +1 -1
- package/dist/components/calendar.js +78 -35
- package/dist/components/calendar.js.map +1 -1
- package/dist/console.d.ts.map +1 -1
- package/dist/console.js +39 -11
- package/dist/console.js.map +1 -1
- package/dist/data.d.ts +2 -0
- package/dist/data.d.ts.map +1 -1
- package/dist/data.js +4 -0
- package/dist/data.js.map +1 -1
- package/dist/desk-page.js +5 -5
- package/dist/desk-page.js.map +1 -1
- package/dist/feed-words.js +6 -0
- package/dist/feed-words.js.map +1 -1
- package/dist/i18n/en.d.ts +6 -0
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +8 -1
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/ko.d.ts.map +1 -1
- package/dist/i18n/ko.js +24 -17
- package/dist/i18n/ko.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/plugin/capabilities.d.ts +1 -1
- package/dist/plugin/capabilities.d.ts.map +1 -1
- package/dist/plugin/capabilities.js +6 -1
- package/dist/plugin/capabilities.js.map +1 -1
- package/dist/plugin/context.d.ts +62 -1
- package/dist/plugin/context.d.ts.map +1 -1
- package/dist/plugin/limits.d.ts +7 -0
- package/dist/plugin/limits.d.ts.map +1 -1
- package/dist/plugin/limits.js +7 -0
- package/dist/plugin/limits.js.map +1 -1
- package/dist/plugin/testing.d.ts +2 -0
- package/dist/plugin/testing.d.ts.map +1 -1
- package/dist/plugin/testing.js +2 -0
- package/dist/plugin/testing.js.map +1 -1
- package/dist/rules.js +1 -1
- package/dist/rules.js.map +1 -1
- package/dist/runner/claude.d.ts.map +1 -1
- package/dist/runner/claude.js +138 -9
- package/dist/runner/claude.js.map +1 -1
- package/dist/runner/desk.d.ts.map +1 -1
- package/dist/runner/desk.js +11 -4
- package/dist/runner/desk.js.map +1 -1
- package/dist/runner/message.d.ts +32 -2
- package/dist/runner/message.d.ts.map +1 -1
- package/dist/runner/message.js +163 -27
- package/dist/runner/message.js.map +1 -1
- package/dist/runner/runner.d.ts +15 -1
- package/dist/runner/runner.d.ts.map +1 -1
- package/dist/runner/runner.js +131 -15
- package/dist/runner/runner.js.map +1 -1
- package/dist/runner/slack.d.ts +17 -11
- package/dist/runner/slack.d.ts.map +1 -1
- package/dist/runner/slack.js +1007 -105
- package/dist/runner/slack.js.map +1 -1
- package/dist/runner/types.d.ts +110 -5
- package/dist/runner/types.d.ts.map +1 -1
- package/dist/runner/types.js.map +1 -1
- package/dist/runner.d.ts +4 -4
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +3 -3
- package/dist/runner.js.map +1 -1
- package/dist/schemas.d.ts +103 -0
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +55 -0
- package/dist/schemas.js.map +1 -1
- package/docs/specs/cli.md +2 -1
- package/docs/specs/plugins.md +7 -2
- package/docs/specs/rest.md +4 -2
- package/docs/specs/runner.md +50 -19
- package/package.json +1 -1
- package/skills/building-a-plugin/SKILL.md +3 -3
- package/skills/planning-the-board/references/setting-up.md +1 -1
- package/skills/running-an-agent/SKILL.md +10 -67
- package/skills/running-an-agent/references/preparing-the-machine.md +17 -0
- package/skills/running-an-agent/references/several-tasks.md +1 -1
- package/skills/running-an-agent/references/slack-app.md +36 -6
- package/skills/running-an-agent/references/the-account-and-the-invitation.md +5 -0
- package/skills/running-an-agent/references/what-was-not-seen-run-yet.md +3 -0
- package/skills/running-an-agent/references/when-the-agent-could-not-go-on.md +16 -0
- package/skills/running-an-agent/references/your-first-task.md +14 -0
- package/skills/working-the-board/SKILL.md +9 -13
- package/skills/working-the-board/references/a-pack-skills-questions.md +3 -0
- package/skills/working-the-board/references/a-plugins-commands.md +3 -0
- package/skills/working-the-board/references/a-review.md +3 -0
- package/skills/working-the-board/references/an-open-run.md +3 -0
- package/skills/working-the-board/references/requirements.md +7 -0
- package/skills/working-the-board/references/what-they-were-told.md +3 -0
- package/skills/working-the-board/references/work-given-in-chat.md +5 -0
- package/src/agent-page.tsx +41 -40
- package/src/agent-usage.ts +55 -12
- package/src/api.ts +7 -0
- package/src/cli/cli.ts +84 -0
- package/src/cli/help.ts +3 -3
- package/src/client.ts +11 -0
- package/src/components/agent-page.tsx +114 -36
- package/src/components/calendar.tsx +92 -36
- package/src/console.tsx +46 -10
- package/src/data.ts +6 -0
- package/src/desk-page.tsx +5 -5
- package/src/feed-words.ts +6 -0
- package/src/i18n/en.ts +11 -1
- package/src/i18n/ko.ts +30 -17
- package/src/index.ts +2 -0
- package/src/plugin/capabilities.ts +8 -1
- package/src/plugin/context.ts +63 -0
- package/src/plugin/limits.ts +7 -0
- package/src/plugin/testing.ts +4 -0
- package/src/rules.ts +1 -1
- package/src/runner/claude.ts +154 -9
- package/src/runner/desk.ts +13 -4
- package/src/runner/message.ts +176 -29
- package/src/runner/runner.ts +173 -15
- package/src/runner/slack.ts +1273 -124
- package/src/runner/types.ts +102 -2
- package/src/runner.ts +16 -1
- package/src/schemas.ts +64 -0
|
@@ -252,8 +252,16 @@ export type TalkItem =
|
|
|
252
252
|
* their parent, read as a conversation of their own. Nothing for a call that started none.
|
|
253
253
|
*/
|
|
254
254
|
readonly steps?: readonly TalkItem[] | undefined;
|
|
255
|
-
/**
|
|
255
|
+
/**
|
|
256
|
+
* When the turn or the session it ran in ended, where that came before its answer; for a
|
|
257
|
+
* sub-agent that goes on in the background, when its session ended before it did.
|
|
258
|
+
*/
|
|
256
259
|
readonly endedAt?: string | undefined;
|
|
260
|
+
/**
|
|
261
|
+
* The event of the sub-agent's that says it ended, and how (`over`, ADR-0161): the last
|
|
262
|
+
* of them, and none where the sub-agent did something after it, as one started again does.
|
|
263
|
+
*/
|
|
264
|
+
readonly over?: RestTranscriptEvent | undefined;
|
|
257
265
|
};
|
|
258
266
|
|
|
259
267
|
/** The most characters of a sub-agent's name that a label shows. */
|
|
@@ -291,8 +299,27 @@ const endsTurn = (event: RestTranscriptEvent): boolean =>
|
|
|
291
299
|
event.sealed === null &&
|
|
292
300
|
(event.data.turn === "completed" || typeof event.data.ended === "string");
|
|
293
301
|
|
|
302
|
+
/** Whether an event is a sub-agent's word that it ended: a runner writes how under `over` (ADR-0161). */
|
|
303
|
+
const saysOver = (event: RestTranscriptEvent): boolean =>
|
|
304
|
+
event.kind === "status" && typeof event.data.over === "string";
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* The kinds of event by which a sub-agent that ended is at work again: what it says, thinks and
|
|
308
|
+
* calls, and its own word that it was started again. A tool's answer is none: a product that
|
|
309
|
+
* stops a sub-agent in the middle of a call says first that it ended, and then what became of
|
|
310
|
+
* the call.
|
|
311
|
+
*/
|
|
312
|
+
const AT_WORK: ReadonlySet<string> = new Set(["assistant", "thinking", "tool_call", "status"]);
|
|
313
|
+
|
|
294
314
|
type ToolItem = Extract<TalkItem, { type: "tool" }>;
|
|
295
315
|
|
|
316
|
+
/**
|
|
317
|
+
* Whether a call was answered with the word that its sub-agent goes on in the background
|
|
318
|
+
* (`background` on its answer, ADR-0161): the answer is then not the sub-agent's, which goes on
|
|
319
|
+
* past it, and past the turn it was started in.
|
|
320
|
+
*/
|
|
321
|
+
const goesOn = (item: ToolItem): boolean => item.result?.data.background === true;
|
|
322
|
+
|
|
296
323
|
/** Things in the order they are read: the session's own, or one sub-agent's. */
|
|
297
324
|
type TalkLineOf = TalkItem[];
|
|
298
325
|
|
|
@@ -313,7 +340,9 @@ interface TalkPlace {
|
|
|
313
340
|
* not a thing of the line the call stands in. A call that says it starts a sub-agent (`starts`)
|
|
314
341
|
* has such a line from the first, empty; one a runner of before wrote has it from the first
|
|
315
342
|
* event that names it. An event that names a call the events do not hold stays where it stood.
|
|
316
|
-
* A turn or a session that ended ends every sub-agent still open in it
|
|
343
|
+
* A turn or a session that ended ends every sub-agent still open in it, but for one that goes on
|
|
344
|
+
* in the background (ADR-0161): its own line says when it ended, and nothing but its session's
|
|
345
|
+
* end ends it before.
|
|
317
346
|
*/
|
|
318
347
|
export function talkOf(events: readonly RestTranscriptEvent[]): TalkItem[] {
|
|
319
348
|
const top: TalkLineOf = [];
|
|
@@ -323,7 +352,7 @@ export function talkOf(events: readonly RestTranscriptEvent[]): TalkItem[] {
|
|
|
323
352
|
const calls = new Map<string, TalkPlace>();
|
|
324
353
|
/** The line of each sub-agent, by the id of the call that started it. */
|
|
325
354
|
const lines = new Map<string, TalkLineOf>();
|
|
326
|
-
/** The calls that started a sub-agent
|
|
355
|
+
/** The calls that started a sub-agent that nothing ended yet, as far as the events read say. */
|
|
327
356
|
let running: TalkPlace[] = [];
|
|
328
357
|
const toolAt = (place: TalkPlace | undefined): ToolItem | undefined => {
|
|
329
358
|
const item = place === undefined ? undefined : place.line[place.at];
|
|
@@ -370,6 +399,13 @@ export function talkOf(events: readonly RestTranscriptEvent[]): TalkItem[] {
|
|
|
370
399
|
const parent = parentOf(event);
|
|
371
400
|
const starter = parent === undefined ? undefined : calls.get(parent);
|
|
372
401
|
const line = parent === undefined || starter === undefined ? top : lineOf(parent, starter);
|
|
402
|
+
// What a sub-agent's own line says of its end stands until the sub-agent does something
|
|
403
|
+
// after it, as one that was started again does: then it is at work again.
|
|
404
|
+
const begun = toolAt(starter);
|
|
405
|
+
if (starter !== undefined && begun !== undefined && event.sealed === null) {
|
|
406
|
+
const over = saysOver(event) ? event : AT_WORK.has(event.kind) ? undefined : begun.over;
|
|
407
|
+
set(starter, { ...begun, over });
|
|
408
|
+
}
|
|
373
409
|
// A sealed event says who sealed it and why, wherever it stood.
|
|
374
410
|
if (event.sealed !== null) {
|
|
375
411
|
line.push({ type: "note", event });
|
|
@@ -442,15 +478,26 @@ export function talkOf(events: readonly RestTranscriptEvent[]): TalkItem[] {
|
|
|
442
478
|
} else {
|
|
443
479
|
line.push({ type: "note", event });
|
|
444
480
|
// Where the session's own line says a turn ended, or the session did, nothing started in
|
|
445
|
-
// it goes on: a sub-agent that was not answered by then is ended there.
|
|
481
|
+
// it goes on: a sub-agent that was not answered by then is ended there. One that goes on
|
|
482
|
+
// in the background goes on past a turn's end, and is ended by its session's alone.
|
|
446
483
|
if (parent === undefined && endsTurn(event)) {
|
|
484
|
+
const session = typeof event.data.ended === "string";
|
|
485
|
+
const still: TalkPlace[] = [];
|
|
447
486
|
for (const place of running) {
|
|
448
487
|
const tool = toolAt(place);
|
|
449
|
-
if (tool
|
|
488
|
+
if (tool === undefined) {
|
|
489
|
+
continue;
|
|
490
|
+
}
|
|
491
|
+
if (goesOn(tool) && !session) {
|
|
492
|
+
still.push(place);
|
|
493
|
+
} else if (
|
|
494
|
+
(goesOn(tool) ? tool.over === undefined : tool.result === undefined) &&
|
|
495
|
+
tool.endedAt === undefined
|
|
496
|
+
) {
|
|
450
497
|
set(place, { ...tool, endedAt: event.at });
|
|
451
498
|
}
|
|
452
499
|
}
|
|
453
|
-
running =
|
|
500
|
+
running = still;
|
|
454
501
|
}
|
|
455
502
|
}
|
|
456
503
|
}
|
|
@@ -527,6 +574,11 @@ function atOf(steps: readonly TalkItem[]): Working {
|
|
|
527
574
|
* otherwise, which only an open session's is (`live`); how long it ran, to its answer, to where
|
|
528
575
|
* it was ended or to the last thing it did, and to `now` while it runs; how many tools it
|
|
529
576
|
* called; and what it is at. Nothing for a thing that is no call that started a sub-agent.
|
|
577
|
+
*
|
|
578
|
+
* One that goes on in the background (ADR-0161) is not answered for by its call's answer, which
|
|
579
|
+
* says only that it was started: it stands by its own word that it ended, done, failed or
|
|
580
|
+
* stopped, is ended where its session ended first, and is at work otherwise, whatever turn
|
|
581
|
+
* ended meanwhile.
|
|
530
582
|
*/
|
|
531
583
|
export function subAgentOf(
|
|
532
584
|
item: TalkItem,
|
|
@@ -544,24 +596,34 @@ export function subAgentOf(
|
|
|
544
596
|
const named = typeof said === "string" ? said : steps.map(firstOf).find(Boolean)?.data.subagent;
|
|
545
597
|
const name = typeof named === "string" ? named.trim().slice(0, MAX_SUBAGENT_NAME) : "";
|
|
546
598
|
const started = Date.parse(first.at);
|
|
547
|
-
|
|
599
|
+
// What the sub-agent answered: the call's answer, but for one that says the sub-agent goes on.
|
|
600
|
+
const answer = goesOn(item) ? undefined : item.result;
|
|
601
|
+
const how = item.over?.data.over;
|
|
548
602
|
const cut = item.endedAt === undefined ? Number.NaN : Date.parse(item.endedAt);
|
|
549
603
|
const state: SubAgentState =
|
|
550
|
-
|
|
551
|
-
?
|
|
604
|
+
answer !== undefined
|
|
605
|
+
? answer.data.error === true
|
|
552
606
|
? "failed"
|
|
553
607
|
: "done"
|
|
554
|
-
: item.
|
|
555
|
-
? "
|
|
556
|
-
|
|
608
|
+
: item.over !== undefined
|
|
609
|
+
? how === "failed"
|
|
610
|
+
? "failed"
|
|
611
|
+
: how === "stopped"
|
|
612
|
+
? "ended"
|
|
613
|
+
: "done"
|
|
614
|
+
: item.endedAt !== undefined || refusedOf(item) || !input.live
|
|
615
|
+
? "ended"
|
|
616
|
+
: "running";
|
|
557
617
|
const until =
|
|
558
618
|
state === "running"
|
|
559
619
|
? input.now
|
|
560
|
-
:
|
|
561
|
-
?
|
|
562
|
-
: item.
|
|
563
|
-
?
|
|
564
|
-
:
|
|
620
|
+
: answer !== undefined
|
|
621
|
+
? Date.parse(answer.at)
|
|
622
|
+
: item.over !== undefined
|
|
623
|
+
? Date.parse(item.over.at)
|
|
624
|
+
: item.endedAt !== undefined
|
|
625
|
+
? cut
|
|
626
|
+
: Math.max(started, ...steps.flatMap(momentsOf));
|
|
565
627
|
const seconds = Math.floor((until - started) / 1000);
|
|
566
628
|
return {
|
|
567
629
|
n: first.n,
|
|
@@ -588,22 +650,33 @@ function subAgentsIn(
|
|
|
588
650
|
}
|
|
589
651
|
|
|
590
652
|
/**
|
|
591
|
-
* The sub-agents at work in
|
|
592
|
-
*
|
|
593
|
-
*
|
|
653
|
+
* The sub-agents at work in an open session, read off its events alone, in the order they were
|
|
654
|
+
* started: those a call of the turn under way started that was not answered yet, and those that
|
|
655
|
+
* go on in the background, whatever turn started them, until each says it ended (ADR-0161).
|
|
656
|
+
* None where the session has no event; none but those in the background where its last turn is
|
|
657
|
+
* over.
|
|
594
658
|
*/
|
|
595
659
|
export function atWorkOf(events: readonly RestTranscriptEvent[], now: number): readonly SubAgent[] {
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
660
|
+
return subAgentsIn(talkOf(events), { now, live: true }).filter((one) => one.state === "running");
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* Whether the events read hold what a sub-agent did and not the call that started it: the call
|
|
665
|
+
* then stands before them, as it does once a sub-agent has worked for long, and what it did is
|
|
666
|
+
* read under it only once the events before are read too.
|
|
667
|
+
*/
|
|
668
|
+
export function lacksStarter(events: readonly RestTranscriptEvent[]): boolean {
|
|
669
|
+
const calls = new Set<string>();
|
|
670
|
+
for (const event of events) {
|
|
671
|
+
const id = event.kind === "tool_call" ? idOf(event) : undefined;
|
|
672
|
+
if (id !== undefined) {
|
|
673
|
+
calls.add(id);
|
|
602
674
|
}
|
|
603
675
|
}
|
|
604
|
-
return
|
|
605
|
-
|
|
606
|
-
|
|
676
|
+
return events.some((event) => {
|
|
677
|
+
const parent = parentOf(event);
|
|
678
|
+
return parent !== undefined && !calls.has(parent);
|
|
679
|
+
});
|
|
607
680
|
}
|
|
608
681
|
|
|
609
682
|
/**
|
|
@@ -956,7 +1029,8 @@ function sameItem(a: TalkItem, b: TalkItem): boolean {
|
|
|
956
1029
|
a.call === b.call &&
|
|
957
1030
|
a.result === b.result &&
|
|
958
1031
|
a.permission === b.permission &&
|
|
959
|
-
a.endedAt === b.endedAt
|
|
1032
|
+
a.endedAt === b.endedAt &&
|
|
1033
|
+
a.over === b.over
|
|
960
1034
|
);
|
|
961
1035
|
}
|
|
962
1036
|
return a.type === b.type && a.event === b.event;
|
|
@@ -1462,7 +1536,8 @@ const TalkLine: NamedExoticComponent<TalkLineProps> = memo(function Line(
|
|
|
1462
1536
|
);
|
|
1463
1537
|
}
|
|
1464
1538
|
// A wake, a status, an error, and whatever a newer runner calls otherwise: a note between.
|
|
1465
|
-
// What the note's own words say already, how a session ended, is not said
|
|
1539
|
+
// What the note's own words say already, how a session or a sub-agent ended, is not said
|
|
1540
|
+
// twice as a fact.
|
|
1466
1541
|
// The id of the call that started a sub-agent is for joining, and says nothing to a reader;
|
|
1467
1542
|
// whose a note is, is not said again under the sub-agent that made it.
|
|
1468
1543
|
const facts = Object.entries(event.data).filter(
|
|
@@ -1471,6 +1546,7 @@ const TalkLine: NamedExoticComponent<TalkLineProps> = memo(function Line(
|
|
|
1471
1546
|
name !== "signal" &&
|
|
1472
1547
|
name !== "kind" &&
|
|
1473
1548
|
name !== "ended" &&
|
|
1549
|
+
name !== "over" &&
|
|
1474
1550
|
name !== "parent" &&
|
|
1475
1551
|
!(name === "subagent" && props.inside === true),
|
|
1476
1552
|
);
|
|
@@ -1709,22 +1785,24 @@ export function TalkWaiting(props: TalkWaitingProps) {
|
|
|
1709
1785
|
* The sign that the agent is at work while a turn is under way: its picture, three dots, and
|
|
1710
1786
|
* what it is at, a thought, a tool by its name, or the work between. Where sub-agents run, it
|
|
1711
1787
|
* says how many, with each under it: its name, what it is at, how many tools it called and how
|
|
1712
|
-
* long it has run, which the page counts by itself (ADR-0141).
|
|
1713
|
-
*
|
|
1788
|
+
* long it has run, which the page counts by itself (ADR-0141). Sub-agents that go on in the
|
|
1789
|
+
* background are at work past the turn that started them (ADR-0161), and the sign stands for
|
|
1790
|
+
* them alone then. A row of the conversation's list; nothing where no turn is under way and no
|
|
1791
|
+
* sub-agent is at work.
|
|
1714
1792
|
*/
|
|
1715
1793
|
export function TalkWorking(props: {
|
|
1716
1794
|
readonly working: Working | undefined;
|
|
1717
1795
|
readonly agent?: RestPerson | undefined;
|
|
1718
|
-
/** The sub-agents at work in the
|
|
1796
|
+
/** The sub-agents at work in the session: `atWorkOf` says which. */
|
|
1719
1797
|
readonly agents?: readonly SubAgent[] | undefined;
|
|
1720
1798
|
}) {
|
|
1721
1799
|
const live = useWords().agents.page.live;
|
|
1722
1800
|
const words = live.working;
|
|
1723
1801
|
const { working } = props;
|
|
1724
|
-
|
|
1802
|
+
const agents = props.agents ?? [];
|
|
1803
|
+
if (working === undefined && agents.length === 0) {
|
|
1725
1804
|
return null;
|
|
1726
1805
|
}
|
|
1727
|
-
const agents = props.agents ?? [];
|
|
1728
1806
|
return (
|
|
1729
1807
|
<li
|
|
1730
1808
|
className={cx(
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
import {
|
|
11
11
|
addDays,
|
|
12
12
|
addMonths,
|
|
13
|
+
dayOf,
|
|
13
14
|
daysBetween,
|
|
14
15
|
deviceLanguage,
|
|
15
16
|
firstDayOfWeek,
|
|
@@ -31,17 +32,59 @@ import { CategoryBadge, cx, PersonChip, personName, StateBadge, Time, Workers }
|
|
|
31
32
|
// The calendar of a project (ADR-0019): the month as a grid, or one week on its own. A task
|
|
32
33
|
// planned from a start to a due day lies across its days as a bar, in a lane of its own within
|
|
33
34
|
// each week so that the bars of one week never cross; a task with one day alone, a due day or
|
|
34
|
-
// a start, sits on that day as a dot.
|
|
35
|
-
//
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
//
|
|
35
|
+
// a start, sits on that day as a dot. A task with no day of its plan lies where it was worked,
|
|
36
|
+
// by the moments the board keeps, a bar or a dot the same way (ADR-0159). On a project's
|
|
37
|
+
// calendar the person who has a task stands before its title, since the days hold several
|
|
38
|
+
// people's work. Who has what says whether the work is on its days. The task under the pointer
|
|
39
|
+
// is shown in full within its item, with the facts its own page lists, above or below it where
|
|
40
|
+
// there is more room. Takes its data as props and nothing from the network; the month or the
|
|
41
|
+
// week shown is the address's (ADR-0010).
|
|
39
42
|
|
|
40
43
|
const isOpen = (task: RestTaskBrief): boolean => OPEN_TASK_STATES.includes(task.state);
|
|
41
44
|
|
|
42
|
-
/**
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
/** The day a moment fell on, by this machine's clock, as the calendar spells a day. */
|
|
46
|
+
function dayOfMoment(moment: string | null): string | undefined {
|
|
47
|
+
if (moment === null) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
const date = new Date(moment);
|
|
51
|
+
return Number.isNaN(date.getTime()) ? undefined : dayOf(date);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The days a task lies on, on a calendar: the first and the last, one day where it lies on one. */
|
|
55
|
+
export interface TaskDays {
|
|
56
|
+
readonly from: string;
|
|
57
|
+
readonly to: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Where a task lies on a calendar, counted from `today`, or nowhere. A task with a day of its
|
|
62
|
+
* plan lies on its plan (ADR-0019): from its start to its due day, or on the one day it has. A
|
|
63
|
+
* task with none lies where it was worked, by the moments the board keeps (ADR-0159): from the
|
|
64
|
+
* day it was started through today while it is in progress, and else through the day its last
|
|
65
|
+
* run ended, which is where its work ended however long it waits for its review; with no run
|
|
66
|
+
* that ended, through the day it was done, or on the day it was started alone. The plan is read
|
|
67
|
+
* and never written: a task neither planned nor started lies nowhere.
|
|
68
|
+
*/
|
|
69
|
+
export function daysOf(task: RestTaskBrief, today: string): TaskDays | undefined {
|
|
70
|
+
const planned = task.dueOn ?? task.startsOn;
|
|
71
|
+
if (planned !== null) {
|
|
72
|
+
const begins = task.startsOn !== null && task.startsOn < planned ? task.startsOn : planned;
|
|
73
|
+
return { from: begins, to: planned };
|
|
74
|
+
}
|
|
75
|
+
const done = dayOfMoment(task.doneAt);
|
|
76
|
+
// A task done before the board kept when it was started has the day it was done alone.
|
|
77
|
+
const from = dayOfMoment(task.startedAt) ?? done;
|
|
78
|
+
if (from === undefined) {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
const ended = dayOfMoment(task.lastRunEndedAt ?? null);
|
|
82
|
+
// A run left open by hand may end after the task was done, which ended the work.
|
|
83
|
+
const over = ended !== undefined && done !== undefined && done < ended ? done : (ended ?? done);
|
|
84
|
+
const to = task.state === "in_progress" ? today : (over ?? from);
|
|
85
|
+
// The reader's clock may be behind the board's: such a task sits on the day it reaches.
|
|
86
|
+
return to < from ? { from: to, to } : { from, to };
|
|
87
|
+
}
|
|
45
88
|
|
|
46
89
|
export interface CalendarProps<T extends RestTaskBrief = RestTaskBrief> {
|
|
47
90
|
readonly tasks: readonly T[];
|
|
@@ -77,11 +120,14 @@ export interface WeekSegment<T extends RestTaskBrief = RestTaskBrief> {
|
|
|
77
120
|
/**
|
|
78
121
|
* The bars of one week: every task lying across days that touches the week, cut to it, each
|
|
79
122
|
* in the first lane where it crosses nothing that was laid before it. The longest and earliest
|
|
80
|
-
* go first, so that the lanes stay few.
|
|
123
|
+
* go first, so that the lanes stay few. A task with no day of its plan lies across the days it
|
|
124
|
+
* was worked, through `today` while it is at work ({@link daysOf}); the browser's today when left
|
|
125
|
+
* out.
|
|
81
126
|
*/
|
|
82
127
|
export function weekSegments<T extends RestTaskBrief>(
|
|
83
128
|
week: readonly GridDay[],
|
|
84
129
|
tasks: readonly T[],
|
|
130
|
+
today: string = todayOf(),
|
|
85
131
|
): WeekSegment<T>[] {
|
|
86
132
|
const first = week[0]?.day;
|
|
87
133
|
const last = week[week.length - 1]?.day;
|
|
@@ -89,16 +135,14 @@ export function weekSegments<T extends RestTaskBrief>(
|
|
|
89
135
|
return [];
|
|
90
136
|
}
|
|
91
137
|
const cut = tasks
|
|
92
|
-
.filter(spans)
|
|
93
138
|
.flatMap((task) => {
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
if (dueOn < first || startsOn > last) {
|
|
139
|
+
const days = daysOf(task, today);
|
|
140
|
+
if (days === undefined || days.from === days.to || days.to < first || days.from > last) {
|
|
97
141
|
return [];
|
|
98
142
|
}
|
|
99
|
-
const from =
|
|
100
|
-
const to =
|
|
101
|
-
return [{ task, from, to, begins:
|
|
143
|
+
const from = days.from < first ? 0 : daysBetween(first, days.from);
|
|
144
|
+
const to = days.to > last ? week.length - 1 : daysBetween(first, days.to);
|
|
145
|
+
return [{ task, from, to, begins: days.from >= first, ends: days.to <= last }];
|
|
102
146
|
})
|
|
103
147
|
.sort(
|
|
104
148
|
(a, b) => a.from - b.from || b.to - b.from - (a.to - a.from) || a.task.number - b.task.number,
|
|
@@ -125,16 +169,19 @@ function push<T extends RestTaskBrief>(map: Map<string, T[]>, day: string, task:
|
|
|
125
169
|
}
|
|
126
170
|
}
|
|
127
171
|
|
|
128
|
-
/**
|
|
129
|
-
|
|
172
|
+
/**
|
|
173
|
+
* The tasks that sit on one day each, by day: due on it, beginning on it with no due day yet,
|
|
174
|
+
* or, with no day of its plan, worked on it alone ({@link daysOf}).
|
|
175
|
+
*/
|
|
176
|
+
function onDays<T extends RestTaskBrief>(
|
|
177
|
+
tasks: readonly T[],
|
|
178
|
+
today: string,
|
|
179
|
+
): ReadonlyMap<string, readonly T[]> {
|
|
130
180
|
const on = new Map<string, T[]>();
|
|
131
181
|
for (const task of tasks) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
const day = task.dueOn ?? task.startsOn;
|
|
136
|
-
if (day !== null) {
|
|
137
|
-
push(on, day, task);
|
|
182
|
+
const days = daysOf(task, today);
|
|
183
|
+
if (days !== undefined && days.from === days.to) {
|
|
184
|
+
push(on, days.from, task);
|
|
138
185
|
}
|
|
139
186
|
}
|
|
140
187
|
// Within a day, what is still open comes first; the rest reads as what was.
|
|
@@ -144,14 +191,20 @@ function onDays<T extends RestTaskBrief>(tasks: readonly T[]): ReadonlyMap<strin
|
|
|
144
191
|
return on;
|
|
145
192
|
}
|
|
146
193
|
|
|
147
|
-
/**
|
|
148
|
-
|
|
194
|
+
/**
|
|
195
|
+
* The tasks of one day: those on it alone and those lying across it, the open ones first;
|
|
196
|
+
* counted from `today` as {@link daysOf} counts, the browser's today when left out.
|
|
197
|
+
*/
|
|
198
|
+
export function tasksOn<T extends RestTaskBrief>(
|
|
199
|
+
day: string,
|
|
200
|
+
tasks: readonly T[],
|
|
201
|
+
today: string = todayOf(),
|
|
202
|
+
): T[] {
|
|
149
203
|
return tasks
|
|
150
|
-
.filter((task) =>
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
)
|
|
204
|
+
.filter((task) => {
|
|
205
|
+
const days = daysOf(task, today);
|
|
206
|
+
return days !== undefined && days.from <= day && day <= days.to;
|
|
207
|
+
})
|
|
155
208
|
.sort((a, b) => Number(isOpen(b)) - Number(isOpen(a)) || a.number - b.number);
|
|
156
209
|
}
|
|
157
210
|
|
|
@@ -595,11 +648,14 @@ export function Calendar<T extends RestTaskBrief>(props: CalendarProps<T>) {
|
|
|
595
648
|
const now = props.today ?? todayOf();
|
|
596
649
|
const firstDay = firstDayOfWeek(deviceLanguage(tag), props.weekStart);
|
|
597
650
|
const weeks = monthGrid(props.month, firstDay);
|
|
598
|
-
const onPicked = picked === null ? [] : tasksOn(picked, props.tasks);
|
|
599
|
-
const on = onDays(props.tasks);
|
|
651
|
+
const onPicked = picked === null ? [] : tasksOn(picked, props.tasks, now);
|
|
652
|
+
const on = onDays(props.tasks, now);
|
|
600
653
|
const goalsOn = props.goalHref === undefined ? undefined : goalsOnDays(props.goals ?? []);
|
|
601
654
|
const inMonth = (day: string) => monthOf(day) === props.month;
|
|
602
|
-
const monthWeeks = weeks.map((week) => ({
|
|
655
|
+
const monthWeeks = weeks.map((week) => ({
|
|
656
|
+
week,
|
|
657
|
+
segments: weekSegments(week, props.tasks, now),
|
|
658
|
+
}));
|
|
603
659
|
const nothing =
|
|
604
660
|
[...on.keys()].every((day) => !inMonth(day)) &&
|
|
605
661
|
monthWeeks.every(({ week, segments }) =>
|
|
@@ -732,8 +788,8 @@ export function Week<T extends RestTaskBrief>(props: WeekProps<T>) {
|
|
|
732
788
|
const first = days[0] ?? now;
|
|
733
789
|
const last = days[days.length - 1] ?? now;
|
|
734
790
|
const week: GridDay[] = days.map((day) => ({ day, inMonth: true }));
|
|
735
|
-
const on = onDays(props.tasks);
|
|
736
|
-
const segments = weekSegments(week, props.tasks);
|
|
791
|
+
const on = onDays(props.tasks, now);
|
|
792
|
+
const segments = weekSegments(week, props.tasks, now);
|
|
737
793
|
const nothing = segments.length === 0 && days.every((day) => !on.has(day));
|
|
738
794
|
return (
|
|
739
795
|
<div className="sc-calendar sc-week">
|
package/src/console.tsx
CHANGED
|
@@ -2612,11 +2612,11 @@ function PlatePage(props: {
|
|
|
2612
2612
|
) {
|
|
2613
2613
|
setForbidden(true);
|
|
2614
2614
|
} else {
|
|
2615
|
-
setProblem(errorWords(failure, couldNotLoad));
|
|
2615
|
+
setProblem(errorWords(failure, couldNotLoad, words));
|
|
2616
2616
|
}
|
|
2617
2617
|
});
|
|
2618
2618
|
return () => controller.abort();
|
|
2619
|
-
}, [load, couldNotLoad, refused, remember, early]);
|
|
2619
|
+
}, [load, couldNotLoad, refused, remember, early, words]);
|
|
2620
2620
|
return (
|
|
2621
2621
|
<>
|
|
2622
2622
|
{props.headless !== true && (
|
|
@@ -2766,6 +2766,7 @@ function useMyDecisions(
|
|
|
2766
2766
|
/** What the first page is remembered by, with whose it is. */
|
|
2767
2767
|
remember: string,
|
|
2768
2768
|
): DecisionsRead {
|
|
2769
|
+
const words = useWords();
|
|
2769
2770
|
const [items, setItems] = useState<RestMyDecisions["items"] | undefined>(
|
|
2770
2771
|
() => rememberedAs<RememberedDecisions>(remember)?.items,
|
|
2771
2772
|
);
|
|
@@ -2795,7 +2796,7 @@ function useMyDecisions(
|
|
|
2795
2796
|
setMore(page.more);
|
|
2796
2797
|
} catch (failure: unknown) {
|
|
2797
2798
|
if (signal?.aborted !== true) {
|
|
2798
|
-
setProblem(errorWords(failure, couldNotLoad));
|
|
2799
|
+
setProblem(errorWords(failure, couldNotLoad, words));
|
|
2799
2800
|
}
|
|
2800
2801
|
} finally {
|
|
2801
2802
|
if (signal?.aborted !== true) {
|
|
@@ -2803,7 +2804,7 @@ function useMyDecisions(
|
|
|
2803
2804
|
}
|
|
2804
2805
|
}
|
|
2805
2806
|
},
|
|
2806
|
-
[myDecisions, raised, couldNotLoad, remember],
|
|
2807
|
+
[myDecisions, raised, couldNotLoad, remember, words],
|
|
2807
2808
|
);
|
|
2808
2809
|
useEffect(() => {
|
|
2809
2810
|
const controller = new AbortController();
|
|
@@ -2836,7 +2837,8 @@ function NotificationsBell(props: {
|
|
|
2836
2837
|
readonly data: ConsoleData;
|
|
2837
2838
|
readonly onNavigate: (href: string) => void;
|
|
2838
2839
|
}) {
|
|
2839
|
-
const
|
|
2840
|
+
const words = useWords();
|
|
2841
|
+
const said = words.notifications;
|
|
2840
2842
|
const { data } = props;
|
|
2841
2843
|
const { notifications, readNotifications } = data.actions;
|
|
2842
2844
|
const [items, setItems] = useState<RestNotifications["items"] | undefined>(undefined);
|
|
@@ -2866,10 +2868,10 @@ function NotificationsBell(props: {
|
|
|
2866
2868
|
setMore(page.more);
|
|
2867
2869
|
} catch (failure: unknown) {
|
|
2868
2870
|
if (mine === turn.current) {
|
|
2869
|
-
setProblem(errorWords(failure, said.couldNotLoad));
|
|
2871
|
+
setProblem(errorWords(failure, said.couldNotLoad, words));
|
|
2870
2872
|
}
|
|
2871
2873
|
}
|
|
2872
|
-
}, [notifications, readNotifications, said.couldNotLoad]);
|
|
2874
|
+
}, [notifications, readNotifications, said.couldNotLoad, words]);
|
|
2873
2875
|
const readMore = useCallback(async () => {
|
|
2874
2876
|
const mine = turn.current;
|
|
2875
2877
|
try {
|
|
@@ -2941,11 +2943,11 @@ function NotificationSettingsPage(props: { readonly data: ConsoleData }) {
|
|
|
2941
2943
|
})
|
|
2942
2944
|
.catch((failure: unknown) => {
|
|
2943
2945
|
if (!controller.signal.aborted) {
|
|
2944
|
-
setProblem(errorWords(failure, said.couldNotLoad));
|
|
2946
|
+
setProblem(errorWords(failure, said.couldNotLoad, words));
|
|
2945
2947
|
}
|
|
2946
2948
|
});
|
|
2947
2949
|
return () => controller.abort();
|
|
2948
|
-
}, [notificationSettings, said.couldNotLoad]);
|
|
2950
|
+
}, [notificationSettings, said.couldNotLoad, words]);
|
|
2949
2951
|
const shownProblem = problem ?? error;
|
|
2950
2952
|
return (
|
|
2951
2953
|
<>
|
|
@@ -3055,6 +3057,34 @@ function MyDecisionsPage(props: { readonly data: ConsoleData }) {
|
|
|
3055
3057
|
);
|
|
3056
3058
|
}
|
|
3057
3059
|
|
|
3060
|
+
/** How often the agents are read again while a page that says how they stand is in view. */
|
|
3061
|
+
const AGENTS_AGAIN_MS = 30_000;
|
|
3062
|
+
|
|
3063
|
+
/**
|
|
3064
|
+
* Keeps the agent accounts as they stand while a page shows them, how each stands and what its
|
|
3065
|
+
* allowance has used (ADR-0156): read again as the page is opened, every half a minute while its
|
|
3066
|
+
* window is in view, as often as a runner says how it stands, and when the person comes back to
|
|
3067
|
+
* it. A window nobody looks at asks nothing.
|
|
3068
|
+
*/
|
|
3069
|
+
function AgentsKept(props: { readonly data: ConsoleData }) {
|
|
3070
|
+
const { refreshAgents } = props.data.actions;
|
|
3071
|
+
useEffect(() => {
|
|
3072
|
+
const again = () => {
|
|
3073
|
+
if (document.visibilityState === "visible") {
|
|
3074
|
+
refreshAgents().catch(() => undefined);
|
|
3075
|
+
}
|
|
3076
|
+
};
|
|
3077
|
+
again();
|
|
3078
|
+
const timer = setInterval(again, AGENTS_AGAIN_MS);
|
|
3079
|
+
document.addEventListener("visibilitychange", again);
|
|
3080
|
+
return () => {
|
|
3081
|
+
clearInterval(timer);
|
|
3082
|
+
document.removeEventListener("visibilitychange", again);
|
|
3083
|
+
};
|
|
3084
|
+
}, [refreshAgents]);
|
|
3085
|
+
return null;
|
|
3086
|
+
}
|
|
3087
|
+
|
|
3058
3088
|
function WorkPage(props: {
|
|
3059
3089
|
readonly data: ConsoleData;
|
|
3060
3090
|
readonly components: ConsoleComponents;
|
|
@@ -3065,7 +3095,12 @@ function WorkPage(props: {
|
|
|
3065
3095
|
return (
|
|
3066
3096
|
<PlatePage
|
|
3067
3097
|
components={props.components}
|
|
3068
|
-
under={
|
|
3098
|
+
under={
|
|
3099
|
+
<>
|
|
3100
|
+
<AgentsKept data={props.data} />
|
|
3101
|
+
<AgentsNeedingYou agents={props.data.agents} me={props.data.me?.person?.id} />
|
|
3102
|
+
</>
|
|
3103
|
+
}
|
|
3069
3104
|
load={plate}
|
|
3070
3105
|
remember={`work:${props.data.me?.person?.id ?? ""}`}
|
|
3071
3106
|
early="work"
|
|
@@ -3633,6 +3668,7 @@ function WorkspacePage(props: {
|
|
|
3633
3668
|
{error !== undefined && <Callout tone="danger">{error}</Callout>}
|
|
3634
3669
|
{view !== "connected" ? (
|
|
3635
3670
|
<>
|
|
3671
|
+
<AgentsKept data={data} />
|
|
3636
3672
|
<section className="sc-people-group" aria-label={agents.views.mine}>
|
|
3637
3673
|
<p className="sc-lead">{accounts.intro}</p>
|
|
3638
3674
|
<components.AgentAccountList
|
package/src/data.ts
CHANGED
|
@@ -105,6 +105,8 @@ export interface ConsoleActions {
|
|
|
105
105
|
* time it is shown, so that what waits in each project is what waits now (ADR-0107).
|
|
106
106
|
*/
|
|
107
107
|
refreshProjects(): Promise<void>;
|
|
108
|
+
/** Reads the agent accounts again, for a page that says how they stand: what fails stays as it was. */
|
|
109
|
+
refreshAgents(): Promise<void>;
|
|
108
110
|
/** Makes a project, whose owner the person becomes, with an image for its mark when one is given. */
|
|
109
111
|
createProject(input: RestProjectInput, icon?: FileUpload): Promise<RestProject>;
|
|
110
112
|
/** Changes the settings of the project the page is on; for an owner. */
|
|
@@ -742,6 +744,10 @@ export function useConsoleData(client: ConsoleClient, projectKey: string | undef
|
|
|
742
744
|
const answer = await client.projects();
|
|
743
745
|
setProjects(answer.items);
|
|
744
746
|
},
|
|
747
|
+
async refreshAgents() {
|
|
748
|
+
const answer = await client.agents();
|
|
749
|
+
setAgents(answer.items);
|
|
750
|
+
},
|
|
745
751
|
async createProject(input, icon) {
|
|
746
752
|
const made = await client.createProject(input);
|
|
747
753
|
const marked = icon === undefined ? made : await client.project(made.key).setIcon(icon);
|
package/src/desk-page.tsx
CHANGED
|
@@ -147,11 +147,11 @@ export function DeskPage(props: DeskPageProps) {
|
|
|
147
147
|
})
|
|
148
148
|
.catch((failure: unknown) => {
|
|
149
149
|
if (!controller.signal.aborted) {
|
|
150
|
-
setProblem(errorWords(failure, couldNotLoad));
|
|
150
|
+
setProblem(errorWords(failure, couldNotLoad, pack));
|
|
151
151
|
}
|
|
152
152
|
});
|
|
153
153
|
return () => controller.abort();
|
|
154
|
-
}, [client, view, personId, couldNotLoad]);
|
|
154
|
+
}, [client, view, personId, couldNotLoad, pack]);
|
|
155
155
|
|
|
156
156
|
// The closed work is read each time a view that shows it is come to, or its words change:
|
|
157
157
|
// the first page of each project, for the figures everything, for the archive what the
|
|
@@ -173,7 +173,7 @@ export function DeskPage(props: DeskPageProps) {
|
|
|
173
173
|
})
|
|
174
174
|
.catch((failure: unknown) => {
|
|
175
175
|
if (!controller.signal.aborted) {
|
|
176
|
-
setProblem(errorWords(failure, couldNotLoad));
|
|
176
|
+
setProblem(errorWords(failure, couldNotLoad, pack));
|
|
177
177
|
}
|
|
178
178
|
})
|
|
179
179
|
.finally(() => {
|
|
@@ -182,7 +182,7 @@ export function DeskPage(props: DeskPageProps) {
|
|
|
182
182
|
}
|
|
183
183
|
});
|
|
184
184
|
return () => controller.abort();
|
|
185
|
-
}, [client, reads, wanted, personId, projects, couldNotLoad]);
|
|
185
|
+
}, [client, reads, wanted, personId, projects, couldNotLoad, pack]);
|
|
186
186
|
|
|
187
187
|
if (personId === undefined) {
|
|
188
188
|
return null;
|
|
@@ -203,7 +203,7 @@ export function DeskPage(props: DeskPageProps) {
|
|
|
203
203
|
};
|
|
204
204
|
(shown.words.length === 0 ? setWhole : setFound)(next);
|
|
205
205
|
})
|
|
206
|
-
.catch((failure: unknown) => setProblem(errorWords(failure, couldNotLoad)))
|
|
206
|
+
.catch((failure: unknown) => setProblem(errorWords(failure, couldNotLoad, pack)))
|
|
207
207
|
.finally(() => setBusy(false));
|
|
208
208
|
};
|
|
209
209
|
// A run that ended on a task still open has its title on the plate, where the plate was read.
|