Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

refactor(settings): redesign prompt-enhancement editor to ext-sheet system

vastsa93d16ec343d0
diff --git a/apps/desktop/src/features/settings/prompt-enhancement-card.tsx b/apps/desktop/src/features/settings/prompt-enhancement-card.tsx
index f0d7f68e2..f4426a611 100644
--- a/apps/desktop/src/features/settings/prompt-enhancement-card.tsx
+++ b/apps/desktop/src/features/settings/prompt-enhancement-card.tsx
@@ -80,8 +80,12 @@ export function PromptEnhancementCard({
}
/**
- * The editor itself. Drafts are local until Save, so closing the sheet abandons
- * the edit — the same contract as the subagent editor.
+ * The editor itself. Drafts are local until Save, so closing the sheet
+ * abandons the edit — the same contract as the subagent editor.
+ *
+ * Layout follows the ext-sheet design system: head / body / error / actions.
+ * Insert Draft and Restore Default are left-side utility buttons in the
+ * actions footer, matching SubagentEditorSheet's pattern.
*/
function PromptEnhancementEditorSheet({
settings,
@@ -111,8 +115,6 @@ function PromptEnhancementEditorSheet({
useEffect(() => {
const onKeyDown = (event: KeyboardEvent) => {
- // Escape closes only when nothing is in flight, so a save cannot be
- // abandoned halfway through.
if (event.key === "Escape" && !saving) onClose();
};
window.addEventListener("keydown", onKeyDown);
@@ -146,15 +148,12 @@ function PromptEnhancementEditorSheet({
setSaving(true);
setSaveError(false);
try {
- // The default text is never persisted, so a later change to the default
- // still reaches a user who left the field at its default value.
const savedTemplateValue =
templateDraft === PROMPT_ENHANCEMENT_DEFAULT_USER_TEMPLATE
? ""
: templateDraft;
await saveSettings({
promptEnhancementUserTemplate: savedTemplateValue,
- // A saved non-empty template is active; restoring default deactivates.
promptEnhancementCustomTemplate: Boolean(savedTemplateValue.trim()),
});
onClose();
@@ -165,6 +164,15 @@ function PromptEnhancementEditorSheet({
}
};
+ const hasValidationError = templateMissingVariable || templateTooLong;
+ const errorMessage = templateMissingVariable
+ ? t("settings.promptEnhancementMissingDraftVariable")
+ : templateTooLong
+ ? t("settings.promptEnhancementTooLong")
+ : saveError
+ ? t("settings.promptEnhancementSaveError")
+ : null;
+
return portalOverlay(
<div
className="overlay ext-sheet-overlay"
@@ -184,7 +192,9 @@ function PromptEnhancementEditorSheet({
<h3 id="prompt-enhancement-sheet-title" className="ext-sheet-title">
{t("settings.promptEnhancementTitle")}
</h3>
- <div className="ext-sheet-sub">{t("settings.promptEnhancementDesc")}</div>
+ <div className="ext-sheet-sub">
+ {t("settings.promptEnhancementDesc")}
+ </div>
</div>
<TooltipButton
type="button"
@@ -205,50 +215,34 @@ function PromptEnhancementEditorSheet({
label={t("settings.promptEnhancementUserTemplate")}
hint={t("settings.promptEnhancementUserTemplateDesc")}
>
- {/* A plain textarea: the shared Textarea wrapper does not forward a
- ref, and the insert action needs one to place the caret. */}
<textarea
ref={templateRef}
className="field-textarea ext-skill-body"
value={templateDraft}
- rows={8}
+ rows={10}
onChange={(event) => setTemplateDraft(event.target.value)}
aria-label={t("settings.promptEnhancementUserTemplate")}
- aria-invalid={templateMissingVariable || templateTooLong}
+ aria-invalid={hasValidationError}
spellCheck={false}
autoCorrect="off"
autoCapitalize="off"
/>
</Field>
-
- {templateMissingVariable ? (
- <span className="settings-command-shell-state error" role="status">
- {t("settings.promptEnhancementMissingDraftVariable")}
- </span>
- ) : null}
- {templateTooLong ? (
- <span className="settings-command-shell-state error" role="status">
- {t("settings.promptEnhancementTooLong")}
- </span>
- ) : null}
-
- <div className="settings-panel-actions">
- <Button variant="secondary" type="button" onClick={insertDraftVariable}>
- {t("settings.promptEnhancementInsertDraft")}
- </Button>
- <Button variant="secondary" type="button" onClick={restoreTemplateDefault}>
- {t("settings.promptEnhancementRestore")}
- </Button>
- </div>
-
- {saveError ? (
- <span className="settings-command-shell-state error" role="status">
- {t("settings.promptEnhancementSaveError")}
- </span>
- ) : null}
</div>
+ {errorMessage ? (
+ <p className="ext-sheet-error" role="alert">
+ {errorMessage}
+ </p>
+ ) : null}
+
<div className="ext-sheet-actions">
+ <Button variant="ghost" type="button" onClick={insertDraftVariable}>
+ {t("settings.promptEnhancementInsertDraft")}
+ </Button>
+ <Button variant="ghost" type="button" onClick={restoreTemplateDefault}>
+ {t("settings.promptEnhancementRestore")}
+ </Button>
<div className="ext-sheet-actions-end">
<Button variant="ghost" type="button" disabled={saving} onClick={onClose}>
{t("common.cancel")}
@@ -256,7 +250,7 @@ function PromptEnhancementEditorSheet({
<Button
variant="primary"
type="button"
- disabled={!dirty || saving || templateMissingVariable || templateTooLong}
+ disabled={!dirty || saving || hasValidationError}
onClick={() => void save()}
>
{saving ? t("common.saving") : t("common.save")}