@johngaynor/entourage 0.4.1-next.10 → 0.4.1-next.13

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.
@@ -241,6 +241,7 @@ log_view() {
241
241
  when status = 'answered' then 'answered'
242
242
  when status = 'failed' then phase || ' failed'
243
243
  else phase || ' ' || status end as label,
244
+ case when seconds is null then '' else (%s) end as short,
244
245
  case when seconds is null then ''
245
246
  when status = 'answered' and before = 'needs-human' then 'waited ' || (%s)
246
247
  when before = 'needs-human' then (%s) || ', includes waiting on the human'
@@ -249,7 +250,8 @@ log_view() {
249
250
  else 'waiting on the human for ' || (%s) end as waiting
250
251
  from timed)" \
251
252
  "$3" "$(sql_str "$1")" "$(sql_str "$2")" \
252
- "$(sql_took seconds)" "$(sql_took seconds)" "$(sql_took seconds)" "$(sql_took open_seconds)"
253
+ "$(sql_took seconds)" "$(sql_took seconds)" "$(sql_took seconds)" "$(sql_took seconds)" \
254
+ "$(sql_took open_seconds)"
253
255
  }
254
256
 
255
257
  LOG_USAGE='usage: entourage task log <project> <card> [--json]'
@@ -284,7 +286,7 @@ task_log() {
284
286
 
285
287
  if [ "$json" = 1 ]; then
286
288
  if [ ! -e "$STORE" ]; then
287
- printf '{"project":"%s","card":"%s","state":null,"waiting":null,"steps":[]}\n' \
289
+ printf '{"project":"%s","card":"%s","state":null,"waiting":null,"run":null,"steps":[]}\n' \
288
290
  "$(json_str "$name")" "$(json_str "$card")"
289
291
  return
290
292
  fi
@@ -300,7 +302,7 @@ task_log() {
300
302
  'steps', (select json_group_array(json(step)) from (
301
303
  select json_object('run', run, 'at', at, 'clock', strftime('%H:%M', at, 'localtime'),
302
304
  'phase', phase, 'status', status, 'next', next, 'kind', kind, 'label', label,
303
- 'took', took, 'seconds', seconds, 'waiting', nullif(waiting, ''),
305
+ 'took', took, 'short', short, 'seconds', seconds, 'waiting', nullif(waiting, ''),
304
306
  'summary', summary, 'flags', flags, 'question', question, 'options', options,
305
307
  'answer', answer, 'reason', reason) as step
306
308
  from shown order by id)));" ||
@@ -4,6 +4,8 @@
4
4
  // All of that is worked out by `entourage task log <project> <card> --json`.
5
5
  // This mod draws the view that command returns and holds no rules about
6
6
  // hand-offs: every label and every length of time arrives as text.
7
+ //
8
+ // A step is one line. A click on it opens what the step said.
7
9
  import { View, div } from "gpui-kit";
8
10
  import { v_flex, h_flex } from "gpui-base";
9
11
  import { exec, spaces, theme, layout, window, checking, appHome } from "herdr";
@@ -16,21 +18,20 @@ const TIMEOUT_MS = 10000;
16
18
  const LINKED_AT = "/herdr/mods/steps";
17
19
  // A tab is a card's when it is named as `entourage task new` names it.
18
20
  const CARD = /^[A-Za-z][A-Za-z0-9]*-[0-9]+$/;
19
- const OLD_CLI = "This entourage cannot give a card's steps as JSON. Run: entourage update";
20
- // A time longer than this goes on a line of its own.
21
- const SHORT = 14;
22
21
 
23
22
  // `herdr-app check` draws the mod once, with no card selected, which would
24
- // show one line of text and none of the rows. It is given these to draw, so a
25
- // mistake in a row fails the check.
23
+ // 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.
26
25
  const SAMPLE = {
27
26
  run: 1,
27
+ state: "waiting on the human",
28
+ waiting: "waiting on the human for 2m 05s",
28
29
  steps: [
29
- { run: 1, clock: "10:00", kind: "start", label: "started", took: "" },
30
- { run: 1, clock: "10:00", kind: "step", label: "define done", took: "50s", summary: "A summary.", flags: "A flag." },
31
- { run: 1, clock: "10:09", kind: "wait", label: "answered", took: "waited 7m 04s", answer: "approve" },
32
- { run: 1, clock: "10:17", kind: "step", label: "plan done", took: "7m 24s, includes waiting on the human" },
33
- { run: 1, clock: "10:17", kind: "step", label: "breakdown asked a question", took: "5s", question: "Approve?", waiting: "waiting on the human for 2m 05s" },
30
+ { run: 1, at: "a", clock: "10:00", kind: "start", label: "started", took: "", short: "" },
31
+ { run: 1, at: "b", clock: "10:00", kind: "step", label: "define done", took: "50s", short: "50s", summary: "A summary.", flags: "A flag." },
32
+ { run: 1, at: "c", clock: "10:09", kind: "wait", label: "answered", took: "waited 7m 04s", short: "7m 04s", answer: "approve" },
33
+ { run: 1, at: "d", clock: "10:17", kind: "step", label: "plan done", took: "7m 24s, includes waiting on the human", short: "7m 24s" },
34
+ { run: 1, at: "e", clock: "10:17", kind: "step", label: "breakdown asked a question", took: "5s", short: "5s", question: "Approve?", waiting: "waiting on the human for 2m 05s" },
34
35
  ],
35
36
  };
36
37
 
@@ -57,6 +58,13 @@ function parse(text) {
57
58
  // What a failed command said, without the name it starts its errors with.
58
59
  const said = (r) => (r.stderr || r.stdout).trim().replace(/^entourage: /, "");
59
60
 
61
+ const OLD_CLI = "This entourage cannot give a card's steps as JSON. Run: entourage update";
62
+ // An entourage from before --json answers with its usage line, not JSON.
63
+ const failure = (r, what) => {
64
+ const text = said(r);
65
+ return text.startsWith("usage:") ? OLD_CLI : text || `${what} failed`;
66
+ };
67
+
60
68
  // What is selected on this computer: the shown space's folder, and the card
61
69
  // its shown tab is for, if it is a card's tab.
62
70
  function selected() {
@@ -77,6 +85,8 @@ export default class Steps extends View {
77
85
  this.error = null;
78
86
  this.busy = false;
79
87
  this.readAt = 0;
88
+ this.drawn = null; // what the last redraw showed, to redraw only on a change
89
+ this.open = null; // the step whose lines are showing, by its time
80
90
  if (checking()) return;
81
91
  cx.timer.every(LOOK_MS, (cx) => this.look(cx));
82
92
  this.look(cx);
@@ -99,10 +109,13 @@ export default class Steps extends View {
99
109
  }
100
110
 
101
111
  // Read again when another card is selected, or the one on hand is stale.
112
+ // Nothing is read while nobody can see the panel, and a tab that is not a
113
+ // card's has nothing to read again.
102
114
  look(cx) {
103
- if (this.busy || window()?.visible === false) return;
115
+ if (this.busy || window()?.visible === false || narrow()) return;
104
116
  const now = selected();
105
- if (now.key === this.key && Date.now() - this.readAt < REREAD_MS) return;
117
+ const stale = Boolean(now.card) && Date.now() - this.readAt >= REREAD_MS;
118
+ if (now.key === this.key && !stale) return;
106
119
  this.busy = true;
107
120
  cx.spawn(async (cx) => {
108
121
  let project = null;
@@ -116,7 +129,7 @@ export default class Steps extends View {
116
129
  this.projects = list;
117
130
  this.projectsAt = Date.now();
118
131
  } else {
119
- error = r.code === 0 ? OLD_CLI : said(r) || "entourage project ls failed";
132
+ error = r.code === 0 ? OLD_CLI : failure(r, "entourage project ls");
120
133
  }
121
134
  }
122
135
  project = (this.projects ?? []).find((p) => p.folder === now.folder)?.name ?? null;
@@ -124,7 +137,7 @@ export default class Steps extends View {
124
137
  const r = await this.entourage(["task", "log", project, now.card, "--json"]);
125
138
  const got = r.code === 0 ? parse(r.stdout) : null;
126
139
  if (got && Array.isArray(got.steps)) view = got;
127
- else error = r.code === 0 ? OLD_CLI : said(r) || "entourage task log failed";
140
+ else error = r.code === 0 ? OLD_CLI : failure(r, "entourage task log");
128
141
  }
129
142
  } catch (e) {
130
143
  error = `Could not run entourage: ${e?.message ?? e}`;
@@ -135,31 +148,43 @@ export default class Steps extends View {
135
148
  this.error = error;
136
149
  this.readAt = Date.now();
137
150
  this.busy = false;
138
- cx.notify();
151
+ // A redraw of a mod redraws the whole window, so only when what it
152
+ // shows has changed.
153
+ const drawn = JSON.stringify([now.key, project, view, error]);
154
+ if (drawn !== this.drawn) {
155
+ this.drawn = drawn;
156
+ cx.notify();
157
+ }
139
158
  });
140
159
  }
141
160
 
142
- // One hand-off. `s` is a step of the view: its clock, label and took are
143
- // text to show as they are, and its kind says whether it is a wait.
144
- row(s, i, t) {
161
+ // One hand-off, on one line: its clock, its label and the time alone. A
162
+ // click opens the rest of what the view says about it. `s` is a step of the
163
+ // view, and its kind says whether it is a wait.
164
+ row(s, i, t, open) {
145
165
  const wait = s.kind === "wait";
146
166
  const start = s.kind === "start";
147
- const took = s.took ?? "";
148
- const beside = took.length <= SHORT;
149
- const detail = s.question ?? s.answer ?? s.reason ?? s.summary ?? null;
167
+ // An entourage from before `short` gives the whole of `took` here.
168
+ const short = s.short ?? s.took ?? "";
169
+ const full = s.took && s.took !== short ? s.took : null;
170
+ const lines = [full, s.question, s.answer, s.reason, s.summary, s.flags ? `Flags: ${s.flags}` : null]
171
+ .filter(Boolean);
150
172
  const small = (text, color) =>
151
173
  div().pl(46).pr(4).text_size(11.5).text_color(color).whitespace_normal().child(text);
152
- return v_flex().id(`step-${i}`).flex_none().px(8).py(5).gap(2).rounded(8)
174
+ return v_flex().id(`step-${i}`).flex_none().px(8).py(4).gap(2).rounded(8)
175
+ .hover((el) => el.bg(t.hover))
176
+ .on_click((_e, cx) => {
177
+ this.open = this.open === s.at ? null : s.at;
178
+ cx.notify();
179
+ })
153
180
  .child(h_flex().gap(8).items_center()
154
181
  .child(div().w(38).flex_none().text_size(11.5).text_color(t.dim).child(s.clock ?? ""))
155
182
  .child(div().flex_1().min_w(0).truncate()
156
183
  .text_color(wait ? t.blocked : start ? t.muted : t.foreground).child(s.label ?? ""))
157
- .when(beside && took !== "", (el) =>
158
- el.child(div().flex_none().text_size(11.5).text_color(wait ? t.blocked : t.dim).child(took))))
159
- .when(!beside, (el) => el.child(small(took, t.dim)))
160
- .when(Boolean(detail), (el) => el.child(small(detail, t.muted)))
161
- .when(Boolean(s.flags), (el) => el.child(small(`Flags: ${s.flags}`, t.dim)))
162
- .when(Boolean(s.waiting), (el) => el.child(small(s.waiting, t.blocked)));
184
+ .child(div().flex_none().text_size(11.5).text_color(wait ? t.blocked : t.dim).child(short)))
185
+ // A question still waiting shows whether or not the step is open.
186
+ .when(Boolean(s.waiting), (el) => el.child(small(s.waiting, t.blocked)))
187
+ .when(open, (el) => el.children(lines.map((text) => small(text, t.muted))));
163
188
  }
164
189
 
165
190
  render() {
@@ -173,13 +198,18 @@ export default class Steps extends View {
173
198
  const items = [];
174
199
  // The latest run only: a card written up twice keeps both in its log.
175
200
  const steps = (view?.steps ?? []).filter((s) => s.run === view.run);
176
- if (sample) steps.forEach((s, i) => items.push(this.row(s, i, t)));
201
+ const rows = () => {
202
+ // Where the card stands, as the view words it.
203
+ if (view.state) items.push(note(view.state, view.waiting ? t.blocked : t.dim));
204
+ steps.forEach((s, i) => items.push(this.row(s, i, t, sample || this.open === s.at)));
205
+ };
206
+ if (sample) rows();
177
207
  else if (!now.card) items.push(note("Select a card's tab to see its steps.", t.dim));
178
208
  else if (now.key !== this.key) items.push(note("Loading…", t.dim));
179
209
  else if (this.error) items.push(note(this.error, t.blocked));
180
210
  else if (!this.project) items.push(note("This space is not an entourage project.", t.dim));
181
211
  else if (steps.length === 0) items.push(note(`No hand-offs recorded for ${now.card} yet.`, t.dim));
182
- else steps.forEach((s, i) => items.push(this.row(s, i, t)));
212
+ else rows();
183
213
  return v_flex().size_full().min_h(0).bg(t.chrome).text_size(13)
184
214
  .child(h_flex().h(31).flex_none().pl(16).pr(14).items_center().justify_between()
185
215
  .text_size(11.5).text_color(t.dim)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@johngaynor/entourage",
3
- "version": "0.4.1-next.10",
3
+ "version": "0.4.1-next.13",
4
4
  "description": "A software factory: agent skills and the Herdr setup to run them, installed with one command.",
5
5
  "bin": {
6
6
  "entourage": "cli/entourage"