@bivy/bivy 0.17.3-staging.6 → 0.17.3-staging.7
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.
|
@@ -532,6 +532,9 @@ function loadClaudeTranscript(sessionId) {
|
|
|
532
532
|
// re-drive, or a session the user resumed), so it's noise — we keep only a
|
|
533
533
|
// trailing one, where the session actually ended interrupted. See below.
|
|
534
534
|
const restartNoticeIdx = [];
|
|
535
|
+
// The latest user prompt, and the index of an API-error reply just kept.
|
|
536
|
+
let lastPrompt;
|
|
537
|
+
let lastErrorIdx = -1;
|
|
535
538
|
try {
|
|
536
539
|
for (const line of fs.readFileSync(file, "utf8").split(/\r?\n/)) {
|
|
537
540
|
if (!line.trim())
|
|
@@ -567,7 +570,21 @@ function loadClaudeTranscript(sessionId) {
|
|
|
567
570
|
continue;
|
|
568
571
|
if (typeof content !== "string" && !Array.isArray(content))
|
|
569
572
|
continue;
|
|
573
|
+
// A re-driven prompt: an API-error reply (e.g. a 401 before a credential
|
|
574
|
+
// refresh) followed — past any restart notice — by the same prompt again.
|
|
575
|
+
// The turn was recovered, so drop both; otherwise history shows the error and
|
|
576
|
+
// repeats the prompt at the bottom of the chat.
|
|
577
|
+
if (role === "user" && lastErrorIdx >= 0 && JSON.stringify(content) === JSON.stringify(lastPrompt)) {
|
|
578
|
+
messages.splice(lastErrorIdx, 1);
|
|
579
|
+
restartNoticeIdx.forEach((idx, i) => { if (idx > lastErrorIdx)
|
|
580
|
+
restartNoticeIdx[i] = idx - 1; });
|
|
581
|
+
lastErrorIdx = -1;
|
|
582
|
+
continue;
|
|
583
|
+
}
|
|
584
|
+
if (role === "user" && !(Array.isArray(content) && content.some((block) => block?.type === "tool_result")))
|
|
585
|
+
lastPrompt = content;
|
|
570
586
|
messages.push({ role, content, timestamp: new Date(entry?.timestamp ?? entry?.createdAt ?? Date.now()).getTime() });
|
|
587
|
+
lastErrorIdx = entry?.isApiErrorMessage === true ? messages.length - 1 : -1;
|
|
571
588
|
}
|
|
572
589
|
}
|
|
573
590
|
catch {
|
package/package.json
CHANGED