feat(composer): configurable prompt enhancement with a substantive default prompt - #601
Merged
Merged
Conversation
The old prompt asked for a "clearer, more concise" draft and returned it with
"at most minor polish" when it looked fine, which made the action read as inert
and left the rewrite weak. Replace it with the structure mature coding
assistants use for the same job: role, analysis, rewrite principles, an explicit
do-not list, language-following rules, a length brake, and an output contract.
Two constraints the old text lacked are now explicit. Code, commands, file
paths, identifiers, API names, and other proper nouns are reproduced exactly, so
a rewrite cannot corrupt a draft's technical content. The answer carries no
language meta note such as "The draft is in Chinese".
The user side becomes a template: the draft is injected at a {{draft}}
placeholder inside <draft> tags, with few-shot examples for Chinese, English,
mixed-language input, and the meta-note failure mode. Substitution uses
split/join, so a draft containing $&, $', $` or $1 is inserted literally instead
of expanding as a String.replace pattern, and every occurrence is replaced. One
matching pair of wrapping quotation marks is stripped from the answer.
The defaults live in @pi-desktop/shared so the runtime, the settings UI, and the
restore-default action read one copy; the runtime keeps its existing export
names.
…onfigurable Issue #562 asks for a way to customize the prompt behind the Composer's Enhance prompt action. Three surfaces change, each next to the thing it configures. The prompt card on AI settings carries a switch, `Use a custom template`, and the settings icon button the subagent rows use for editing, which opens an editor sheet. The sheet holds only the user template and saves on Save, so closing it abandons the edit. The switch is the gate, not the text: it is disabled until a usable template exists, turning on when one is saved, and turning it off keeps the stored text so turning it back on restores it. Editing the field back to the exact built-in default clears the override rather than storing a frozen copy, so a later improvement to the default still reaches users who never customized it. An insert action writes the draft variable at the caret, and a save that would leave the template without it is refused locally. host-core enforces the same rules for any writer: a non-blank user template must contain {{draft}}, each value is bounded by PROMPT_ENHANCEMENT_TEMPLATE_MAX_LENGTH, a blank value is stored as absent rather than as an empty string, and a stored system-prompt override is dropped. The system prompt stays built in because it carries the contract the spec and E2E scenario assert; a stored override could silently remove a rule. The enhancement model and its reasoning effort get their own card on the Model configuration page, because both are model decisions and the model picker needs a title and a current value rather than a bare control. The model row reuses the default-model row's anchored, searchable menu, so the page shows one kind of picker. An unresolvable pin falls back to the Composer's current model with a warning: a stale pin must not disable the action. The reasoning row lists the levels the selected model actually supports, resolved exactly as a turn resolves them (binding thinkingLevels, then the live catalog, then the provider default), is disabled when the model supports none, defaults to off, and offers no follow-the-session entry. Changing model re-clamps and rewrites the stored level, so a persisted level is always runnable. One request is now bounded by a 60-second ceiling. The transport only consults its abort signal between provider retries, so aborting alone cannot release a stalled call; the handler races the promise to guarantee the caller is freed, and reports TIMEOUT with the budget rather than retrying on another model, which would double the wait. The prompt/enhance payload, process boundaries, and storage ownership are unchanged. The eight shipped catalogs carry the new copy, and settings search indexes the new rows.
Revise ADR 0121 rather than adding a second ADR: the one-shot, main-owned decision stands, so only the prompt shape, the settings surfaces, and the model pin change. Record the rejected alternatives, including letting the user override the system prompt (it would let a stored value silently violate a contract the spec and E2E scenario assert), storing the default text as the user's value (a later improvement to the default would then never reach those users), and failing when a pinned model is unresolvable (a stale pin would disable the action long after the user forgot the choice). Add D447 for the default-value decisions: the substantive-rewrite orientation, the proper-noun and no-meta-note rules, the switch semantics, the model page split, and the model-aware reasoning ladder. Update the UX spec (request boundary, and the user template, model, and reasoning sections) with its zh-CN mirror, plus the settings IA and data-storage specs and their mirrors. Extend E2E-218 and add E2E-259 for the switch, sheet, restore, validation, timeout, language, proper-noun, and quote-stripping contract, and refresh the traceability matrix.
Review of PR #586: abort the in-flight one-shot on the 60s ceiling so retries cannot keep burning tokens, drop the hard 800-character rewrite limit, stop few-shot labels from leaking into the Composer, keep a stale pin visible, and restore the zh-CN Voice settings-IA bullet.
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lands #586 (panda-z519) onto current main, plus review follow-ups.
From #586
Configurable Composer Enhance prompt: custom user template, enhancement model/reasoning on Settings → Models, 60s request bound, rewritten default prompt.
Review follow-ups
Enhanced:labels leaking into the ComposerDoes not close #562 (plugin UI hook for the enhance button is still open).