@hearsay-tools/squawk 0.18.0-pr3446.6039 → 0.18.0-pr3448.6045
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/dist/delegation/routes.d.ts +77 -77
- package/dist/delegation/transport.d.ts +17 -17
- package/dist/git-worktree.d.ts +52 -0
- package/dist/git-worktree.js +374 -2
- package/dist/git-worktree.js.map +1 -1
- package/dist/project-migration/live.js +1 -1
- package/dist/project-migration/live.js.map +1 -1
- package/dist/runs/live-tasks.d.ts +10 -0
- package/dist/runs/live-tasks.js +33 -0
- package/dist/runs/live-tasks.js.map +1 -0
- package/dist/serve-command.js +1 -0
- package/dist/serve-command.js.map +1 -1
- package/dist/server/forge/draft-pr.js +1 -1
- package/dist/server/forge/draft-pr.js.map +1 -1
- package/dist/server/live-routes.d.ts +6 -6
- package/dist/server/project-context.d.ts +7 -10
- package/dist/server/project-context.js +8 -36
- package/dist/server/project-context.js.map +1 -1
- package/dist/server/server.d.ts +10 -8
- package/dist/server/server.js +4 -5
- package/dist/server/server.js.map +1 -1
- package/dist/server/start-run-options.d.ts +2 -1
- package/dist/server/start-run-options.js +1 -1
- package/dist/server/start-run-options.js.map +1 -1
- package/dist/server/workspace-projects.d.ts +1 -1
- package/dist/server/workspace-projects.js +1 -0
- package/dist/server/workspace-projects.js.map +1 -1
- package/dist/workflows/run/continuation-session.d.ts +1 -1
- package/dist/workflows/run/run-settlement.d.ts +1 -1
- package/dist/workflows/run/run-settlement.js.map +1 -1
- package/dist/workflows/run/worktree-autosave.d.ts +1 -1
- package/dist/workflows/run/worktree-autosave.js +1 -1
- package/dist/workflows/run/worktree-autosave.js.map +1 -1
- package/package.json +4 -4
- package/scripts/benchmark-run-store.ts +2 -1
- package/scripts/benchmark-workspace-events.ts +2 -1
- package/scripts/measure-transcript-facts-health.mjs +2 -1
- package/web/dist/assets/activity-motion-Dld5ms7x.js +2 -0
- package/web/dist/assets/{activity-route-DQI_8J09.js → activity-route-CNZPeNfz.js} +1 -1
- package/web/dist/assets/{agent-accounts-C6eyz75V.js → agent-accounts-B-Gpf8IN.js} +1 -1
- package/web/dist/assets/attention-VmnPpwJx.js +1 -0
- package/web/dist/assets/{commit-diff-panel-C7BUSPzE.js → commit-diff-panel-NClCG68F.js} +1 -1
- package/web/dist/assets/control-locations-B88tMDqg.js +1 -0
- package/web/dist/assets/diff-nIehE-T6.js +3 -0
- package/web/dist/assets/{diff-view-B9kgeZTm.js → diff-view-DcvEkA3I.js} +1 -1
- package/web/dist/assets/{file-preview-DrXgM1-S.js → file-preview-D5OEhi_p.js} +1 -1
- package/web/dist/assets/{git-toolbar-B1gOn_1U.js → git-toolbar-6nOTPb_C.js} +1 -1
- package/web/dist/assets/github-kqE3kY6l.js +1 -0
- package/web/dist/assets/github-sidebar-model-DkUAF09l.js +1 -0
- package/web/dist/assets/{global-activity-route-CZ_xwiz3.js → global-activity-route-BExanylS.js} +1 -1
- package/web/dist/assets/{index-75IttVLX.js → index-DBNT3CYH.js} +11 -11
- package/web/dist/assets/live-refetch-CZb2VOyu.js +1 -0
- package/web/dist/assets/popover-G6KGT-qq.js +1 -0
- package/web/dist/assets/{preview-pane-connected-Cx8q-Yrh.js → preview-pane-connected-BN0BWrKD.js} +1 -1
- package/web/dist/assets/queries-D2MPDhtr.js +1 -0
- package/web/dist/assets/repo-git-CPEbNCTy.js +1 -0
- package/web/dist/assets/{report-reader-CeBtx_Sf.js → report-reader-Ltc8JdIV.js} +1 -1
- package/web/dist/assets/{reports-CRPxIRMM.js → reports-DHuR8gwU.js} +1 -1
- package/web/dist/assets/run-header-BDtR-uVy.js +2 -0
- package/web/dist/assets/{skills-DDoJCcmD.js → skills-DTowIB5z.js} +1 -1
- package/web/dist/assets/task-changes-NqJ_-tod.js +1 -0
- package/web/dist/assets/task-commits-BbhrfhCT.js +1 -0
- package/web/dist/assets/{task-files-CkPJZE0w.js → task-files-n29-eIMD.js} +1 -1
- package/web/dist/assets/task-github-item-BwS8ltjs.js +1 -0
- package/web/dist/assets/task-thread-DkF28KyV.js +9 -0
- package/web/dist/assets/{thread-state-BtmIMbkZ.js → thread-state-C8XI1WNf.js} +1 -1
- package/web/dist/assets/use-hand-to-agent-state-CY43kvaa.js +1 -0
- package/web/dist/assets/workflows-CWFMDlCn.js +7 -0
- package/web/dist/index.html +10 -9
- package/dist/autosave-commit.d.ts +0 -52
- package/dist/autosave-commit.js +0 -378
- package/dist/autosave-commit.js.map +0 -1
- package/web/dist/assets/activity-motion-Bqd8S9Xy.js +0 -2
- package/web/dist/assets/control-locations-DlrUP5vD.js +0 -1
- package/web/dist/assets/diff-Bwy0qFul.js +0 -3
- package/web/dist/assets/github-g-ZOTwHQ.js +0 -1
- package/web/dist/assets/github-sidebar-model-BdoLA7qT.js +0 -1
- package/web/dist/assets/live-refetch-pzhdhNS_.js +0 -1
- package/web/dist/assets/popover-N-u5z2xh.js +0 -1
- package/web/dist/assets/queries-BtScxiQP.js +0 -1
- package/web/dist/assets/repo-git-DgZuI4FP.js +0 -1
- package/web/dist/assets/run-header-C8Eeonkx.js +0 -2
- package/web/dist/assets/task-changes-XAcKfebn.js +0 -1
- package/web/dist/assets/task-commits-D5V0Q0au.js +0 -1
- package/web/dist/assets/task-github-item-CbCOKkvp.js +0 -1
- package/web/dist/assets/task-thread-DyR8HsDz.js +0 -9
- package/web/dist/assets/use-hand-to-agent-state-BUpbMYM9.js +0 -1
- package/web/dist/assets/workflows-CEFtJj_h.js +0 -7
package/dist/autosave-commit.js
DELETED
|
@@ -1,378 +0,0 @@
|
|
|
1
|
-
import { logPrefix } from './home/display.js';
|
|
2
|
-
import { fallbackProjectWriteError } from './project-paths.js';
|
|
3
|
-
import { autosaveGit } from './autosave-git.js';
|
|
4
|
-
import { realpathSync } from 'node:fs';
|
|
5
|
-
import { readFile, stat } from 'node:fs/promises';
|
|
6
|
-
import { join, resolve } from 'node:path';
|
|
7
|
-
/**
|
|
8
|
-
* Leftover merge-conflict markers, anchored at line start as git writes them.
|
|
9
|
-
* All three must appear *in order*: a bare `=======` line is ordinary Markdown
|
|
10
|
-
* (a setext heading underline), and any of the three alone — or the pair
|
|
11
|
-
* `<<<<<<<`/`>>>>>>>` in either order — occurs legitimately in checked-in
|
|
12
|
-
* patch fixtures and in docs that demonstrate conflict markers. Requiring the
|
|
13
|
-
* full ordered triple is what separates a real conflict from a file that
|
|
14
|
-
* merely talks about one.
|
|
15
|
-
*/
|
|
16
|
-
const CONFLICT_START = /^<{7}(?:\s|$)/;
|
|
17
|
-
const CONFLICT_MID = /^={7}(?:\s|$)/;
|
|
18
|
-
const CONFLICT_END = /^>{7}(?:\s|$)/;
|
|
19
|
-
/**
|
|
20
|
-
* Largest file the marker scan will read. Autosave runs as often as every 90 s,
|
|
21
|
-
* and decoding a large tracked file into a JS string each time is a real memory
|
|
22
|
-
* cost for a check that only ever looks at a few marker lines. Oversized files
|
|
23
|
-
* are skipped, which fails *open* — consistent with the rest of this guard,
|
|
24
|
-
* where a false negative costs noise and a false positive costs the recovery
|
|
25
|
-
* point.
|
|
26
|
-
*/
|
|
27
|
-
const MARKER_SCAN_MAX_BYTES = 2_000_000;
|
|
28
|
-
/** Does this file carry a complete, ordered conflict hunk? */
|
|
29
|
-
function hasConflictMarkers(text) {
|
|
30
|
-
let want = 0; // 0: `<<<<<<<`, 1: `=======`, 2: `>>>>>>>`
|
|
31
|
-
for (const line of text.split('\n')) {
|
|
32
|
-
if (want === 0) {
|
|
33
|
-
if (CONFLICT_START.test(line))
|
|
34
|
-
want = 1;
|
|
35
|
-
}
|
|
36
|
-
else if (want === 1) {
|
|
37
|
-
if (CONFLICT_MID.test(line))
|
|
38
|
-
want = 2;
|
|
39
|
-
}
|
|
40
|
-
else if (CONFLICT_END.test(line)) {
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
/** Serialize all autosave entry points, including periodic/final flush overlap. */
|
|
47
|
-
const autosaves = new Map();
|
|
48
|
-
/** HEAD's symbolic ref, `null` on a detached HEAD, `undefined` when the read failed. */
|
|
49
|
-
async function readAutosaveHead(dir, git) {
|
|
50
|
-
// Exit 1 under -q is a detached HEAD; anything else is a failed read.
|
|
51
|
-
const ref = await git(dir, ['symbolic-ref', '-q', 'HEAD']);
|
|
52
|
-
if (!ref.ok && ref.code !== 1)
|
|
53
|
-
return undefined;
|
|
54
|
-
return ref.ok ? ref.stdout.trim() : null;
|
|
55
|
-
}
|
|
56
|
-
function autosaveBranchName(head) {
|
|
57
|
-
return head?.startsWith('refs/heads/') ? head.slice('refs/heads/'.length) : head;
|
|
58
|
-
}
|
|
59
|
-
function reportAutosave(onOutcome, outcome) {
|
|
60
|
-
try {
|
|
61
|
-
onOutcome?.(outcome);
|
|
62
|
-
}
|
|
63
|
-
catch { /* Reporting must not change what the save did. */ }
|
|
64
|
-
}
|
|
65
|
-
// HEAD is not the task branch: the work stays uncommitted, reported with the paths status saw.
|
|
66
|
-
function skipAutosave(head, status, onOutcome) {
|
|
67
|
-
reportAutosave(onOutcome, { result: 'skipped', branch: autosaveBranchName(head), changedPaths: status.split('\n').filter(Boolean).length });
|
|
68
|
-
return 'skipped';
|
|
69
|
-
}
|
|
70
|
-
/** A resolved merge, cherry-pick or revert the agent has not concluded: `git commit`
|
|
71
|
-
* would conclude it under `cezar autosave`. The agent concludes it with its own
|
|
72
|
-
* message; the next flush picks the work up (hearsay-tools/cezarion#1004). Asked of
|
|
73
|
-
* Git, not looked up as files: only MERGE_HEAD is always a file. CHERRY_PICK_HEAD and
|
|
74
|
-
* REVERT_HEAD are root refs in the ref backend, which a reftable repository keeps in
|
|
75
|
-
* its reftable stack, so a file check would miss them there. */
|
|
76
|
-
async function pendingAutosaveOperation(dir, reason, git) {
|
|
77
|
-
for (const pending of ['MERGE_HEAD', 'CHERRY_PICK_HEAD', 'REVERT_HEAD']) {
|
|
78
|
-
const found = await git(dir, ['rev-parse', '--verify', '-q', pending]);
|
|
79
|
-
if (found.ok) {
|
|
80
|
-
console.warn(`${logPrefix()} skipping ${reason} autosave in ${dir}: ${pending} is set, the operation is not concluded`);
|
|
81
|
-
return 'refused';
|
|
82
|
-
}
|
|
83
|
-
if (found.code !== 1)
|
|
84
|
-
return 'failed';
|
|
85
|
-
}
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
/** Commit as the CURRENT git user, so the branch's commits (and any PR opened from it) are
|
|
89
|
-
* attributed to the real author and pass CLA / attribution checks. The old hardcoded
|
|
90
|
-
* `cezar <cezar@local>` identity made every autosave look like a non-GitHub user. Fall back to
|
|
91
|
-
* that identity ONLY when the machine has no git identity configured — otherwise `git commit`
|
|
92
|
-
* would fail and the autosave (the run's recovery point) would be lost. */
|
|
93
|
-
async function autosaveIdentityArgs(dir, git) {
|
|
94
|
-
const name = await git(dir, ['config', 'user.name']);
|
|
95
|
-
if (!name.ok && name.code !== 1)
|
|
96
|
-
return 'failed';
|
|
97
|
-
const email = await git(dir, ['config', 'user.email']);
|
|
98
|
-
if (!email.ok && email.code !== 1)
|
|
99
|
-
return 'failed';
|
|
100
|
-
return (name.ok && name.stdout.trim() && email.ok && email.stdout.trim())
|
|
101
|
-
? [] : ['-c', 'user.name=cezar', '-c', 'user.email=cezar@local'];
|
|
102
|
-
}
|
|
103
|
-
async function commitAutosaveOnHead(dir, identityArgs, message, branch, onOutcome, git) {
|
|
104
|
-
const commit = await git(dir, [...identityArgs, 'commit', '--no-verify', '-m', message]);
|
|
105
|
-
if (!commit.ok)
|
|
106
|
-
return 'failed';
|
|
107
|
-
if (onOutcome) {
|
|
108
|
-
// The commit already landed: a failed read loses the sha, never the report.
|
|
109
|
-
const sha = await git(dir, ['rev-parse', '--short', 'HEAD']);
|
|
110
|
-
reportAutosave(onOutcome, { result: 'committed', sha: (sha.ok && sha.stdout.trim()) || null, branch });
|
|
111
|
-
}
|
|
112
|
-
return 'committed';
|
|
113
|
-
}
|
|
114
|
-
/** The task branch is written by compare-and-swap, never through HEAD: the agent can
|
|
115
|
-
* check another branch out after the `symbolic-ref` check in `readAutosaveHead`, and `git commit`
|
|
116
|
-
* resolves HEAD again at its own start, so the save landed on the agent's branch
|
|
117
|
-
* (review on hearsay-tools/cezarion#1111). `update-ref <ref> <new> <old>` moves the
|
|
118
|
-
* branch only while it still points at the tip read here (an unborn one: while it
|
|
119
|
-
* still does not exist); a moved branch fails the save and the next flush retries.
|
|
120
|
-
* Unlike the porcelain this runs no prepare-commit-msg or post-commit hook
|
|
121
|
-
* (`--no-verify` already skipped pre-commit and commit-msg), and the reflog entry
|
|
122
|
-
* reads `cezar autosave (<reason>)` without the `commit: ` prefix. commit-tree
|
|
123
|
-
* stopped reading commit.gpgSign in Git 2.9 (its release notes tell scripts to read
|
|
124
|
-
* it and pass -S), so it is read here: a user who signs every commit still does. */
|
|
125
|
-
async function writeAutosaveCommit(dir, taskBranch, identityArgs, message, git) {
|
|
126
|
-
const ref = `refs/heads/${taskBranch}`;
|
|
127
|
-
const tip = await git(dir, ['rev-parse', '--verify', '-q', ref]);
|
|
128
|
-
if (!tip.ok && tip.code !== 1)
|
|
129
|
-
return 'failed';
|
|
130
|
-
const parent = tip.ok ? tip.stdout.trim() : '';
|
|
131
|
-
const written = await git(dir, ['write-tree']);
|
|
132
|
-
const tree = written.stdout.trim();
|
|
133
|
-
if (!written.ok || !tree)
|
|
134
|
-
return 'failed';
|
|
135
|
-
if (parent) {
|
|
136
|
-
// Dirty when status looked, identical once staged: nothing to save.
|
|
137
|
-
const parentTree = await git(dir, ['rev-parse', '--verify', '-q', `${parent}^{tree}`]);
|
|
138
|
-
if (!parentTree.ok)
|
|
139
|
-
return 'failed';
|
|
140
|
-
if (parentTree.stdout.trim() === tree)
|
|
141
|
-
return 'nothing-to-do';
|
|
142
|
-
}
|
|
143
|
-
const sign = await git(dir, ['config', '--type=bool', 'commit.gpgsign']);
|
|
144
|
-
if (!sign.ok && sign.code !== 1)
|
|
145
|
-
return 'failed';
|
|
146
|
-
const created = await git(dir, [
|
|
147
|
-
...identityArgs,
|
|
148
|
-
'commit-tree',
|
|
149
|
-
...(sign.ok && sign.stdout.trim() === 'true' ? ['-S'] : []),
|
|
150
|
-
tree,
|
|
151
|
-
...(parent ? ['-p', parent] : []),
|
|
152
|
-
'-m',
|
|
153
|
-
message,
|
|
154
|
-
]);
|
|
155
|
-
const sha = created.stdout.trim();
|
|
156
|
-
if (!created.ok || !sha)
|
|
157
|
-
return 'failed';
|
|
158
|
-
return { sha, parent };
|
|
159
|
-
}
|
|
160
|
-
async function publishAutosaveCommit(dir, taskBranch, sha, parent, message, status, onOutcome, reason, git) {
|
|
161
|
-
const ref = `refs/heads/${taskBranch}`;
|
|
162
|
-
// The save is not atomic against the agent's own Git commands. It guarantees that no
|
|
163
|
-
// ref other than refs/heads/<taskBranch> moves, and that no merge, cherry-pick or
|
|
164
|
-
// revert Git has recorded as pending (its MERGE_HEAD, CHERRY_PICK_HEAD or REVERT_HEAD
|
|
165
|
-
// written) by this recheck is committed: the check before `add -A` cannot see one that
|
|
166
|
-
// starts after it, and the save would record that operation's content without its
|
|
167
|
-
// ancestry (review round 4 on hearsay-tools/cezarion#1004). An operation that starts
|
|
168
|
-
// after `write-tree` cannot be in this tree; one recorded before it is still pending
|
|
169
|
-
// here, unless the agent also concluded it, which moved the branch and fails the
|
|
170
|
-
// compare-and-swap, or aborted it within those few commands, whose content the save
|
|
171
|
-
// then still records. A Git command still running during the save is not excluded:
|
|
172
|
-
// `git merge` publishes the merged index before it writes MERGE_HEAD, so a save in
|
|
173
|
-
// between records that content single-parent, as `git add -A && git commit` always
|
|
174
|
-
// did (review round 5 reproduced the same result on main). The save also commits only
|
|
175
|
-
// when HEAD names the task branch at both of its reads, before `add -A` and here after
|
|
176
|
-
// `write-tree`, so a checkout between them skips it (review round 2 on
|
|
177
|
-
// hearsay-tools/cezarion#1111). A checkout away and back again between the reads is not
|
|
178
|
-
// excluded, nor is one still running, which writes the new index and working tree
|
|
179
|
-
// before it moves HEAD, so a save in between commits the other branch's files onto the
|
|
180
|
-
// task branch, as `git add -A && git commit` on main does. A refusal or a skip here
|
|
181
|
-
// leaves what `add -A` staged in the index, as every failure after it does.
|
|
182
|
-
const moved = await readAutosaveHead(dir, git);
|
|
183
|
-
if (moved === undefined)
|
|
184
|
-
return 'failed';
|
|
185
|
-
if (moved !== ref)
|
|
186
|
-
return skipAutosave(moved, status, onOutcome);
|
|
187
|
-
const late = await pendingAutosaveOperation(dir, reason, git);
|
|
188
|
-
if (late)
|
|
189
|
-
return late;
|
|
190
|
-
if (!(await git(dir, ['update-ref', '-m', message, ref, sha, parent])).ok)
|
|
191
|
-
return 'failed';
|
|
192
|
-
if (onOutcome) {
|
|
193
|
-
// The commit already landed: a failed read loses the sha, never the report.
|
|
194
|
-
const short = await git(dir, ['rev-parse', '--short', sha]);
|
|
195
|
-
reportAutosave(onOutcome, { result: 'committed', sha: (short.ok && short.stdout.trim()) || null, branch: taskBranch });
|
|
196
|
-
}
|
|
197
|
-
return 'committed';
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* Stage and commit everything in the worktree as a "cezar autosave" commit
|
|
201
|
-
* (janitor pattern) — the agent's progress is recoverable from the `cez/<id8>`
|
|
202
|
-
* branch history. Quietly a no-op when nothing changed. With `taskBranch`, a
|
|
203
|
-
* worktree whose HEAD the agent moved to another branch (or detached) is left
|
|
204
|
-
* uncommitted instead: an autosave commit there lands in the agent's own PR
|
|
205
|
-
* history (hearsay-tools/cezarion#1004).
|
|
206
|
-
*
|
|
207
|
-
* The message carries `reason` so the opt-in periodic timer and the always-on
|
|
208
|
-
* flushes are distinguishable in `git log`; the `cezar autosave` prefix is kept
|
|
209
|
-
* so existing log greps still match.
|
|
210
|
-
*
|
|
211
|
-
* Refuses to commit a worktree that is mid-merge or still carries conflict
|
|
212
|
-
* markers: the incident behind #471 was an autosave capturing a half-resolved
|
|
213
|
-
* merge, and a blind `git add -A` would do it again.
|
|
214
|
-
*/
|
|
215
|
-
export async function autosaveCommit(dir, reason, options = {}) {
|
|
216
|
-
if (fallbackProjectWriteError(dir)) {
|
|
217
|
-
console.info(`${logPrefix()} Autosave skipped 1 read-only fallback worktree under .ai/squawk/.`);
|
|
218
|
-
return 'skipped';
|
|
219
|
-
}
|
|
220
|
-
let key = resolve(dir);
|
|
221
|
-
try {
|
|
222
|
-
key = realpathSync(dir);
|
|
223
|
-
}
|
|
224
|
-
catch { /* Missing/unreadable dir fails through Git. */ }
|
|
225
|
-
const previous = autosaves.get(key);
|
|
226
|
-
const task = (async () => {
|
|
227
|
-
if (previous)
|
|
228
|
-
await previous;
|
|
229
|
-
return save();
|
|
230
|
-
})();
|
|
231
|
-
autosaves.set(key, task);
|
|
232
|
-
try {
|
|
233
|
-
return await task;
|
|
234
|
-
}
|
|
235
|
-
finally {
|
|
236
|
-
if (autosaves.get(key) === task)
|
|
237
|
-
autosaves.delete(key);
|
|
238
|
-
}
|
|
239
|
-
async function save() {
|
|
240
|
-
const git = (cwd, args) => autosaveGit(cwd, args, options);
|
|
241
|
-
const status = await git(dir, ['status', '--porcelain']);
|
|
242
|
-
if (!status.ok)
|
|
243
|
-
return 'failed';
|
|
244
|
-
if (!status.stdout.trim())
|
|
245
|
-
return 'nothing-to-do';
|
|
246
|
-
const { taskBranch, onOutcome } = options;
|
|
247
|
-
let head = null;
|
|
248
|
-
if (taskBranch !== undefined || onOutcome) {
|
|
249
|
-
const read = await readAutosaveHead(dir, git);
|
|
250
|
-
if (read === undefined)
|
|
251
|
-
return 'failed';
|
|
252
|
-
head = read;
|
|
253
|
-
}
|
|
254
|
-
const branch = autosaveBranchName(head);
|
|
255
|
-
if (taskBranch !== undefined && head !== `refs/heads/${taskBranch}`)
|
|
256
|
-
return skipAutosave(head, status.stdout, onOutcome);
|
|
257
|
-
const unresolved = await unresolvedConflicts(dir, status.stdout);
|
|
258
|
-
if (unresolved) {
|
|
259
|
-
// Losing one recovery point beats poisoning the branch with a commit that
|
|
260
|
-
// does not build. For the periodic and turn-end flushes the next one picks
|
|
261
|
-
// the work up once the merge resolves; the pre-PR flush has no next one,
|
|
262
|
-
// which is why callers get `refused` rather than a bare `false`.
|
|
263
|
-
console.warn(`${logPrefix()} skipping ${reason} autosave in ${dir}: ${unresolved}`);
|
|
264
|
-
return 'refused';
|
|
265
|
-
}
|
|
266
|
-
if (taskBranch !== undefined) {
|
|
267
|
-
// Checked before staging too, so a pending operation's index stays as the agent left it.
|
|
268
|
-
const pending = await pendingAutosaveOperation(dir, reason, git);
|
|
269
|
-
if (pending)
|
|
270
|
-
return pending;
|
|
271
|
-
}
|
|
272
|
-
if (!(await git(dir, ['add', '-A'])).ok)
|
|
273
|
-
return 'failed';
|
|
274
|
-
const identityArgs = await autosaveIdentityArgs(dir, git);
|
|
275
|
-
if (identityArgs === 'failed')
|
|
276
|
-
return 'failed';
|
|
277
|
-
const message = `cezar autosave (${reason})`;
|
|
278
|
-
if (taskBranch === undefined) {
|
|
279
|
-
return commitAutosaveOnHead(dir, identityArgs, message, branch, onOutcome, git);
|
|
280
|
-
}
|
|
281
|
-
const written = await writeAutosaveCommit(dir, taskBranch, identityArgs, message, git);
|
|
282
|
-
if (written === 'failed' || written === 'nothing-to-do')
|
|
283
|
-
return written;
|
|
284
|
-
return publishAutosaveCommit(dir, taskBranch, written.sha, written.parent, message, status.stdout, onOutcome, reason, git);
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* Is the worktree mid-merge or still carrying conflict markers? Returns a
|
|
289
|
-
* human-readable reason, or `null` when it is safe to autosave.
|
|
290
|
-
*
|
|
291
|
-
* Two independent checks, because they catch different failures: porcelain `U`
|
|
292
|
-
* codes catch an *unresolved* merge, while the marker scan catches the worse
|
|
293
|
-
* case — someone ran `git add` on a file they had not finished resolving, which
|
|
294
|
-
* clears the `U` code but leaves `<<<<<<<` in the text.
|
|
295
|
-
*/
|
|
296
|
-
async function unresolvedConflicts(dir, porcelain) {
|
|
297
|
-
const entries = porcelain.split('\n').filter(Boolean);
|
|
298
|
-
const unmerged = entries.filter((line) => {
|
|
299
|
-
const xy = line.slice(0, 2);
|
|
300
|
-
// Unmerged per `git status` docs: any side U, plus the AA / DD collisions.
|
|
301
|
-
return xy.includes('U') || xy === 'AA' || xy === 'DD';
|
|
302
|
-
});
|
|
303
|
-
const firstUnmerged = unmerged[0];
|
|
304
|
-
if (firstUnmerged) {
|
|
305
|
-
return `${unmerged.length} unmerged path(s), e.g. ${firstUnmerged.slice(3)}`;
|
|
306
|
-
}
|
|
307
|
-
// Deleted paths have no content to scan. Untracked (`??`) ones are skipped
|
|
308
|
-
// even though `git add -A` will commit them: a conflict always lands in a
|
|
309
|
-
// tracked file, whereas an untracked fixture or doc that legitimately
|
|
310
|
-
// contains marker-shaped lines would otherwise wedge every autosave. False
|
|
311
|
-
// negatives here cost noise; false positives would cost the recovery point.
|
|
312
|
-
const candidates = entries
|
|
313
|
-
.filter((line) => !line.startsWith('D ') && !line.startsWith(' D') && !line.startsWith('??'))
|
|
314
|
-
.map((line) => {
|
|
315
|
-
// A rename reads `old -> new`; the new path is what gets committed.
|
|
316
|
-
const raw = line.slice(3).trim();
|
|
317
|
-
const path = raw.includes(' -> ') ? (raw.split(' -> ')[1] ?? raw) : raw;
|
|
318
|
-
return unquotePath(path);
|
|
319
|
-
});
|
|
320
|
-
for (const path of candidates) {
|
|
321
|
-
// Read the working tree, not the index: this runs before `git add -A`, so
|
|
322
|
-
// the on-disk copy is what would be committed. Binary files decode to
|
|
323
|
-
// mojibake rather than throwing, but cannot match the anchored marker
|
|
324
|
-
// pattern; unreadable paths (races, symlinks) are skipped, not fatal.
|
|
325
|
-
let text;
|
|
326
|
-
try {
|
|
327
|
-
const full = join(dir, path);
|
|
328
|
-
if ((await stat(full)).size > MARKER_SCAN_MAX_BYTES)
|
|
329
|
-
continue;
|
|
330
|
-
text = await readFile(full, 'utf8');
|
|
331
|
-
}
|
|
332
|
-
catch {
|
|
333
|
-
continue;
|
|
334
|
-
}
|
|
335
|
-
if (hasConflictMarkers(text)) {
|
|
336
|
-
return `leftover conflict markers in ${path}`;
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
return null;
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* Undo `git status --porcelain` path quoting. Git quotes a path containing a
|
|
343
|
-
* space or a non-ASCII byte, escaping the latter as octal — `café.txt` reads
|
|
344
|
-
* back as `"caf\303\251.txt"`. Stripping the quotes alone leaves those escapes
|
|
345
|
-
* literal, so the file would not open and a real conflict in it would go
|
|
346
|
-
* unnoticed. Decoding the octal bytes as UTF-8 restores the actual name.
|
|
347
|
-
*/
|
|
348
|
-
function unquotePath(path) {
|
|
349
|
-
if (!path.startsWith('"') || !path.endsWith('"'))
|
|
350
|
-
return path;
|
|
351
|
-
const inner = path.slice(1, -1);
|
|
352
|
-
const bytes = [];
|
|
353
|
-
for (let i = 0; i < inner.length; i += 1) {
|
|
354
|
-
if (inner[i] !== '\\') {
|
|
355
|
-
bytes.push(...Buffer.from(inner[i], 'utf8'));
|
|
356
|
-
continue;
|
|
357
|
-
}
|
|
358
|
-
const next = inner[i + 1];
|
|
359
|
-
if (next === undefined)
|
|
360
|
-
break;
|
|
361
|
-
const octal = inner.slice(i + 1, i + 4);
|
|
362
|
-
if (/^[0-7]{3}$/.test(octal)) {
|
|
363
|
-
bytes.push(parseInt(octal, 8));
|
|
364
|
-
i += 3;
|
|
365
|
-
continue;
|
|
366
|
-
}
|
|
367
|
-
// C-style single-character escapes git also emits.
|
|
368
|
-
const simple = { n: 10, t: 9, r: 13, '"': 34, '\\': 92 };
|
|
369
|
-
const escaped = simple[next];
|
|
370
|
-
if (escaped === undefined)
|
|
371
|
-
bytes.push(...Buffer.from(next, 'utf8'));
|
|
372
|
-
else
|
|
373
|
-
bytes.push(escaped);
|
|
374
|
-
i += 1;
|
|
375
|
-
}
|
|
376
|
-
return Buffer.from(bytes).toString('utf8');
|
|
377
|
-
}
|
|
378
|
-
//# sourceMappingURL=autosave-commit.js.map
|
|
@@ -1 +0,0 @@
|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,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QACxC,IAAI,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAC7B,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;YAC/B,CAAC,IAAI,CAAC,CAAC;YACP,SAAS;QACX,CAAC;QACD,mDAAmD;QACnD,MAAM,MAAM,GAA2B,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;QACjF,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;QAC7B,IAAI,OAAO,KAAK,SAAS;YAAE,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;;YAC/D,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACzB,CAAC,IAAI,CAAC,CAAC;IACT,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{L as t,p as n,t as r,u as i}from"./button-CS5tOblf.js";import{i as a,t as o}from"./react-runtime-CCIEwYL0.js";import{t as s}from"./live-refetch-pzhdhNS_.js";import{An as c,Dr as l,In as u,Kr as d,Pr as f,Rt as p,Tr as m,f as ee,gr as te,i as ne,or as re,wn as ie,zn as h}from"./project-scope-context-DSkcNKO7.js";import{$ as g,A as ae,J as _,K as v,V as oe,W as se,X as ce,Y as le,Z as y,ct as ue,et as b,it as de,rt as x,st as fe}from"./live-protocol-DBPXI6ks.js";import{t as pe}from"./useQuery-8pHkglP4.js";import{n as me,t as he}from"./ws-CEQH0TUT.js";import{t as S}from"./createLucideIcon-BHp8sXmF.js";import{n as ge,r as _e,t as ve}from"./hourglass-B0lPAJvT.js";import{t as ye}from"./eye-B8okNWXU.js";import{t as be}from"./message-square-B-MD-8rD.js";import{t as C}from"./project-router-BFKfAFvq.js";import{Nt as xe,Xt as w,yn as T}from"./index-75IttVLX.js";var Se=S(`ban`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]),Ce=S(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),we=S(`git-merge`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]),Te=S(`git-pull-request`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`line`,{x1:`6`,x2:`6`,y1:`9`,y2:`21`,key:`rroup`}]]),Ee=S(`messages-square`,[[`path`,{d:`M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z`,key:`1n2ejm`}],[`path`,{d:`M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1`,key:`1qfcsi`}]]),De=S(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),Oe=S(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),ke=S(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),Ae=S(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),E=e(a(),1),D=o(),O=ue(),k=g().int().nonnegative(),A=x().min(1),je=b({title:x().max(160),toolKind:v([`read`,`edit`,`delete`,`move`,`search`,`execute`,`think`,`fetch`,`task`,`plan`,`other`]),status:v([`pending`,`running`,`completed`,`failed`,`declined`]),startedAt:O,endedAt:O.optional()}).strict(),Me=v([`pass`,`fail`,`pending`,`skipping`,`cancel`]),Ne=b({checks:_(b({name:x().max(100),bucket:Me}).strict()).max(100),counts:b({pass:k,fail:k,pending:k,skipping:k,cancel:k}).strict(),truncated:y(!0).optional()}).strict(),Pe=ce(`kind`,[b({kind:y(`human`),since:O,detail:b({question:x().max(500).optional(),reason:v([`question`,`turn-end`,`budget`,`completion`]),queuedMessages:g().int().positive().optional()}).strict()}).strict(),b({kind:y(`usage-limit`),detail:b({resumeAt:x()}).strict()}).strict(),b({kind:y(`workers`),since:O,deadline:O.optional(),detail:b({owed:k,total:k,settled:k,replies:y(!0).optional(),mode:ae.optional(),recipientRunIds:_(A)}).strict()}).strict(),b({kind:y(`peers`),since:O,deadline:O,detail:b({peerRunIds:_(A)}).strict()}).strict(),b({kind:y(`subagents`),since:O,deadline:O,detail:b({running:k}).strict()}).strict(),b({kind:y(`pr`),since:O,deadline:O,detail:b({number:g().int().positive(),target:re,checks:Ne.shape.checks.optional(),counts:Ne.shape.counts.optional(),truncated:y(!0).optional()}).strict()}).strict(),b({kind:y(`process`),since:O,deadline:O,detail:b({pid:g().int(),note:x().optional()}).strict()}).strict(),b({kind:y(`timer`),since:O,deadline:O,detail:b({wakeAt:O,note:x().optional()}).strict()}).strict()]),Fe={runId:A,title:x(),status:te,rung:v(u),runner:se.optional(),model:x().optional(),currentStepId:x().optional(),startedAt:x().optional(),wait:Pe.optional(),tool:je.optional(),rate:_(k).length(30),error:x().max(200).optional()},Ie=b({...Fe,revision:k,collected:le()}).strict(),Le=b({...Fe,workers:_(Ie)}).strict(),Re=b({requestId:fe(),relationship:v([`family`,`peer`]),senderRunId:A,recipientRunId:A,text:x().max(500),senderTitle:x().optional(),recipientTitle:x().optional(),createdAt:O,deadline:O.optional()}).strict(),ze=b({requestId:fe(),senderRunId:A,recipientRunId:A,status:oe.shape.status,observedAt:O}).strict(),Be=b({generatedAt:O,projects:_(b({projectId:x(),name:x(),loaded:le(),unavailable:b({status:de([y(404),y(409),y(503)]),error:x()}).strict().optional(),inReview:k,tasks:_(Le),requests:_(Re),closed:_(ze)}).strict())}).strict();b({project:de([y(`default`),x().regex(c)]).optional()});var Ve=5e3,He=e=>[`workspace`,`activity`,e.kind===`project`?e.projectId:null],Ue=e=>e.kind===`project`?`activity:project:${e.projectId}`:`activity:workspace`,We=e=>e.kind===`project`?`/api/v1/workspace/activity?project=${encodeURIComponent(e.projectId)}`:`/api/v1/workspace/activity`,Ge=`the ${t(`cezar`)} server answered /workspace/activity with an unexpected body`;function Ke(e){let t=Be.safeParse(e);if(!t.success)throw new ne(200,Ge);return t.data}async function qe(e,t){let n=e.kind===`project`?{project:e.projectId}:{};return Ke(await ie(await ee.api.v1.workspace.activity.$get({query:n},p(t)),`/workspace/activity`))}function Je(e,t){return e!==void 0&&Date.parse(t.generatedAt)<Date.parse(e.generatedAt)?e:t}var Ye=new Date(0).toISOString();function Xe(e){return e!==void 0&&e!==Ye&&!Number.isNaN(Date.parse(e))}var Ze=new Set([404,409,503]);function Qe(e,t,n,r){let i=e?.projects.find(e=>e.projectId===t)?.name??t;return{generatedAt:e?.generatedAt??Ye,projects:[{projectId:t,name:i,loaded:!0,unavailable:{status:n,error:r},inReview:0,tasks:[],requests:[],closed:[]}]}}function $e(e,t){return new ne(Number(/^HTTP (\d+)$/.exec(t)?.[1]??0),e&&typeof e==`object`&&typeof e.error==`string`?e.error:t)}var et=(e,t)=>e.kind===`project`&&Ze.has(t.status)?t.status:void 0;function tt(e){let t=e.kind===`project`?e.projectId:void 0,n=(0,E.useMemo)(()=>t===void 0?{kind:`workspace`}:{kind:`project`,projectId:t},[t]),r=(0,E.useMemo)(()=>He(n),[n]),i=d(),a=pe({queryKey:r,queryFn:async({signal:e})=>{let t=i.getQueryData(r);try{return Je(t,await qe(n,{signal:e}))}catch(e){let r=e instanceof ne?et(n,e):void 0;if(r===void 0||n.kind!==`project`)throw e;return Qe(t,n.projectId,r,e.message)}},staleTime:1/0});return(0,E.useEffect)(()=>{let e=!0,t=t=>{i.cancelQueries({queryKey:r,exact:!0}).then(()=>{if(!e)return;let a=et(n,t);if(a!==void 0&&n.kind===`project`){i.setQueryData(r,e=>Qe(e,n.projectId,a,t.message));return}let o=i.getQueryCache().find({queryKey:r,exact:!0});o?.setState({status:`error`,error:t,errorUpdatedAt:Date.now(),errorUpdateCount:o.state.errorUpdateCount+1,fetchStatus:`idle`})})},a=n=>{let a;try{a=Ke(n)}catch(e){t(e);return}i.cancelQueries({queryKey:r,exact:!0}).then(()=>{e&&i.setQueryData(r,e=>Je(e,a))})},o=he(Ue(n),a),c=s(Ve),u,d=()=>{let e=m()===`finite`&&c!==!1;e&&!u?u=me({path:We(n),intervalMs:c},(e,n)=>{n===void 0?a(e):t($e(e,n))}):!e&&u&&(u(),u=void 0)};d();let f=l(d);return()=>{e=!1,f(),u?.(),o()}},[i,r,n]),a}var j=e=>String(e).padStart(2,`0`);function M(e){let t=Math.max(0,Math.floor(e/1e3)),n=Math.floor(t/3600),r=Math.floor(t/60)%60,i=t%60;return n>0?`${n}:${j(r)}:${j(i)}`:`${r}:${j(i)}`}function N(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t} s`;let n=Math.floor(t/60);return n<60?`${n} min`:`${Math.floor(n/60)} h ${j(n%60)} min`}function P(e,t){let n=e===void 0?NaN:Date.parse(e);return Number.isNaN(n)?0:t-n}var nt=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`});function F(e){let t=Date.parse(e);return Number.isNaN(t)?e:nt.format(t)}function rt(){return Intl.DateTimeFormat().resolvedOptions().timeZone}var it=new Set([`queued`,`running`,`waiting`]),at={review:`In review`,failed:`Failed`,done:`Done`,cancelled:`Cancelled`},ot={review:`review`,failed:`failed`,done:`done`,cancelled:`cancelled`},I=e=>it.has(e),L=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`,R=e=>h(e.rung).tone,st=(e,t=`Deadline`)=>e?`${t} ${F(e)}`:void 0;function ct(e,t,n){return t.length===1&&t[0]!==void 0?`${e} ${n.titleOf(t[0])}`:`${e} ${L(t.length,`task`)}`}function lt(e,t){let n=e.tool,r={verb:`Doing`,tone:R(e),icon:`tool`},i=n?.endedAt!==void 0&&P(n.endedAt,t.now)>1e4;if(n===void 0)return{...r,main:`Thinking`,...e.startedAt?{since:e.startedAt}:{}};let a=`Last tool ${N(P(n.endedAt??n.startedAt,t.now))} ago`;return i?{...r,main:`Thinking`,detail:a,since:n.endedAt??n.startedAt}:{...r,main:n.title,mono:!0,detail:a,since:n.startedAt}}function ut(e,t){let n={verb:`Needs you`,tone:R(e),icon:`user`,...t?{since:t.since}:{}};if(t?.detail.reason===`question`)return t.detail.question?{...n,main:t.detail.question,action:`answer`}:{...n,main:`Your turn`,action:`answer`};if(t?.detail.reason===`budget`){let e=t.detail.queuedMessages;return{...n,main:e?`Automatic wakes used up · ${L(e,`message`)} queued`:`Automatic wakes used up`,action:`open`}}return{...n,main:`Your turn`,action:`open`}}function dt(e){return{verb:`Needs you`,tone:R(e),icon:`user`,main:`Permission`,action:`open`}}function ft(e,t,n){let{owed:r,total:i,settled:a,replies:o,mode:s,recipientRunIds:c}=t.detail,l=i>0?a/i:0,u={tone:R(e),since:t.since};if(o){let e=c.length>0?ct(`From`,c,n):`Waiting for replies`;return{...u,verb:`Waiting for reply`,icon:`reply`,main:e,...z(`detail`,st(t.deadline,`Reply due`))}}let d=c.length>0?`${r} owed · ${a} settled`:s?`${pt[s]} of ${i} · ${a} settled`:`${r} owed`;return{...u,verb:`Waiting for workers`,icon:`workers`,main:d,bar:l,...z(`detail`,st(t.deadline))}}var pt={one:`One`,any:`Any`,all:`All`};function mt(e){let t=e.detail.counts;if(t===void 0)return`PR ${e.detail.number} checks`;let n=t.pass+t.fail+t.pending;return`PR ${e.detail.number} checks · ${t.pass} of ${n} passed`}var ht=[`fail`,`pending`,`pass`,`skipping`,`cancel`];function gt(e){let{counts:t,checks:n=[],truncated:r}=e.detail;if(!r||t===void 0)return;let i=e=>Math.max(0,t[e]-n.filter(t=>t.bucket===e).length),a=ht.reduce((e,t)=>e+i(t),0),o=ht.find(e=>i(e)>0);return a>0&&o?{count:a,bucket:o}:void 0}var _t=[[`pass`,`passed`],[`fail`,`failed`],[`pending`,`pending`],[`skipping`,`skipped`],[`cancel`,`cancelled`]];function vt(e){let{counts:t,checks:n}=e.detail,r=e=>t?t[e]:(n??[]).filter(t=>t.bucket===e).length,i=_t.filter(([e])=>r(e)>0).map(([e,t])=>`${r(e)} ${t}`),a=gt(e);return a&&i.push(`+${a.count} more not listed`),i.length>0?i.join(`, `):void 0}function yt(e,t){let n={tone:R(e),since:t.since,...z(`detail`,st(t.deadline))};if(t.detail.target!==`checks`)return{...n,verb:`Waiting for merge`,icon:`merge`,main:`PR ${t.detail.number}`};let r=t.detail.checks?[...t.detail.checks].sort((e,t)=>e.name.localeCompare(t.name)):void 0;return{...n,verb:`Waiting for CI`,icon:`ci`,main:mt(t),...z(`checks`,r),...z(`overflow`,gt(t)),...z(`checkSummary`,vt(t))}}function z(e,t){return t===void 0?{}:{[e]:t}}function bt(e,t,n){let r=R(e);switch(t.kind){case`workers`:return ft(e,t,n);case`peers`:return{verb:`Waiting for a peer`,tone:r,icon:`peer`,since:t.since,main:ct(`For`,t.detail.peerRunIds,n),detail:`Deadline ${F(t.deadline)}`};case`subagents`:return{verb:`Waiting for subagents`,tone:r,icon:`subagents`,since:t.since,main:L(t.detail.running,`native subagent`),detail:`Deadline ${F(t.deadline)}`};case`pr`:return yt(e,t);case`process`:return{verb:`Waiting for command`,tone:r,icon:`command`,since:t.since,main:t.detail.note??`Process ${t.detail.pid}`,detail:`Running ${M(P(t.since,n.now))} · deadline ${F(t.deadline)}`};case`timer`:return{verb:`Waiting for timer`,tone:r,icon:`timer`,since:t.since,main:t.detail.note??`Timer`,detail:`Wakes ${F(t.detail.wakeAt)} · in ${M(-P(t.detail.wakeAt,n.now))}`};case`usage-limit`:return xt(e,t.detail.resumeAt,n);case`human`:return}}function xt(e,t,n){let r=Date.parse(t),i=Number.isNaN(r)?`Resumes ${t}`:`Resumes ${F(t)} · in ${M(r-n.now)}`;return{verb:`Paused`,tone:R(e),icon:`pause`,main:`Usage limit`,detail:i}}function St(e,t){let n=e.wait&&`since`in e.wait?e.wait.since:e.startedAt;return{verb:`Queued`,tone:R(e),icon:`queued`,main:`Waiting for a free slot`,...n?{since:n,detail:`Waiting ${N(P(n,t.now))}`}:{}}}function B(e,t){return{verb:at[e.status]??e.status,tone:R(e),icon:ot[e.status]??`done`,main:t}}function Ct(e,t){return I(e.status)?wt(e,t):B(e,L(e.workers.filter(e=>I(e.status)).length,`live worker`))}function wt(e,t){let n=e.wait;switch(e.rung){case`running`:return lt(e,t);case`needs-permission`:return dt(e);case`needs-you`:return ut(e,n?.kind===`human`?n:void 0);case`usage-limit`:return n?.kind===`usage-limit`?xt(e,n.detail.resumeAt,t):{verb:`Paused`,tone:R(e),icon:`pause`,main:`Usage limit`};case`queued`:case`waiting-for-capacity`:return St(e,t);default:return(n&&bt(e,n,t))??St(e,t)}}function Tt(e,t,n){if(n!==void 0&&I(e.status))return{verb:`Asks parent`,tone:R(e),main:`“${n}”`,asks:!0};let r=Et(e,t);return{verb:r.verb,tone:r.tone,main:r.main,...r.mono?{mono:!0}:{}}}function Et(e,t){switch(e.status){case`done`:return B(e,e.collected?`Collected`:`Ready to collect`);case`review`:return B(e,`Waiting for the parent’s review`);case`failed`:case`cancelled`:return B(e,e.error??at[e.status]??e.status);default:return wt({...e,workers:[]},t)}}function Dt(e){if(e.unavailable)return e.unavailable.error;if(!e.loaded)return`Not loaded in this cockpit`}function Ot(e){let t=new Map;for(let n of e.tasks){t.set(n.runId,{title:n.title,cardId:n.runId,role:`root`});for(let e of n.workers)t.set(e.runId,{title:e.title,cardId:n.runId,role:`worker`})}return t}function V(e,t,n){return e.get(t)?.title??n??`Unreadable task`}var kt=(e,t)=>V(e,t.senderRunId,t.senderTitle),H=(e,t)=>V(e,t.recipientRunId,t.recipientTitle),At=(e,t)=>`wait:${e}:${t}`;function jt(e){let t=[];for(let n of e){let e=n.wait;if(!(!I(n.status)||e?.kind!==`peers`))for(let r of new Set(e.detail.peerRunIds))r!==n.runId&&t.push({id:At(n.runId,r),waiterRunId:n.runId,peerRunId:r,since:e.since,deadline:e.deadline})}return t}function Mt(e,t){let n=new Set;for(let r of t)r.waiterRunId===e&&n.add(r.peerRunId),r.peerRunId===e&&n.add(r.waiterRunId);return n}function Nt(e,t){return t.filter(t=>t.waiterRunId===e)}function Pt(e,t,n,r=[]){let i=[];for(let r of t)r.senderRunId===e&&i.push(`Waiting for a reply from ${H(n,r)}`),r.recipientRunId===e&&i.push(`${kt(n,r)} waits for your reply`);for(let t of r)t.waiterRunId===e&&i.push(`Waiting for a message from ${V(n,t.peerRunId)}`),t.peerRunId===e&&i.push(`${V(n,t.waiterRunId)} waits for you to write`);return i}function Ft(e,t,n){return n.find(n=>n.relationship===`family`&&n.senderRunId===e&&n.recipientRunId===t)}function It(e,t){let n=-P(e,t);return n>=1e3?`reply due in ${M(n)}`:`reply overdue`}function Lt(e,t){return t.filter(t=>t.relationship===`peer`&&t.senderRunId===e)}function Rt(e,t){return e.relationship===`peer`?{kind:`Request`,relation:`Peer`}:{kind:`Question`,relation:zt[Bt(e,t)]}}var zt={worker:`Worker → parent`,parent:`Parent → worker`,unknown:`Family`};function Bt(e,t){let n=t.get(e.senderRunId)?.role;if(n)return n===`worker`?`worker`:`parent`;let r=t.get(e.recipientRunId)?.role;return r?r===`root`?`worker`:`parent`:`unknown`}var Vt=new Set([`needs-you`,`needs-permission`]),Ht=new Set([`queued`,`waiting-for-capacity`]);function Ut(e){if(I(e.status))return Vt.has(e.rung)?`needsYou`:e.rung===`running`?`working`:Ht.has(e.rung)?`queued`:`waiting`}function Wt(e){let t={needsYou:0,working:0,waiting:0,queued:0,activeWorkers:0,openRequests:0,inReview:0};for(let n of e){t.inReview+=n.inReview,t.openRequests+=n.requests.length;for(let e of n.tasks){let n=Ut(e);n&&(t[n]+=1),t.activeWorkers+=e.workers.filter(e=>I(e.status)).length}}return t}function Gt(e,t=()=>!1){let n=0,r=0;for(let i of e.workers)t(i.runId)||((i.status===`done`||i.status===`cancelled`)&&(n+=1),i.status===`failed`&&(n+=1,r+=1));return{finished:n,failed:r}}function Kt({finished:e,failed:t}){if(e!==0)return t>0?`✓ ${e} finished · ${t} failed`:`✓ ${e} worker${e===1?``:`s`} finished`}var U={flash:1300,cardEnter:700,cardLeave:500,workerEnter:700,workerHold:3e3,workerFold:500,comet:1100,replied:900,fade:800,bump:500,slide:450,check:800},W={flash:{},entering:{},leaving:{},workerEnter:{},workerHold:{},opening:{},closing:{},waitsClosing:{},comets:{},bumps:{},slides:{},checks:{}},qt=(e,t)=>`${e}\n${t}`;function Jt(e,t){let n=qt(t,``);return new Set(Object.keys(e.checks).filter(e=>e.startsWith(n)).map(e=>e.slice(n.length)))}var Yt=class{key;changes=[];timers=[];constructor(e){this.key=e}timed(e,t,n,r){this.changes.push({field:e,id:t,value:{...n,key:this.key}}),this.timers.push({after:r,change:{field:e,id:t,ifKey:this.key}})}later(e,t,n,r){this.timers.push({after:r,change:{field:e,id:t,value:{...n,key:this.key},ifKey:this.key}})}drop(e,t){this.changes.push({field:e,id:t})}},Xt={done:`success`,review:`success`,failed:`danger`,cancelled:`neutral`};function Zt(e,t){let n=Xt[t.status]??`success`;if(t.status===`review`){e.timed(`workerHold`,t.runId,{tone:n,phase:`flash`},U.flash);return}e.timed(`workerHold`,t.runId,{tone:n,phase:`flash`},U.workerHold+U.workerFold),e.later(`workerHold`,t.runId,{tone:n,phase:`fold`},U.workerHold)}function Qt(e,t){e.drop(`closing`,t.requestId),e.timed(`opening`,t.requestId,{},U.fade),e.timed(`comets`,`${t.requestId}:open:${e.key}`,{requestId:t.requestId,reverse:!1,tone:t.relationship},U.comet)}function $t(e,t,n,r){let i=n.requestId;if(e.drop(`opening`,i),!r){e.timed(`closing`,i,{projectId:t,request:n,replied:!1,phase:`fade`},U.fade);return}let a=U.comet+U.replied+U.fade;e.timed(`closing`,i,{projectId:t,request:n,replied:!0,phase:`reply`},a),e.later(`closing`,i,{projectId:t,request:n,replied:!0,phase:`replied`},U.comet),e.later(`closing`,i,{projectId:t,request:n,replied:!0,phase:`fade`},U.comet+U.replied),e.timed(`comets`,`${i}:reply:${e.key}`,{requestId:i,reverse:!0,tone:`success`},U.comet)}function en(e,t){switch(t.kind){case`rung-changed`:return e.timed(`flash`,t.task.runId,{tone:h(t.task.rung).tone},U.flash);case`tool-started`:return e.timed(`slides`,t.runId,{},U.slide);case`worker-started`:return e.timed(`workerEnter`,t.worker.runId,{},U.workerEnter);case`worker-settled`:return Zt(e,t.worker);case`card-entered`:return e.drop(`leaving`,t.task.runId),e.timed(`entering`,t.task.runId,{},U.cardEnter);case`card-left`:return e.timed(`leaving`,t.task.runId,{projectId:t.projectId,task:t.task},U.cardLeave);case`check-passed`:return e.timed(`checks`,qt(t.runId,t.name),{},U.check);case`request-opened`:return Qt(e,t.request);case`request-closed`:return $t(e,t.projectId,t.request,t.status===`replied`);case`chip-changed`:return e.timed(`bumps`,t.chip,{},U.bump);case`wait-opened`:return e.drop(`waitsClosing`,t.wait.id),e.timed(`opening`,t.wait.id,{},U.fade);case`wait-closed`:return e.drop(`opening`,t.wait.id),e.timed(`waitsClosing`,t.wait.id,{projectId:t.projectId,wait:t.wait},U.fade)}}function tn(e,t,n){let r=new Yt(t);if(!n)for(let t of e)en(r,t);return{changes:r.changes,timers:r.timers}}function nn(e,t){let n=e[t.field];if(t.ifKey!==void 0&&n[t.id]?.key!==t.ifKey||t.value===void 0&&!(t.id in n))return e;let r={...n};return t.value===void 0?delete r[t.id]:r[t.id]=t.value,{...e,[t.field]:r}}function rn(e,t){return t.reduce(nn,e)}function an(e,t,n){let r=new Set(t.map(e=>e.id));return Object.values(n.waitsClosing).filter(t=>t.projectId===e&&!r.has(t.wait.id)).map(e=>e.wait)}var on={success:`text-success`,pending:`text-signal-word-amber`,danger:`text-signal-word-red`,accent:`text-accent-text`,info:`text-info`,running:`text-status-running`,neutral:`text-muted-foreground`};function sn({tone:e,className:t,children:n,...r}){return(0,D.jsx)(`span`,{...r,className:i(`bg-card-2`,{"text-success":e===`success`,"text-signal-word-amber":e===`pending`,"text-signal-word-red":e===`danger`,"text-accent-text":e===`accent`,"text-info":e===`info`,"text-status-running":e===`running`,"text-muted-foreground":e===`neutral`},t),children:n})}var cn={success:`border-success`,pending:`border-pending-strong`,danger:`border-danger`,accent:`border-accent-strong`,info:`border-info`,running:`border-status-running`,neutral:`border-soft-foreground`},ln={success:`bg-success`,pending:`bg-pending-strong`,danger:`bg-danger`,accent:`bg-accent-strong`,info:`bg-info`,running:`bg-status-running`,neutral:`bg-soft-foreground`},un={tool:Ae,user:ke,workers:T,reply:be,peer:Ee,subagents:T,ci:Te,merge:we,command:Oe,timer:Ce,pause:De,queued:ve,review:ye,failed:ge,done:_e,cancelled:Se};function dn(e,t){let n=h(e.rung),r=e.rung===`waiting-on-workers`&&(t===`worker`||e.wait?.kind===`peers`);return{tone:n.tone,shape:r?`ring`:n.shape,label:pn(e,t)??n.label}}var fn=(e,t,n)=>`${e} ${t} ${n}${t===1?``:`s`}`;function pn(e,t){let n=e.wait;if(e.rung===`waiting-on-workers`){if(t===`worker`)return`waiting on parent reply`;if(n?.kind===`peers`&&n.detail.peerRunIds.length>0)return fn(`waiting on`,n.detail.peerRunIds.length,`task`);if(n?.kind===`workers`&&n.detail.replies)return`waiting on replies`;if(n?.kind===`workers`&&n.detail.owed>0)return fn(`waiting on`,n.detail.owed,`worker`)}if(e.rung===`waiting-on-subagents`&&n?.kind===`subagents`&&n.detail.running>0)return fn(`waiting for`,n.detail.running,`subagent`)}function mn(e,t){if(I(e.status))return e.rung===`running`&&t===`filled`?`activity-pulse`:t===`filled`?void 0:`activity-breathe`}function G({run:e,role:t}){let{tone:n,shape:r,label:a}=dn(e,t);return(0,D.jsx)(`span`,{"data-activity-anchor":e.runId,className:i(`inline-flex size-[12px] shrink-0 items-center justify-center`,mn(e,r)),children:(0,D.jsx)(w,{tone:n,shape:r,role:`img`,"aria-label":a})})}function hn({runId:e,requests:t,waits:n,index:r,link:i,pathOf:a,className:o,linkClassName:s}){let c=Lt(e,t),l=Nt(e,n);return c.length===0&&l.length===0?null:(0,D.jsxs)(`ul`,{"data-slot":`activity-peer-links`,className:o,children:[c.map(e=>(0,D.jsx)(`li`,{children:(0,D.jsxs)(i,{to:a(e.recipientRunId),className:s,children:[`→ `,H(r,e)]})},e.requestId)),l.map(e=>(0,D.jsx)(`li`,{children:(0,D.jsxs)(i,{to:a(e.peerRunId),className:s,children:[`⋯ waits on `,V(r,e.peerRunId)]})},e.id))]})}var gn={pass:`bg-success`,fail:`bg-danger`,pending:`bg-info`,skipping:`border border-soft-foreground`,cancel:`border border-soft-foreground`},_n=(e,t)=>t?`activity-check-pass`:e===`pending`?`activity-breathe-fast`:void 0;function vn({checks:e,overflow:t,passed:n}){return(0,D.jsxs)(`span`,{"data-slot":`activity-checks`,"aria-hidden":`true`,className:i(`col-start-2 mt-[5px] flex items-center`,e.length>40?`gap-px`:`gap-[3px]`),children:[e.map(e=>(0,D.jsx)(`i`,{"data-bucket":e.bucket,"data-passed":n.has(e.name)?`true`:void 0,title:e.name,className:i(`h-[5px] min-w-px flex-1 rounded-[2px]`,gn[e.bucket],_n(e.bucket,n.has(e.name)))},e.name)),t?(0,D.jsxs)(`span`,{"data-slot":`activity-checks-overflow`,"data-bucket":t.bucket,className:`ml-1 flex shrink-0 items-center gap-1 text-[10px] leading-none text-muted-foreground tabular-nums`,children:[(0,D.jsx)(`i`,{className:i(`h-[5px] w-2 rounded-[2px]`,gn[t.bucket])}),`+`,t.count]}):null]})}function yn({value:e,ink:t}){return(0,D.jsx)(`span`,{"data-slot":`activity-bar`,"aria-hidden":`true`,className:`col-start-2 mt-[5px] block h-1 overflow-hidden rounded-sm bg-border`,children:(0,D.jsx)(`span`,{className:i(`block h-full bg-current`,t),style:{width:`${Math.round(e*100)}%`}})})}var bn=new Set;function xn({box:e,now:t,dense:n,motion:r={}}){let a=un[e.icon],o=on[e.tone];return(0,D.jsxs)(`div`,{"data-slot":`activity-now`,"data-verb":e.verb,className:`relative grid grid-cols-[16px_minmax(0,1fr)] gap-x-2 gap-y-px overflow-hidden rounded-lg bg-card-2 px-2.5 py-2`,children:[r.sweep?(0,D.jsx)(`span`,{"data-slot":`activity-sweep`,"aria-hidden":`true`,className:`activity-sweep`}):null,(0,D.jsx)(a,{"aria-hidden":`true`,className:i(`mt-px size-[15px]`,o)}),(0,D.jsxs)(sn,{tone:e.tone,className:`flex gap-2 text-[11px] font-semibold tracking-[0.04em] uppercase`,children:[(0,D.jsx)(`span`,{"data-slot":`activity-verb`,children:e.verb}),e.since?(0,D.jsx)(`span`,{"data-slot":`activity-age`,className:`ml-auto font-medium tracking-normal text-muted-foreground normal-case tabular-nums`,children:M(P(e.since,t))}):null]}),(0,D.jsx)(`span`,{"data-slot":`activity-main`,className:i(`col-start-2 truncate text-[12.5px] text-foreground`,e.mono&&`font-mono text-[12px]`,r.slideKey!==void 0&&`activity-slide`),children:e.main},r.slideKey??`still`),e.checks?(0,D.jsx)(vn,{checks:e.checks,overflow:e.overflow,passed:r.passed??bn}):null,e.checkSummary?(0,D.jsx)(`span`,{"data-slot":`activity-checks-summary`,className:`sr-only`,children:e.checkSummary}):null,e.bar===void 0?null:(0,D.jsx)(yn,{value:e.bar,ink:o}),e.detail&&!n?(0,D.jsx)(`span`,{"data-slot":`activity-detail`,className:`col-start-2 text-[11.5px] text-muted-foreground tabular-nums`,children:e.detail}):null]})}function Sn({rate:e,className:t}){let n=e.reduce((e,t)=>e+t,0),r=Math.max(4,...e);return(0,D.jsxs)(`svg`,{"data-slot":`activity-heartbeat`,role:`img`,"aria-label":`${n} tool call${n===1?``:`s`} in the last ${e.length} s`,viewBox:`0 0 62 16`,className:i(`block h-4 w-[62px] shrink-0`,t),children:[(0,D.jsx)(`path`,{d:`M0 15.5h62`,className:`stroke-border`}),e.map((e,t)=>{if(e<=0)return null;let n=Math.max(1.5,e/r*14);return(0,D.jsx)(`rect`,{x:t*2.07,y:15-n,width:1.4,height:n,className:`fill-status-running`},t)})]})}var K=e=>`/tasks/${encodeURIComponent(e)}`;function Cn(e,t){return[e.runner,e.model,e.currentStepId?`step ${e.currentStepId}`:void 0,e.startedAt?N(P(e.startedAt,t)):void 0].filter(e=>!!e).join(` · `)}function wn({texts:e}){return e.length===0?null:(0,D.jsx)(`ul`,{"data-slot":`activity-line-text`,className:`sr-only`,children:e.map((e,t)=>(0,D.jsx)(`li`,{children:e},t))})}function Tn({worker:e,parentId:t,requests:n,index:r,ctx:a,motion:o}){let s=Tt(e,a,Ft(e.runId,t,n)?.text),c=o.workerHold[e.runId];return(0,D.jsxs)(`li`,{"data-slot":`activity-worker`,"data-run":e.runId,"data-asks":s.asks?`true`:void 0,"data-hold":c?.phase,className:i(`relative grid grid-cols-[14px_minmax(0,1fr)] items-start gap-x-2 rounded-lg py-[5px] before:absolute before:top-[13px] before:-left-3.5 before:w-2.5 before:border-t before:border-border`,s.asks&&`-mx-1.5 bg-message-inbound-bg px-1.5`,e.runId in o.workerEnter&&`activity-row-enter`,c?.phase===`fold`&&`activity-row-fold`),children:[c?(0,D.jsx)(`span`,{"aria-hidden":`true`,className:i(`activity-row-flash`,ln[c.tone])},c.key):null,(0,D.jsx)(`span`,{className:`mt-[3px]`,children:(0,D.jsx)(G,{run:e,role:`worker`})}),(0,D.jsxs)(`span`,{className:`min-w-0 truncate text-[12.5px] font-medium`,children:[(0,D.jsx)(C,{to:K(e.runId),className:`relative z-[1] hover:underline focus-visible:outline-2 focus-visible:outline-ring max-md:inline-flex max-md:min-h-11 max-md:items-center`,children:e.title}),(0,D.jsx)(`span`,{className:`ml-1.5 text-[11px] font-normal text-muted-foreground`,children:[e.runner,e.model].filter(Boolean).join(` · `)})]}),(0,D.jsxs)(`span`,{"data-slot":`activity-worker-line`,className:`col-start-2 truncate text-[11.5px] text-muted-foreground tabular-nums`,children:[(0,D.jsx)(`b`,{className:i(`font-semibold`,on[s.tone]),children:s.verb}),` · `,(0,D.jsx)(`span`,{className:i(s.mono&&`font-mono`),children:s.main})]}),(0,D.jsx)(wn,{texts:Pt(e.runId,n,r)})]})}function En({workers:e}){return(0,D.jsxs)(`div`,{"data-slot":`activity-worker-dots`,className:`mt-2 ml-[18px] flex flex-wrap items-center gap-1 text-[11px] text-muted-foreground`,children:[e.map(e=>(0,D.jsx)(G,{run:e,role:`worker`},e.runId)),(0,D.jsxs)(`span`,{className:`ml-1`,children:[e.length,` worker`,e.length===1?``:`s`]})]})}function Dn({task:e,requests:t,index:n,ctx:r,dense:i,motion:a}){let o=e=>e in a.workerHold,s=e.workers.filter(e=>I(e.status)||e.status===`review`||o(e.runId)),c=Kt(Gt(e,o));return(0,D.jsxs)(D.Fragment,{children:[s.length>0&&i?(0,D.jsx)(En,{workers:s}):null,s.length>0&&!i?(0,D.jsx)(`ul`,{"data-slot":`activity-workers`,className:`mt-2 ml-1 border-l border-border pl-3.5`,children:s.map(i=>(0,D.jsx)(Tn,{worker:i,parentId:e.runId,requests:t,index:n,ctx:r,motion:a},i.runId))}):null,c?(0,D.jsx)(`p`,{"data-slot":`activity-finished`,className:`mt-1.5 ml-[18px] text-[11px] text-muted-foreground`,children:c}):null]})}var On=`relative z-[1] text-[12px] text-message-peer-accent hover:underline focus-visible:outline-2 focus-visible:outline-ring max-md:inline-flex max-md:min-h-11 max-md:items-center`;function kn(e,t){return t?{onPointerEnter:()=>t(`pointer`,e),onPointerLeave:()=>t(`pointer`,void 0),onFocus:()=>t(`focus`,e),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||t(`focus`,void 0)}}:{}}function An(e,t,n){return n?`activity-card-leave`:e.runId in t.entering?`activity-card-enter`:void 0}function jn({task:e,motion:t,glow:n}){let r=t.flash[e.runId];return(0,D.jsxs)(D.Fragment,{children:[n?(0,D.jsx)(`span`,{"aria-hidden":`true`,className:`activity-glow`}):null,r?(0,D.jsx)(`span`,{"data-slot":`activity-flash`,"data-tone":r.tone,"aria-hidden":`true`,className:i(`activity-flash`,cn[r.tone])},r.key):null]})}var Mn=[];function Nn({task:e,requests:t,waits:n=Mn,index:a,ctx:o,dense:s,narrow:c,motion:l=W,ghost:u=!1,linked:d=!1,onHover:f}){let p=Ct(e,o),m=u?{"data-activity-ghost":e.runId,inert:!0,"aria-hidden":!0}:{"data-activity-card":e.runId},ee={sweep:e.rung===`running`&&I(e.status),slideKey:l.slides[e.runId]?.key,passed:Jt(l,e.runId)};return(0,D.jsxs)(`article`,{...m,"data-flip":e.runId,"data-rung":e.rung,"data-linked":d&&!u?`true`:void 0,...u?{}:kn(e.runId,f),className:i(`relative min-w-0 rounded-xl border bg-card px-3.5 py-3`,p.action?`border-pending`:`border-border`,d&&!u&&`outline-2 outline-offset-2 outline-message-peer-accent`,An(e,l,u)),children:[(0,D.jsx)(jn,{task:e,motion:l,glow:p.action!==void 0&&!u}),(0,D.jsxs)(`header`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(G,{run:e,role:`root`}),(0,D.jsx)(`h3`,{className:`min-w-0 flex-1 truncate text-[13.5px] font-semibold`,children:(0,D.jsx)(C,{to:K(e.runId),className:`after:absolute after:inset-0 after:rounded-xl after:content-[''] focus-visible:outline-2 focus-visible:outline-ring`,children:e.title})}),(0,D.jsx)(Sn,{rate:e.rate})]}),(0,D.jsx)(`p`,{className:`mt-0.5 mb-2 ml-5 truncate text-[11.5px] text-muted-foreground`,children:Cn(e,o.now)}),(0,D.jsx)(wn,{texts:Pt(e.runId,t,a,n)}),(0,D.jsx)(xn,{box:p,now:o.now,dense:s,motion:ee}),p.action?(0,D.jsx)(`div`,{className:`mt-2 flex gap-1.5`,children:(0,D.jsx)(r,{asChild:!0,size:`sm`,variant:p.action===`answer`?`primary`:`outline`,className:`relative z-[1] max-md:min-h-11`,children:(0,D.jsx)(C,{to:K(e.runId),children:p.action===`answer`?`Answer`:`Open task`})})}):null,c?(0,D.jsx)(hn,{runId:e.runId,requests:t,waits:n,index:a,link:C,pathOf:K,className:`mt-2 flex flex-col gap-1`,linkClassName:On}):null,(0,D.jsx)(Dn,{task:e,requests:t,index:a,ctx:o,dense:s,motion:l})]})}function Pn(e){return!Number.isFinite(e)||e<=0?1:Math.max(1,Math.floor((e+96)/396))}function Fn(e,t){let n=e[0],r=1/0;for(let i of e){let e=i.reduce((e,n)=>e+t(n),0);e<r&&(n=i,r=e)}return n}function In(e,t,n,r=()=>1){let i=Math.max(1,Math.floor(n)),a=new Set(t),o=e?.length===i?e.map(e=>e.filter(e=>a.has(e))):Array.from({length:i},()=>[]),s=new Set(o.flat());for(let e of t)s.has(e)||(Fn(o,r).push(e),s.add(e));return o}function Ln(e,t){return e!==void 0&&e.length===t.length&&e.every((e,n)=>e.length===t[n]?.length&&e.every((e,r)=>e===t[n]?.[r]))}var Rn=(e,t)=>({x0:Math.min(e.x,t.x),y0:Math.min(e.y,t.y),x1:Math.max(e.x,t.x),y1:Math.max(e.y,t.y)});function zn(e,t,n=1){return t.some(t=>t.x+n<e.x1&&e.x0<t.x+t.w-n&&t.y+n<e.y1&&e.y0<t.y+t.h-n)}var Bn=(e,...t)=>e.filter(e=>!t.some(t=>Vn(e,t))),Vn=(e,t)=>e.x===t.x&&e.y===t.y&&e.w===t.w&&e.h===t.h,Hn=e=>Math.round(e*10)/10,q=e=>`${Hn(e.x)} ${Hn(e.y)}`;function Un(e){let t=[];for(let n of e){let e=t[t.length-1];if(e&&e.x===n.x&&e.y===n.y)continue;let r=t[t.length-2];r&&e&&(r.x===e.x&&e.x===n.x||r.y===e.y&&e.y===n.y)&&t.pop(),t.push(n)}return t}function Wn(e,t=8){let n=Un(e),r=n[0];if(!r)return``;let i=`M${q(r)}`;for(let e=1;e<n.length;e++){let r=n[e],a=n[e-1],o=n[e+1];if(!o){i+=` L ${q(r)}`;continue}let s=Math.min(t,Math.hypot(r.x-a.x,r.y-a.y)/2,Math.hypot(o.x-r.x,o.y-r.y)/2),c=(e,t,n)=>{let r=Math.hypot(t.x-e.x,t.y-e.y)||1;return{x:e.x+(t.x-e.x)/r*n,y:e.y+(t.y-e.y)/r*n}};i+=` L ${q(c(r,a,s))} Q ${q(r)}, ${q(c(r,o,s))}`}return i}function Gn(e,t,n){let r=[];for(let i of[...e].sort((e,n)=>t(e)-t(n))){let e=r[r.length-1];e&&Math.abs(t(i)-e.from)<=2?e.to=Math.max(e.to,n(i)):r.push({from:t(i),to:n(i)})}return r}function Kn(e){return{rows:Gn(e,e=>e.y,e=>e.y+e.h).map(({from:e,to:t})=>({top:e,bottom:t})),cols:Gn(e,e=>e.x,e=>e.x+e.w).map(({from:e,to:t})=>({left:e,right:t}))}}var J=(e,t,n)=>Math.max(0,e.findIndex(e=>Math.abs(t(e)-n)<=2)),Y=(e,t)=>((e.rows[t]?.bottom??0)+(e.rows[t+1]?.top??(e.rows[t]?.bottom??0)+16))/2;function qn(e,t,n){let r=e.cols,i=e=>((r[e]?.right??0)+(r[e+1]?.left??0))/2;return t<n?i(t):t>n?i(t-1):t+1<r.length?i(t):t>0?i(t-1):(r[t]?.right??0)+8}function Jn(e,t,n,r=0){let i=Kn(n),a=J(i.rows,e=>e.top,e.y),o=J(i.rows,e=>e.top,t.y),s=o>a,c=e.x+e.w/2+r,l=t.x+t.w/2+r,u=(s?Y(i,a):Y(i,a-1))+r/2,d=(s?Y(i,o-1):Y(i,o))+r/2,f=qn(i,J(i.cols,e=>e.left,e.x),J(i.cols,e=>e.left,t.x))+r/2,p={x:c,y:s?e.y+e.h+1:e.y-1},m={x:l,y:s?t.y-3:t.y+t.h+3};return{points:[p,{x:c,y:u},{x:f,y:u},{x:f,y:d},{x:l,y:d},m],label:{x:(c+f)/2,y:u}}}var Yn=15;function Xn(e,t,n){let r=[...n,...e.flatMap(e=>[e.y-Yn,e.y+e.h+Yn])].filter(t=>t>=0&&!e.some(e=>e.y-6<t&&t<e.y+e.h+6));return r.reduce((e,n)=>Math.abs(n-t)<Math.abs(e-t)?n:e,r[0]??t)}function Zn(e,t,n,r,i=0){let a=t.x>e.x?1:-1,o=e.x+a*n/2+i,s=t.x-a*n/2+i,c=Xn(r.filter(e=>e.x+e.w>Math.min(o,s)&&e.x<Math.max(o,s)),(e.y+t.y)/2,[e.y,t.y])+(i===0?0:Math.sign(i)*Math.min(Math.abs(i),Yn-6)),l=c===e.y?{x:s,y:(c+t.y)/2}:{x:o,y:(e.y+c)/2};return{points:[e,{x:o,y:e.y},{x:o,y:c},{x:s,y:c},{x:s,y:t.y},{x:t.x-a*2,y:t.y}],label:l}}function Qn(e){let t=new Map;for(let n of e){let e=[n.senderRunId,n.recipientRunId].sort().join(`
|
|
2
|
-
`);t.set(e,[...t.get(e)??[],n.requestId])}let n=new Map;for(let e of t.values())e.forEach((t,r)=>n.set(t,(r-(e.length-1)/2)*12));return n}function $n(e,t,n,r=4){let i=[],a=new Map;for(let{id:o,at:s}of e){let e={...s};for(let a=0;a<=i.length;a++){let a=i.find(n=>Math.abs(e.x-n.x)<t.w+r&&Math.abs(e.y-n.y)<t.h+r);if(!a)break;n===`x`?e.x=a.x+t.w+r:e.y=a.y+t.h+r}i.push(e),a.set(o,e)}return a}var er=e=>Math.round(e*10)/10,X=e=>`${er(e.x)} ${er(e.y)}`;function tr(e,t,n){return t&&t.x>e.x+40?1:t&&t.x<e.x-40?-1:e.x+e.w+96<=n+1?1:-1}function nr(e,t,n,r,i,a){let o=r>0?Math.max(e.x+e.w,t.x+t.w):Math.min(e.x,t.x),s=(70+n)*r;return{d:`M${X({x:o,y:i})} C ${X({x:o+s,y:i})}, ${X({x:o+s,y:a})}, ${X({x:o+2*r,y:a})}`,label:{x:o+s*.75,y:(i+a)/2}}}function rr(e,t,n=[],r=0,i=1){let a=e.y+22+r,o=t.y+22+r;if(Math.abs(e.x-t.x)<40)return nr(e,t,r,i,a,o);let s=t.x>e.x,c=s?e.x+e.w:e.x,l=s?t.x:t.x+t.w,u=Math.max(40,Math.abs(l-c)*.5)*(s?1:-1),d=l-(s?2:-2);if(zn(Rn({x:c,y:a},{x:l,y:o}),Bn(n,e,t))){let i=Zn({x:c,y:a},{x:l,y:o},96,Bn(n,e,t),r);return{d:Wn(i.points),label:i.label}}return{d:`M${X({x:c,y:a})} C ${X({x:c+u,y:a})}, ${X({x:l-u,y:o})}, ${X({x:d,y:o})}`,label:{x:(c+l)/2,y:(a+o)/2}}}function ir(e,{other:t,view:n,labelHeight:r}){let i=r/2+4,a=!t||!n?e+44:t.y>e?Math.max(e+44,n.y1-i):Math.min(e-44,n.y0+i);return n?ar(a,n.y0+i,n.y1-i):a}var ar=(e,t,n)=>Math.max(t,Math.min(n,e));function or(e,t,n){let r=n.lane??0,i=e.y+22+r,a=n.side>0?e.x+e.w:e.x,o=a+n.side*96/2+r/2,s={x:o,y:ir(i,n)};return{d:Wn(t===`sender`?[{x:a,y:i},{x:o,y:i},s]:[s,{x:o,y:i},{x:a+2*n.side,y:i}]),label:s}}function sr(e,t,n,r=0){let i={x:e.x,y:e.y+e.h/2},a={x:t.x-2,y:t.y+t.h/2},o=n.x-18+r/2;return{d:`M${X(i)} C ${X({x:o,y:i.y})}, ${X({x:o,y:a.y})}, ${X(a)}`,label:{x:o,y:(i.y+a.y)/2}}}function cr(e,t,n=[],r=0){let i=e.x+e.w/2+r,a=t.x+t.w/2+r;if(t.y>=e.y+e.h||t.y+t.h<=e.y){let o=t.y>e.y,s=o?e.y+e.h+1:e.y-1,c=o?t.y-3:t.y+t.h+3,l=(c-s)/2;if(zn(Rn({x:i,y:s},{x:a,y:c}),Bn(n,e,t))){let i=Jn(e,t,n,r);return{d:Wn(i.points),label:i.label}}return{d:`M${X({x:i,y:s})} C ${X({x:i,y:s+l})}, ${X({x:a,y:c-l})}, ${X({x:a,y:c})}`,label:{x:(i+a)/2,y:(s+c)/2}}}let o=e.y-1,s=t.y-1,c=Math.min(o,s),l=Math.max(8,Math.min(30,18+Math.abs(a-i)*.05)+r);return{d:`M${X({x:i,y:o})} C ${X({x:i,y:c-l})}, ${X({x:a,y:c-l})}, ${X({x:a,y:s-3})}`,label:{x:(i+a)/2,y:c-l*.75}}}function lr(e,t){return{x:e.left-t.left,y:e.top-t.top,w:e.width,h:e.height}}function ur(e,t){let n=[];for(let r of e){let e=n.find(e=>Math.abs((e[0]?.at.x??NaN)-r.at.x)<t);e?e.push(r):n.push([r])}return n}function dr(e,t,n,r){let i=e.map(e=>Math.min(r,Math.max(n,e.at.y))),a=i.map((e,t)=>t).sort((e,t)=>i[e]-i[t]);for(let e=1;e<a.length;e++){let n=a[e];i[n]=Math.max(i[n],i[a[e-1]]+t)}for(let e=a.length-1;e>=0;e--){let n=a[e],o=e+1<a.length?i[a[e+1]]-t:r;i[n]=Math.min(i[n],o)}return e.map((e,t)=>({id:e.id,at:{x:e.at.x,y:i[t]}}))}function fr(e,t,n,r=4){let i=n?n.y0+t.h/2:-1/0,a=n?n.y1-t.h/2:1/0,o=new Map;for(let n of ur(e,t.w+r))for(let e of dr(n,t.h+r,i,a))o.set(e.id,e.at);return o}var pr=(e,t)=>e.x<=t.x1&&t.x0<=e.x+e.w&&e.y<=t.y1&&t.y0<=e.y+e.h;function mr(e,t,n){let r=e!==void 0&&pr(e,n),i=t!==void 0&&pr(t,n);return r&&i?`both`:r?`sender`:i?`recipient`:`none`}var hr=e=>/(auto|scroll|hidden|clip)/.test(getComputedStyle(e).overflowY);function gr(e){let t=[];for(let n=e.parentElement;n&&n!==document.body&&n!==document.documentElement;n=n.parentElement)hr(n)&&t.push(n);return t}function _r(e,t){return{x0:Math.max(e.x0,t.x0),y0:Math.max(e.y0,t.y0),x1:Math.min(e.x1,t.x1),y1:Math.min(e.y1,t.y1)}}function vr(e){let t=e.getBoundingClientRect(),n={x0:0,y0:0,x1:window.innerWidth,y1:window.innerHeight};for(let t of gr(e)){let e=t.getBoundingClientRect();e.width>0&&e.height>0&&(n=_r(n,{x0:e.left,y0:e.top,x1:e.right,y1:e.bottom}))}return{x0:n.x0-t.left,y0:n.y0-t.top,x1:n.x1-t.left,y1:n.y1-t.top}}var Z={w:88,h:40};function yr(e,t){let n=e.getBoundingClientRect(),r=new Map;for(let i of e.querySelectorAll(`[${t}]`)){let e=i.getAttribute(t);e&&r.set(e,lr(i.getBoundingClientRect(),n))}return r}function br({base:e,from:t,to:n,fromName:r,toName:i},a,o,s){let c=a.get(t),l=a.get(n),u=s.view??{x0:-1/0,y0:-1/0,x1:1/0,y1:1/0},d=(e,t)=>({side:tr(e,t,s.width),labelHeight:Z.h,lane:o??0,view:u,...t?{other:t}:{}});switch(mr(c,l,u)){case`both`:return c&&l?{...e,...rr(c,l,[...a.values()],o,tr(c,void 0,s.width))}:void 0;case`sender`:return c?{...e,...or(c,`sender`,d(c,l)),away:i()}:void 0;case`recipient`:return l?{...e,...or(l,`recipient`,d(l,c)),away:r()}:void 0;case`none`:return}}var xr=(e,t)=>({base:{id:e.requestId,kind:`peer`},from:e.senderRunId,to:e.recipientRunId,fromName:()=>kt(t,e),toName:()=>H(t,e)}),Sr=(e,t)=>({base:{id:e.id,kind:`wait`},from:e.peerRunId,to:e.waiterRunId,fromName:()=>V(t,e.peerRunId),toName:()=>V(t,e.waiterRunId)}),Cr=e=>({requestId:e.id,senderRunId:e.peerRunId,recipientRunId:e.waiterRunId});function wr(e,t){return[...new Set([...e.values()].map(e=>Math.round(e.x+e.w)))].filter(e=>e+96<=t+1).map(e=>e+96/2)}function Tr(e,t){return t.length===0?e:{x:t.reduce((t,n)=>Math.abs(n-e.x)<Math.abs(t-e.x)?n:t),y:e.y}}function Er(e,t,n,r,i,a){let o=r.get(e.senderRunId)?.cardId??r.get(e.recipientRunId)?.cardId,s=o===void 0?void 0:t.get(o),c=n.get(e.senderRunId),l=n.get(e.recipientRunId);if(!(!s||!c||!l||a&&!pr(s,a)))return{id:e.requestId,kind:`family`,...sr(c,l,s,i)}}function Dr(e,t,n,{peers:r,frame:i={width:e.clientWidth},waits:a=[]}){let o=yr(e,`data-activity-card`),s=yr(e,`data-activity-anchor`),c=Qn([...t,...a.map(Cr)]),l=[];for(let e of t){let t=c.get(e.requestId),a=e.relationship===`peer`?r?br(xr(e,n),o,t,i):void 0:Er(e,o,s,n,t,i.view);a&&l.push(a)}for(let e of r?a:[]){let t=br(Sr(e,n),o,c.get(e.id),i);t&&l.push(t)}let u=wr(o,i.width),d=fr(l.filter(e=>e.kind!==`family`).map(e=>({id:e.id,at:Tr(e.label,u)})),Z,i.view);return l.map(e=>({...e,label:d.get(e.id)??e.label}))}function Or(e,t){return e.length===t.length&&e.every((e,n)=>{let r=t[n];return r!==void 0&&e.id===r.id&&e.d===r.d&&e.away===r.away&&e.label.x===r.label.x&&e.label.y===r.label.y})}function kr({frame:e,cancel:t,draw:n}){let r=[],i,a=t=>{i=void 0,r=r.map(e=>({...e,start:e.start??t})).filter(e=>t<e.start+e.duration),n(r,t),r.length>0&&(i=e(a))};return{launch(t){r.some(e=>e.id===t.id)||(r.push(t),i===void 0&&(i=e(a)))},stop(){i!==void 0&&t(i),i=void 0,r=[],n([],0)},running:()=>i!==void 0}}var Ar=e=>e<.5?2*e*e:1-(-2*e+2)**2/2;function jr(e,t,n=0){let r=Math.min(1,Math.max(0,(t-e.start)/e.duration)),i=Math.max(0,Ar(r)-n);return e.reverse?1-i:i}var Mr=`http://www.w3.org/2000/svg`,Nr=[0,.03,.06,.09,.12],Pr=[4.5,3.5,3,2.5,2],Fr={peer:`fill-message-peer-accent`,family:`fill-message-inbound-accent`,success:`fill-success`};function Ir(e,t){let n=e.querySelector(`g[data-comet="${CSS.escape(t.id)}"]`);if(n)return n;let r=document.createElementNS(Mr,`g`);r.setAttribute(`data-comet`,t.id);let i=document.createElementNS(Mr,`circle`);return i.setAttribute(`r`,`9`),i.setAttribute(`class`,`${Fr[t.tone]} opacity-35`),r.append(i),Nr.forEach((e,n)=>{let i=document.createElementNS(Mr,`circle`);i.setAttribute(`r`,String(Pr[n])),i.setAttribute(`class`,n===0?`fill-foreground`:Fr[t.tone]),i.setAttribute(`opacity`,String(1-n*.15)),r.append(i)}),e.append(r),r}function Lr(e,t,n){let r=new Set(t.map(e=>e.id));for(let t of e.querySelectorAll(`g[data-comet]`))r.has(t.getAttribute(`data-comet`)??``)||t.remove();let i=e.ownerSVGElement;for(let r of t){let t=i?.querySelector(`path[data-request="${CSS.escape(r.requestId)}"]`);if(!t||typeof t.getTotalLength!=`function`)continue;let a=t.getTotalLength();Ir(e,r).querySelectorAll(`circle`).forEach((e,i)=>{let o=t.getPointAtLength(jr(r,n,Nr[Math.max(0,i-1)])*a);e.setAttribute(`transform`,`translate(${o.x} ${o.y})`)})}}var Rr=e=>typeof requestAnimationFrame==`function`?requestAnimationFrame(e):setTimeout(()=>e(performance.now()),16),zr=e=>typeof cancelAnimationFrame==`function`?cancelAnimationFrame(e):clearTimeout(e);function Br(e,t,n){let r=E.useRef(null),i=E.useRef(void 0),a=E.useRef(new Set);return E.useEffect(()=>{let e=r.current;if(!e)return;let t=kr({frame:Rr,cancel:zr,draw:(t,n)=>Lr(e,t,n)});return i.current=t,()=>{t.stop(),i.current=void 0}},[]),E.useEffect(()=>{if(n){i.current?.stop();return}for(let t of a.current)t in e||a.current.delete(t);for(let[n,r]of Object.entries(e))a.current.has(n)||!t.has(r.requestId)||(a.current.add(n),i.current?.launch({id:n,requestId:r.requestId,reverse:r.reverse,tone:r.tone,duration:U.comet}))},[e,t,n]),r}function Vr(e,t){let n=new Map;for(let[r,i]of t){let t=e.get(r);if(!t)continue;let a={x:t.x-i.x,y:t.y-i.y};(Math.abs(a.x)>=1||Math.abs(a.y)>=1)&&n.set(r,a)}return n}function Hr(e,t){let n=new Map;for(let r of e.querySelectorAll(`[${t}]`)){let e=r.getBoundingClientRect();n.set(r.getAttribute(t)??``,{el:r,at:{x:e.left,y:e.top}})}return n}var Ur=`activity-layout-settled`;function Wr(e,t,n,r){let i=E.useRef(void 0),a=E.useRef(new Set);E.useLayoutEffect(()=>{let o=e.current;if(!o)return;let s=Hr(o,t),c=new Map([...s].map(([e,t])=>[e,t.at])),l=i.current;if(i.current={key:n,at:c},!(!r||!l||l.key===n))for(let[e,t]of Vr(l.at,c)){let n=s.get(e)?.el.animate?.([{transform:`translate(${t.x}px, ${t.y}px)`},{transform:`none`}],{duration:400,easing:`cubic-bezier(0.2, 0, 0, 1)`});n&&Gr(n,a.current,o)}}),E.useEffect(()=>{if(!r)for(let e of[...a.current])e.cancel()},[r])}function Gr(e,t,n){t.add(e);let r=()=>{t.delete(e)&&t.size===0&&n.dispatchEvent(new Event(Ur))};e.addEventListener(`finish`,r),e.addEventListener(`cancel`,r)}function Kr(e,t,n,r,i,a=!1){let[o,s]=E.useState([]);return E.useLayoutEffect(()=>{let i=e.current?.parentElement;if(!i)return;let o=()=>{let e=t(i);s(t=>n(t,e)?t:e)};o();let c=a?qr(i,o):void 0;i.addEventListener(Ur,o);let l=typeof ResizeObserver>`u`?void 0:new ResizeObserver(o);l?.observe(i);for(let e of i.querySelectorAll(r))l?.observe(e);return()=>{l?.disconnect(),i.removeEventListener(Ur,o),c?.()}},[e,t,n,r,i,a]),o}function qr(e,t){let n,r=()=>{n===void 0&&(n=requestAnimationFrame(()=>{n=void 0,t()}))},i=[...gr(e),window];for(let e of i)e.addEventListener(`scroll`,r,{passive:!0});return window.addEventListener(`resize`,r),()=>{for(let e of i)e.removeEventListener(`scroll`,r);window.removeEventListener(`resize`,r),n!==void 0&&cancelAnimationFrame(n)}}var Jr=28;function Yr(e){let t=e.replace(/\s+/g,` `).trim();return t.length>Jr?`${t.slice(0,Jr-1).trimEnd()}…`:t}function Xr(e,t){if(e.deadline!==void 0)return Zr(e.createdAt,e.deadline,t)}function Zr(e,t,n){let r=Date.parse(e),i=Date.parse(t);return Number.isNaN(r)||Number.isNaN(i)||i<=r?1:Math.min(1,Math.max(0,(n-r)/(i-r)))}function Qr(e,t){if(e===`fade`)return`activity-line-out`;if(e!==`replied`)return i(`activity-march`,t&&`activity-line-in`)}function $r(e,t){return t in e.waitsClosing?`activity-line-out`:i(`activity-drift`,t in e.opening&&`activity-line-in`)}var ei=`pointer-events-none absolute z-[4] -translate-x-1/2 -translate-y-1/2 rounded-lg border bg-background px-1.5 py-[3px] text-[10px] leading-[1.3] text-foreground tabular-nums`;function ti({line:e,wait:t,now:n,motion:r}){return(0,D.jsxs)(`div`,{"data-slot":`activity-line-label`,"data-wait":t.id,"aria-hidden":`true`,style:{left:e.label.x,top:e.label.y,width:Z.w},className:i(ei,`border-dashed border-message-peer-accent`,t.id in r.waitsClosing&&`activity-line-out`),children:[(0,D.jsxs)(`span`,{className:`flex gap-1 font-semibold`,children:[(0,D.jsx)(`span`,{className:`min-w-0 truncate text-message-peer-accent`,children:`Waiting`}),(0,D.jsx)(`span`,{className:`ml-auto shrink-0`,children:M(P(t.since,n))})]}),e.away?(0,D.jsx)(`span`,{className:`block truncate`,children:e.away}):null,(0,D.jsx)(`span`,{"data-slot":`activity-wait-bar`,className:`mt-[3px] block h-[3px] overflow-hidden rounded-sm bg-border`,children:(0,D.jsx)(`span`,{className:`block h-full bg-message-peer-accent opacity-70`,style:{width:`${Math.round(Zr(t.since,t.deadline,n)*100)}%`}})})]})}function ni({line:e,request:t,now:n,phase:r,replied:a}){let o=Xr(t,n);return(0,D.jsxs)(`div`,{"data-slot":`activity-line-label`,"data-request":t.requestId,"data-phase":r,"aria-hidden":`true`,style:{left:e.label.x,top:e.label.y,width:Z.w},className:i(ei,a?`border-success`:`border-message-peer-accent`,r===`fade`&&`activity-line-out`),children:[(0,D.jsxs)(`span`,{className:`flex gap-1 font-semibold`,children:[a?(0,D.jsx)(`span`,{className:`text-success`,children:`Replied`}):(0,D.jsx)(`span`,{className:`min-w-0 truncate text-message-peer-accent`,children:`Request`}),(0,D.jsx)(`span`,{className:`ml-auto shrink-0`,children:M(P(t.createdAt,n))})]}),(0,D.jsx)(`span`,{className:`block truncate`,children:e.away??Yr(t.text)}),o===void 0||a?null:(0,D.jsx)(`span`,{className:`mt-[3px] block h-[3px] overflow-hidden rounded-sm bg-border`,children:(0,D.jsx)(`span`,{className:`block h-full bg-message-peer-accent`,style:{width:`${Math.round(o*100)}%`}})})]})}var ri=(e,t)=>e.closing[t]?.phase??`open`;function ii(e,t){let n=e.closing[t];return n!==void 0&&n.replied&&n.phase!==`reply`}var ai=new Set;function oi({line:e,motion:t}){let n=ri(t,e.id);return(0,D.jsx)(`path`,{"data-request":e.id,"data-kind":e.kind,"data-phase":n,d:e.d,fill:`none`,strokeDasharray:n===`replied`?void 0:`6 5`,strokeWidth:e.kind===`peer`?2.2:1.8,markerEnd:`url(#activity-arrow-${e.kind})`,className:i(e.kind===`peer`?`stroke-message-peer-accent`:`stroke-message-inbound-accent`,Qr(n,e.id in t.opening))})}function si({line:e,motion:t,active:n}){return(0,D.jsx)(`path`,{"data-wait":e.id,"data-kind":`wait`,"data-active":n?`true`:void 0,d:e.d,fill:`none`,strokeDasharray:`0 8`,strokeLinecap:`round`,strokeWidth:n?3.2:2.4,markerEnd:`url(#activity-ring-wait)`,className:i(`stroke-message-peer-accent`,n?`opacity-100`:`opacity-80`,$r(t,e.id))})}function ci({id:e}){return(0,D.jsx)(`marker`,{id:e,viewBox:`0 0 12 12`,refX:`10`,refY:`6`,markerWidth:`5`,markerHeight:`5`,markerUnits:`strokeWidth`,orient:`auto`,children:(0,D.jsx)(`circle`,{cx:`6`,cy:`6`,r:`4`,strokeWidth:`2.4`,className:`fill-background stroke-message-peer-accent`})})}var li=[];function ui({requests:e,waits:t=li,active:n=ai,index:r,peers:i,layoutKey:a,now:o,motion:s=W,paused:c=!1}){let l=E.useRef(null),u=Kr(l,E.useCallback(n=>Dr(n,e,r,{peers:i,waits:t,frame:{width:n.clientWidth,view:vr(n)}}),[e,t,r,i]),Or,`[data-activity-card]`,a,!0),d=E.useMemo(()=>new Set(u.map(e=>e.id)),[u]),f=Br(s.comets,d,c),p=new Map(e.map(e=>[e.requestId,e])),m=new Map(t.map(e=>[e.id,e]));return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`svg`,{ref:l,"data-slot":`activity-lines`,"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 z-[3] size-full overflow-visible`,children:[(0,D.jsxs)(`defs`,{children:[(0,D.jsx)(`marker`,{id:`activity-arrow-peer`,viewBox:`0 0 10 10`,refX:`8`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto`,children:(0,D.jsx)(`path`,{d:`M0 0 10 5 0 10z`,className:`fill-message-peer-accent`})}),(0,D.jsx)(`marker`,{id:`activity-arrow-family`,viewBox:`0 0 10 10`,refX:`8`,refY:`5`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,D.jsx)(`path`,{d:`M0 0 10 5 0 10z`,className:`fill-message-inbound-accent`})}),(0,D.jsx)(ci,{id:`activity-ring-wait`})]}),u.map(e=>e.kind===`wait`?(0,D.jsx)(si,{line:e,motion:s,active:n.has(e.id)},e.id):(0,D.jsx)(oi,{line:e,motion:s},e.id)),(0,D.jsx)(`g`,{ref:f,"data-slot":`activity-comets`})]}),u.map(e=>{let t=e.kind===`wait`?m.get(e.id):void 0;if(t)return(0,D.jsx)(ti,{line:e,wait:t,now:o,motion:s},e.id);let n=p.get(e.id);return e.kind===`peer`&&n?(0,D.jsx)(ni,{line:e,request:n,now:o,phase:ri(s,e.id),replied:ii(s,e.id)},e.id):null})]})}function di(e,t){let n=new Map;for(let r of[...e?.projects??[],...t.projects])for(let[e,t]of Ot(r))n.set(e,t);return n}var fi={"timed-out":`timed out`,cancelled:`was cancelled`,destroyed:`closed: the recipient was destroyed`,failed:`closed: the recipient failed`,"completed-without-reply":`closed without a reply`,"sender-closed":`was closed by its sender`,"human-fallback":`went to a human`,deleted:`closed: the recipient was deleted`};function pi(e,t,n){let r=n(e.senderRunId,e.senderTitle),i=n(e.recipientRunId,e.recipientTitle);return t===`replied`?`${i} replied to ${r}`:`${r}’s request to ${i} ${fi[t??``]??`closed`}`}var mi={done:{tone:`success`,word:`finished`},failed:{tone:`danger`,word:`failed`},cancelled:{tone:`neutral`,word:`was cancelled`},review:{tone:`info`,word:`waits for review`}},hi=e=>e.relationship===`peer`?`peer`:`family`;function gi(e,t,n){let r=(e,n)=>V(t,e,n);switch(e.kind){case`request-opened`:return{tone:hi(e.request),text:`${r(e.request.senderRunId,e.request.senderTitle)} asked ${r(e.request.recipientRunId,e.request.recipientTitle)}`};case`request-closed`:return{tone:e.status===`replied`?`success`:`neutral`,text:pi(e.request,e.status,r)};case`rung-changed`:return{tone:h(e.task.rung).tone,text:`${e.task.title}: ${Ct(e.task,{now:n,titleOf:e=>r(e)}).verb}`};case`worker-started`:return{tone:`running`,text:`${e.worker.title} started`};case`worker-settled`:{let t=mi[e.worker.status]??{tone:`neutral`,word:`settled`};return{tone:t.tone,text:`${e.worker.title} ${t.word}`}}case`card-entered`:return{tone:h(e.task.rung).tone,text:`${e.task.title} started`};case`card-left`:return{tone:`neutral`,text:`${e.task.title} left active work`};case`check-passed`:return{tone:`success`,text:`PR ${e.pr}: check “${e.name}” passed`};default:return}}function _i(e,t,n,r){return[...t.map((e,t)=>({...e,id:r+t,at:n})),...e].slice(0,6)}function vi(e){let t=Math.max(0,Math.floor(e/1e3));return t<5?`now`:t<60?`${t} s`:`${Math.floor(t/60)} min`}var yi=new Set;function bi(e){let[t,n]=E.useState({}),r=t.pointer??t.focus,i=E.useCallback((e,t)=>n(n=>n[e]===t?n:{...n,[e]:t}),[]);return{linked:E.useMemo(()=>r===void 0?yi:Mt(r,e),[r,e]),active:E.useMemo(()=>r===void 0?yi:new Set(e.filter(e=>e.waiterRunId===r||e.peerRunId===r).map(e=>e.id)),[r,e]),onHover:i}}var xi=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`}),Si=`inline-flex items-center px-3 py-[5px] text-[12px] font-medium focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring max-md:min-h-11`;function Ci({scope:e,projectId:t}){let r=e=>i(Si,e?`bg-card-2 text-foreground`:`text-muted-foreground hover:text-foreground`);return(0,D.jsxs)(`nav`,{"aria-label":`Activity scope`,"data-slot":`activity-scope`,className:`ml-auto inline-flex overflow-hidden rounded-lg border border-border`,children:[t===null?null:(0,D.jsx)(n,{to:`/p/${encodeURIComponent(t)}/activity`,"aria-current":e===`project`?`page`:void 0,className:r(e===`project`),children:`This project`}),(0,D.jsx)(n,{to:`/activity`,state:{activityProjectId:t},"aria-current":e===`all`?`page`:void 0,className:r(e===`all`),children:`All projects`})]})}function wi({now:e,stale:t}){return(0,D.jsxs)(`span`,{"data-slot":`activity-clock`,"data-stale":t?`true`:void 0,className:`inline-flex items-center gap-1.5 text-[12px] text-muted-foreground tabular-nums`,children:[(0,D.jsx)(`span`,{"data-tone":`success`,className:i(`inline-flex size-[12px] items-center justify-center`,!t&&`activity-pulse`),children:(0,D.jsx)(w,{tone:t?`neutral`:`success`,"aria-hidden":`true`})}),(0,D.jsx)(`b`,{className:i(`font-semibold`,t?`text-muted-foreground`:`text-success`),children:t?`Not updating`:`Live`}),xi.format(e),` `,rt()]})}function Ti({name:e,now:t,stale:n=!1,children:r}){return(0,D.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[(0,D.jsxs)(`h1`,{className:`min-w-0 truncate text-[18px] font-semibold`,children:[`Activity `,(0,D.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`· `,e]})]}),t===void 0?null:(0,D.jsx)(wi,{now:t,stale:n}),r]})}function Ei({value:e,bump:t}){return(0,D.jsx)(`strong`,{"data-bump":t===void 0?void 0:`true`,className:i(`font-semibold text-foreground tabular-nums`,t!==void 0&&`activity-bump`),children:e},t??`still`)}function Q({icon:e,count:t,label:n,bump:r}){return(0,D.jsxs)(`li`,{"data-slot":`activity-chip`,"data-chip":n,className:`inline-flex items-center gap-[7px] rounded-full border border-border bg-card px-[11px] py-[5px] text-[12px] text-muted-foreground`,children:[e,(0,D.jsx)(Ei,{value:t,bump:r}),` `,n]})}function Di({summary:e,tasksTo:t,bumps:n={}}){let r=e=>n[e]?.key;return(0,D.jsxs)(`ul`,{"data-slot":`activity-summary`,"aria-live":`polite`,"aria-label":`Summary`,className:`flex flex-wrap gap-2`,children:[(0,D.jsx)(Q,{icon:(0,D.jsx)(w,{tone:`pending`,"aria-hidden":`true`}),count:e.needsYou,label:`needs you`,bump:r(`needsYou`)}),(0,D.jsx)(Q,{icon:(0,D.jsx)(w,{tone:`running`,"aria-hidden":`true`}),count:e.working,label:`working`,bump:r(`working`)}),(0,D.jsx)(Q,{icon:(0,D.jsx)(w,{tone:`running`,shape:`ring`,"aria-hidden":`true`}),count:e.waiting,label:`waiting`,bump:r(`waiting`)}),(0,D.jsx)(Q,{icon:(0,D.jsx)(w,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}),count:e.queued,label:`queued`,bump:r(`queued`)}),(0,D.jsx)(Q,{icon:(0,D.jsx)(T,{"aria-hidden":`true`,className:`size-3.5`}),count:e.activeWorkers,label:`active workers`,bump:r(`activeWorkers`)}),(0,D.jsx)(Q,{icon:(0,D.jsx)(be,{"aria-hidden":`true`,className:`size-3.5 text-message-peer-accent`}),count:e.openRequests,label:`open requests`,bump:r(`openRequests`)}),(0,D.jsx)(`li`,{"data-slot":`activity-chip`,"data-chip":`in review`,children:(0,D.jsxs)(C,{to:t,className:`inline-flex items-center gap-[7px] rounded-full border border-border bg-card px-[11px] py-[5px] text-[12px] text-muted-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:min-h-11`,children:[(0,D.jsx)(w,{tone:`info`,"aria-hidden":`true`}),(0,D.jsx)(Ei,{value:e.inReview,bump:r(`inReview`)}),` in review`]})})]})}var $=e=>new Map(e.map(e=>[e.runId,e])),Oi=e=>e!==void 0&&Dt(e)===void 0;function ki(e,t,n,r){let i=$(t.workers);for(let t of n.workers){let a=i.get(t.runId);!a&&I(t.status)&&r({kind:`worker-started`,projectId:e,parentId:n.runId,worker:t}),a&&I(a.status)&&!I(t.status)&&r({kind:`worker-settled`,projectId:e,parentId:n.runId,worker:t})}}function Ai(e,t,n,r){if(t.wait?.kind!==`pr`||n.wait?.kind!==`pr`||t.wait.detail.number!==n.wait.detail.number)return;let i=new Set((t.wait.detail.checks??[]).filter(e=>e.bucket===`pending`).map(e=>e.name));for(let t of n.wait.detail.checks??[])t.bucket===`pass`&&i.has(t.name)&&r({kind:`check-passed`,projectId:e,runId:n.runId,pr:n.wait.detail.number,name:t.name})}var ji=(e,t)=>t.tool!==void 0&&(t.tool.startedAt!==e.tool?.startedAt||t.tool.title!==e.tool?.title);function Mi(e,t,n,r){t.rung!==n.rung&&r({kind:`rung-changed`,projectId:e,task:n,from:t.rung}),ji(t,n)&&r({kind:`tool-started`,projectId:e,runId:n.runId}),ki(e,t,n,r),Ai(e,t,n,r)}function Ni(e,t,n){let r=$(e.tasks),i=$(t.tasks);for(let e of t.tasks){let i=r.get(e.runId);i?Mi(t.projectId,i,e,n):n({kind:`card-entered`,projectId:t.projectId,task:e})}for(let r of e.tasks)i.has(r.runId)||n({kind:`card-left`,projectId:t.projectId,task:r})}function Pi(e,t,n){let r=new Set(e.requests.map(e=>e.requestId)),i=new Set(t.requests.map(e=>e.requestId)),a=new Map(t.closed.map(e=>[e.requestId,e.status]));for(let e of t.requests)r.has(e.requestId)||n({kind:`request-opened`,projectId:t.projectId,request:e});for(let r of e.requests){if(i.has(r.requestId))continue;let e=a.get(r.requestId);n({kind:`request-closed`,projectId:t.projectId,request:r,...e?{status:e}:{}})}}function Fi(e,t,n){let r=jt(e.tasks),i=jt(t.tasks),a=new Set(r.map(e=>e.id)),o=new Set(i.map(e=>e.id));for(let e of i)a.has(e.id)||n({kind:`wait-opened`,projectId:t.projectId,wait:e});for(let e of r)o.has(e.id)||n({kind:`wait-closed`,projectId:t.projectId,wait:e})}var Ii=[`needsYou`,`working`,`waiting`,`queued`,`activeWorkers`,`openRequests`,`inReview`];function Li(e,t,n){let r=Wt(e),i=Wt(t);for(let e of Ii)r[e]!==i[e]&&n({kind:`chip-changed`,chip:e,from:r[e],to:i[e]})}function Ri(e,t){if(e===void 0)return[];let n=[],r=e=>n.push(e),i=new Map(e.projects.map(e=>[e.projectId,e]));for(let e of t.projects){let t=i.get(e.projectId);!Oi(t)||!Oi(e)||(Ni(t,e,r),Pi(t,e,r),Fi(t,e,r))}return Li(e.projects,t.projects,r),n}function zi(e){return{input:e,reconcile:!1,seq:0,motion:W,feed:[],epoch:0,...e.snapshot?{seen:e.snapshot}:{}}}function Bi(e){let{plan:t,...n}=e;return{...n,motion:W,epoch:e.epoch+1}}function Vi(e,t,n){let r=Ri(t,n);if(r.length===0)return e;let i=Date.parse(n.generatedAt),a=di(t,n),o=r.flatMap(e=>gi(e,a,i)??[]),s=e.seq+o.length+1,c=tn(r,s,e.input.reduced);return{...e,seq:s,feed:o.length>0?_i(e.feed,o,i,e.seq+1):e.feed,motion:rn(e.motion,c.changes),...c.timers.length>0?{plan:{key:s,timers:c.timers}}:{}}}function Hi(e,t){let n=e.seen;if(!t||t===n)return e;let r={...e,seen:t};return!n||!e.input.active?r:e.reconcile?{...r,reconcile:!1}:Vi(r,n,t)}function Ui(e,t){let n=e.input;if(t.scope!==n.scope)return{...zi(t),seq:e.seq,epoch:e.epoch+1};if(t.snapshot===n.snapshot&&t.active===n.active&&t.reduced===n.reduced)return e;let r={...e,input:t};return n.active&&!t.active&&(r={...Bi(r),reconcile:!0}),!n.reduced&&t.reduced&&(r=Bi(r)),Hi(r,t.snapshot)}var Wi=`(prefers-reduced-motion: reduce)`,Gi=()=>typeof window<`u`&&typeof window.matchMedia==`function`?window.matchMedia(Wi):void 0;function Ki(e){let t=Gi();return t?.addEventListener?.(`change`,e),()=>t?.removeEventListener?.(`change`,e)}function qi(){return Gi()?.matches??!1}function Ji(){return(0,E.useSyncExternalStore)(Ki,qi,()=>!1)}function Yi(e,t){let n=E.useRef(new Set);E.useEffect(()=>{let e=n.current;return()=>{for(let t of e)clearTimeout(t);e.clear()}},[e.epoch]),E.useEffect(()=>{for(let{after:r,change:i}of e.plan?.timers??[]){let e=setTimeout(()=>{n.current.delete(e),t(e=>({...e,motion:rn(e.motion,[i])}))},r);n.current.add(e)}},[e.plan?.key])}function Xi(e,t){let n=Ji(),r=f(),i={snapshot:e,scope:t,active:r,reduced:n},[a,o]=E.useState(()=>zi(i)),s=Ui(a,i);return s!==a&&o(s),Yi(s,o),{motion:s.motion,feed:s.feed,reduced:n,paused:!r}}function Zi(e,t){let n=xe(1e3),[r,i]=E.useState({offset:0}),a=r.offset;return Xe(e)&&e!==r.generatedAt&&t!==0&&(a=Date.parse(e)-t,i({generatedAt:e,offset:a})),n+a}export{Sn as A,jt as B,Pn as C,jn as D,Nn as E,W as F,kt as G,H,an as I,Ct as J,Wt as K,Rt as L,G as M,ln as N,wn as O,sn as P,tt as Q,Pt as R,$n as S,Ln as T,It as U,Dt as V,Ot as W,M as X,F as Y,P as Z,Br as _,Di as a,lr as b,ui as c,ri as d,ii as f,Wr as g,Kr as h,Ci as i,hn as j,kn as k,ci as l,Xr as m,Xi as n,bi as o,$r as p,I as q,Ti as r,vi as s,Zi as t,Qr as u,Cr as v,In as w,Qn as x,cr as y,V as z};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,p as n,u as r}from"./button-CS5tOblf.js";import{i,t as a}from"./react-runtime-CCIEwYL0.js";import{Ln as o,Rn as s,Zt as c,it as l}from"./queries-BtScxiQP.js";import{F as u,I as d,N as f,P as p,U as m,_ as h,ct as g,g as _,h as v,m as y,p as b}from"./design-icons-DmYTv2r1.js";import{t as x}from"./createLucideIcon-BHp8sXmF.js";import{n as S,r as C,t as w}from"./popover-N-u5z2xh.js";var T=x(`search-x`,[[`path`,{d:`m13.5 8.5-5 5`,key:`1cs55j`}],[`path`,{d:`m8.5 8.5 5 5`,key:`a8mexj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),E=e(i(),1),D=a(),O=(0,E.createContext)(null);function k({children:e}){let[t,n]=(0,E.useState)(()=>new Map),r=(0,E.useCallback)((e,t)=>{n(n=>{let r=new Map(n);return r.set(e,t),r})},[]),i=(0,E.useCallback)(e=>{n(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),a=l((0,E.useMemo)(()=>[...t.values()].flat(),[t])),o=(0,E.useMemo)(()=>({publish:r,retract:i,lookup:a}),[r,i,a]);return(0,D.jsx)(O.Provider,{value:o,children:e})}var A=(0,E.createContext)(null);function j({projectId:e,repoBase:t,requests:n,children:r}){let i=(0,E.useContext)(O),a=(0,E.useContext)(A),o=(0,E.useId)();(0,E.useEffect)(()=>{if(i)return i.publish(o,n),()=>i.retract(o)},[i,o,n.map(e=>`${e.projectId} ${e.kind}#${e.number}`).sort().join(`|`)]);let s=l(i?M:n),c=i?.lookup??s,u=t??(a&&a.projectId===e?a.repoBase:void 0),d=(0,E.useMemo)(()=>({lookup:c,projectId:e,repoBase:u}),[c,e,u]);return(0,D.jsx)(A.Provider,{value:d,children:r})}var M=[];function N(e,t,n){let r=(0,E.useContext)(A),i=n??r?.projectId;return!r||!i||t===void 0?te:r.lookup({projectId:i,kind:e,number:t})}function ee(e,t){let n=(0,E.useContext)(A),r=t??n?.projectId;return!n||!r?[]:e.filter(e=>n.lookup({projectId:r,kind:`PR`,number:e}).conflicting===!0)}function P(){let e=(0,E.useContext)(A);return{projectId:e?.projectId,repoBase:e?.repoBase}}var te=Object.freeze({state:`idle`}),F={success:`border-success/40 text-success`,danger:`border-danger/40 text-danger`,accent:`border-accent-strong/35 text-accent-text`,merged:`border-merged-strong/35 text-merged-text`,info:`border-info/40 text-info`,neutral:`border-border text-muted-foreground`,pending:`border-pending-strong/45 text-pending-strong`,conflict:`border-conflict/45 text-conflict`},I={success:`text-success`,danger:`text-danger`,accent:`text-merged-text`,merged:`text-merged-text`,info:`text-info`,neutral:`text-soft-foreground`,pending:`text-pending-strong`,conflict:`text-conflict`},ne={success:`hover:bg-success/10`,danger:`hover:bg-danger/10`,accent:`hover:bg-accent-strong/10`,merged:`hover:bg-merged-strong/10`,info:`hover:bg-info/10`,neutral:`hover:bg-muted`,pending:`hover:bg-pending-strong/10`,conflict:`hover:bg-conflict/10`},re={draft:u,"review-required":d,"changes-requested":m,"checks-pending":null,"checks-failing":h,ready:b,merged:f,closed:p,open:y,completed:b,"not-planned":_};function L(e){return e===`PR`?`pr-chip`:`issue-chip`}function R(e){return e?{"data-conflicting":`true`}:{}}function z(e,t,n,r){return!n||r!==void 0&&c({kind:e,number:t??0,url:n},r)}function B(e,t,n){return e===`PR`&&(t??n)===!0}function V({plain:e,inert:t,conflicting:n,className:i,tone:a}){return e?r(`inline-flex items-center gap-1 rounded-[2px] text-inherit`,n&&`text-conflict font-medium`,!t&&`group/reference focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-link-foreground`,i):r(`inline-flex h-[22px] items-center gap-1 rounded-md border px-1.5 font-mono text-[12px] font-normal`,F[a],i)}function H(e,t,n,r){return n&&!r?t?`${e===`PR`?`PR `:``}#${t}`:e:t?`${!r&&e===`Issue`?`Issue `:``}#${t}`:e}function U(e){return e===`PR`?`pull request`:`issue`}function W(e,t,n,r){return`Open the ${e}${t?` #${t}`:``} for ${n}${r?` — ${r.label}`:``}`}function G(e,t){return e&&t?I[t.tone]:void 0}function K(e,n){return!e&&(!n||!t(n))}function q({conflicting:e,presentation:t,status:n,plain:i,compact:a,inert:o,kind:s,label:c,glyphClass:l}){return(0,D.jsxs)(D.Fragment,{children:[e?(0,D.jsx)(g,{className:r(`size-2.5 shrink-0`,l),"aria-hidden":`true`}):(0,D.jsx)($,{status:t?n:void 0,className:i?r(`size-2.5`,l):void 0}),i&&a?s===`PR`?(0,D.jsx)(d,{"data-slot":`reference-kind`,className:`size-2.5 shrink-0`,"aria-hidden":`true`}):(0,D.jsx)(y,{"data-slot":`reference-kind`,className:`size-2.5 shrink-0`,"aria-hidden":`true`}):null,i?(0,D.jsx)(`span`,{className:o?void 0:`underline-offset-2 group-hover/reference:underline group-focus-visible/reference:underline`,children:c}):c]})}function J({kind:e,status:t,conflicting:n,chipClass:r,body:i}){return(0,D.jsx)(`span`,{"data-slot":L(e),"data-status":t,"data-inert":`true`,...R(n),className:r,children:i})}function Y({kind:e,number:n,tooltip:r,url:i}){return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`span`,{className:`block font-medium`,children:[e===`PR`?`Pull request`:`Issue`,n?` #${n}`:``,` · `,r.headline]}),(0,D.jsx)(`span`,{className:`block`,children:r.detail}),r.also?(0,D.jsx)(`span`,{className:`block opacity-70`,children:r.also}):null,i&&t(i)?(0,D.jsx)(`span`,{className:`block opacity-70`,children:i.replace(/^https?:\/\//,``)}):null]})}function ie({reference:e,taskTitle:t,status:n,conflicting:i,conflictAction:a,projectId:c,repoBase:l,to:u,className:d,compact:f=!1,plain:p=!1,inert:m=!1}){let{kind:h,number:g,url:_}=e,v=P(),y=N(h,z(h,g,_,l??v.repoBase)?g:void 0,c),b=n??y.status,x=s(b),S=B(h,i,y.conflicting),C=S?o:x,w=C?.tone??`accent`,T=V({plain:p,inert:m,conflicting:S,className:d,tone:w}),E=le(y,C,S?x:void 0),O=H(h,g,p,f),k=U(h),A=W(k,g,t,C),j=(0,D.jsx)(q,{conflicting:S,presentation:C,status:b,plain:p,compact:f,inert:m,kind:h,label:O,glyphClass:G(p,C)});if(m)return(0,D.jsx)(J,{kind:h,status:b,conflicting:S,chipClass:T,body:j});let M=K(u,_)?(0,D.jsx)(`span`,{"data-slot":L(h),"data-status":b,...R(S),"aria-label":C?`${k} ${O} — ${C.label}`:void 0,className:T,children:j}):(0,D.jsx)(ae,{to:u,url:_,"data-slot":L(h),"data-status":b,...R(S),title:E?void 0:_,"aria-label":A,className:p?T:r(T,ne[w]),children:j});return E?(0,D.jsx)(ce,{chip:M,action:S?a:void 0,state:y.state,children:(0,D.jsx)(Y,{kind:h,number:g,tooltip:E,url:_})}):M}function ae({to:e,url:t,children:r,...i}){return e?(0,D.jsx)(n,{to:e,...i,children:r}):(0,D.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,...i,children:r})}var X=(0,E.createContext)(()=>{});function oe(){return(0,E.useContext)(X)}var se=150,Z=120;function ce({chip:e,action:t,state:n,children:r}){let[i,a]=(0,E.useState)(!1),o=(0,E.useRef)(null),s=(0,E.useRef)(null),c=(0,E.useRef)(void 0),l=(0,E.useCallback)((e,t)=>{clearTimeout(c.current),c.current=setTimeout(()=>a(e),t)},[]),u=(0,E.useCallback)(()=>{clearTimeout(c.current),a(!1)},[]);(0,E.useEffect)(()=>()=>clearTimeout(c.current),[]);let d=e=>e instanceof Node&&(s.current?.contains(e)||o.current?.contains(e));return(0,D.jsxs)(w,{open:i,onOpenChange:e=>e?a(!0):u(),children:[(0,D.jsx)(S,{asChild:!0,ref:o,onPointerEnter:e=>{e.pointerType!==`touch`&&l(!0,se)},onPointerLeave:e=>{e.pointerType!==`touch`&&l(!1,Z)},onFocus:()=>a(!0),onBlur:e=>{d(e.relatedTarget)||u()},onKeyDown:e=>{if(e.key===`Escape`)return u();if(e.key!==`Tab`||e.shiftKey||!t)return;let n=s.current?.querySelector(`button:not([disabled]), [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`);n&&(e.preventDefault(),n.focus())},...t?{"aria-haspopup":`dialog`,"aria-expanded":i}:{},children:e}),(0,D.jsxs)(C,{ref:s,side:`top`,role:t?`dialog`:`tooltip`,"data-slot":`reference-status-card`,"data-tooltip-state":n,className:`w-64 space-y-2 p-3 text-xs`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>{e.preventDefault(),d(document.activeElement)&&o.current?.focus()},onPointerEnter:()=>clearTimeout(c.current),onPointerLeave:e=>{e.pointerType!==`touch`&&l(!1,Z)},children:[(0,D.jsx)(`div`,{className:`space-y-0.5`,children:r}),t?(0,D.jsx)(X.Provider,{value:u,children:t}):null]})]})}function le(e,t,n){if(t){let{label:r,hint:i}=t,a=n?`also ${ue(n.label)} — ${n.hint}`:void 0;return e.state===`unavailable`?{headline:r,detail:`last known — GitHub is unreachable${e.reason?` (${e.reason})`:``}`,...a?{also:a}:{}}:{headline:r,detail:i,...a?{also:a}:{}}}switch(e.state){case`loading`:return{headline:`Checking GitHub…`,detail:`the status of this reference is on its way`};case`unavailable`:return{headline:`Status unavailable`,detail:e.reason??`GitHub could not be reached — the chip says nothing rather than guessing`};case`unknown`:return{headline:`Not found on this repository`,detail:`GitHub has no such number here — the reference may point at another repo`};default:return null}}function ue(e){return e.charAt(0).toLowerCase()+e.slice(1)}function Q({kind:e,number:t,className:n}){let i=N(e,t),a=s(i.status),c=e===`PR`&&i.conflicting===!0,l=c?o:a;if(!l)return null;let u=r(`size-2.5`,I[l.tone]);return(0,D.jsx)(`span`,{"data-slot":`reference-status-glyph`,"data-status":i.status,...c?{"data-conflicting":`true`}:{},"aria-hidden":`true`,className:r(`inline-flex items-center`,n),children:c?(0,D.jsx)(g,{className:r(`shrink-0`,u),"aria-hidden":`true`}):(0,D.jsx)($,{status:i.status,className:u})})}function $({status:e,className:t}){if(!e)return null;if(e===`checks-pending`)return(0,D.jsx)(v,{"data-slot":`status-dot`,"data-tone":`pending`,className:r(`size-3 animate-pulse motion-reduce:animate-none`,t),"aria-hidden":`true`});let n=re[e];return n?(0,D.jsx)(n,{className:r(`size-2.5 shrink-0`,t),"aria-hidden":`true`}):null}var de={general:[`Settings`,`General`],webhooks:[`Settings`,`General`,`Webhooks`],providers:[`Settings`,`Agents`,`Providers`],projects:[`Settings`,`Projects`],worktrees:[`Settings`,`Worktrees`],sidebar:[`Settings`,`Sidebar`]};function fe(e,t=` → `){return de[e].join(t)}export{j as a,P as c,oe as i,N as l,ie as n,k as o,Q as r,ee as s,fe as t,T as u};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/diff-view-B9kgeZTm.js","assets/rolldown-runtime-QTnfLwEv.js","assets/button-CS5tOblf.js","assets/react-runtime-CCIEwYL0.js","assets/bundle-mjs-BT31bpU6.js","assets/eye-B8okNWXU.js","assets/createLucideIcon-BHp8sXmF.js","assets/index-75IttVLX.js","assets/live-refetch-pzhdhNS_.js","assets/project-scope-context-DSkcNKO7.js","assets/live-protocol-DBPXI6ks.js","assets/useInfiniteQuery-BmfExLUr.js","assets/queries-BtScxiQP.js","assets/useQuery-8pHkglP4.js","assets/ws-CEQH0TUT.js","assets/toaster-CRVRHlMR.js","assets/cez-idle-NomdGTfa.js","assets/design-icons-DmYTv2r1.js","assets/nav-row-styles-CEA9c88Q.js","assets/popover-N-u5z2xh.js","assets/es2015-CX0rgbM5.js","assets/dropdown-menu-D7f0O7xR.js","assets/dist-DvNdR7gM.js","assets/format-BNCkW110.js","assets/play-CmVAj_fu.js","assets/control-locations-DlrUP5vD.js","assets/alert-dialog-h-3h9B4l.js","assets/dialog-Dw7fMdDQ.js","assets/input-DIwJvCgi.js","assets/github-sidebar-model-BdoLA7qT.js","assets/project-router-BFKfAFvq.js","assets/agent-accounts-C6eyz75V.js","assets/skills-DFBiAuJG.js","assets/centered-state-BmsqxbI8.js","assets/chunk-BO2N2NFS-DE6qKn3r.js","assets/lib-BxQXEXDF.js","assets/sortable.esm-zp_qkYGV.js","assets/index-9YmaiQ1k.css","assets/image-preview-Dy3o8upo.js","assets/zoomable-image-UzXCYU7Z.js","assets/markdown-BBDDg-4t.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{u as t}from"./button-CS5tOblf.js";import{i as n,t as r}from"./react-runtime-CCIEwYL0.js";import{i}from"./bundle-mjs-BT31bpU6.js";import{P as a}from"./index-75IttVLX.js";import{n as o,t as s}from"./image-preview-Dy3o8upo.js";var c=e(n(),1),l=r();function u(e){let[n,r]=(0,c.useState)(null);return(0,c.useEffect)(()=>{let e=!1;return i(()=>import(`./diff-view-B9kgeZTm.js`).then(t=>{e||r({View:t.DiffView})},()=>{e||r(`failed`)}),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40])),()=>{e=!0}},[]),e.files.length===0?(0,l.jsx)(`p`,{"data-slot":`diff-empty`,className:t(`px-1 text-xs text-soft-foreground`,e.className),children:`No changes.`}):n===`failed`?(0,l.jsx)(d,{...e}):n===null?(0,l.jsx)(`p`,{"data-slot":`diff-loading`,className:t(`px-1 text-xs text-soft-foreground`,e.className),children:`Loading diff…`}):(0,l.jsx)(n.View,{...e})}function d({files:e,wrap:n=!1,imageSrc:r,onOpenInApp:i,viewRef:o,className:s}){let u={adds:e.reduce((e,t)=>e+t.adds,0),dels:e.reduce((e,t)=>e+t.dels,0),files:e.length},d=(0,c.useRef)(null);return(0,c.useImperativeHandle)(o,()=>({scrollToPath:e=>{for(let t of d.current?.querySelectorAll(`[data-slot="diff-file"]`)??[])if(t.dataset.path===e){t.scrollIntoView({block:`start`,behavior:`smooth`});return}}})),(0,l.jsxs)(`div`,{ref:d,"data-slot":`diff`,"data-fallback":`true`,className:t(`flex min-w-0 flex-col gap-3`,s),children:[(0,l.jsxs)(`p`,{"data-slot":`diff-totals`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,l.jsxs)(`span`,{children:[u.files,` `,u.files===1?`file`:`files`,` changed`]}),(0,l.jsx)(a,{stat:u})]}),e.map(e=>(0,l.jsx)(f,{file:e,wrap:n,imageSrc:r,onOpenInApp:i},`${e.oldPath??``}→${e.path}`))]})}function f({file:e,wrap:n,imageSrc:r,onOpenInApp:i}){return(0,l.jsxs)(`section`,{"data-slot":`diff-file`,"data-path":e.path,className:`min-w-0 overflow-clip rounded-md border border-border bg-card`,children:[(0,l.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-border/50 px-3 py-2`,children:[(0,l.jsx)(`span`,{"data-slot":`diff-file-path`,className:`min-w-0 truncate font-mono text-xs font-medium`,children:e.oldPath?`${e.oldPath} → ${e.path}`:e.path}),(0,l.jsx)(`span`,{className:`ml-auto shrink-0`,children:(0,l.jsx)(a,{stat:{adds:e.adds,dels:e.dels,files:1},className:`text-[11px]`})})]}),o(e)?(0,l.jsx)(s,{file:e,imageSrc:r,onOpenInApp:i}):e.binary?(0,l.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`Binary file — no text diff.`}):e.patch===``?(0,l.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`No content changes (metadata only).`}):(0,l.jsx)(`pre`,{className:t(`py-2 font-mono text-xs leading-[1.7]`,n?`break-words whitespace-pre-wrap`:`overflow-x-auto whitespace-pre`),children:e.patch.split(`
|
|
3
|
-
`).map((e,n)=>(0,l.jsxs)(`span`,{className:t(`block px-4`,e.startsWith(`+`)&&!e.startsWith(`+++`)&&`bg-diff-add`,e.startsWith(`-`)&&!e.startsWith(`---`)&&`bg-diff-del`,e.startsWith(`@@`)&&`text-soft-foreground`),children:[e,e===``?` `:``]},n))})]})}export{u as t};
|