Skip to content

refactor(desktop): decompose use-prompt-actions (slash + submit sub-hooks) - #55504

Merged
OutThisLife merged 2 commits into
mainfrom
bb/desktop-split-prompt-body
Jun 30, 2026
Merged

refactor(desktop): decompose use-prompt-actions (slash + submit sub-hooks)#55504
OutThisLife merged 2 commits into
mainfrom
bb/desktop-split-prompt-body

Conversation

@OutThisLife

Copy link
Copy Markdown
Collaborator

Summary

God-hook split #3 of 3 — and the deepest. usePromptActions' standalone helpers already shipped (#55459) + foldered (#55493), so what remained was the stateful body. Its single biggest unit is executeSlashCommand: a ~530-line /command dispatcher (with a recursive inner runSlash).

This lifts it into a colocated useSlashCommand sub-hook (use-prompt-actions/slash.ts). The ~13 values it closed over become a typed SlashCommandDeps object the parent passes in; the dispatcher body (and its inner runSlash recursion + nested handlers) moves verbatim. The slash-only SlashActionCtx type moves with it.

index.ts: 1,772 → 1,212 lines (slash.ts is 614).

Notes

  • Pure restructuring — the dispatcher body is unchanged; only the closure surface is now an explicit deps object. tsc verifies every reference is threaded (a missing dep = a compile error).
  • Behavior-preserving, verified: the full use-prompt-actions test suite (51 tests) still passes, including the real usePromptActions hook test that drives slash commands.
  • usePromptActions keeps its other callbacks (submit/retry, attachment upload, restore/edit, steer, cancel) and now does const executeSlashCommand = useSlashCommand({ … }).

Test plan

  • npm run typecheck — 0 errors
  • eslint on the folder — clean
  • vitest run use-prompt-actions — 51 pass
  • Smoke: /help, /model, /skin, a skill command, an alias (e.g. recursive dispatch), /undo prefill, an exec command that renders inline output

…lash

The usePromptActions body's largest unit was executeSlashCommand — a ~530-line
`/command` dispatcher. Lift it into a colocated useSlashCommand sub-hook
(use-prompt-actions/slash.ts): the ~13 values it closed over become a typed
SlashCommandDeps object the parent passes in; the dispatcher body (and its inner
runSlash recursion) moves verbatim. SlashActionCtx (slash-only) moves with it.

Pure restructuring, no behaviour change (verified: full use-prompt-actions test
suite still green). index.ts: 1,772 -> ~1,250.
…bmit

After the slash dispatcher, the next-largest body unit was submitPromptText —
a ~280-line submit pipeline. Lift it into a colocated useSubmitPrompt sub-hook
(use-prompt-actions/submit.ts) with a typed SubmitPromptDeps object; body moves
verbatim. SubmitTextOptions moves to utils.ts (shared by submit + submitText).

Pure restructuring, no behaviour change (full use-prompt-actions suite green).
index.ts: 1,212 -> 937.
@OutThisLife OutThisLife changed the title refactor(desktop): extract slash dispatcher into use-prompt-actions/slash refactor(desktop): decompose use-prompt-actions (slash + submit sub-hooks) Jun 30, 2026
@OutThisLife

Copy link
Copy Markdown
Collaborator Author

Extended: also lifted the ~280-line submitPromptText pipeline into a useSubmitPrompt sub-hook (submit.ts); SubmitTextOptions moved to utils.ts. index.ts is now 1,772 → 937. typecheck/eslint clean; full 51-test suite green.

@OutThisLife
OutThisLife merged commit f9b619d into main Jun 30, 2026
20 checks passed
@OutThisLife
OutThisLife deleted the bb/desktop-split-prompt-body branch June 30, 2026 08:22
@alt-glitch alt-glitch added type/refactor Code restructuring, no behavior change comp/desktop Electron desktop app (apps/desktop/*) P3 Low — cosmetic, nice to have labels Jun 30, 2026
waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
…lit-prompt-body

refactor(desktop): decompose use-prompt-actions (slash + submit sub-hooks)
habarmc1223-sudo pushed a commit to habarmc1223-sudo/hermes-agent-fluxmem that referenced this pull request Jul 8, 2026
…lit-prompt-body

refactor(desktop): decompose use-prompt-actions (slash + submit sub-hooks)
santhreal pushed a commit to santhreal/hermes-agent that referenced this pull request Jul 13, 2026
…lit-prompt-body

refactor(desktop): decompose use-prompt-actions (slash + submit sub-hooks)
Gravezzz pushed a commit to Gravezzz/hermes-agent that referenced this pull request Jul 21, 2026
…lit-prompt-body

refactor(desktop): decompose use-prompt-actions (slash + submit sub-hooks)
leewenjie pushed a commit to leewenjie/hermes-agent that referenced this pull request Aug 7, 2026
…lit-prompt-body

refactor(desktop): decompose use-prompt-actions (slash + submit sub-hooks)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/desktop Electron desktop app (apps/desktop/*) P3 Low — cosmetic, nice to have type/refactor Code restructuring, no behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants