Skip to content

fix: display task complexity in list after analyze-complexity#1672

Open
withsivram wants to merge 1 commit intoeyaltoledano:mainfrom
withsivram:fix/show-complexity-in-list-issue-1614
Open

fix: display task complexity in list after analyze-complexity#1672
withsivram wants to merge 1 commit intoeyaltoledano:mainfrom
withsivram:fix/show-complexity-in-list-issue-1614

Conversation

@withsivram
Copy link
Copy Markdown

@withsivram withsivram commented Mar 22, 2026

Summary

  • Fix complexity data showing as N/A in list output after running analyze-complexity with a tag
  • Root cause: in legacy file format, loadTasks('master') falls back to the first available tag (e.g., foo) when loading tasks, but was still using 'master' when looking up the complexity report — causing a file path mismatch (task-complexity-report.json vs task-complexity-report_foo.json)
  • Add FormatHandler.resolveTag() to determine the actual tag used for task extraction, then pass it to enrichTasksWithComplexity() so the correct complexity report is loaded

Test plan

  • Run task-master parse-prd --input .taskmaster/docs/prd.md --tag foo then task-master analyze-complexity --tag foo then task-master list — complexity column should now show scores
  • Run npm run test -w @tm/core -- --run format-handler.spec --no-coverage — 5 unit tests for resolveTag pass
  • Run npm run test -w @tm/core -- --run complexity-tag-fallback --no-coverage — 3 integration tests pass (including the key regression test)
  • Run npm run test -w @tm/core -- --run file-storage-metadata --no-coverage — all 18 existing tests pass (no regressions)
  • Run npm run typecheck -w @tm/core — no type errors

Fixes #1614

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Fixed an issue where complexity analysis results would not appear in task list output when tasks were stored under non-master tags while using the default master tag. The system now correctly resolves and applies complexity data from tag-specific reports.

…o#1614)

When tasks are stored under a non-master tag in legacy format and the
list command defaults to 'master', the complexity report lookup was
using 'master' as the tag — which doesn't match the tag-specific
report file (e.g., task-complexity-report_foo.json).

Root cause: In legacy format, FormatHandler.extractTasks() falls back
from 'master' to the first available tag when loading tasks, but
FileStorage.loadTasks() was still passing 'master' to the complexity
enrichment step, causing a report file mismatch.

Fix: Add FormatHandler.resolveTag() to determine the actual tag used
for task extraction, then pass that resolved tag to
enrichTasksWithComplexity() so the correct complexity report is loaded.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 22, 2026 06:55
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 22, 2026

🦋 Changeset detected

Latest commit: add4239

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 22, 2026

📝 Walkthrough

Walkthrough

This PR fixes a bug where task complexity data failed to display in the list output when tasks were stored under non-master tags. It introduces a resolveTag() method to the FormatHandler that determines the correct tag for complexity enrichment and updates FileStorage.loadTasks() to use the resolved tag instead of the initially provided one.

Changes

Cohort / File(s) Summary
FormatHandler Enhancement
packages/tm-core/src/modules/storage/adapters/file-storage/format-handler.ts, packages/tm-core/src/modules/storage/adapters/file-storage/format-handler.spec.ts
Added public resolveTag(data, tag) method that inspects file format and returns the requested tag if present in legacy data; falls back to the first available legacy tag when "master" is requested but unavailable. Includes comprehensive unit tests covering legacy/standard formats, null inputs, and consistency with extractTasks().
FileStorage Complexity Enrichment Fix
packages/tm-core/src/modules/storage/adapters/file-storage/file-storage.ts
Modified loadTasks() to compute actualTag via formatHandler.resolveTag() and pass it to enrichTasksWithComplexity() instead of the raw resolvedTag, ensuring complexity data loads from the correct tag-specific report.
Integration Tests
packages/tm-core/tests/integration/storage/complexity-tag-fallback.test.ts
Added integration test suite verifying that FileStorage.loadTasks() correctly enriches tasks with complexity values when reports exist for specific tags, with explicit tag loading, and graceful handling when reports are absent.
Changelog Entry
.changeset/fix-complexity-tag-fallback.md
Documented patch-level fix for @tm/core addressing tag-fallback behavior in complexity reporting.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • PR #1270 — Introduced the complexity enrichment code path that this PR fixes by improving tag resolution logic.
  • PR #1250 — Modified FileStorage implementation; this PR extends that adapter's behavior for tag-aware complexity loading.

Suggested reviewers

  • Crunchyman-ralph
  • eyaltoledano
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main fix: addressing the display of task complexity in list output after running analyze-complexity.
Linked Issues check ✅ Passed All code changes directly address issue #1614: the FormatHandler.resolveTag() method [format-handler.ts] resolves the actual tag used for task extraction, and file-storage.ts uses this resolved tag for complexity enrichment, ensuring the correct complexity report file is loaded and complexity data displays in list output.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the complexity tag fallback issue: FormatHandler method addition, file-storage integration, spec tests for the new method, and integration tests verifying the fix—no out-of-scope changes present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a legacy tag-fallback mismatch so task-master list shows complexity scores (instead of N/A) after running analyze-complexity on a non-master tag, by ensuring the complexity report lookup uses the same resolved tag as task extraction.

Changes:

  • Add FormatHandler.resolveTag() to determine the effective tag used when legacy master falls back to the first available tag.
  • Update FileStorage.loadTasks() to pass the resolved “actual tag” into complexity enrichment/report lookup.
  • Add unit + integration tests covering the regression and edge cases, plus a patch changeset.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/tm-core/src/modules/storage/adapters/file-storage/format-handler.ts Adds tag-resolution helper to mirror legacy extraction fallback behavior.
packages/tm-core/src/modules/storage/adapters/file-storage/file-storage.ts Uses resolved tag for complexity enrichment so the correct report file is loaded.
packages/tm-core/src/modules/storage/adapters/file-storage/format-handler.spec.ts Adds unit tests for resolveTag() behavior and consistency with extraction.
packages/tm-core/tests/integration/storage/complexity-tag-fallback.test.ts Adds integration coverage for the reported regression (issue #1614).
.changeset/fix-complexity-tag-fallback.md Publishes the bugfix as a patch release note for @tm/core.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1 to +6
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import * as fs from 'fs';
import * as path from 'path';
import * as os from 'os';
import { FileStorage } from '../../../src/modules/storage/adapters/file-storage/file-storage.js';

Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

This integration test file is missing the standard file-level header comment (e.g., @fileoverview) that other tests in tests/integration/storage use. Adding a short header describing the scenario and regression (issue #1614) would keep test documentation consistent and make intent easier to scan in the suite.

Copilot uses AI. Check for mistakes.
Comment on lines +55 to +59
const availableKeys = Object.keys(data).filter(
(key) => key !== 'tasks' && key !== 'metadata'
);
if (tag === 'master' && availableKeys.length > 0) {
return availableKeys[0];
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

resolveTag() re-implements the same legacy fallback-tag selection logic that already exists in extractTasksFromLegacy() and extractMetadataFromLegacy(). To prevent future drift between these code paths, consider extracting a single private helper (e.g., “resolveLegacyTag”) and reusing it in all three places.

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +3
import { describe, expect, it } from 'vitest';
import { FormatHandler } from './format-handler.js';

Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

This new spec file doesn’t include a file-level header comment (e.g., @fileoverview), while other spec files in this package typically do. Adding a short header helps keep test intent discoverable when browsing the src/ tree.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
.changeset/fix-complexity-tag-fallback.md (1)

5-5: Tighten the changeset summary to one concise user-facing sentence.

This currently mixes user impact with implementation detail. Consider keeping only the user-visible behavior change.

✍️ Suggested wording
-Fix complexity data not showing in `list` after `analyze-complexity` with tags. When tasks are stored under a non-master tag and the list command defaults to 'master', complexity data from the tag-specific report is now correctly loaded.
+Show computed complexity in `task-master list` after `analyze-complexity` when using tags.

Based on learnings: "Provide a concise, single-line changeset summary in imperative mood ... from a user/consumer perspective, not implementation details."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.changeset/fix-complexity-tag-fallback.md at line 5, Replace the current
multi-part summary in .changeset/fix-complexity-tag-fallback.md with a single
concise, imperative user-facing sentence (drop implementation details like "when
tasks are stored under a non-master tag" or "defaults to 'master'"); for
example, state the user-visible effect such as "Load complexity data from
tag-specific reports when listing tasks" ensuring it's one line, imperative
mood, and focused on behavior change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In @.changeset/fix-complexity-tag-fallback.md:
- Line 5: Replace the current multi-part summary in
.changeset/fix-complexity-tag-fallback.md with a single concise, imperative
user-facing sentence (drop implementation details like "when tasks are stored
under a non-master tag" or "defaults to 'master'"); for example, state the
user-visible effect such as "Load complexity data from tag-specific reports when
listing tasks" ensuring it's one line, imperative mood, and focused on behavior
change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 77479f2f-dc29-4fcb-bde4-cadd567727c0

📥 Commits

Reviewing files that changed from the base of the PR and between 2d1211b and add4239.

📒 Files selected for processing (5)
  • .changeset/fix-complexity-tag-fallback.md
  • packages/tm-core/src/modules/storage/adapters/file-storage/file-storage.ts
  • packages/tm-core/src/modules/storage/adapters/file-storage/format-handler.spec.ts
  • packages/tm-core/src/modules/storage/adapters/file-storage/format-handler.ts
  • packages/tm-core/tests/integration/storage/complexity-tag-fallback.test.ts

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.

bug: task complexity is not shown in list after analyze-complexity

2 participants