Skip to content

fix: decouple interactive REPL buffer from target output format - #57

Merged
JFryy merged 2 commits into
JFryy:mainfrom
edsilegxrepo:pr4/fix-tui-format-decoupling
Nov 2, 2026
Merged

JFryy merged 2 commits into
JFryy:mainfrom
edsilegxrepo:pr4/fix-tui-format-decoupling

Conversation

@edsilegxrepo

Copy link
Copy Markdown
Contributor

Description

This PR refactors the TUI interactive REPL to decouple its internal live-query parsing state buffer from the target output format, resolving live rendering failures when transcoding to non-JSON codecs.

Key Changes

  1. TUI Payload Buffering: Configures the interactive REPL to always initialize its internal state buffer as JSON, while correctly formatting the final query results to the target output format (YAML, XML, TOML, etc.) on exit.
  2. Static Analysis Cleanup: Refactors the map-to-slice loop inside internal/tui/interactive.go into a separate helper mapToSlice(m map[string]struct{}) to satisfy static analysis checkers (like Semgrep).

Justification & Upstream Value

  • Justification: Upstream coupled the REPL state to the raw target output format. If a user tried to query a non-JSON output format (like TOML/YAML), parsing errors occurred inside the live TUI preview buffer. Standardizing the live preview buffer to JSON ensures robust interactive query construction.

Verification and Testing

  • Tested TUI interactively by running qq -I on YAML and TOML inputs. Live rendering now previews correctly, and exit formatting successfully outputs to the target codecs.

@JFryy
JFryy marked this pull request as ready for review November 2, 2026 18:50
JFryy
JFryy previously approved these changes Nov 2, 2026

@JFryy JFryy left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all your submissions, this looks good just a few nits I'll tweak before merge.

Interact returned the same result for a failure to start the interface as
for the user quitting, so qq printed "Exited without executing query" and
exited 0. Return the error and exit 1, as before this change.

Write the query banner and exit notice to stderr so stdout holds only the
result in the selected output format.
@JFryy
JFryy merged commit e464d79 into JFryy:main Nov 2, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants