Skip to content

refactor: share query output formatting helpers - #304

Merged
Sinity merged 2 commits into
masterfrom
feature/refactor/query-output-formatting
Apr 21, 2026
Merged

Sinity merged 2 commits into
masterfrom
feature/refactor/query-output-formatting

Conversation

@Sinity

@Sinity Sinity commented Apr 21, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds shared query-output helpers for display dates, title truncation, conversation rows, summary rows, and stream date serialization.
  • Reuses the helper path across hydrated-list output, summary-list output, CSV output, rich summary tables, and stream headers.
  • Preserves existing public function names, aliases, and output behavior.

Problem

polylogue/cli/query_output.py had small repeated formatting decisions scattered across list, summary, CSV, rich table, and streaming output paths. That made the adapter surface more path-dependent than necessary and increased drift risk around truncation/date behavior.

Solution

  • Centralize date formatting and ellipsis behavior.
  • Route conversation and summary text rows through shared helpers.
  • Replace repeated machine-output format sets with one constant.
  • Keep delivery behavior and query dispatch untouched.

Ref #270

Verification

  • ruff format polylogue/cli/query_output.py
  • ruff check polylogue/cli/query_output.py
  • mypy polylogue/cli/query_output.py tests/unit/cli/test_query_fmt.py tests/unit/cli/test_query_exec_laws.py
  • pytest -q tests/unit/cli/test_query_fmt.py tests/unit/cli/test_query_exec_laws.py -k 'format or output_results or stream or summary_list or csv'
  • push hook: devtools verify --quick

@coderabbitai

coderabbitai Bot commented Apr 21, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: dd114dc4-7d1a-4300-afc5-25320a56a8fd

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/refactor/query-output-formatting

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Sinity
Sinity force-pushed the feature/refactor/query-stats-contracts branch from a1260f3 to 6c0562d Compare April 21, 2026 14:38
@Sinity
Sinity force-pushed the feature/refactor/query-output-formatting branch from 89c5957 to 656b998 Compare April 21, 2026 14:39
Base automatically changed from feature/refactor/query-stats-contracts to master April 21, 2026 16:49
@Sinity
Sinity merged commit f92c062 into master Apr 21, 2026
3 checks passed
@Sinity
Sinity deleted the feature/refactor/query-output-formatting branch April 21, 2026 16:50
Sinity added a commit that referenced this pull request Apr 22, 2026
## Summary
- Adds shared query-output helpers for display dates, title truncation, conversation rows, summary rows, and stream date serialization.
- Reuses the helper path across hydrated-list output, summary-list output, CSV output, rich summary tables, and stream headers.
- Preserves existing public function names, aliases, and output behavior.

## Problem
`polylogue/cli/query_output.py` had small repeated formatting decisions scattered across list, summary, CSV, rich table, and streaming output paths. That made the adapter surface more path-dependent than necessary and increased drift risk around truncation/date behavior.

## Solution
- Centralize date formatting and ellipsis behavior.
- Route conversation and summary text rows through shared helpers.
- Replace repeated machine-output format sets with one constant.
- Keep delivery behavior and query dispatch untouched.

Ref #270

## Verification
- `ruff format polylogue/cli/query_output.py`
- `ruff check polylogue/cli/query_output.py`
- `mypy polylogue/cli/query_output.py tests/unit/cli/test_query_fmt.py tests/unit/cli/test_query_exec_laws.py`
- `pytest -q tests/unit/cli/test_query_fmt.py tests/unit/cli/test_query_exec_laws.py -k 'format or output_results or stream or summary_list or csv'`
- push hook: `devtools verify --quick`
@Sinity Sinity added area:cli CLI area:parser Parser tool:claude Claude type:refactor Code restructuring labels Apr 22, 2026
Sinity added a commit that referenced this pull request Apr 22, 2026
`cli/query_output.py` had small repeated formatting decisions
scattered across list, summary, CSV, rich table, and streaming
output paths — making the adapter surface more path-dependent than
necessary and increasing drift risk around truncation/date
behavior.

Adds shared query-output helpers for display dates, title
truncation, conversation rows, summary rows, and stream date
serialization. Reuses the helper path across hydrated-list output,
summary-list output, CSV output, rich summary tables, and stream
headers. Centralizes date formatting and ellipsis behavior. Routes
conversation and summary text rows through shared helpers. Replaces
repeated machine-output format sets with one constant. Keeps
delivery behavior and query dispatch untouched, and preserves
existing public function names, aliases, and output behavior.

Verification: ruff + mypy + pytest over query-fmt / query-exec-laws
format/output/stream/summary/csv coverage; devtools verify --quick
green.

Ref #270
Sinity added a commit that referenced this pull request Apr 22, 2026
`cli/query_output.py` had small repeated formatting decisions
scattered across list, summary, CSV, rich table, and streaming
output paths — making the adapter surface more path-dependent than
necessary and increasing drift risk around truncation/date
behavior.

Adds shared query-output helpers for display dates, title
truncation, conversation rows, summary rows, and stream date
serialization. Reuses the helper path across hydrated-list output,
summary-list output, CSV output, rich summary tables, and stream
headers. Centralizes date formatting and ellipsis behavior. Routes
conversation and summary text rows through shared helpers. Replaces
repeated machine-output format sets with one constant. Keeps
delivery behavior and query dispatch untouched, and preserves
existing public function names, aliases, and output behavior.

Verification: ruff + mypy + pytest over query-fmt / query-exec-laws
format/output/stream/summary/csv coverage; devtools verify --quick
green.

Ref #270
Sinity added a commit that referenced this pull request Apr 22, 2026
`cli/query_output.py` had small repeated formatting decisions
scattered across list, summary, CSV, rich table, and streaming
output paths — making the adapter surface more path-dependent than
necessary and increasing drift risk around truncation/date
behavior.

Adds shared query-output helpers for display dates, title
truncation, conversation rows, summary rows, and stream date
serialization. Reuses the helper path across hydrated-list output,
summary-list output, CSV output, rich summary tables, and stream
headers. Centralizes date formatting and ellipsis behavior. Routes
conversation and summary text rows through shared helpers. Replaces
repeated machine-output format sets with one constant. Keeps
delivery behavior and query dispatch untouched, and preserves
existing public function names, aliases, and output behavior.

Verification: ruff + mypy + pytest over query-fmt / query-exec-laws
format/output/stream/summary/csv coverage; devtools verify --quick
green.

Ref #270
@Sinity

Sinity commented May 1, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Sinity
Sinity requested a review from Copilot May 1, 2026 01:53
@Sinity
Sinity removed the request for review from Copilot May 1, 2026 02:15
Sinity pushed a commit that referenced this pull request Sep 2, 2026
Bumps [pytest-benchmark](https://github.com/ionelmc/pytest-benchmark)
from 5.2.3 to 5.3.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/ionelmc/pytest-benchmark/releases">pytest-benchmark's
releases</a>.</em></p>
<blockquote>
<h2>v5.3.0</h2>
<ul>
<li>Added --benchmark-precision and --benchmark-confidence: instead of a
fixed number of rounds, stop once the mean's relative margin of error
falls below the given fraction. Contributed by Aarni Koskela in <a
href="https://redirect.github.com/ionelmc/pytest-benchmark/pull/318">ionelmc/pytest-benchmark#318</a>.</li>
<li>Added compare --between mode. Example: pytest-benchmark compare
--between=min 0001 0002. Contributed by Aarni Koskela in <a
href="https://redirect.github.com/ionelmc/pytest-benchmark/pull/302">ionelmc/pytest-benchmark#302</a>.</li>
<li>Modernized the CI/linting and added spellchecking. Contributed by
Aarni Koskela in <a
href="https://redirect.github.com/ionelmc/pytest-benchmark/pull/304">ionelmc/pytest-benchmark#304</a>,
<a
href="https://redirect.github.com/ionelmc/pytest-benchmark/pull/306">ionelmc/pytest-benchmark#306</a>
and <a
href="https://redirect.github.com/ionelmc/pytest-benchmark/pull/319">ionelmc/pytest-benchmark#319</a>.</li>
<li>Defer the xdist auto-disable warning until a benchmark fixture is
collected. Contributed by xlyyddy in <a
href="https://redirect.github.com/ionelmc/pytest-benchmark/pull/317">ionelmc/pytest-benchmark#317</a>
(fixes <a
href="https://redirect.github.com/ionelmc/pytest-benchmark/issues/65">ionelmc/pytest-benchmark#65</a>).</li>
<li>Replaced deprecated argparse.FileType. Contributed by Sophia
Castellarin in <a
href="https://redirect.github.com/ionelmc/pytest-benchmark/pull/310">ionelmc/pytest-benchmark#310</a>.</li>
<li>Fixed various spelling/typos. Contributed by Daniel Holth and Hugo
van Kemenade in <a
href="https://redirect.github.com/ionelmc/pytest-benchmark/pull/297">ionelmc/pytest-benchmark#297</a>
and <a
href="https://redirect.github.com/ionelmc/pytest-benchmark/pull/299">ionelmc/pytest-benchmark#299</a>.</li>
<li>Cleaned up various dead code. Contributed by Hugo van Kemenade in <a
href="https://redirect.github.com/ionelmc/pytest-benchmark/pull/300">ionelmc/pytest-benchmark#300</a>
and <a
href="https://redirect.github.com/ionelmc/pytest-benchmark/pull/301">ionelmc/pytest-benchmark#301</a>.</li>
<li>CI now tests only with latest Pytest (now 9.1.1), Python 3.10-3.14
and PyPy 3.11.</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/ionelmc/pytest-benchmark/blob/master/CHANGELOG.rst">pytest-benchmark's
changelog</a>.</em></p>
<blockquote>
<h2>v5.3.0 (2026-08-23)</h2>
<ul>
<li>Added <code>--benchmark-precision</code> and
<code>--benchmark-confidence</code>:
instead of a fixed number of rounds, stop once the mean's relative
margin of error falls below the given fraction.
Contributed by Aarni Koskela in
<code>[#318](ionelmc/pytest-benchmark#318)
&lt;https://github.com/ionelmc/pytest-benchmark/pull/318&gt;</code>_.</li>
<li>Added <code>compare --between</code> mode. Example:
<code>pytest-benchmark compare --between=min 0001 0002</code>.
Contributed by Aarni Koskela in
<code>[#302](ionelmc/pytest-benchmark#302)
&lt;https://github.com/ionelmc/pytest-benchmark/pull/302&gt;</code>_.</li>
<li>Modernized the CI/linting and added spellchecking.
Contributed by Aarni Koskela in
<code>[#304](ionelmc/pytest-benchmark#304)
&lt;https://github.com/ionelmc/pytest-benchmark/pull/304&gt;</code><em>,
<code>[#306](ionelmc/pytest-benchmark#306)
&lt;https://github.com/ionelmc/pytest-benchmark/pull/306&gt;</code></em>
and
<code>[#319](ionelmc/pytest-benchmark#319)
&lt;https://github.com/ionelmc/pytest-benchmark/pull/319&gt;</code>_.</li>
<li>Defer the xdist auto-disable warning until a benchmark fixture is
collected.
Contributed by xlyyddy in
<code>[#317](ionelmc/pytest-benchmark#317)
&lt;https://github.com/ionelmc/pytest-benchmark/pull/317&gt;</code>_
(fixes
<code>[#65](ionelmc/pytest-benchmark#65)
&lt;https://github.com/ionelmc/pytest-benchmark/issues/65&gt;</code>_).</li>
<li>Replaced deprecated argparse.FileType.
Contributed by Sophia Castellarin in
<code>[#310](ionelmc/pytest-benchmark#310)
&lt;https://github.com/ionelmc/pytest-benchmark/pull/310&gt;</code>_.</li>
<li>Fixed various spelling/typos.
Contributed by Daniel Holth and Hugo van Kemenade in
<code>[#297](ionelmc/pytest-benchmark#297)
&lt;https://github.com/ionelmc/pytest-benchmark/pull/297&gt;</code>_ and
<code>[#299](ionelmc/pytest-benchmark#299)
&lt;https://github.com/ionelmc/pytest-benchmark/pull/299&gt;</code>_.</li>
<li>Cleaned up various dead code.
Contributed by Hugo van Kemenade in
<code>[#300](ionelmc/pytest-benchmark#300)
&lt;https://github.com/ionelmc/pytest-benchmark/pull/300&gt;</code>_ and
<code>[#301](ionelmc/pytest-benchmark#301)
&lt;https://github.com/ionelmc/pytest-benchmark/pull/301&gt;</code>_.</li>
<li>CI now tests only with latest Pytest (now 9.1.1), Python 3.10-3.14
and PyPy 3.11.</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/ionelmc/pytest-benchmark/commit/07d519672687402e6c3fac1a543fbefd810d1e5b"><code>07d5196</code></a>
Bump version: 5.2.3 → 5.3.0</li>
<li><a
href="https://github.com/ionelmc/pytest-benchmark/commit/accf7331e22c0ede38ffa72081c38f3469e0c9b5"><code>accf733</code></a>
Add some details on <a
href="https://redirect.github.com/ionelmc/pytest-benchmark/issues/304">#304</a>.</li>
<li><a
href="https://github.com/ionelmc/pytest-benchmark/commit/417dd9fa275e8b9d62c469e676cdb7546d2c4b8f"><code>417dd9f</code></a>
Really update the changelog.</li>
<li><a
href="https://github.com/ionelmc/pytest-benchmark/commit/898acb34430c99ad877e94c52c8b90256a3bb4a8"><code>898acb3</code></a>
Update changelog and plan release.</li>
<li><a
href="https://github.com/ionelmc/pytest-benchmark/commit/9cc7ef0bb1ad3785a46834b24660562dd48e4a0b"><code>9cc7ef0</code></a>
Defer xdist warning until benchmark collection (<a
href="https://redirect.github.com/ionelmc/pytest-benchmark/issues/65">#65</a>)</li>
<li><a
href="https://github.com/ionelmc/pytest-benchmark/commit/ef485506f04d5510831fdbdee5be7014f4726a93"><code>ef48550</code></a>
Some minor skel updates: test only against latest pytest; bump
linting/format...</li>
<li><a
href="https://github.com/ionelmc/pytest-benchmark/commit/88eaea957d1685f604a5835555d2ce5dbec1ac29"><code>88eaea9</code></a>
Add --benchmark-precision for adaptive rounds (opt-in)</li>
<li><a
href="https://github.com/ionelmc/pytest-benchmark/commit/3b83d127127de74d9f71a3a78e5f661fac044950"><code>3b83d12</code></a>
Update and freeze GHA actions</li>
<li><a
href="https://github.com/ionelmc/pytest-benchmark/commit/4b7662fbfba046eb92dd183e005e8708ac81e6cd"><code>4b7662f</code></a>
Fix ruff complaints</li>
<li><a
href="https://github.com/ionelmc/pytest-benchmark/commit/26b011361d2c41f529a73833e1be8d3a565600fa"><code>26b0113</code></a>
Remove Taplo lint (unmaintained)</li>
<li>Additional commits viewable in <a
href="https://github.com/ionelmc/pytest-benchmark/compare/v5.2.3...v5.3.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=pytest-benchmark&package-manager=uv&previous-version=5.2.3&new-version=5.3.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:cli CLI area:parser Parser tool:claude Claude type:refactor Code restructuring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant