-
Notifications
You must be signed in to change notification settings - Fork 578
feat: Add support for transaction status indicator (\T) in prompt
#1553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for a transaction status indicator escape (\T) in the prompt, analogous to psql’s %x, so users can see transaction state directly in their prompt.
Changes:
- Introduces
PGExecute.transaction_indicator(andis_connection_closed) to derive a single-character transaction state marker (*,!,?, or empty). - Extends
PGCli.get_promptand the defaultpgclircconfiguration to support a new\Tprompt escape for transaction status. - Adds tests for
\Tprompt rendering and updatesAUTHORS.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
pgcli/pgexecute.py |
Adds is_connection_closed and the transaction_indicator property, reusing existing transaction status helpers to compute the * / ! / ? / empty marker. |
pgcli/main.py |
Extends get_prompt to replace \T with pgexecute.transaction_indicator, wiring the new indicator into prompt rendering. |
pgcli/pgclirc |
Documents the new \T prompt escape and its behavior alongside existing prompt placeholders. |
tests/test_main.py |
Adds tests covering \T in simple and full prompts; currently sets transaction_indicator via PropertyMock on MagicMock’s type, which mutates global MagicMock state. |
AUTHORS |
Adds a new contributor entry. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Use direct attribute assignment on MagicMock instead of type() to avoid polluting the global MagicMock class state.
|
I’m not sure why this test is failing. It doesn’t appear to be related to the changes in this patch. The same patch passes all CI checks on my fork (see: https://github.com/devadathanmb/pgcli/actions/runs/21539731264?pr=2) Could you please rerun the actions? |
Description
Adds support for displaying transaction status in the prompt via the
\Tescape sequence, similar to psql's%xBehavior:
*— inside a valid transaction block!— inside a failed transaction block?— connection is closed/indeterminateExample usage in
~/.config/pgcli/config:This produces prompts like (as shown in the attached screenshot below):
NOTE: Uses
\Tinstead of\xto avoid conflicts with ANSI escape sequences (\x1b) processing done in the codebase.Closes #1552
Checklist
changelog.rst.AUTHORSfile (or it's already there).pip install pre-commit && pre-commit install).