@narumitw/pi-goal 0.1.37 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/goal.ts +19 -3
package/package.json
CHANGED
package/src/goal.ts
CHANGED
|
@@ -154,6 +154,7 @@ export default function goal(pi: ExtensionAPI) {
|
|
|
154
154
|
});
|
|
155
155
|
|
|
156
156
|
pi.on("session_start", (_event, ctx) => {
|
|
157
|
+
clearCompletionStatusTimer();
|
|
157
158
|
clearContinuationTracking();
|
|
158
159
|
activeGoal = loadGoalFromSession(ctx);
|
|
159
160
|
if (activeGoal) updateStatus(ctx, activeGoal);
|
|
@@ -164,7 +165,7 @@ export default function goal(pi: ExtensionAPI) {
|
|
|
164
165
|
if (activeGoal) persistGoal(activeGoal);
|
|
165
166
|
clearContinuationTracking();
|
|
166
167
|
ctx.ui.setStatus(STATUS_KEY, undefined);
|
|
167
|
-
|
|
168
|
+
clearCompletionStatusTimer();
|
|
168
169
|
});
|
|
169
170
|
|
|
170
171
|
pi.on("input", (event) => {
|
|
@@ -520,6 +521,7 @@ async function sendPrompt(pi: ExtensionAPI, ctx: StatusContext, prompt: string)
|
|
|
520
521
|
}
|
|
521
522
|
|
|
522
523
|
function updateStatus(ctx: StatusContext, goal: ActiveGoal) {
|
|
524
|
+
clearCompletionStatusTimer();
|
|
523
525
|
ctx.ui.setStatus(STATUS_KEY, formatStatus(goal));
|
|
524
526
|
}
|
|
525
527
|
|
|
@@ -728,9 +730,23 @@ function clearActiveGoal(ctx: StatusContext) {
|
|
|
728
730
|
}
|
|
729
731
|
|
|
730
732
|
function showCompletionStatus(ctx: StatusContext) {
|
|
731
|
-
|
|
733
|
+
clearCompletionStatusTimer();
|
|
732
734
|
ctx.ui.setStatus(STATUS_KEY, "🎯 complete");
|
|
733
|
-
completionStatusTimer = setTimeout(() =>
|
|
735
|
+
completionStatusTimer = setTimeout(() => {
|
|
736
|
+
completionStatusTimer = undefined;
|
|
737
|
+
try {
|
|
738
|
+
ctx.ui.setStatus(STATUS_KEY, undefined);
|
|
739
|
+
} catch {
|
|
740
|
+
// The completion status is best-effort; the captured ctx may be stale after
|
|
741
|
+
// session replacement or reload before this timer fires.
|
|
742
|
+
}
|
|
743
|
+
}, 8_000);
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
function clearCompletionStatusTimer() {
|
|
747
|
+
if (!completionStatusTimer) return;
|
|
748
|
+
clearTimeout(completionStatusTimer);
|
|
749
|
+
completionStatusTimer = undefined;
|
|
734
750
|
}
|
|
735
751
|
|
|
736
752
|
function readState(): Record<string, unknown> {
|