refactor(desktop): extract use-prompt-actions standalone helpers into utils - #55459
Merged
Conversation
… utils The usePromptActions hook is the textbook "god hook" AGENTS.md warns against. As a first, safe slice, pull its module-level standalone helpers (no closure over hook state) into a focused, testable use-prompt-actions-utils.ts sibling: - error classifiers: isSessionNotFoundError, isSessionBusyError, isProviderSetupError, inlineErrorMessage - session-busy retry: withSessionBusyRetry (+ its constants) - attachment IO: base64FromDataUrl, imageFilenameFromPath, readImageForRemoteAttach, readFileDataUrlForAttach, friendlyRemoteAttachError - misc: delay, isSessionIdCandidate, blobToDataUrl, renderCommandsCatalog, slashStatusText, appendText, visibleUserOrdinal, visibleUserIndexAtOrdinal, the _submitInFlight guard set, and the GatewayRequest type Pure restructuring, no behavior change; the usePromptActions and uploadComposerAttachment exports (and their import paths) are unchanged. Adds unit tests for the pure helpers. use-prompt-actions.ts: 1,956 -> 1,772.
tonydwb
reviewed
Jun 30, 2026
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary\n\nVerdict: LGTM\n\nClean god-file split — use-prompt-actions.ts reduced from 1,956 to 1,772 lines by extracting standalone helpers into use-prompt-actions-utils.ts. Pure restructuring with no behavior change. Tests pass (51 unit tests). Well-scoped 3-file change with clear module boundaries.\n\n### Looks Good\n- Verbatim move of standalone helpers with no logic changes\n- New test file covers the extracted functions\n- TypeCheck and ESLint clean\n---\nReviewed by Hermes Agent
tonydwb
reviewed
Jun 30, 2026
tonydwb
left a comment
There was a problem hiding this comment.
Code Review: LGTM
Clean extraction of prompt-action utility functions into a dedicated use-prompt-actions-utils.ts module. All exported functions have unit tests covering edge cases (session ID candidates, error message parsing, data URL extraction, image filename extraction, etc.). The parent hook imports from the new module without behavioral change.
Verdict: LGTM -- well-tested god-file reduction.
4 tasks
waefrebeorn
pushed a commit
to waefrebeorn/slermes
that referenced
this pull request
Jul 2, 2026
…lit-prompt-actions refactor(desktop): extract use-prompt-actions standalone helpers into utils
habarmc1223-sudo
pushed a commit
to habarmc1223-sudo/hermes-agent-fluxmem
that referenced
this pull request
Jul 8, 2026
…lit-prompt-actions refactor(desktop): extract use-prompt-actions standalone helpers into utils
santhreal
pushed a commit
to santhreal/hermes-agent
that referenced
this pull request
Jul 13, 2026
…lit-prompt-actions refactor(desktop): extract use-prompt-actions standalone helpers into utils
Gravezzz
pushed a commit
to Gravezzz/hermes-agent
that referenced
this pull request
Jul 21, 2026
…lit-prompt-actions refactor(desktop): extract use-prompt-actions standalone helpers into utils
leewenjie
pushed a commit
to leewenjie/hermes-agent
that referenced
this pull request
Aug 7, 2026
…lit-prompt-actions refactor(desktop): extract use-prompt-actions standalone helpers into utils
melon-xf
added a commit
to melon-xf/hermes-agent
that referenced
this pull request
Sep 3, 2026
…lit-prompt-actions refactor(desktop): extract use-prompt-actions standalone helpers into utils
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
Fifth in the
apps/desktopgod-file split series.usePromptActionsis the textbook "god hook" AGENTS.md's TS guidance warns against. As a first, safe slice, this pulls the hook's module-level standalone helpers (no closure over hook state) into a focused, testableuse-prompt-actions-utils.tssibling.use-prompt-actions.ts: 1,956 → 1,772 lines.Moved into
use-prompt-actions-utils.tsisSessionNotFoundError,isSessionBusyError,isProviderSetupError,inlineErrorMessagewithSessionBusyRetry(+SESSION_BUSY_RETRY_*constants)base64FromDataUrl,imageFilenameFromPath,readImageForRemoteAttach,readFileDataUrlForAttach,friendlyRemoteAttachErrordelay,isSessionIdCandidate,blobToDataUrl,renderCommandsCatalog,slashStatusText,appendText,visibleUserOrdinal,visibleUserIndexAtOrdinal, the_submitInFlightguard set, and theGatewayRequesttypeNotes
usePromptActionsanduploadComposerAttachmentexports (and their import paths inthread.tsx/desktop-controller.tsx/ the test) are unchanged.Test plan
npm run typecheck(desktop) — passeseslinton changed/added files — cleanvitest runforuse-prompt-actions-utils.test.ts+ the existinguse-prompt-actions.test.tsx— 51 pass/help,/model, …), remote attachment upload, message edit/restoreNote: a whole-tree
npm run lintreports 4 pre-existing errors in unrelated files onmain; none are touched here.