Skip to content

feat(cli): complete read formats from view profiles (#1844) - #2034

Merged
Sinity merged 2 commits into
masterfrom
feature/feat/read-format-profile-completion-1844
Jun 17, 2026
Merged

Sinity merged 2 commits into
masterfrom
feature/feat/read-format-profile-completion-1844

Conversation

@Sinity

@Sinity Sinity commented Jun 17, 2026 •

Copy link
Copy Markdown
Owner

Summary

Makes read --format choices and shell completions come from SessionViewProfile.formats, matching the existing profile-backed read --view behavior.

Problem

#1844 says completion metadata should come from the parser/action/view registries rather than parallel lists. read --view already used READ_VIEW_PROFILES, but read --format still used an ad hoc static tuple, so a view-profile format rename/add/delete could drift from the CLI option and shell completions.

Solution

Derive the read format choice set from the union of READ_VIEW_PROFILES[*].formats, add a read-format completer that narrows candidates to the selected --view when available, and test both direct Click metadata and bash/zsh/fish completion behavior. The CLI reference was regenerated for the changed option surface.

Verification

  • nix develop --command devtools test tests/unit/cli/test_query_verbs_runtime.py -k 'read_format or read_view' → 7 passed, 16 deselected
  • nix develop --command devtools test tests/unit/cli/test_completion_matrix.py -k 'read_format or static_completers' → 24 passed, 64 deselected
  • nix develop --command devtools verify --quick → exit_code 0

Ref #1844

Summary by CodeRabbit

  • New Features

    • Shell completion for read --format now intelligently filters available formats based on the selected --view.
  • Documentation

    • Updated CLI reference and help text to display all supported output formats for the read command, including plaintext and text options.

Problem: #1844 requires read views and formats to come from view-profile metadata, but read --format still used an ad hoc static tuple even though read-view ids already came from SessionViewProfile.\n\nWhat changed: derive the read format choice set from READ_VIEW_PROFILES, add a read-format shell completer that narrows to the selected --view when present, and cover both direct Click metadata and bash/zsh/fish completion behavior. Regenerated the CLI reference for the changed option surface.\n\nVerification: nix develop --command devtools test tests/unit/cli/test_query_verbs_runtime.py -k 'read_format or read_view' passed 7 selected tests. nix develop --command devtools test tests/unit/cli/test_completion_matrix.py -k 'read_format or static_completers' passed 24 selected tests. nix develop --command devtools verify --quick passed.
@coderabbitai

coderabbitai Bot commented Jun 17, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: f8e4a2da-1893-4243-8886-6149a1d8f005

📥 Commits

Reviewing files that changed from the base of the PR and between c5bdbed and 5ce405f.

📒 Files selected for processing (5)
  • docs/cli-reference.md
  • polylogue/cli/query_verbs.py
  • tests/baselines/showcase/help-read.txt
  • tests/unit/cli/test_completion_matrix.py
  • tests/unit/cli/test_query_verbs_runtime.py

📝 Walkthrough

Walkthrough

The read --format CLI option now derives its allowed values dynamically from registered read-view profiles instead of a hardcoded list. Two new helpers (_selected_read_view, _complete_read_format) enable view-scoped shell completion. The CLI reference, help baseline, and tests are updated to match.

Changes

Dynamic read --format completion from view profiles

Layer / File(s) Summary
Dynamic format derivation and completion logic
polylogue/cli/query_verbs.py, docs/cli-reference.md, tests/baselines/showcase/help-read.txt
Imports READ_VIEW_PROFILE_BY_ID, replaces the hardcoded _READ_FORMATS tuple with a dynamically aggregated sorted set from all view profiles, introduces _selected_read_view and _complete_read_format helpers for view-scoped shell completion, and wires _complete_read_format into the read_verb --format option. CLI reference and help baseline are updated to reflect the expanded format list.
Tests for dynamic choices and view-scoped completion
tests/unit/cli/test_query_verbs_runtime.py, tests/unit/cli/test_completion_matrix.py
Adds unit tests asserting read_verb output_format uses click.Choice derived from all view profiles and that completion narrows to the selected view's formats. Extends STATIC_COMPLETERS to cover read --view and read --format, and adds a parametrized per-shell test asserting read --view raw --format returns exactly json.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 Hop hop, the formats are free!
No more hardcoded list, just profiles you see.
A --view is selected, completion narrows right down,
Dynamic and tidy, no reason to frown.
The rabbit approves — let the shell completions abound! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: deriving read format completions from view profiles instead of static values.
Description check ✅ Passed The description includes all required sections with sufficient detail: Summary, Problem, Solution, Verification, and References issue #1844. Changelog section appropriately notes this is user-visible.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/feat/read-format-profile-completion-1844

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.

Problem: deriving read --format choices from SessionViewProfile.formats changed the generated read help output, and showcase-verify caught the stale help-read baseline in CI.\n\nWhat changed: refresh the committed help-read showcase baseline for the profile-derived format list.\n\nVerification: nix develop --command devtools lab-scenario verify-baselines passed. nix develop --command devtools verify --quick passed.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9e27ac3399

ℹ️ 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".

Comment thread polylogue/cli/query_verbs.py Resolved
@Sinity

Sinity commented Jun 17, 2026

Copy link
Copy Markdown
Owner Author

Addressed the showcase-baseline finding in commit 5ce405f: refreshed tests/baselines/showcase/help-read.txt and verified with devtools lab-scenario verify-baselines plus devtools verify --quick.

@Sinity
Sinity merged commit ddf9694 into master Jun 17, 2026
14 checks passed
@Sinity
Sinity deleted the feature/feat/read-format-profile-completion-1844 branch June 17, 2026 07:15
@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

  • 61.F107 / P2: stale at the checked revision: The cited showcase help snapshots and their verify-baselines lane are absent at the pin, so the reported snapshot comparison cannot run. Current read format choices help is derived from the live command declarations at polylogue/cli/query_verbs.py:248.

Only the rows listed above are dispositioned. Held findings remain open.

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.

1 participant