@danypops/papyrus 0.27.3 → 0.27.5
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.
|
@@ -35,6 +35,27 @@ import {
|
|
|
35
35
|
wrapTextWithAnsi,
|
|
36
36
|
} from "@earendil-works/pi-tui";
|
|
37
37
|
import { renderSingleSelectRows, type AskOption } from "./discuss-ask-layout.ts";
|
|
38
|
+
import { callService } from "./service-client.ts";
|
|
39
|
+
|
|
40
|
+
/** Temporary RCA instrumentation for the live-observed duplicate-picker defect. Fire-and-forget: never lets a logging failure affect the actual ask. Remove once root-caused. */
|
|
41
|
+
const DIAG_SOURCE = "papyrus-discuss-ask-diag";
|
|
42
|
+
let diagSequence = 0;
|
|
43
|
+
function diag(message: string, fields?: Record<string, unknown>): void {
|
|
44
|
+
void callService("logs.append", {
|
|
45
|
+
source_id: DIAG_SOURCE,
|
|
46
|
+
source_label: "Discuss live-ask RCA",
|
|
47
|
+
level: "info",
|
|
48
|
+
message,
|
|
49
|
+
operation_id: `diag-${Date.now()}-${++diagSequence}`,
|
|
50
|
+
...(fields ? { fields } : {}),
|
|
51
|
+
}).catch((error) => {
|
|
52
|
+
void callService("logs.append", {
|
|
53
|
+
source_id: DIAG_SOURCE, source_label: "Discuss live-ask RCA", level: "error",
|
|
54
|
+
message: `diag() itself failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
55
|
+
operation_id: `diag-error-${Date.now()}-${++diagSequence}`,
|
|
56
|
+
}).catch(() => {});
|
|
57
|
+
});
|
|
58
|
+
}
|
|
38
59
|
|
|
39
60
|
/** See pi-ask-user's identical safeMarkdownTheme() comment: a broken theme Proxy throws only on
|
|
40
61
|
* property access, not construction, so a bare try/catch around getMarkdownTheme() alone would
|
|
@@ -1066,7 +1087,9 @@ async function askViaDialogs(
|
|
|
1066
1087
|
|
|
1067
1088
|
const selectOptions = options.map((o) => o.title);
|
|
1068
1089
|
if (allowFreeform) selectOptions.push(FREEFORM_SENTINEL);
|
|
1090
|
+
diag("askViaDialogs: calling ui.select", { dialogOpts: dialogOpts === undefined ? null : JSON.stringify(dialogOpts), promptPreview: prompt.slice(0, 80) });
|
|
1069
1091
|
const selected = (await ui.select(prompt, selectOptions, dialogOpts)) as string | undefined;
|
|
1092
|
+
diag("askViaDialogs: ui.select resolved", { selected: selected ?? null });
|
|
1070
1093
|
if (isCancelledInput(selected)) return null;
|
|
1071
1094
|
|
|
1072
1095
|
if (selected === FREEFORM_SENTINEL) {
|
|
@@ -1114,10 +1137,11 @@ const pendingByKey = new Map<string, Promise<AskAnswer | undefined>>();
|
|
|
1114
1137
|
* contexts all resolve to undefined.
|
|
1115
1138
|
*/
|
|
1116
1139
|
export async function askQuestion(ctx: ExtensionContext, params: AskQuestionParams): Promise<AskAnswer | undefined> {
|
|
1140
|
+
diag("askQuestion() called", { question: params.question, key: params.key, hasUI: ctx.hasUI, mode: ctx.mode, optionCount: params.options?.length ?? 0, alreadyPendingForKey: params.key !== undefined && pendingByKey.has(params.key) });
|
|
1117
1141
|
if (!ctx.hasUI || !ctx.ui) return undefined;
|
|
1118
1142
|
if (params.key !== undefined) {
|
|
1119
1143
|
const existing = pendingByKey.get(params.key);
|
|
1120
|
-
if (existing) return existing;
|
|
1144
|
+
if (existing) { diag("joining an already in-flight ask for this key", { key: params.key }); return existing; }
|
|
1121
1145
|
}
|
|
1122
1146
|
const promise = askQuestionUnguarded(ctx, params);
|
|
1123
1147
|
if (params.key !== undefined) {
|
|
@@ -1193,8 +1217,12 @@ async function askQuestionBlocking(
|
|
|
1193
1217
|
});
|
|
1194
1218
|
}
|
|
1195
1219
|
|
|
1220
|
+
diag("calling ctx.ui.custom()", { displayMode });
|
|
1196
1221
|
const customResult = await ctx.ui.custom<AskResponse | null>(factory, buildCustomUIOptions(displayMode, (handle) => { overlayHandle = handle; }));
|
|
1222
|
+
diag("ctx.ui.custom() resolved", { wasUndefined: customResult === undefined, result: customResult === undefined ? undefined : JSON.stringify(customResult) });
|
|
1223
|
+
if (customResult === undefined) diag("falling back to askViaDialogs -- about to call ctx.ui.select with dialogOpts", { explicitTimeout: params.timeout ?? null });
|
|
1197
1224
|
response = customResult !== undefined ? customResult : await askViaDialogs(ctx.ui, params.question, normalizedContext, options, allowMultiple, allowFreeform, allowComment, params.timeout);
|
|
1225
|
+
diag("askQuestionBlocking resolved", { response: response === null ? null : JSON.stringify(response) });
|
|
1198
1226
|
} finally {
|
|
1199
1227
|
removeOverlayInputListener?.();
|
|
1200
1228
|
}
|
package/package.json
CHANGED