@danypops/papyrus 0.27.12 → 0.27.14
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.
|
@@ -658,7 +658,10 @@ class AskComponent extends Container {
|
|
|
658
658
|
this.addChild(new BoxBorderBottom((s) => theme.fg("accent", s)));
|
|
659
659
|
|
|
660
660
|
this.updateStaticText();
|
|
661
|
-
|
|
661
|
+
// A freeform-only ask (no options at all) has no select list to show -- start directly in
|
|
662
|
+
// the freeform editor instead of a select mode that would have nothing to render.
|
|
663
|
+
if (this.options.length === 0) this.showFreeformMode();
|
|
664
|
+
else this.showSelectMode();
|
|
662
665
|
}
|
|
663
666
|
|
|
664
667
|
override invalidate(): void { super.invalidate(); this.updateStaticText(); this.updateHelpText(); }
|
|
@@ -877,12 +880,13 @@ class AskComponent extends Container {
|
|
|
877
880
|
|
|
878
881
|
if (this.mode === "freeform" || this.mode === "comment") {
|
|
879
882
|
const alternateCancelKeys = this.keybindings.getKeys("tui.select.cancel").filter((key) => key !== "escape" && key !== "esc");
|
|
883
|
+
const canGoBack = this.options.length > 0;
|
|
880
884
|
const hints = [
|
|
881
885
|
keybindingHint(theme, this.keybindings, "tui.input.submit", this.mode === "comment" ? "submit/skip" : "submit"),
|
|
882
886
|
keybindingHint(theme, this.keybindings, "tui.input.newLine", "newline"),
|
|
883
|
-
literalHint(theme, "esc", "back"),
|
|
887
|
+
literalHint(theme, "esc", canGoBack ? "back" : "cancel"),
|
|
884
888
|
overlayHint,
|
|
885
|
-
alternateCancelKeys.length > 0 ? literalHint(theme, formatKeyList(alternateCancelKeys), "cancel") : null,
|
|
889
|
+
canGoBack && alternateCancelKeys.length > 0 ? literalHint(theme, formatKeyList(alternateCancelKeys), "cancel") : null,
|
|
886
890
|
].filter((hint): hint is string => !!hint).join(" • ");
|
|
887
891
|
this.helpText.setText(theme.fg("dim", hints));
|
|
888
892
|
return;
|
|
@@ -1031,7 +1035,8 @@ class AskComponent extends Container {
|
|
|
1031
1035
|
handleInput(data: string): void {
|
|
1032
1036
|
if (this.handlePromptScrollInput(data)) { this.tui.requestRender(); return; }
|
|
1033
1037
|
if (this.mode === "freeform" || this.mode === "comment") {
|
|
1034
|
-
|
|
1038
|
+
// A freeform-only ask has no select mode to go back to -- escape cancels outright.
|
|
1039
|
+
if (matchesKey(data, Key.escape)) { if (this.options.length > 0) this.showSelectMode(); else this.onDone(null); return; }
|
|
1035
1040
|
if (this.keybindings.matches(data, "tui.select.cancel")) { this.onDone(null); return; }
|
|
1036
1041
|
this.ensureEditor().handleInput(data);
|
|
1037
1042
|
this.tui.requestRender();
|
|
@@ -1057,6 +1062,11 @@ async function askViaDialogs(
|
|
|
1057
1062
|
const dialogOpts = timeout ? { timeout } : undefined;
|
|
1058
1063
|
const prompt = context ? `${question}\n\nContext:\n${context}` : question;
|
|
1059
1064
|
|
|
1065
|
+
if (options.length === 0) {
|
|
1066
|
+
const answer = (await ui.input(prompt, "Type your answer...", dialogOpts)) as string | undefined;
|
|
1067
|
+
return isCancelledInput(answer) ? null : createFreeformResponse(answer);
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1060
1070
|
if (allowMultiple) {
|
|
1061
1071
|
const rawSelections = (await ui.input(`${prompt}\n\nOptions (select one or more):\n${formatOptionsForMessage(options)}`, "Type your selection(s)...", dialogOpts)) as string | undefined;
|
|
1062
1072
|
if (isCancelledInput(rawSelections)) return null;
|
|
@@ -1139,13 +1149,9 @@ async function askQuestionBlocking(
|
|
|
1139
1149
|
displayMode: AskDisplayMode,
|
|
1140
1150
|
normalizedContext: string | undefined,
|
|
1141
1151
|
): Promise<AskAnswer | undefined> {
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
const response = createFreeformResponse(answer);
|
|
1146
|
-
return response ? toAskAnswer(response) : undefined;
|
|
1147
|
-
}
|
|
1148
|
-
|
|
1152
|
+
// A freeform-only ask (no options) still goes through the same rich AskComponent/ctx.ui.custom()
|
|
1153
|
+
// path below, not a bare ctx.ui.input() -- otherwise it renders as a plain, contextless single
|
|
1154
|
+
// line while every options-bearing ask gets the full bordered box, title, and markdown context.
|
|
1149
1155
|
const shortcuts: ResolvedAskShortcuts = {
|
|
1150
1156
|
overlayToggle: resolveShortcut(undefined, process.env["PAPYRUS_DISCUSS_OVERLAY_TOGGLE_KEY"], DEFAULT_OVERLAY_TOGGLE_KEY),
|
|
1151
1157
|
commentToggle: resolveShortcut(undefined, process.env["PAPYRUS_DISCUSS_COMMENT_TOGGLE_KEY"], DEFAULT_COMMENT_TOGGLE_KEY),
|
package/extension/src/discuss.ts
CHANGED
|
@@ -83,9 +83,13 @@ export async function showDiscussions(ctx: ExtensionCommandContext): Promise<voi
|
|
|
83
83
|
if (choice === "Reply") {
|
|
84
84
|
const pending = (() => { try { return readDiscussionExtra(discussion.extra); } catch { return undefined; } })();
|
|
85
85
|
const question = `Reply to "${discussion.title}":`;
|
|
86
|
+
// Same fix as the live discuss tool: the title alone isn't the actual question -- show
|
|
87
|
+
// the most recent round's real content as context, not a bare title prompt.
|
|
88
|
+
const transcript = await callService<Record<string, unknown>, DiscussionAndRounds>("discuss.show", { id: discussion.id });
|
|
89
|
+
const context = transcript.rounds.at(-1)?.content?.trim() || undefined;
|
|
86
90
|
const answer = pending?.pendingOptions && pending.pendingOptions.length > 0 && pending.pendingOptionsMode
|
|
87
|
-
? await askQuestion(commandCtx, { question, options: pending.pendingOptions.map((title) => ({ title })), allowMultiple: pending.pendingOptionsMode === "multi" })
|
|
88
|
-
: await askQuestion(commandCtx, { question });
|
|
91
|
+
? await askQuestion(commandCtx, { question, context, options: pending.pendingOptions.map((title) => ({ title })), allowMultiple: pending.pendingOptionsMode === "multi" })
|
|
92
|
+
: await askQuestion(commandCtx, { question, context });
|
|
89
93
|
if (!answer) return; // canceled
|
|
90
94
|
await callService("discuss.reply", { id: discussion.id, actor: ACTOR, content: answer.content, ...(answer.selected ? { selected: answer.selected } : {}), source: SOURCE });
|
|
91
95
|
commandCtx.ui.notify(answer.selected ? `Selected: ${answer.selected.join(", ")}` : "Reply added.", "info");
|
|
@@ -39,20 +39,25 @@ function text(message: string, details: unknown = {}) {
|
|
|
39
39
|
* is available, never throws -- an unanswered live prompt still leaves the round it already
|
|
40
40
|
* recorded intact.
|
|
41
41
|
*/
|
|
42
|
-
async function liveAnswer(ctx: ExtensionContext, discussion: Artifact, onUpdate: AgentToolUpdateCallback | undefined, signal: AbortSignal | undefined): Promise<{ content: string; selected?: string[] } | undefined> {
|
|
42
|
+
async function liveAnswer(ctx: ExtensionContext, discussion: Artifact, latestContent: string | undefined, onUpdate: AgentToolUpdateCallback | undefined, signal: AbortSignal | undefined): Promise<{ content: string; selected?: string[] } | undefined> {
|
|
43
43
|
if (!ctx.hasUI) return undefined;
|
|
44
44
|
const pending = (() => { try { return readDiscussionExtra(discussion.extra); } catch { return undefined; } })();
|
|
45
45
|
const question = `Reply to "${discussion.title}":`;
|
|
46
|
+
// The discussion's title alone is often not the actual question -- a human staring at a bare
|
|
47
|
+
// "Reply to '<title>':" prompt with no visible content has no way to tell what's being asked.
|
|
48
|
+
// The just-recorded round's own content is the real question text; show it as context.
|
|
49
|
+
const context = latestContent?.trim() || undefined;
|
|
46
50
|
if (pending?.pendingOptions && pending.pendingOptions.length > 0 && pending.pendingOptionsMode) {
|
|
47
51
|
return askQuestion(ctx, {
|
|
48
52
|
question,
|
|
53
|
+
context,
|
|
49
54
|
options: pending.pendingOptions.map((title) => ({ title })),
|
|
50
55
|
allowMultiple: pending.pendingOptionsMode === "multi",
|
|
51
56
|
onUpdate,
|
|
52
57
|
signal,
|
|
53
58
|
});
|
|
54
59
|
}
|
|
55
|
-
return askQuestion(ctx, { question, onUpdate, signal });
|
|
60
|
+
return askQuestion(ctx, { question, context, onUpdate, signal });
|
|
56
61
|
}
|
|
57
62
|
|
|
58
63
|
/**
|
|
@@ -722,7 +727,7 @@ export function registerDomainTools(pi: ExtensionAPI): void {
|
|
|
722
727
|
? text(`Opened discussion ${artifactLine(result.discussion)}`, createArtifactDetails("discuss.open", result.discussion))
|
|
723
728
|
: text(`Round ${result.rounds[0]?.roundNumber} added to "${result.discussion.title}"`, createArtifactDetails("discuss.reply", result.discussion));
|
|
724
729
|
if (params.live !== true) return fallback;
|
|
725
|
-
const answer = await liveAnswer(ctx, result.discussion, onUpdate, signal);
|
|
730
|
+
const answer = await liveAnswer(ctx, result.discussion, result.rounds[0]?.content, onUpdate, signal);
|
|
726
731
|
if (!answer) return fallback;
|
|
727
732
|
const answered = await callService<Record<string, unknown>, DiscussionAndRounds>("discuss.reply", {
|
|
728
733
|
id: result.discussion.id, actor: "human", content: answer.content, ...(answer.selected ? { selected: answer.selected } : {}), source: "discuss-live",
|
package/package.json
CHANGED