mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-12-03 00:09:19 -08:00
Quiet the Tidy up banner once a tidy-up finds nothing
AI Assisted
This commit is contained in:
1 parent
634e4df10e
commit
ee530d36c0
9 files changed
+148
-8
No files matched your search
@@ -16,6 +16,7 @@ import {
|
||||
} from "../selectors.js";
|
||||
import { whenTitle, whenWords } from "../labels.js";
|
||||
import { hooks, page, redraw, saveNow } from "../state.js";
|
||||
import { postJson } from "../net.js";
|
||||
import { el, approvalTip, mdInto, releasesLink, copyButton, lightDismiss, icon, SVG_NS } from "../render.js";
|
||||
import { needsRoleNudge, ROLE_NOT_SET } from "../starters.js";
|
||||
import { looks, saveLooks } from "../looks.js";
|
||||
@@ -1483,6 +1484,15 @@ function learningBanner(sc) {
|
||||
if (why) b.title = why;
|
||||
b.addEventListener("click", () => sendLearning(what));
|
||||
r.appendChild(b);
|
||||
if (what === "tidy") {
|
||||
// Not now needs no agent: the server remembers it, on this machine only,
|
||||
// and the nudge stays hidden until the saved lessons change.
|
||||
const later = el("button", "btn sm", "Not now");
|
||||
later.type = "button";
|
||||
later.title = "Hide this until your lessons change.";
|
||||
later.addEventListener("click", () => quietTidyNudge());
|
||||
r.appendChild(later);
|
||||
}
|
||||
banner.appendChild(r);
|
||||
};
|
||||
if (text) row(text, "Review", "review", true);
|
||||
@@ -1490,6 +1500,17 @@ function learningBanner(sc) {
|
||||
return banner;
|
||||
}
|
||||
|
||||
// Hide the tidy-up nudge until the saved lessons change (POST /learning/tidy-quiet;
|
||||
// the server pushes the patched scan, so the banner redraws without it). Used by
|
||||
// Not now and by a Tidy up that came back with nothing to propose. A failure is
|
||||
// quiet: the nudge simply stays, as it did before.
|
||||
async function quietTidyNudge() {
|
||||
try {
|
||||
await postJson("/learning/tidy-quiet", {});
|
||||
} catch {}
|
||||
redraw();
|
||||
}
|
||||
|
||||
// The agent finishing with nothing to show ends the wait early: a Review whose
|
||||
// card never came (the banner was stale) says so at once instead of spinning
|
||||
// to the limit, and a saved choice stops when the agent is back to waiting.
|
||||
@@ -1514,6 +1535,9 @@ function watchLearningBusy(busy) {
|
||||
clearInterval(timer);
|
||||
page.learningBusy = null;
|
||||
if (busy.what === "review" || busy.what === "tidy") {
|
||||
// A tidy-up with nothing to propose is an answer: remember it, so the
|
||||
// nudge does not come straight back for the same lessons.
|
||||
if (busy.what === "tidy") quietTidyNudge();
|
||||
const none = hooks.banner(busy.what === "tidy" ? "Nothing to tidy up right now." : "No lessons are waiting any more.", "info");
|
||||
setTimeout(() => hooks.clearBanner(none), 4000);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user