refactor(app): isolate local command dispatch - #111
Merged
Conversation
dcavalcante
force-pushed
the
refactor/local-command-dispatch
branch
from
August 13, 2026 22:44
9ebba94 to
896bf87
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the internal/app execution path by extracting local (client-side) command lookup/dispatch out of app.go into a dedicated local_commands.go, keeping execute focused on routing input to local commands vs meta-commands vs SQL execution.
Changes:
- Moved the local command registry (currently
\clear) intointernal/app/local_commands.go. - Added
(*pgxCLI).runLocal(query)as the single entry point for exact-match local command dispatch. - Added regression tests to confirm exact-match behavior for
\clearand non-matching variants.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/app/local_commands.go | Introduces the local command registry and runLocal dispatch method. |
| internal/app/local_commands_test.go | Adds tests to ensure runLocal matches \clear exactly and rejects similar inputs. |
| internal/app/app.go | Switches local command execution to use p.runLocal(query) and preserves prompt-wrapping behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Owner
|
Looks great, thanks for working on this! |
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
This separates client-side command dispatch from the main execution path.
Previously,
app.gocontained both the local command registry and its lookup logic. This change moves those responsibilities intolocal_commands.go, leavingexecutefocused on deciding whether an input should be handled locally or passed to the existing meta-command and SQL execution paths.The existing
\clearcommand is used to establish this boundary. Its handler, logging, prompt handling, and exact-match behavior remain unchanged.Changes
app.gorunLocalas the local command lookup and dispatch entry point\cleardispatch and exact command matchingBehavior
This is a structural refactor with no intended user-facing changes.
Testing
go test ./...go vet ./...golangci-lint run