@staff0rd/assist 0.245.4 → 0.247.0

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.
Files changed (2) hide show
  1. package/dist/index.js +22 -12
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { Command } from "commander";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "@staff0rd/assist",
9
- version: "0.245.4",
9
+ version: "0.247.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -4327,9 +4327,9 @@ async function deleteComment(orm, itemId, commentId) {
4327
4327
  // src/commands/backlog/web/shared.ts
4328
4328
  async function listItems(req, res) {
4329
4329
  applyCwdFromReq(req);
4330
- const url = new URL(req.url ?? "/", "http://localhost");
4331
- const q = url.searchParams.get("q");
4332
- respondJson(res, 200, q ? await searchBacklog(q) : await loadBacklog());
4330
+ const q = new URL(req.url ?? "/", "http://localhost").searchParams.get("q");
4331
+ const items2 = q ? await searchBacklog(q) : await loadBacklog();
4332
+ respondJson(res, 200, items2.slice().reverse());
4333
4333
  }
4334
4334
  async function findItemOr404(res, id) {
4335
4335
  const { orm } = await getReady();
@@ -17063,6 +17063,19 @@ async function discoverSessions() {
17063
17063
  return sessions;
17064
17064
  }
17065
17065
 
17066
+ // src/commands/sessions/daemon/shouldAutoDismiss.ts
17067
+ function shouldAutoDismiss(session, exitCode) {
17068
+ const args = session.assistArgs;
17069
+ return session.status === "done" && exitCode === 0 && args !== void 0 && args.includes("--once") && args[0] !== "next";
17070
+ }
17071
+
17072
+ // src/commands/sessions/daemon/applyStatusChange.ts
17073
+ function applyStatusChange(session, status2, exitCode, dismiss, notify2) {
17074
+ session.status = status2;
17075
+ if (shouldAutoDismiss(session, exitCode)) dismiss(session.id);
17076
+ else notify2();
17077
+ }
17078
+
17066
17079
  // src/commands/sessions/daemon/broadcast.ts
17067
17080
  function sendTo(client, msg) {
17068
17081
  client.send(JSON.stringify(msg));
@@ -17331,9 +17344,9 @@ function wirePtyEvents(session, clients, onStatusChange) {
17331
17344
  scheduleIdle(session, () => onStatusChange(session, "waiting"));
17332
17345
  broadcast(clients, { type: "output", sessionId: session.id, data });
17333
17346
  });
17334
- session.pty.onExit(() => {
17347
+ session.pty.onExit(({ exitCode }) => {
17335
17348
  clearIdle(session);
17336
- onStatusChange(session, "done");
17349
+ onStatusChange(session, "done", exitCode);
17337
17350
  });
17338
17351
  scheduleIdle(session, () => onStatusChange(session, "waiting"));
17339
17352
  }
@@ -17521,10 +17534,7 @@ var SessionManager = class {
17521
17534
  resume(sessionId, cwd, name) {
17522
17535
  return this.add(resumeSession(String(this.nextId++), sessionId, cwd, name));
17523
17536
  }
17524
- onStatusChange = (s, status2) => {
17525
- s.status = status2;
17526
- this.notify();
17527
- };
17537
+ onStatusChange = (s, status2, exitCode) => applyStatusChange(s, status2, exitCode, this.dismissSession, this.notify);
17528
17538
  wire(session) {
17529
17539
  this.sessions.set(session.id, session);
17530
17540
  wirePtyEvents(session, this.clients, this.onStatusChange);
@@ -17540,9 +17550,9 @@ var SessionManager = class {
17540
17550
  const s = this.sessions.get(id);
17541
17551
  if (s && retrySession(s, this.clients, this.onStatusChange)) this.notify();
17542
17552
  }
17543
- dismissSession(id) {
17553
+ dismissSession = (id) => {
17544
17554
  if (dismissSession(this.sessions, id)) this.notify();
17545
- }
17555
+ };
17546
17556
  listSessions() {
17547
17557
  return [...this.sessions.values()].map(toSessionInfo);
17548
17558
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.245.4",
3
+ "version": "0.247.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {