@johngaynor/entourage 0.4.1-next.22 → 0.4.1-next.30
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 +8 -0
- package/cli/entourage +7 -4
- package/cli/lib/handoff.sh +79 -23
- package/cli/lib/task.sh +1 -1
- package/herdr/README.md +44 -5
- package/herdr/layouts/test.json +11 -0
- package/herdr/mods/cards/main.js +330 -0
- package/herdr/mods/cards/mod.json +1 -0
- package/herdr/mods/cards/refresh.svg +4 -0
- package/herdr/mods/steps/main.js +100 -29
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,6 +22,7 @@ the step that comes next. The agent records each block with
|
|
|
22
22
|
`entourage task handoff`, and your answer when you reply to a question.
|
|
23
23
|
`entourage task log` shows them for a card, with how long each step took, and
|
|
24
24
|
the Steps panel in Herdr shows the same for the card whose tab is selected.
|
|
25
|
+
With no card, both list the project's cards and where each stands.
|
|
25
26
|
|
|
26
27
|
## Setting up a machine
|
|
27
28
|
|
|
@@ -96,6 +97,13 @@ waited for your answer:
|
|
|
96
97
|
entourage task log my-project ABC-122
|
|
97
98
|
```
|
|
98
99
|
|
|
100
|
+
Leave the card out to see every card in the project that has hand-offs,
|
|
101
|
+
newest first, with where each stands, such as waiting on you:
|
|
102
|
+
|
|
103
|
+
```sh
|
|
104
|
+
entourage task log my-project
|
|
105
|
+
```
|
|
106
|
+
|
|
99
107
|
`task start` starts the work. It makes a branch and a git worktree of it in
|
|
100
108
|
every repo of the project, and opens a tab for it:
|
|
101
109
|
|
package/cli/entourage
CHANGED
|
@@ -24,8 +24,9 @@ Usage:
|
|
|
24
24
|
entourage task start <project> <branch> [<repo>[:<group>[,<group>...]] ...]
|
|
25
25
|
start the work: a worktree per repo, opened as a tab
|
|
26
26
|
entourage task handoff <project> <card> record how a step ended: a handoff block on stdin
|
|
27
|
-
entourage task log <project> <card> [--json]
|
|
28
|
-
list a card's hand-offs and how long each step took
|
|
27
|
+
entourage task log <project> [<card>] [--json]
|
|
28
|
+
list a card's hand-offs and how long each step took,
|
|
29
|
+
or with no card the cards that have hand-offs and where each stands
|
|
29
30
|
entourage linear key save your Linear API key, so entourage can read Linear
|
|
30
31
|
entourage help
|
|
31
32
|
|
|
@@ -59,8 +60,10 @@ Join several groups with a comma: `app:athlete,coach`.
|
|
|
59
60
|
when the human answers a question. It reads a handoff block on stdin (phase,
|
|
60
61
|
status, next and so on, one per line), refuses one that breaks the rules, and
|
|
61
62
|
records it. `task log` lists what was recorded for a card, with how long each
|
|
62
|
-
step took and how long it waited on the human. With
|
|
63
|
-
|
|
63
|
+
step took and how long it waited on the human. With no card it lists the
|
|
64
|
+
project's cards that have hand-offs, newest first, each with where it stands
|
|
65
|
+
and for how long. With --json it prints the same view as one line, for
|
|
66
|
+
programs: the Steps panel in Herdr draws it. Run
|
|
64
67
|
`entourage task handoff <project> <card>` with no block to see the rules.
|
|
65
68
|
|
|
66
69
|
Herdr's folder is ~/.config/herdr-app (HERDR_APP_HOME picks another).
|
package/cli/lib/handoff.sh
CHANGED
|
@@ -194,8 +194,10 @@ task_handoff() {
|
|
|
194
194
|
# --- the log ----------------------------------------------------------------
|
|
195
195
|
|
|
196
196
|
# One query works out a card's view: each hand-off with its label, how long it
|
|
197
|
-
# took
|
|
198
|
-
# they cannot disagree, and a Herdr mod that
|
|
197
|
+
# took, whether it is a wait, and where the card stood after it. The plain log
|
|
198
|
+
# and the JSON both read it, so they cannot disagree, and a Herdr mod that
|
|
199
|
+
# draws the JSON formats nothing. With no card it works out the view of every
|
|
200
|
+
# card in the project at once, and the list of cards is each one's latest row.
|
|
199
201
|
#
|
|
200
202
|
# Nothing about time is stored beyond each row's own. A step's time is from
|
|
201
203
|
# the row before it to its own row. The time from a needs-human row to its
|
|
@@ -203,25 +205,29 @@ task_handoff() {
|
|
|
203
205
|
# row with nothing after it is still waiting, measured to now. A `new` row
|
|
204
206
|
# starts a run, so it has no time, however long ago the run before it ended.
|
|
205
207
|
|
|
206
|
-
# SQL for a number of seconds as text: 50s, 1m 44s, 1h 02m.
|
|
208
|
+
# SQL for a number of seconds as text: 50s, 1m 44s, 1h 02m, 3d 04h. @ stands
|
|
209
|
+
# for the column that holds the seconds.
|
|
207
210
|
sql_took() {
|
|
208
|
-
local s
|
|
209
|
-
|
|
210
|
-
when
|
|
211
|
-
else (
|
|
212
|
-
|
|
211
|
+
local t="case when @ < 60 then @ || 's'
|
|
212
|
+
when @ < 3600 then (@ / 60) || 'm ' || printf('%02d', @ % 60) || 's'
|
|
213
|
+
when @ < 86400 then (@ / 3600) || 'h ' || printf('%02d', @ % 3600 / 60) || 'm'
|
|
214
|
+
else (@ / 86400) || 'd ' || printf('%02d', @ % 86400 / 3600) || 'h' end"
|
|
215
|
+
printf '%s' "${t//@/$1}"
|
|
213
216
|
}
|
|
214
217
|
|
|
215
|
-
# SQL that starts a query on one card's view,
|
|
216
|
-
#
|
|
218
|
+
# SQL that starts a query on one card's view, or on every card's in the
|
|
219
|
+
# project, as the table `shown`. Each card's rows are worked out on their own.
|
|
220
|
+
# log_view <project> <card, or empty for all> <answer column, or null in a store without one>
|
|
217
221
|
log_view() {
|
|
222
|
+
local cards=''
|
|
223
|
+
[ -z "$2" ] || cards="and card = $(sql_str "$2")"
|
|
218
224
|
printf "with base as (
|
|
219
|
-
select id, at, phase, status, next, summary, flags, question, options,
|
|
225
|
+
select id, at, card, phase, status, next, summary, flags, question, options,
|
|
220
226
|
%s as answer, reason,
|
|
221
227
|
lag(at) over w as prev_at, lag(status) over w as before, lead(id) over w as after,
|
|
222
228
|
sum(case when phase = 'new' then 1 else 0 end) over w as run
|
|
223
|
-
from handoffs where project = %s
|
|
224
|
-
window w as (order by id)),
|
|
229
|
+
from handoffs where project = %s %s
|
|
230
|
+
window w as (partition by card order by id)),
|
|
225
231
|
timed as (
|
|
226
232
|
select *,
|
|
227
233
|
case when phase = 'new' or prev_at is null then null
|
|
@@ -229,7 +235,7 @@ log_view() {
|
|
|
229
235
|
case when after is null and status = 'needs-human'
|
|
230
236
|
then max(cast(strftime('%%s', 'now') - strftime('%%s', at) as integer), 0) end as open_seconds
|
|
231
237
|
from base),
|
|
232
|
-
|
|
238
|
+
labeled as (
|
|
233
239
|
select *,
|
|
234
240
|
case when phase = 'new' then 'start'
|
|
235
241
|
when status = 'answered' and before = 'needs-human' then 'wait'
|
|
@@ -248,16 +254,64 @@ log_view() {
|
|
|
248
254
|
else (%s) end as took,
|
|
249
255
|
case when open_seconds is null then ''
|
|
250
256
|
else 'waiting on the human for ' || (%s) end as waiting
|
|
251
|
-
from timed)
|
|
252
|
-
|
|
257
|
+
from timed),
|
|
258
|
+
shown as (
|
|
259
|
+
select *,
|
|
260
|
+
case when status = 'needs-human' then 'waiting on the human'
|
|
261
|
+
when phase = 'new' then 'started'
|
|
262
|
+
else label || substr(what, length(status) + 1) end as state
|
|
263
|
+
from labeled)" \
|
|
264
|
+
"$3" "$(sql_str "$1")" "$cards" \
|
|
253
265
|
"$(sql_took seconds)" "$(sql_took seconds)" "$(sql_took seconds)" "$(sql_took seconds)" \
|
|
254
266
|
"$(sql_took open_seconds)"
|
|
255
267
|
}
|
|
256
268
|
|
|
257
|
-
LOG_USAGE='usage: entourage task log <project> <card> [--json]'
|
|
269
|
+
LOG_USAGE='usage: entourage task log <project> [<card>] [--json]'
|
|
270
|
+
|
|
271
|
+
# The project's cards that have hand-offs, newest first by their latest row:
|
|
272
|
+
# where each stands and how long it has stood there. With --json, the same as
|
|
273
|
+
# one line of JSON.
|
|
274
|
+
# log_cards <project> <json: 1 or 0> <view>
|
|
275
|
+
log_cards() {
|
|
276
|
+
local name=$1 json=$2 list
|
|
277
|
+
# Each card's latest row is the one with nothing after it.
|
|
278
|
+
list="$3, latest as (
|
|
279
|
+
select *, max(cast(strftime('%s', 'now') - strftime('%s', at) as integer), 0) as since
|
|
280
|
+
from shown where after is null)"
|
|
281
|
+
if [ "$json" = 1 ]; then
|
|
282
|
+
if [ ! -e "$STORE" ]; then
|
|
283
|
+
printf '{"project":"%s","cards":[]}\n' "$(json_str "$name")"
|
|
284
|
+
return
|
|
285
|
+
fi
|
|
286
|
+
store "$STORE" "$list
|
|
287
|
+
select json_object('project', $(sql_str "$name"),
|
|
288
|
+
'cards', (select json_group_array(json(c)) from (
|
|
289
|
+
select json_object('card', card, 'at', at, 'state', state,
|
|
290
|
+
'waiting', nullif(waiting, ''), 'for', $(sql_took since), 'seconds', since,
|
|
291
|
+
'run', run, 'phase', phase, 'status', status, 'next', next) as c
|
|
292
|
+
from latest order by at desc, id desc)));" ||
|
|
293
|
+
die "could not read the hand-offs in $STORE. It may not be entourage's store."
|
|
294
|
+
return
|
|
295
|
+
fi
|
|
296
|
+
|
|
297
|
+
local sep=$'\x1f' found='' count=0 card state for
|
|
298
|
+
if [ -e "$STORE" ]; then
|
|
299
|
+
found=$(store -separator "$sep" "$STORE" "$list
|
|
300
|
+
select card, state, $(sql_took since) from latest order by at desc, id desc;") ||
|
|
301
|
+
die "could not read the hand-offs in $STORE. It may not be entourage's store."
|
|
302
|
+
fi
|
|
303
|
+
while IFS=$sep read -r card state for; do
|
|
304
|
+
[ -n "$card" ] || continue
|
|
305
|
+
[ "$count" -gt 0 ] || say "Cards in '$name' with hand-offs, newest first"
|
|
306
|
+
count=$((count + 1))
|
|
307
|
+
printf '%-10s %-28s for %s\n' "$card" "$state" "$for"
|
|
308
|
+
done <<< "$found"
|
|
309
|
+
[ "$count" -gt 0 ] || say "No hand-offs recorded in '$name'."
|
|
310
|
+
}
|
|
258
311
|
|
|
259
312
|
# List a card's hand-offs, oldest first, with how long each step took. With
|
|
260
|
-
# --json, the same view as
|
|
313
|
+
# no card, list the project's cards instead. With --json, the same view as
|
|
314
|
+
# one line of JSON.
|
|
261
315
|
task_log() {
|
|
262
316
|
local json=0 a
|
|
263
317
|
local args=()
|
|
@@ -272,17 +326,21 @@ task_log() {
|
|
|
272
326
|
local name=${1:-} card=${2:-}
|
|
273
327
|
[ -n "$name" ] || die "$LOG_USAGE"
|
|
274
328
|
project_named "$name" || die "there is no entourage project called '$name'. See: entourage project ls"
|
|
275
|
-
card=$(handoff_card "$name" "$card" log) || exit 1
|
|
276
329
|
[ "$#" -le 2 ] || die "$LOG_USAGE"
|
|
330
|
+
[ -z "$card" ] || card=$(handoff_card "$name" "$card" log) || exit 1
|
|
277
331
|
have_sqlite || die "$SQLITE is not installed, so no hand-offs have been recorded on this machine."
|
|
278
332
|
|
|
279
333
|
# Reading never changes the store. An older one has no answer column, so it
|
|
280
334
|
# is read without one.
|
|
281
|
-
local answer_column=null view found=''
|
|
335
|
+
local answer_column=null view='' found=''
|
|
282
336
|
if [ -e "$STORE" ]; then
|
|
283
337
|
! has_answer_column || answer_column=answer
|
|
284
338
|
view=$(log_view "$name" "$card" "$answer_column")
|
|
285
339
|
fi
|
|
340
|
+
if [ -z "$card" ]; then
|
|
341
|
+
log_cards "$name" "$json" "$view"
|
|
342
|
+
return
|
|
343
|
+
fi
|
|
286
344
|
|
|
287
345
|
if [ "$json" = 1 ]; then
|
|
288
346
|
if [ ! -e "$STORE" ]; then
|
|
@@ -294,9 +352,7 @@ task_log() {
|
|
|
294
352
|
# cannot be read is an error, not an empty history.
|
|
295
353
|
store "$STORE" "$view
|
|
296
354
|
select json_object('project', $(sql_str "$name"), 'card', $(sql_str "$card"),
|
|
297
|
-
'state', (select
|
|
298
|
-
when phase = 'new' then 'started' else label || substr(what, length(status) + 1) end
|
|
299
|
-
from shown order by id desc limit 1),
|
|
355
|
+
'state', (select state from shown order by id desc limit 1),
|
|
300
356
|
'waiting', (select nullif(waiting, '') from shown order by id desc limit 1),
|
|
301
357
|
'run', (select max(run) from shown),
|
|
302
358
|
'steps', (select json_group_array(json(step)) from (
|
package/cli/lib/task.sh
CHANGED
|
@@ -355,6 +355,6 @@ cmd_task() {
|
|
|
355
355
|
start) shift; task_start "$@" ;;
|
|
356
356
|
handoff) shift; task_handoff "$@" ;;
|
|
357
357
|
log) shift; task_log "$@" ;;
|
|
358
|
-
*) die "usage: entourage task ls <project> [--json], or: entourage task new <project> <card>, or: entourage task start <project> <branch> [<repo>[:<group>[,<group>...]] ...], or: entourage task handoff <project> <card>, or: entourage task log <project> <card> [--json] (see: entourage help)" ;;
|
|
358
|
+
*) die "usage: entourage task ls <project> [--json], or: entourage task new <project> <card>, or: entourage task start <project> <branch> [<repo>[:<group>[,<group>...]] ...], or: entourage task handoff <project> <card>, or: entourage task log <project> [<card>] [--json] (see: entourage help)" ;;
|
|
359
359
|
esac
|
|
360
360
|
}
|
package/herdr/README.md
CHANGED
|
@@ -10,9 +10,10 @@ layouts (whole-window arrangements of mods).
|
|
|
10
10
|
| `mods/cpu/` | Live CPU usage with a scrolling history. macOS only (reads `/usr/bin/top`). |
|
|
11
11
|
| `mods/layout-switch/` | A dropdown that shows the current layout and switches to another. |
|
|
12
12
|
| `mods/projects/` | Every project in your config, open or not. Click one to show its space; `+` makes a new one. |
|
|
13
|
-
| `mods/
|
|
13
|
+
| `mods/cards/` | The open Linear cards of the project whose space is showing, under their statuses. Start writes a card up with `task new`; Open shows the tab of a card already started. |
|
|
14
|
+
| `mods/steps/` | The steps of the card whose tab is selected: what each did, how long it took, and how long it waited on you. With no card's tab selected, the project's cards and where each stands. |
|
|
14
15
|
| `layouts/default.json` | Herdr's own layout, plus the layout dropdown. |
|
|
15
|
-
| `layouts/test.json` | `default` with the projects list in place of spaces, plus the Steps
|
|
16
|
+
| `layouts/test.json` | `default` with the projects list in place of spaces, plus the Cards and Steps panels and the CPU mod in the sidebar. |
|
|
16
17
|
| `projects/template/` | The starting `PROJECT.md` for every new project. |
|
|
17
18
|
|
|
18
19
|
The skills are in [../skills/](../skills/), outside this folder. They are
|
|
@@ -211,6 +212,36 @@ entourage task new <project> <card>
|
|
|
211
212
|
`~/.claude/skills` stops it before anything is opened. Run
|
|
212
213
|
`entourage update` to link the skills.
|
|
213
214
|
|
|
215
|
+
### The Cards panel
|
|
216
|
+
|
|
217
|
+
On the `test` layout, the Cards panel under the projects list shows the open
|
|
218
|
+
cards of the project whose space is showing, each with a button that writes
|
|
219
|
+
the card up.
|
|
220
|
+
|
|
221
|
+
- **It shows what `task ls` lists**: the same statuses in the same order, each
|
|
222
|
+
with its count, and the cards under them. A click on a status closes its
|
|
223
|
+
group, and another opens it again. Which groups are closed is kept between
|
|
224
|
+
starts of Herdr.
|
|
225
|
+
- **Start runs `entourage task new <project> <card>`**, so the card's tab
|
|
226
|
+
opens in the project's space with the agent running. One card starts at a
|
|
227
|
+
time. The button reads Starting… until the command is done, and if the
|
|
228
|
+
command fails, a notification shows what it said.
|
|
229
|
+
- **A card whose tab is open reads Open**, and a click shows that tab rather
|
|
230
|
+
than starting the card a second time. A tab is the card's when it is named
|
|
231
|
+
after the card's ID, as `task new` names it.
|
|
232
|
+
- **When the cards cannot be listed, the panel shows why**, in the words of
|
|
233
|
+
`task ls`: no Linear key saved, a project with no team, Linear out of reach.
|
|
234
|
+
A space that is not a project says so.
|
|
235
|
+
- **It reads the cards again** when another space is shown, about once a
|
|
236
|
+
minute while the window is visible, and when the refresh button above the
|
|
237
|
+
list is clicked.
|
|
238
|
+
- **It works nothing out itself.** The project comes from
|
|
239
|
+
`entourage project ls --json` and the cards from
|
|
240
|
+
`entourage task ls <project> --json`, so the panel and the commands always
|
|
241
|
+
agree. It needs what `task ls` needs: the Linear key and the project's teams.
|
|
242
|
+
- **On the sidebar's narrow rail**, each card shows as its number, and a click
|
|
243
|
+
does what its button would.
|
|
244
|
+
|
|
214
245
|
### Hand-offs
|
|
215
246
|
|
|
216
247
|
Each step of a write-up ends by handing off: which step it was, how it ended
|
|
@@ -227,7 +258,7 @@ EOF
|
|
|
227
258
|
```
|
|
228
259
|
|
|
229
260
|
```sh
|
|
230
|
-
entourage task log <project> <card>
|
|
261
|
+
entourage task log <project> [<card>]
|
|
231
262
|
```
|
|
232
263
|
|
|
233
264
|
- **The command holds the rules.** It refuses a block with a missing line, an
|
|
@@ -245,6 +276,11 @@ entourage task log <project> <card>
|
|
|
245
276
|
waited on you as a line of its own, counted in no step. A question with no
|
|
246
277
|
answer yet shows how long it has been waiting. A step that followed a
|
|
247
278
|
question with no recorded answer is marked as including the wait.
|
|
279
|
+
- **With no card, it lists the project's cards.** `task log <project>` shows
|
|
280
|
+
every card in the project that has hand-offs, newest first by its latest
|
|
281
|
+
one, with where it stands (waiting on you, failed, or the step it finished
|
|
282
|
+
and the one that comes next) and for how long. A card with no hand-offs is
|
|
283
|
+
not listed: `task ls` lists the cards in Linear.
|
|
248
284
|
- **They are kept in `~/.config/entourage/entourage.db`,** a SQLite file
|
|
249
285
|
beside your projects, on this machine only. It needs `sqlite3`, which macOS
|
|
250
286
|
ships; `ENTOURAGE_SQLITE` picks another command. Without it `task new`
|
|
@@ -256,8 +292,11 @@ entourage task log <project> <card>
|
|
|
256
292
|
new` opened, and the panel lists that card's steps: the time of day, what
|
|
257
293
|
the step did, how long it took, and its summary. A wait on you stands out,
|
|
258
294
|
and so does a question still waiting. It shows the latest run of a card
|
|
259
|
-
written up more than once.
|
|
260
|
-
|
|
295
|
+
written up more than once. With no card's tab selected, it lists the
|
|
296
|
+
project's cards instead, and a card waiting on you stands out. Click a card
|
|
297
|
+
to see its steps, even when its tab is closed, and "All cards" to go back;
|
|
298
|
+
selecting another tab goes back too. The panel draws what
|
|
299
|
+
`entourage task log <project> [<card>] --json` prints and works nothing out
|
|
261
300
|
itself, so the two always agree.
|
|
262
301
|
|
|
263
302
|
### Starting the work
|
package/herdr/layouts/test.json
CHANGED
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
// The open Linear cards of the project whose space is showing, under their
|
|
2
|
+
// statuses, with a button on each card that starts it.
|
|
3
|
+
//
|
|
4
|
+
// Which project a space is, and which cards are open, are the entourage
|
|
5
|
+
// command's to say: `entourage project ls --json` and
|
|
6
|
+
// `entourage task ls <project> --json`. This mod draws what they answer and
|
|
7
|
+
// holds no rules about projects or Linear. A card's button runs
|
|
8
|
+
// `entourage task new <project> <card>`, which opens the card's tab in the
|
|
9
|
+
// project's space with the agent running in it.
|
|
10
|
+
//
|
|
11
|
+
// A click on a status opens or closes its group.
|
|
12
|
+
import { View, div, svg } from "gpui-kit";
|
|
13
|
+
import { v_flex, h_flex } from "gpui-base";
|
|
14
|
+
import { exec, spaces, run, notify, theme, layout, window, checking, appHome } from "herdr";
|
|
15
|
+
|
|
16
|
+
const LOOK_MS = 1000; // how often to see whether another space is showing
|
|
17
|
+
const REFRESH_MS = 60000; // how often to read the cards again
|
|
18
|
+
const TIMEOUT_MS = 10000;
|
|
19
|
+
const LIST_TIMEOUT_MS = 30000; // task ls waits up to 20s on Linear
|
|
20
|
+
const START_TIMEOUT_MS = 60000;
|
|
21
|
+
const ROW = 30;
|
|
22
|
+
const RAIL_CELL = 32;
|
|
23
|
+
// How this mod's own link into the repo that ships it ends.
|
|
24
|
+
const LINKED_AT = "/herdr/mods/cards";
|
|
25
|
+
const NOT_A_PROJECT = "The shown space is not an entourage project.";
|
|
26
|
+
const OLD_CLI = "This entourage cannot list a project's cards. Run: entourage update";
|
|
27
|
+
const CHEVRON = "mods/workspace-chrome/chevron";
|
|
28
|
+
const SPINNER = "mods/workspace-chrome/spinner.svg";
|
|
29
|
+
|
|
30
|
+
// `herdr-app check` draws the mod once, with no space showing, which would
|
|
31
|
+
// draw one line of text and none of the rows. It is given these to draw
|
|
32
|
+
// instead: an open group, a closed one, an empty one, a card being started
|
|
33
|
+
// and a card whose tab is open.
|
|
34
|
+
const SAMPLE = {
|
|
35
|
+
project: "sample",
|
|
36
|
+
statuses: [
|
|
37
|
+
{ name: "Backlog", type: "backlog", cards: [
|
|
38
|
+
{ id: "ABC-1", title: "A card", url: "" },
|
|
39
|
+
{ id: "ABC-2", title: "A card being started", url: "" },
|
|
40
|
+
] },
|
|
41
|
+
{ name: "Todo", type: "unstarted", cards: [{ id: "ABC-3", title: "A card in a closed group", url: "" }] },
|
|
42
|
+
{ name: "In Progress", type: "started", cards: [{ id: "ABC-4", title: "A card with its tab open", url: "" }] },
|
|
43
|
+
{ name: "In Review", type: "started", cards: [] },
|
|
44
|
+
],
|
|
45
|
+
};
|
|
46
|
+
const SAMPLE_STARTING = "ABC-2";
|
|
47
|
+
const SAMPLE_CLOSED = new Set(["sample/Todo"]);
|
|
48
|
+
const SAMPLE_TABS = new Map([["ABC-4", { space: { id: "s", active: true }, tab: { id: "t", active: true } }]]);
|
|
49
|
+
|
|
50
|
+
function find(node, id) {
|
|
51
|
+
if (node?.id === id) return node;
|
|
52
|
+
for (const child of node?.children ?? []) {
|
|
53
|
+
const found = find(child, id);
|
|
54
|
+
if (found) return found;
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// The sidebar's rail goes by its width, as in Herdr's own lists.
|
|
60
|
+
const narrow = () => (find(layout(), "sidebar")?.size?.px ?? Infinity) < 160;
|
|
61
|
+
|
|
62
|
+
function parse(text) {
|
|
63
|
+
try {
|
|
64
|
+
return JSON.parse(text);
|
|
65
|
+
} catch {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// What a failed command said, without the name it starts its errors with.
|
|
71
|
+
const said = (r) => (r.stderr || r.stdout).trim().replace(/^entourage: /, "");
|
|
72
|
+
// An entourage from before `task ls` answers with its usage line, not JSON.
|
|
73
|
+
const failure = (r, what) => {
|
|
74
|
+
const text = said(r);
|
|
75
|
+
return text.startsWith("usage:") ? OLD_CLI : text || `${what} failed`;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// The shown space's folder, when that space is on this computer: the only
|
|
79
|
+
// place an entourage project can be.
|
|
80
|
+
function shownFolder() {
|
|
81
|
+
const space = spaces().find((s) => s.active);
|
|
82
|
+
return space && !space.machine ? space.folder : null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// The tabs `task new` has opened in the project's spaces, by card: it names
|
|
86
|
+
// each one after its card.
|
|
87
|
+
function cardTabs(folder) {
|
|
88
|
+
const tabs = new Map();
|
|
89
|
+
for (const space of spaces()) {
|
|
90
|
+
if (space.machine || space.folder !== folder) continue;
|
|
91
|
+
for (const tab of space.tabs) {
|
|
92
|
+
const id = tab.name.toUpperCase();
|
|
93
|
+
// The shown space's tab wins over another space of the same folder.
|
|
94
|
+
if (!tabs.has(id) || space.active) tabs.set(id, { space, tab });
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return tabs;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Which groups are closed: "<project>/<status>", kept between starts.
|
|
101
|
+
function loadClosed() {
|
|
102
|
+
try {
|
|
103
|
+
const list = JSON.parse(localStorage.getItem("closed") ?? "[]");
|
|
104
|
+
return new Set(Array.isArray(list) ? list : []);
|
|
105
|
+
} catch {
|
|
106
|
+
return new Set();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export default class Cards extends View {
|
|
111
|
+
init(_props, cx) {
|
|
112
|
+
this.cmd = "entourage"; // the one on PATH, until that cannot start
|
|
113
|
+
this.closed = loadClosed();
|
|
114
|
+
// What the last listing said for each shown folder: { project, folder,
|
|
115
|
+
// statuses } or { error }. A space shown again draws its last answer
|
|
116
|
+
// while it is read again.
|
|
117
|
+
this.lists = new Map();
|
|
118
|
+
this.key = undefined; // the folder the last listing was read for
|
|
119
|
+
this.readAt = 0;
|
|
120
|
+
this.busy = false;
|
|
121
|
+
this.starting = null; // the card whose `task new` is running
|
|
122
|
+
if (checking()) return;
|
|
123
|
+
cx.timer.every(LOOK_MS, (cx) => this.look(cx));
|
|
124
|
+
this.refresh(cx);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Runs the entourage command. With `fallback`, a command that cannot run is
|
|
128
|
+
// tried again as the copy this mod is linked from (Herdr may have been
|
|
129
|
+
// started without the user's PATH). Only the listing asks for that: it
|
|
130
|
+
// only reads, and it has answered before there is a card to start. A start
|
|
131
|
+
// never does, because its failure may be a timeout with the first run still
|
|
132
|
+
// opening the tab.
|
|
133
|
+
async entourage(args, { fallback = false, timeout = TIMEOUT_MS } = {}) {
|
|
134
|
+
try {
|
|
135
|
+
return await exec(this.cmd, args, { timeout });
|
|
136
|
+
} catch (e) {
|
|
137
|
+
if (!fallback || this.cmd !== "entourage") throw e;
|
|
138
|
+
const link = await exec("readlink", [`${appHome()}/mods/cards`]);
|
|
139
|
+
const at = link.stdout.trim();
|
|
140
|
+
if (link.code !== 0 || !at.endsWith(LINKED_AT)) throw e;
|
|
141
|
+
this.cmd = `${at.slice(0, -LINKED_AT.length)}/cli/entourage`;
|
|
142
|
+
return exec(this.cmd, args, { timeout });
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Read again when another space is showing, or the cards on hand are a
|
|
147
|
+
// minute old. Nothing is read while nobody can see the window.
|
|
148
|
+
look(cx) {
|
|
149
|
+
if (this.busy || window()?.visible === false) return;
|
|
150
|
+
if (shownFolder() === this.key && Date.now() - this.readAt < REFRESH_MS) return;
|
|
151
|
+
this.refresh(cx);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
refresh(cx) {
|
|
155
|
+
if (this.busy) return;
|
|
156
|
+
this.busy = true;
|
|
157
|
+
const folder = shownFolder();
|
|
158
|
+
cx.spawn(async (cx) => {
|
|
159
|
+
cx.notify(); // the refresh button turns while the cards are read
|
|
160
|
+
const got = await this.read(folder);
|
|
161
|
+
this.lists.set(folder, got);
|
|
162
|
+
this.key = folder;
|
|
163
|
+
this.readAt = Date.now();
|
|
164
|
+
this.busy = false;
|
|
165
|
+
cx.notify();
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// The project whose folder is `folder`, and its open cards.
|
|
170
|
+
async read(folder) {
|
|
171
|
+
if (folder === null) return { project: null };
|
|
172
|
+
try {
|
|
173
|
+
const r = await this.entourage(["project", "ls", "--json"], { fallback: true });
|
|
174
|
+
const projects = r.code === 0 ? parse(r.stdout)?.projects : null;
|
|
175
|
+
if (!Array.isArray(projects)) return { error: r.code === 0 ? OLD_CLI : failure(r, "entourage project ls") };
|
|
176
|
+
const project = projects.find((p) => p.folder === folder);
|
|
177
|
+
if (!project) return { project: null };
|
|
178
|
+
const c = await this.entourage(["task", "ls", project.name, "--json"], { timeout: LIST_TIMEOUT_MS });
|
|
179
|
+
const list = c.code === 0 ? parse(c.stdout) : null;
|
|
180
|
+
if (Array.isArray(list?.statuses)) return { project: project.name, folder, statuses: list.statuses };
|
|
181
|
+
return { project: project.name, error: c.code === 0 ? OLD_CLI : failure(c, "entourage task ls") };
|
|
182
|
+
} catch (e) {
|
|
183
|
+
return { error: `Could not run entourage: ${e?.message ?? e}` };
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Runs `task new` for a card, one at a time.
|
|
188
|
+
start(project, card, cx) {
|
|
189
|
+
if (this.starting) return;
|
|
190
|
+
this.starting = card.id;
|
|
191
|
+
cx.notify();
|
|
192
|
+
cx.spawn(async (cx) => {
|
|
193
|
+
let failed = null;
|
|
194
|
+
try {
|
|
195
|
+
const r = await this.entourage(["task", "new", project, card.id], { timeout: START_TIMEOUT_MS });
|
|
196
|
+
if (r.code !== 0) failed = said(r) || "entourage task new failed";
|
|
197
|
+
} catch (e) {
|
|
198
|
+
failed = `Could not run entourage: ${e?.message ?? e}`;
|
|
199
|
+
}
|
|
200
|
+
if (failed !== null) notify({ title: `Could not start ${card.id}`, body: failed, level: "error" });
|
|
201
|
+
this.starting = null;
|
|
202
|
+
cx.notify();
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// Shows the card's tab, in its space.
|
|
207
|
+
show(open) {
|
|
208
|
+
if (!open.space.active) run("space.select", { id: open.space.id });
|
|
209
|
+
run("tab.select", { id: open.tab.id });
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// What a click on a card does: show its tab, or start it.
|
|
213
|
+
act(project, card, open, cx) {
|
|
214
|
+
if (open) this.show(open);
|
|
215
|
+
else this.start(project, card, cx);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
toggle(key, cx) {
|
|
219
|
+
if (this.closed.has(key)) this.closed.delete(key);
|
|
220
|
+
else this.closed.add(key);
|
|
221
|
+
localStorage.setItem("closed", JSON.stringify([...this.closed]));
|
|
222
|
+
cx.notify();
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// A status's header row: its name and how many cards it has.
|
|
226
|
+
header(project, s, i, closed, t) {
|
|
227
|
+
const n = (s.cards ?? []).length;
|
|
228
|
+
return h_flex().id(`status-${i}`).h(26).flex_none().mt(i ? 4 : 0).px(8).gap(7).items_center().rounded(7)
|
|
229
|
+
.text_size(11).text_color(t.dim).cursor_pointer().hover((el) => el.bg(t.hover))
|
|
230
|
+
.on_click((_e, cx) => this.toggle(`${project}/${s.name}`, cx))
|
|
231
|
+
.child(div().flex_1().min_w(0).truncate().child(s.name))
|
|
232
|
+
.child(div().flex_none().child(String(n)))
|
|
233
|
+
.child(svg(`${CHEVRON}-${closed ? "right" : "down"}.svg`).size(11).flex_none());
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// A card: its ID, its title and its button. `open`: its tab, or null.
|
|
237
|
+
// `starting`: the card being started, if any.
|
|
238
|
+
row(project, card, open, starting, t) {
|
|
239
|
+
const on = Boolean(open?.space.active && open.tab.active);
|
|
240
|
+
const mine = starting === card.id;
|
|
241
|
+
const waiting = Boolean(starting) && !mine && !open; // another card is starting
|
|
242
|
+
const label = open ? "Open" : mine ? "Starting…" : "Start";
|
|
243
|
+
const tip = open ? `Show the tab of ${card.id}` : `Start ${card.id}: open its tab with the agent running`;
|
|
244
|
+
const button = h_flex().id(`card-go-${card.id}`).h(22).flex_none().px(8).gap(5).items_center().rounded(6)
|
|
245
|
+
.border_1().border_color(t.input).bg(t.raised).text_size(11.5).text_color(t.foreground)
|
|
246
|
+
.when(mine, (el) => el.text_color(t.muted)
|
|
247
|
+
.child(svg(SPINNER).size(10).flex_none().text_color(t.working).spin(900)))
|
|
248
|
+
.when(waiting, (el) => el.opacity(0.45))
|
|
249
|
+
.when(!mine && !waiting, (el) => el.cursor_pointer().tooltip(tip).hover((s) => s.bg(t.hover))
|
|
250
|
+
.on_click((_e, cx) => this.act(project, card, open, cx)))
|
|
251
|
+
.child(label);
|
|
252
|
+
return h_flex().id(`card-${card.id}`).h(ROW).flex_none().px(8).gap(8).items_center().rounded(8)
|
|
253
|
+
.when(on, (el) => el.bg(t.selected))
|
|
254
|
+
.when(!on, (el) => el.hover((s) => s.bg(t.hover)))
|
|
255
|
+
.child(div().flex_none().text_size(11.5).text_color(t.dim).child(card.id))
|
|
256
|
+
.child(div().id(`card-title-${card.id}`).flex_1().min_w(0).truncate().tooltip(card.title ?? "")
|
|
257
|
+
.text_color(open ? t.foreground : t.muted).child(card.title ?? ""))
|
|
258
|
+
.child(button);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// On the sidebar's rail: the card's number. A click does what its button
|
|
262
|
+
// would.
|
|
263
|
+
compact(project, card, open, starting, t) {
|
|
264
|
+
const on = Boolean(open?.space.active && open.tab.active);
|
|
265
|
+
const mine = starting === card.id;
|
|
266
|
+
const tip = `${card.id}: ${card.title ?? ""}\n${open ? "Click to show its tab" : mine ? "Starting…" : "Click to start it"}`;
|
|
267
|
+
return h_flex().flex_none().justify_center().child(
|
|
268
|
+
h_flex().id(`card-${card.id}`).w(RAIL_CELL).h(26).rounded(6).items_center().justify_center()
|
|
269
|
+
.text_size(11).tooltip(tip)
|
|
270
|
+
.when(on, (el) => el.bg(t.selected))
|
|
271
|
+
.when(!on, (el) => el.hover((s) => s.bg(t.hover)))
|
|
272
|
+
.on_click((_e, cx) => this.act(project, card, open, cx))
|
|
273
|
+
.child(mine
|
|
274
|
+
? svg(SPINNER).size(11).text_color(t.working).spin(900)
|
|
275
|
+
: div().text_color(open ? t.foreground : t.dim).child(card.id.split("-").pop())));
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
render() {
|
|
279
|
+
const t = theme();
|
|
280
|
+
const collapsed = narrow();
|
|
281
|
+
const sample = checking();
|
|
282
|
+
const folder = sample ? "sample" : shownFolder();
|
|
283
|
+
const got = sample ? SAMPLE : this.lists.get(folder) ?? null;
|
|
284
|
+
const closed = sample ? SAMPLE_CLOSED : this.closed;
|
|
285
|
+
const starting = sample ? SAMPLE_STARTING : this.starting;
|
|
286
|
+
const tabs = sample ? SAMPLE_TABS : got?.statuses ? cardTabs(got.folder) : new Map();
|
|
287
|
+
const note = (text, color) =>
|
|
288
|
+
div().px(8).py(6).text_size(12).text_color(color).whitespace_normal().child(text);
|
|
289
|
+
const items = [];
|
|
290
|
+
if (!got) {
|
|
291
|
+
if (!collapsed) items.push(note(folder === null ? NOT_A_PROJECT : "Loading…", t.dim));
|
|
292
|
+
} else if (got.error) {
|
|
293
|
+
// On the rail there is no room for the words: a mark, with them in its tooltip.
|
|
294
|
+
items.push(collapsed
|
|
295
|
+
? h_flex().flex_none().justify_center().child(div().id("cards-error").w(RAIL_CELL).h(26)
|
|
296
|
+
.flex().items_center().justify_center().text_color(t.blocked).tooltip(got.error).child("!"))
|
|
297
|
+
: note(got.error, t.blocked));
|
|
298
|
+
} else if (!got.project) {
|
|
299
|
+
if (!collapsed) items.push(note(NOT_A_PROJECT, t.dim));
|
|
300
|
+
} else {
|
|
301
|
+
got.statuses.forEach((s, i) => {
|
|
302
|
+
const shut = closed.has(`${got.project}/${s.name}`);
|
|
303
|
+
if (!collapsed) items.push(this.header(got.project, s, i, shut, t));
|
|
304
|
+
if (shut) return;
|
|
305
|
+
for (const card of s.cards ?? []) {
|
|
306
|
+
const open = tabs.get(card.id.toUpperCase()) ?? null;
|
|
307
|
+
items.push(collapsed
|
|
308
|
+
? this.compact(got.project, card, open, starting, t)
|
|
309
|
+
: this.row(got.project, card, open, starting, t));
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
const spin = !sample && this.busy;
|
|
314
|
+
return v_flex().size_full().min_h(0).bg(t.chrome).text_size(13)
|
|
315
|
+
.child(h_flex().h(31).flex_none().pl(16).pr(10).gap(6).items_center().justify_between()
|
|
316
|
+
.text_size(11.5).text_color(t.dim)
|
|
317
|
+
.when(collapsed, (el) => el.pl(0).pr(0).justify_center())
|
|
318
|
+
.when(!collapsed, (el) => el.child(div().flex_none().child("Cards"))
|
|
319
|
+
.child(div().flex_1().min_w(0).truncate().text_right().child(got?.project ?? "")))
|
|
320
|
+
.child(div().id("cards-refresh").size(26).flex_none().flex().items_center().justify_center()
|
|
321
|
+
.rounded(6).tooltip("Read the cards again")
|
|
322
|
+
.hover((s) => s.bg(t.hover).text_color(t.foreground))
|
|
323
|
+
.on_click((_e, cx) => this.refresh(cx))
|
|
324
|
+
.child(spin
|
|
325
|
+
? svg("mods/cards/refresh.svg").size(13).spin(900)
|
|
326
|
+
: svg("mods/cards/refresh.svg").size(13))))
|
|
327
|
+
.child(v_flex().id("card-list").flex_1().min_h(0).px(collapsed ? 0 : 8).pb(14)
|
|
328
|
+
.overflow_y_scrollbar().mode("always").children(items));
|
|
329
|
+
}
|
|
330
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "place": "none", "title": "Cards" }
|
package/herdr/mods/steps/main.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
// The steps of the card whose tab is selected: what each step of its write-up
|
|
2
|
-
// did, how long it took, and how long it waited on the human.
|
|
2
|
+
// did, how long it took, and how long it waited on the human. With no card's
|
|
3
|
+
// tab selected, the project's cards that have hand-offs, newest first, with
|
|
4
|
+
// where each stands. A click on a card shows its steps, even when its tab is
|
|
5
|
+
// closed.
|
|
3
6
|
//
|
|
4
|
-
// All of that is worked out by `entourage task log <project> <card> --json`.
|
|
5
|
-
// This mod draws the
|
|
7
|
+
// All of that is worked out by `entourage task log <project> [<card>] --json`.
|
|
8
|
+
// This mod draws the views that command returns and holds no rules about
|
|
6
9
|
// hand-offs: every label and every length of time arrives as text.
|
|
7
10
|
//
|
|
8
11
|
// A step is one line. A click on it opens what the step said.
|
|
@@ -11,7 +14,7 @@ import { v_flex, h_flex } from "gpui-base";
|
|
|
11
14
|
import { exec, spaces, theme, layout, window, checking, appHome } from "herdr";
|
|
12
15
|
|
|
13
16
|
const LOOK_MS = 2000; // how often to see whether another card is selected
|
|
14
|
-
const REREAD_MS = 6000; // how often to read
|
|
17
|
+
const REREAD_MS = 6000; // how often to read what is shown again
|
|
15
18
|
const PROJECTS_MS = 60000; // projects change rarely
|
|
16
19
|
const TIMEOUT_MS = 10000;
|
|
17
20
|
// How this mod's own link into the repo that ships it ends.
|
|
@@ -21,7 +24,15 @@ const CARD = /^[A-Za-z][A-Za-z0-9]*-[0-9]+$/;
|
|
|
21
24
|
|
|
22
25
|
// `herdr-app check` draws the mod once, with no card selected, which would
|
|
23
26
|
// show one line of text and none of the rows. It is given these to draw, all
|
|
24
|
-
// of them open, so a mistake in a row fails the check
|
|
27
|
+
// of them open, so a mistake in a row fails the check: a list of cards and a
|
|
28
|
+
// card's steps, with the way back from one to the other.
|
|
29
|
+
const SAMPLE_CARDS = {
|
|
30
|
+
project: "demo",
|
|
31
|
+
cards: [
|
|
32
|
+
{ card: "ABC-3", state: "waiting on the human", waiting: "waiting on the human for 2m 05s", for: "2m 05s" },
|
|
33
|
+
{ card: "ABC-1", state: "plan done, then breakdown", waiting: null, for: "3d 04h" },
|
|
34
|
+
],
|
|
35
|
+
};
|
|
25
36
|
const SAMPLE = {
|
|
26
37
|
run: 1,
|
|
27
38
|
state: "waiting on the human",
|
|
@@ -58,20 +69,21 @@ function parse(text) {
|
|
|
58
69
|
// What a failed command said, without the name it starts its errors with.
|
|
59
70
|
const said = (r) => (r.stderr || r.stdout).trim().replace(/^entourage: /, "");
|
|
60
71
|
|
|
61
|
-
const OLD_CLI = "This entourage
|
|
62
|
-
// An entourage from before --json answers with its usage line, not JSON
|
|
72
|
+
const OLD_CLI = "This entourage is too old for the Steps panel. Run: entourage update";
|
|
73
|
+
// An entourage from before --json answers with its usage line, not JSON, and
|
|
74
|
+
// one from before the list of cards asks which card.
|
|
63
75
|
const failure = (r, what) => {
|
|
64
76
|
const text = said(r);
|
|
65
|
-
return text.startsWith("usage:") ? OLD_CLI : text || `${what} failed`;
|
|
77
|
+
return text.startsWith("usage:") || text.startsWith("which card?") ? OLD_CLI : text || `${what} failed`;
|
|
66
78
|
};
|
|
67
79
|
|
|
68
|
-
// What is selected on this computer: the shown space's folder,
|
|
69
|
-
//
|
|
80
|
+
// What is selected on this computer: the shown space's folder, the card its
|
|
81
|
+
// shown tab is for, if it is a card's tab, and which tab that is.
|
|
70
82
|
function selected() {
|
|
71
83
|
const space = spaces().find((s) => s.active && !s.machine) ?? null;
|
|
72
84
|
const tab = space?.tabs.find((t) => t.active) ?? null;
|
|
73
85
|
const card = tab && CARD.test(tab.name) ? tab.name.toUpperCase() : null;
|
|
74
|
-
return { folder: space?.folder ?? null, card,
|
|
86
|
+
return { folder: space?.folder ?? null, card, tab: `${space?.id ?? ""}\n${tab?.id ?? ""}` };
|
|
75
87
|
}
|
|
76
88
|
|
|
77
89
|
export default class Steps extends View {
|
|
@@ -81,7 +93,8 @@ export default class Steps extends View {
|
|
|
81
93
|
this.projectsAt = 0;
|
|
82
94
|
this.key = null; // what the view on hand was read for
|
|
83
95
|
this.project = null; // the entourage project of the shown space, or null
|
|
84
|
-
this.
|
|
96
|
+
this.picked = null; // a card chosen from the list, and the tab it was chosen in
|
|
97
|
+
this.view = null; // a card's steps, or the list of cards
|
|
85
98
|
this.error = null;
|
|
86
99
|
this.busy = false;
|
|
87
100
|
this.readAt = 0;
|
|
@@ -108,13 +121,32 @@ export default class Steps extends View {
|
|
|
108
121
|
}
|
|
109
122
|
}
|
|
110
123
|
|
|
111
|
-
//
|
|
112
|
-
//
|
|
113
|
-
//
|
|
124
|
+
// What the panel shows: the card of the selected tab; else the card chosen
|
|
125
|
+
// from the list; else the list. A card chosen from the list is let go as
|
|
126
|
+
// soon as another tab is seen selected, so coming back to that tab shows
|
|
127
|
+
// the list. The panel is drawn again whenever a tab is selected.
|
|
128
|
+
shown() {
|
|
129
|
+
const now = selected();
|
|
130
|
+
if (this.picked && (now.card || this.picked.tab !== now.tab)) this.picked = null;
|
|
131
|
+
const card = now.card ?? this.picked?.card ?? null;
|
|
132
|
+
return { folder: now.folder, card, picked: Boolean(this.picked), key: `${now.folder ?? ""}\n${card ?? ""}` };
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Show a card chosen from the list, or the list again with null.
|
|
136
|
+
pick(card, cx) {
|
|
137
|
+
this.picked = card ? { card, tab: selected().tab } : null;
|
|
138
|
+
this.open = null;
|
|
139
|
+
cx.notify();
|
|
140
|
+
this.look(cx);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Read again when something else is to be shown, or what is on hand is
|
|
144
|
+
// stale. Nothing is read while nobody can see the panel, and a space that
|
|
145
|
+
// is not an entourage project has nothing to read again.
|
|
114
146
|
look(cx) {
|
|
115
147
|
if (this.busy || window()?.visible === false || narrow()) return;
|
|
116
|
-
const now =
|
|
117
|
-
const stale = Boolean(
|
|
148
|
+
const now = this.shown();
|
|
149
|
+
const stale = Boolean(this.project) && Date.now() - this.readAt >= REREAD_MS;
|
|
118
150
|
if (now.key === this.key && !stale) return;
|
|
119
151
|
this.busy = true;
|
|
120
152
|
cx.spawn(async (cx) => {
|
|
@@ -133,10 +165,11 @@ export default class Steps extends View {
|
|
|
133
165
|
}
|
|
134
166
|
}
|
|
135
167
|
project = (this.projects ?? []).find((p) => p.folder === now.folder)?.name ?? null;
|
|
136
|
-
if (!error && project
|
|
137
|
-
const
|
|
168
|
+
if (!error && project) {
|
|
169
|
+
const card = now.card ? [now.card] : [];
|
|
170
|
+
const r = await this.entourage(["task", "log", project, ...card, "--json"]);
|
|
138
171
|
const got = r.code === 0 ? parse(r.stdout) : null;
|
|
139
|
-
if (got && Array.isArray(got.steps)) view = got;
|
|
172
|
+
if (got && Array.isArray(now.card ? got.steps : got.cards)) view = got;
|
|
140
173
|
else error = r.code === 0 ? OLD_CLI : failure(r, "entourage task log");
|
|
141
174
|
}
|
|
142
175
|
} catch (e) {
|
|
@@ -149,15 +182,43 @@ export default class Steps extends View {
|
|
|
149
182
|
this.readAt = Date.now();
|
|
150
183
|
this.busy = false;
|
|
151
184
|
// A redraw of a mod redraws the whole window, so only when what it
|
|
152
|
-
// shows has changed.
|
|
153
|
-
|
|
185
|
+
// shows has changed. A card's seconds change at every read, and only
|
|
186
|
+
// the time drawn from them counts.
|
|
187
|
+
const cards = view?.cards?.map(({ seconds, ...c }) => c);
|
|
188
|
+
const drawn = JSON.stringify([now.key, project, cards ? { ...view, cards } : view, error]);
|
|
154
189
|
if (drawn !== this.drawn) {
|
|
155
190
|
this.drawn = drawn;
|
|
156
191
|
cx.notify();
|
|
157
192
|
}
|
|
193
|
+
// A card chosen while this was being read is read now, not at the
|
|
194
|
+
// next look.
|
|
195
|
+
if (this.shown().key !== now.key) this.look(cx);
|
|
158
196
|
});
|
|
159
197
|
}
|
|
160
198
|
|
|
199
|
+
// One card of the list: its ID and how long it has stood where it is,
|
|
200
|
+
// then where that is. A card waiting on the human stands out. A click shows
|
|
201
|
+
// its steps.
|
|
202
|
+
card(c, i, t) {
|
|
203
|
+
const color = c.waiting ? t.blocked : t.dim;
|
|
204
|
+
return v_flex().id(`card-${i}`).flex_none().px(8).py(4).gap(1).rounded(8)
|
|
205
|
+
.hover((el) => el.bg(t.hover))
|
|
206
|
+
.on_click((_e, cx) => this.pick(c.card, cx))
|
|
207
|
+
.child(h_flex().gap(8).items_center()
|
|
208
|
+
.child(div().flex_1().min_w(0).truncate().text_color(t.foreground).child(c.card ?? ""))
|
|
209
|
+
.child(div().flex_none().text_size(11.5).text_color(color).child(c.for ?? "")))
|
|
210
|
+
.child(div().text_size(11.5).text_color(c.waiting ? t.blocked : t.muted).whitespace_normal()
|
|
211
|
+
.child(c.state ?? ""));
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// The way from a card chosen from the list back to the list.
|
|
215
|
+
back(t) {
|
|
216
|
+
return div().id("back").flex_none().px(8).py(4).rounded(8).text_size(11.5).text_color(t.dim)
|
|
217
|
+
.hover((el) => el.bg(t.hover))
|
|
218
|
+
.on_click((_e, cx) => this.pick(null, cx))
|
|
219
|
+
.child("‹ All cards");
|
|
220
|
+
}
|
|
221
|
+
|
|
161
222
|
// One hand-off, on one line: its clock, its label and the time alone. A
|
|
162
223
|
// click opens the rest of what the view says about it. `s` is a step of the
|
|
163
224
|
// view, and its kind says whether it is a wait.
|
|
@@ -189,32 +250,42 @@ export default class Steps extends View {
|
|
|
189
250
|
|
|
190
251
|
render() {
|
|
191
252
|
const t = theme();
|
|
253
|
+
const now = this.shown();
|
|
192
254
|
if (narrow()) return v_flex().size_full().bg(t.chrome);
|
|
193
255
|
const sample = checking();
|
|
194
|
-
const
|
|
256
|
+
const read = now.key === this.key;
|
|
195
257
|
const view = sample ? SAMPLE : this.view;
|
|
258
|
+
const list = sample ? SAMPLE_CARDS : this.view;
|
|
196
259
|
const note = (text, color) =>
|
|
197
260
|
div().px(8).py(6).text_size(12).text_color(color).whitespace_normal().child(text);
|
|
198
261
|
const items = [];
|
|
199
262
|
// The latest run only: a card written up twice keeps both in its log.
|
|
200
263
|
const steps = (view?.steps ?? []).filter((s) => s.run === view.run);
|
|
264
|
+
const cards = list?.cards ?? [];
|
|
201
265
|
const rows = () => {
|
|
202
266
|
// Where the card stands, as the view words it.
|
|
203
267
|
if (view.state) items.push(note(view.state, view.waiting ? t.blocked : t.dim));
|
|
204
268
|
steps.forEach((s, i) => items.push(this.row(s, i, t, sample || this.open === s.at)));
|
|
205
269
|
};
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
270
|
+
// A card chosen from the list always has the way back, even while it
|
|
271
|
+
// loads or when it could not be read.
|
|
272
|
+
if (sample || now.picked) items.push(this.back(t));
|
|
273
|
+
if (sample) {
|
|
274
|
+
cards.forEach((c, i) => items.push(this.card(c, i, t)));
|
|
275
|
+
rows();
|
|
276
|
+
} else if (!read) items.push(note("Loading…", t.dim));
|
|
209
277
|
else if (this.error) items.push(note(this.error, t.blocked));
|
|
210
278
|
else if (!this.project) items.push(note("This space is not an entourage project.", t.dim));
|
|
211
|
-
else if (
|
|
212
|
-
|
|
279
|
+
else if (now.card) {
|
|
280
|
+
if (steps.length === 0) items.push(note(`No hand-offs recorded for ${now.card} yet.`, t.dim));
|
|
281
|
+
else rows();
|
|
282
|
+
} else if (cards.length === 0) items.push(note("No hand-offs recorded in this project yet.", t.dim));
|
|
283
|
+
else cards.forEach((c, i) => items.push(this.card(c, i, t)));
|
|
213
284
|
return v_flex().size_full().min_h(0).bg(t.chrome).text_size(13)
|
|
214
285
|
.child(h_flex().h(31).flex_none().pl(16).pr(14).items_center().justify_between()
|
|
215
286
|
.text_size(11.5).text_color(t.dim)
|
|
216
287
|
.child("Steps")
|
|
217
|
-
.child(div().child(now.card ?? "")))
|
|
288
|
+
.child(div().child(now.card ?? (read ? this.project : null) ?? "")))
|
|
218
289
|
.child(v_flex().id("step-list").flex_1().min_h(0).px(8).pb(14)
|
|
219
290
|
.overflow_y_scrollbar().mode("always").children(items));
|
|
220
291
|
}
|
package/package.json
CHANGED