@bivy/bivy 0.7.0-staging.105 → 0.7.0-staging.106
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/server.js +40 -5
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -4348,6 +4348,12 @@ function startModelAuthWatcher() {
|
|
|
4348
4348
|
let sessionAdvertiseTarget;
|
|
4349
4349
|
let advertiseTimer;
|
|
4350
4350
|
let advertiseResyncTimer;
|
|
4351
|
+
// Only one replace-all session advert may be in flight. If an older snapshot
|
|
4352
|
+
// (still containing a just-deleted/pruned session) completes after a newer one,
|
|
4353
|
+
// the control plane resurrects that row. Changes arriving during a request set
|
|
4354
|
+
// this flag and are sent immediately after it completes, in order.
|
|
4355
|
+
let advertiseRunning = false;
|
|
4356
|
+
let advertiseAgain = false;
|
|
4351
4357
|
// How often the node re-affirms it's online to the control plane. Kept well
|
|
4352
4358
|
// under the control plane's NODE_ONLINE_TTL_MS (90s) so a missed beat or two
|
|
4353
4359
|
// doesn't flap a healthy node's status.
|
|
@@ -4578,11 +4584,17 @@ async function advertiseSessions() {
|
|
|
4578
4584
|
: [];
|
|
4579
4585
|
return {
|
|
4580
4586
|
sessionId: s.id,
|
|
4581
|
-
|
|
4582
|
-
|
|
4587
|
+
// Failures (including exhausted credits/rate limits) are outcomes to
|
|
4588
|
+
// review, not blocking questions that keep saying "Needs your response".
|
|
4589
|
+
// Only a still-pending approval/question owns that status.
|
|
4590
|
+
status: pendingApproval ? "needs_action" : (record ? (sessionBusy(record) ? "working" : "idle") : "saved"),
|
|
4591
|
+
needsAction: pendingApproval,
|
|
4583
4592
|
source: record?.source || meta?.source,
|
|
4584
4593
|
titleEnc: name ? relay.sealString(name) : undefined,
|
|
4585
4594
|
branch: record?.worktree?.branch || meta?.branch,
|
|
4595
|
+
// This is activity time, not advert receive time. A daemon restart/full
|
|
4596
|
+
// resync must not make every historical row appear freshly updated.
|
|
4597
|
+
updatedAt: isoFrom(record?.lastTouchedAt ?? meta?.lastActivityAt ?? meta?.updatedAt ?? s.modified),
|
|
4586
4598
|
agentServiceAddress,
|
|
4587
4599
|
githubIssueUrl: record?.githubIssueUrl,
|
|
4588
4600
|
prUrl: record?.prUrl,
|
|
@@ -4600,16 +4612,39 @@ async function advertiseSessions() {
|
|
|
4600
4612
|
// best effort; the periodic resync and the next change will retry
|
|
4601
4613
|
}
|
|
4602
4614
|
}
|
|
4603
|
-
/** Debounced advertise — many session events collapse into one
|
|
4615
|
+
/** Debounced, serialized advertise — many session events collapse into one
|
|
4616
|
+
* POST, and replace-all snapshots can never complete out of order. */
|
|
4604
4617
|
function scheduleAdvertise() {
|
|
4605
|
-
if (!sessionAdvertiseTarget
|
|
4618
|
+
if (!sessionAdvertiseTarget)
|
|
4619
|
+
return;
|
|
4620
|
+
if (advertiseRunning) {
|
|
4621
|
+
advertiseAgain = true;
|
|
4622
|
+
return;
|
|
4623
|
+
}
|
|
4624
|
+
if (advertiseTimer)
|
|
4606
4625
|
return;
|
|
4607
4626
|
advertiseTimer = setTimeout(() => {
|
|
4608
4627
|
advertiseTimer = undefined;
|
|
4609
|
-
void
|
|
4628
|
+
void drainSessionAdverts();
|
|
4610
4629
|
}, 1000);
|
|
4611
4630
|
advertiseTimer.unref?.();
|
|
4612
4631
|
}
|
|
4632
|
+
async function drainSessionAdverts() {
|
|
4633
|
+
if (advertiseRunning) {
|
|
4634
|
+
advertiseAgain = true;
|
|
4635
|
+
return;
|
|
4636
|
+
}
|
|
4637
|
+
advertiseRunning = true;
|
|
4638
|
+
try {
|
|
4639
|
+
do {
|
|
4640
|
+
advertiseAgain = false;
|
|
4641
|
+
await advertiseSessions();
|
|
4642
|
+
} while (advertiseAgain);
|
|
4643
|
+
}
|
|
4644
|
+
finally {
|
|
4645
|
+
advertiseRunning = false;
|
|
4646
|
+
}
|
|
4647
|
+
}
|
|
4613
4648
|
let githubPoller;
|
|
4614
4649
|
/**
|
|
4615
4650
|
* Serialize all work for one issue (keyed by its `issue:owner/repo#N` source).
|
package/package.json
CHANGED