Skip to content

Fix status-all context filters - #310

Merged
unbraind merged 2 commits into
mainfrom
fix/status-all-context-filters
Jun 20, 2026
Merged

unbraind merged 2 commits into
mainfrom
fix/status-all-context-filters

Conversation

@unbraind

Copy link
Copy Markdown
Owner

Summary

  • add a shared standalone --status all sentinel for duplicate-safe lifecycle-wide search/list filtering
  • make pm list --status all override the active-only terminal exclusion and echo filters.status=all
  • update CLI/MCP docs, contract snapshot, changelog, and PM tracker evidence for pm-i02t

Verification

  • node scripts/run-tests.mjs test -- tests/unit/core/item/status-normalization.spec.ts tests/unit/commands/search-command.spec.ts tests/unit/commands/list-command.spec.ts
  • node scripts/run-tests.mjs coverage -> 4699 passed, 100/100/100/100
  • pnpm contracts:check && pnpm quality:static
  • pnpm changelog:pm:check with pm-changelog@2026.6.14
  • pm validate --check-resolution --check-history-drift -> history drift ok; pre-existing resolution warnings remain
  • sandboxed temp-dir smoke with PM_PATH/PM_GLOBAL_PATH covering init/create/close/search/list
  • pnpm audit --audit-level moderate, pnpm security:scan, GitHub PR/issue/security alert checks, telemetry health, and Sentry unresolved 24h check

Notes

  • commander@15 is not adopted because it requires Node >=22.12.0 while this repo still declares/supports Node 20 and several workflows run Node 20.
  • @types/node@26 remains a separate dependency-validation lane rather than being bundled into this behavior fix.

Add a shared standalone --status all sentinel for list/search duplicate-discovery workflows, including list's active-only terminal exclusion override and explicit filter echo.

Update CLI/MCP docs, contract snapshot, pm-changelog output, and focused regressions for parser/search/list behavior. Tracker: pm-i02t.
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@unbraind

Copy link
Copy Markdown
Owner Author

@codex review
/gemini review
@gemini-code-assist
@coderabbitai full review

@sourcery-ai sourcery-ai 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.

Sorry @unbraind, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@coderabbitai

coderabbitai Bot commented Jun 20, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@unbraind, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 44 minutes and 37 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: b0c5cc98-dd9b-47fd-80d7-ec54331389a3

📥 Commits

Reviewing files that changed from the base of the PR and between 49955f7 and d993f9f.

📒 Files selected for processing (13)
  • .agents/pm/history/pm-i02t.jsonl
  • .agents/pm/issues/pm-i02t.toon
  • CHANGELOG.md
  • docs/COMMANDS.md
  • src/cli/commands/list.ts
  • src/cli/commands/search.ts
  • src/cli/register-list-query.ts
  • src/core/item/status-filter.ts
  • src/mcp/tool-definitions.ts
  • tests/fixtures/contracts/full.json
  • tests/unit/commands/list-command.spec.ts
  • tests/unit/commands/search-command.spec.ts
  • tests/unit/core/item/status-normalization.spec.ts
📝 Walkthrough

Walkthrough

Adds --status all as a duplicate-safe sentinel for pm list and pm search. The shared parseStatusFilterCsv parser now returns undefined for a standalone all token and throws a usage error when all is mixed with other values. The list command, CLI help strings, MCP tool descriptions, contract snapshots, tests, and docs are all updated accordingly.

Changes

--status all sentinel implementation

Layer / File(s) Summary
Status filter parser: isStatusAllFilterInput and all sentinel handling
src/core/item/status-filter.ts
Adds STATUS_ALL_SENTINEL constant and exported isStatusAllFilterInput helper; extends parseStatusFilterCsv to return undefined for a standalone all token and throw a PmCliError (usage) when all is mixed with other status tokens.
CLI list command and help text wiring
src/cli/commands/list.ts, src/cli/register-list-query.ts
Imports isStatusAllFilterInput in list.ts; updates runList to disable excludeTerminal and echo filters.status as "all" when the sentinel is detected; updates --status help strings for both list-family and search commands to document all.
MCP tool descriptions and contract fixture
src/mcp/tool-definitions.ts, tests/fixtures/contracts/full.json
Adds options.status='all' documentation to pm_search and pm_list description strings, and regenerates the contract fixture to match.
Unit tests for parser, list, and search
tests/unit/core/item/status-normalization.spec.ts, tests/unit/commands/list-command.spec.ts, tests/unit/commands/search-command.spec.ts
Extends parseStatusFilterCsv tests for standalone all (returns undefined) and mixed-all rejection; adds status: "all" assertions to list and search command specs verifying all items are returned and filters.status echoes "all".
Docs, changelog, and agent history
docs/COMMANDS.md, CHANGELOG.md, .agents/pm/...
Updates pm search --status examples in COMMANDS.md; adds a changelog entry; introduces the pm-i02t agent issue record and full audit-trail history log.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix status-all context filters' directly aligns with the main change: adding a shared standalone --status all sentinel for search/list filtering to fix duplicate-safe filtering behavior.
Description check ✅ Passed The description comprehensively covers the changeset, detailing the --status all sentinel addition, list command terminal-exclusion override, documentation updates, and extensive verification steps.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.
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.


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.

@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== PR Details ==="
gh pr view 310 --repo unbraind/pm-cli --json title,body,state,baseRefName,headRefName,files,additions,deletions,changedFiles

echo ""
echo "=== Changed Files ==="
gh pr diff 310 --repo unbraind/pm-cli

Length of output: 45555


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Search command source (status-related logic) ==="
fd -t f 'search' src/cli/commands/
echo ""
fd -t f 'search' src/cli/commands/ | xargs grep -n "filtersStatus\|isStatusAll\|STATUS_ALL\|filters\.status\|explicitAll\|resolvedStatus" 2>/dev/null || echo "No matches"

echo ""
echo "=== isStatusAllFilterInput usages ==="
rg -n "isStatusAllFilterInput" --type ts

echo ""
echo "=== parseStatusFilterCsv surrounding context in search ==="
fd -t f -e ts . src/cli/commands/ | xargs grep -l "parseStatusFilterCsv" 2>/dev/null || echo "No files"

echo ""
echo "=== filtersStatus in search command ==="
rg -n "filtersStatus" --type ts -A3 -B3

Length of output: 4639



@unbraind: Here is the full review of PR #310.


Overall Assessment

The change is well-scoped, correctly implemented, and thoroughly verified. The isStatusAllFilterInput helper is clean and the parseStatusFilterCsv update handles both the happy path (standalone all) and the error path (mixed all,open) properly. Docs, MCP descriptions, contract snapshot, changelog, and tests are all aligned. Two minor observations below.


src/core/item/status-filter.ts

Double-parse inside parseStatusFilterCsv is slightly redundant.

if (tokens.some((token) => token.trim().toLowerCase() === STATUS_ALL_SENTINEL)) {
  if (isStatusAllFilterInput(raw)) {   // re-parses raw from scratch
    return undefined;
  }
  throw ...
}

Once the tokens.some() guard confirms at least one token equals "all", the inner isStatusAllFilterInput(raw) re-tokenises raw from scratch just to check tokens.length === 1. A simpler equivalent, without the re-parse:

if (tokens.some((t) => t.trim().toLowerCase() === STATUS_ALL_SENTINEL)) {
  const allTokens = tokens.filter((t) => t.trim().toLowerCase() === STATUS_ALL_SENTINEL);
  if (tokens.length === allTokens.length) {
    // standalone "all" (or "all,all" — both resolve to no-filter)
    return undefined;
  }
  throw new PmCliError(
    `Invalid ${flagLabel} value "all". Use it by itself, or omit ${flagLabel} to search every status.`,
    EXIT_CODE.USAGE,
  );
}

Or, even more concisely, just check tokens.length === 1 since you already know the single token is "all". The current approach is correct, just slightly over-engineered.


src/cli/commands/search.ts vs src/cli/commands/list.ts — echo normalisation asymmetry

list.ts derives the echo value through isStatusAllFilterInput, which lowercases and trims internally, so it always produces "all" regardless of what the caller passed:

// list.ts
const explicitAllStatuses = isStatusAllFilterInput(options.status); // normalised
const filtersStatus = explicitAllStatuses ? "all" : ...;            // always "all"

search.ts line 368 passes the raw option through directly:

filters.status = options.status;   // raw string — "ALL", "  all  ", etc.

The practical impact is cosmetic — pm search --status ALL would echo filters.status: "ALL" while pm list --status ALL would echo filters.status: "all". Since parseStatusFilterCsv normalises internally, the filtering behaviour is identical. The test suite only covers the lowercase "all" path, so the case inconsistency isn't caught. If consistent serialisation matters (e.g. downstream tooling reading query_summary), the search command could normalise the echo:

// In search.ts, where filters.status is assigned
filters.status = isStatusAllFilterInput(options.status) ? "all" : options.status;

Everything else looks good

Area Status
isStatusAllFilterInput helper ✅ Clean, correctly exported, handles edge cases
parseStatusFilterCsv mixed-all rejection ✅ Clear error message, tested
list.ts terminal-exclusion override ✅ Correct; explicitAllStatuses flag disables excludeTerminal
list.ts filters.status ternary ✅ Correct order of precedence
register-list-query.ts help text ✅ Updated for both --status options
tool-definitions.ts / contract snapshot ✅ Consistent, snapshot regenerated
docs/COMMANDS.md ✅ Example added for --status all duplicate-check use case
Unit tests (status-normalization.spec.ts) ✅ Standalone all, case-insensitive ALL, mixed rejection
Command tests (list-command.spec.ts, search-command.spec.ts) ✅ Count, item IDs, and filters.status echo all verified

@unbraind

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 20, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
src/core/item/status-filter.ts (1)

129-137: 💤 Low value

Consider simplifying the standalone-all detection.

The code calls isStatusAllFilterInput(raw) inside a block that already confirms at least one token equals "all" (line 129). Since tokens is already computed at lines 122-125, you could avoid the re-parse by checking tokens.length === 1 directly:

♻️ Optional simplification
-  if (tokens.some((token) => token.trim().toLowerCase() === STATUS_ALL_SENTINEL)) {
-    if (isStatusAllFilterInput(raw)) {
+  const hasAllToken = tokens.some((token) => token.toLowerCase() === STATUS_ALL_SENTINEL);
+  if (hasAllToken) {
+    if (tokens.length === 1) {
       return undefined;
     }
     throw new PmCliError(

This eliminates the redundant split/map/filter inside isStatusAllFilterInput while preserving identical semantics.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/core/item/status-filter.ts` around lines 129 - 137, The code calls
`isStatusAllFilterInput(raw)` to detect if "all" appears as the only token, but
this function internally re-parses the raw input with split, map, and filter
operations. Since the `tokens` array is already computed at lines 122-125 and
you are already inside a block confirming at least one token equals
STATUS_ALL_SENTINEL, replace the `isStatusAllFilterInput(raw)` call with a
simpler direct check of `tokens.length === 1` to verify that "all" is the only
token, eliminating the redundant re-parsing while preserving identical
semantics.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/core/item/status-filter.ts`:
- Around line 129-137: The code calls `isStatusAllFilterInput(raw)` to detect if
"all" appears as the only token, but this function internally re-parses the raw
input with split, map, and filter operations. Since the `tokens` array is
already computed at lines 122-125 and you are already inside a block confirming
at least one token equals STATUS_ALL_SENTINEL, replace the
`isStatusAllFilterInput(raw)` call with a simpler direct check of `tokens.length
=== 1` to verify that "all" is the only token, eliminating the redundant
re-parsing while preserving identical semantics.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 5cc1fa27-86c1-4f06-a3e7-38d628b31825

📥 Commits

Reviewing files that changed from the base of the PR and between 49955f7 and 50b072d.

📒 Files selected for processing (12)
  • .agents/pm/history/pm-i02t.jsonl
  • .agents/pm/issues/pm-i02t.toon
  • CHANGELOG.md
  • docs/COMMANDS.md
  • src/cli/commands/list.ts
  • src/cli/register-list-query.ts
  • src/core/item/status-filter.ts
  • src/mcp/tool-definitions.ts
  • tests/fixtures/contracts/full.json
  • tests/unit/commands/list-command.spec.ts
  • tests/unit/commands/search-command.spec.ts
  • tests/unit/core/item/status-normalization.spec.ts

Address PR review feedback for pm-i02t by avoiding redundant status-token parsing in the shared status filter helper and normalizing search filter summaries for case-insensitive --status all inputs.

Add compact search regression coverage so status-all echoes remain stable across human-readable and JSON paths.
@unbraind

Copy link
Copy Markdown
Owner Author

Review requested again after follow-up commit d993f9f.

@codex review
/gemini review
@gemini-code-assist
@coderabbitai full review

@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@coderabbitai

coderabbitai Bot commented Jun 20, 2026 •

Copy link
Copy Markdown
🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Follow-up commit d993f9f4 details ==="
gh api repos/unbraind/pm-cli/commits/d993f9f4 --jq '.commit.message'

echo ""
echo "=== Files changed in d993f9f4 ==="
gh api repos/unbraind/pm-cli/commits/d993f9f4 --jq '.files[].filename'

echo ""
echo "=== Commit diff ==="
gh api repos/unbraind/pm-cli/commits/d993f9f4 --jq '.files[] | "--- \(.filename) ---\n\(.patch // "(binary or no patch)")'

Length of output: 1500


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== status-filter.ts current state ==="
cat src/core/item/status-filter.ts

echo ""
echo "=== search.ts relevant sections ==="
grep -n "isStatusAllFilterInput\|filters\.status\|options\.status\|parseStatusFilterCsv" src/cli/commands/search.ts | head -40

echo ""
echo "=== search-command.spec.ts new tests ==="
grep -n -A 15 "status.*all\|ALL\|status_all\|explicitAll" tests/unit/commands/search-command.spec.ts | head -80

Length of output: 9190



@unbraind: Here is the full review of the follow-up commit d993f9f4.


Assessment

Both items flagged in the previous review have been cleanly resolved. The implementation is correct, consistent, and well-tested.


src/core/item/status-filter.ts — redundant re-parse eliminated ✅

The inner isStatusAllFilterInput(raw) call is gone. The new approach counts sentinel tokens and compares against total token count directly — no second tokenisation pass:

const allTokenCount = tokens.filter((t) => t.trim().toLowerCase() === STATUS_ALL_SENTINEL).length;
if (allTokenCount > 0) {
  if (tokens.length === 1) {
    return undefined;          // standalone "all" → no filter
  }
  throw new PmCliError(...);   // mixed "all,open" → usage error
}

This is slightly more general than the tokens.length === 1 shortcut I suggested (it also handles the degenerate "all,all" case), and clearer about intent.


src/cli/commands/search.ts — echo normalisation asymmetry fixed ✅

Both assignment sites now use isStatusAllFilterInput to produce a stable lowercase "all" regardless of the raw input casing:

Line Before After
368 (human-readable path) options.status (raw) isStatusAllFilterInput(options.status) ? "all" : options.status
469 (JSON/compact path) options.status ?? null (raw) isStatusAllFilterInput(options.status) ? "all" : options.status ?? null

pm search --status ALL and pm list --status ALL now both echo filters.status: "all".


tests/unit/commands/search-command.spec.ts — regression coverage added ✅

Three new assertions cover the normalisation path:

  • status: "all" → filters.status === "all" (basic case)
  • status: " ALL " → filters.status === "all" (case-insensitive + trim, human-readable path)
  • status: " ALL " → filters.status === "all" (compact/JSON path, line 3253–3256)

Summary

Area Previous state Now
parseStatusFilterCsv double-parse ⚠️ Redundant isStatusAllFilterInput call ✅ Direct allTokenCount / tokens.length === 1
search.ts echo (human-readable) ⚠️ Raw options.status ✅ Normalised via isStatusAllFilterInput
search.ts echo (compact/JSON) ⚠️ Raw options.status ?? null ✅ Normalised via isStatusAllFilterInput
Case-insensitive echo test ⚠️ Not covered ✅ " ALL " tested on both paths

No further issues. The PR is in good shape.

✅ Action performed

Full review finished.

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