refactor(frontend): extract useQuickTemplates from TerminalView.vue - #326
Merged
Conversation
Second slice of milestone 5-b. Templates state (list + hidden flag +
pending-confirm) and every function that manipulates them
(sendTemplate, requestTemplateSend, confirmTemplateSend, cancelTemplateSend,
onTemplateHotkey, onTemplateBarWheel) plus the parseHotkey/hotkeyMatches
internals were interleaved with the rest of TerminalView.vue's setup.
Move to composables/useQuickTemplates.ts. The composable takes:
{ send, confirmRequired, focused, templatesBridge }
where `send` is the closure that wraps `conn?.sendInput` so the
composable stays session-transport agnostic — critical because that's
where the two-writes-per-template split lives.
⚠️ HARD CONSTRAINT preserved inline in sendTemplate:
send(tpl.text);
window.setTimeout(() => send("\r"), 16);
This must NOT be "simplified" into a single sendInput call — Codex and
other raw-mode TUIs treat bundled "text\r" as a paste (the CR becomes a
literal newline in the prompt instead of submitting). Regressed twice
before: fixed in #63, deleted in #110, re-fixed in #129. Documented in
memory as [[feedback_template_send_split_cr]].
TerminalView side:
- Drop templates / templatesHidden / pendingTemplateConfirm refs (moved).
- Drop templateConfirmOpen computed (composable exports it).
- Drop templateConfirmRequired computed (passed in as confirmRequired arg).
- Drop sendTemplate / requestTemplateSend / cancelTemplateSend /
confirmTemplateSend / onTemplateHotkey / onTemplateBarWheel functions.
- Drop parseHotkey + hotkeyMatches helpers (private to composable now).
- Drop effectiveTemplates import (consumed by composable).
- Add useQuickTemplates destructure + composable import.
- reloadShortcutBars simplifies: delegates templates to
reloadQuickTemplates() and reloads aux keys inline (aux keys stay
here until M5-b-5 extracts TerminalAuxKeyBar).
Test update: two source-scan tests in TerminalView.test.ts that pinned
the exact old inline structure now also scan
useQuickTemplates.ts?raw for the moved parts. Regex tweaked to match
the composable's 2-space-indented nested-function closing braces.
Net: TerminalView.vue -110 / +21 (net -89, 2724 → 2635); new composable
+181. `npm test` 1631/1631; `npm run build` green.
attson
force-pushed
the
refactor/extract-quick-templates
branch
from
August 4, 2026 15:15
1dd20dd to
b9e33d6
Compare
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.
Summary
Second slice of milestone 5-b. Templates state (list + hidden flag + pending-confirm) and every function that manipulates them (`sendTemplate`, `requestTemplateSend`, `confirmTemplateSend`, `cancelTemplateSend`, `onTemplateHotkey`, `onTemplateBarWheel`) plus the `parseHotkey`/`hotkeyMatches` internals were interleaved with the rest of TerminalView.vue's setup.
Move to `composables/useQuickTemplates.ts`. The composable takes:
```ts
{ send, confirmRequired, focused, templatesBridge }
```
where `send` is the closure that wraps `conn?.sendInput` so the composable stays session-transport agnostic — critical because that's where the two-writes-per-template split lives.
```ts
send(tpl.text);
window.setTimeout(() => send("\r"), 16);
```
This must NOT be "simplified" into a single `sendInput` call — Codex and other raw-mode TUIs treat bundled `"text\r"` as a paste (the CR becomes a literal newline in the prompt instead of submitting). Regressed twice before: fixed in #63, deleted in #110, re-fixed in #129. Documented in memory as `[[feedback_template_send_split_cr]]`.
TerminalView side
Test update
Two source-scan tests in `TerminalView.test.ts` that pinned the exact old inline structure now also scan `useQuickTemplates.ts?raw` for the moved parts. Regex tweaked to match the composable's 2-space-indented nested-function closing braces.
Net: TerminalView.vue -110 / +21 (net -89, 2724 → 2635); new composable +181.
Test plan