pi-ext
bugabingas pi extensions
owned by bugabinga
fix(the-system): make doctor notification transient
f5256df044e839c8b4508e215f02de2e867194c4
Oliver Jan Krylow <oliver@bugabinga.net> ·
SSH signature · not checked
Browse filesCompare with HEAD
Changed files (2)
extensions/the-system/__tests__/the-system.test.ts
Modified692 692 validSystem(project);
693 693 const command
= createSystemCommand({
sendUserMessage() {} }
as never);
694 694 const notices
: string[]
= [];
695 + const severities
: string[]
= [];
697 701 waitForIdle:
async ()
=> {},
698 - ui: {
notify: (message
: string)
=> notices.
push(message) },
703 + confirm:
async ()
=> {
707 + notify: (message
: string, severity
: string)
=> {
708 + notices.
push(message);
709 + severities.
push(severity);
700 716 await command.
handler(
"doctor", ctx);
701 717 await command.
handler(
"view PX-SPEC-SPEC0001", ctx);
703 719 await command.
handler(
"view PX-SPEC-SPEC0001 extra", ctx);
704 720 await command.
handler(
"edit PX-SPEC-SPEC0001 extra", ctx);
705 721 assert.
match(notices[
0]
?? "",
/OK/);
722 + assert.
equal(severities[
0],
"info");
723 + assert.
equal(prompts,
0);
724 + assert.
equal(widgets,
0);
706 725 assert.
match(notices[
1]
?? "",
/System view written:/);
707 726 assert.
match(notices[
1]
?? "",
/Open: file:\/\//);
708 727 assert.
match(notices[
2]
?? "",
/System book written:/);
extensions/the-system/system-command.ts
Modified114 114 if (parsed.subcommand
=== "doctor") {
115 115 const result
= runDoctor(ctx.cwd);
116 - await showCommandResult(
118 117 formatDoctor(result),
119 118 result.exitCode
=== 0 ? "info" : "warning",
167 -async function showCommandResult(
168 - ctx
: ExtensionCommandContext,
170 - severity
: "info" | "warning" | "error",
172 - await new Promise((resolve)
=> setTimeout(resolve,
0));
173 - if (ctx.hasUI)
await ctx.ui.
confirm(
"System doctor", message);
174 - else ctx.ui.
notify(message, severity);
175 - ctx.ui.
setWidget?.(
"the-system", message.
split(
"\n"));
178 166 async function runSystemInit(
179 167 pi
: ExtensionAPI,
180 168 activateBundleMigration
: (()
=> void)
| undefined,