Skip to content

feat: add api-storage improvements#1278

Merged
Crunchyman-ralph merged 6 commits intonextfrom
ralph/fix/batch.fixes.for.demo
Oct 6, 2025
Merged

feat: add api-storage improvements#1278
Crunchyman-ralph merged 6 commits intonextfrom
ralph/fix/batch.fixes.for.demo

Conversation

@Crunchyman-ralph
Copy link
Collaborator

@Crunchyman-ralph Crunchyman-ralph commented Oct 6, 2025

What type of PR is this?

  • 🐛 Bug fix
  • ✨ Feature
  • 🔌 Integration
  • 📝 Docs
  • 🧹 Refactor
  • Other:

Description

  • improve set-status command
  • improve metadata handling
  • improve dependency fetching (now display display_id)
  • improve subtask display (in tm list and tm show)

Related Issues

How to Test This

# Example commands or steps

Expected result:

Contributor Checklist

  • Created changeset: npm run changeset
  • Tests pass: npm test
  • Format check passes: npm run format-check (or npm run format to fix)
  • Addressed CodeRabbit comments (if any)
  • Linked related issues (if any)
  • Manually tested the changes

Changelog Entry


For Maintainers

  • PR title follows conventional commits
  • Target branch correct
  • Labels added
  • Milestone assigned (if applicable)

Summary by CodeRabbit

  • New Features

    • Colored subtask complexity display when available; table layout improved for readability.
  • Bug Fixes / Compatibility

    • Subtask IDs now display as simple IDs (no parent-prefixed IDs).
    • Better cross-storage compatibility: dependency handling and ID formats now support API/display IDs.
  • Chores

    • Removed the “Using X storage” console message after status updates.
  • Tests

    • Added unit tests for task mapping, metadata extraction, and status mapping.

- improve set-status by removing what storage its using
- add context-validator
- improve task mapper to better handle metadata if it exists
- add dependency-fetcher class that separates the domain of dependency fetching separately.
@changeset-bot
Copy link

changeset-bot bot commented Oct 6, 2025

⚠️ No Changeset found

Latest commit: 772684b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 6, 2025

Walkthrough

Subtask IDs and types normalized to strings across CLI and core; CLI rendering and task table layout adjusted; TaskMapper metadata and dependency handling updated; added Supabase DependencyFetcher and repository refactor to fetch dependencies by display_id; new repository types and TaskMapper tests added.

Changes

Cohort / File(s) Summary
CLI commands
apps/cli/src/commands/list.command.ts, apps/cli/src/commands/set-status.command.ts
List: compact subtask IDs now rendered as String(subtask.id). Set-status: removed storage-type console log.
CLI UI components & utils
apps/cli/src/ui/components/task-detail.component.ts, apps/cli/src/utils/ui.ts
displaySubtasks signature removed parentId; calls updated to pass only subtasks. Table column widths adjusted; subtask complexity now renders getComplexityWithColor(number) when numeric, otherwise --.
Core entity and types
packages/tm-core/src/entities/task.entity.ts, packages/tm-core/src/types/index.ts
Subtask ID normalization changed to String(subtask.id); Subtask.id type widened to `number
Task mapping
packages/tm-core/src/mappers/TaskMapper.ts, packages/tm-core/src/mappers/TaskMapper.test.ts
mapDatabaseTasksToTasks accepts `Map<string,string[]>
Supabase repository & fetcher
packages/tm-core/src/repositories/supabase/dependency-fetcher.ts, packages/tm-core/src/repositories/supabase/supabase-task-repository.ts, packages/tm-core/src/repositories/supabase/index.ts
Added DependencyFetcher.fetchDependenciesWithDisplayIds; repository now uses AuthManager to obtain briefId, integrates DependencyFetcher for task/subtask dependencies, merges metadata on update, and maps priorities; barrel file re-exports repo and fetcher.
Storage import update
packages/tm-core/src/storage/api-storage.ts
Import updated to use .../repositories/supabase/index.js barrel; no logic change.
Repository types
packages/tm-core/src/types/repository-types.ts
New exported types and errors: TaskWithRelations, DependencyWithDisplayId, TaskMetadata, TaskDatabaseUpdate, TaskQueryConfig, TaskFetchResult, TaskValidationError, ContextValidationError.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor CLI as CLI
  participant Repo as SupabaseTaskRepository
  participant Auth as AuthManager
  participant DB as Supabase
  participant Dep as DependencyFetcher
  participant Mapper as TaskMapper

  CLI->>Repo: getTasks()
  Repo->>Auth: getContext()
  Auth-->>Repo: { briefId }
  Repo->>DB: select tasks by briefId (+relations)
  DB-->>Repo: Task rows
  Repo->>Dep: fetchDependenciesWithDisplayIds(taskIds)
  Dep->>DB: select task_dependencies join tasks(display_id)
  DB-->>Dep: dependency rows (with display_id)
  Dep-->>Repo: Map<task_id, display_id[]>
  Repo->>Mapper: mapDatabaseTasksToTasks(rows, depMap)
  Mapper-->>Repo: Mapped Tasks
  Repo-->>CLI: Tasks
Loading
sequenceDiagram
  autonumber
  actor CLI as CLI
  participant Repo as SupabaseTaskRepository
  participant Auth as AuthManager
  participant DB as Supabase
  participant Dep as DependencyFetcher
  participant Mapper as TaskMapper

  CLI->>Repo: getTask(id)
  Repo->>Auth: getContext()
  Auth-->>Repo: { briefId }
  Repo->>DB: select task by id & briefId (+subtasks)
  DB-->>Repo: Task row + subtasks
  Repo->>Dep: fetchDependenciesWithDisplayIds([taskId, ...subtaskIds])
  Dep->>DB: dependency query with join
  DB-->>Dep: dependencies with display_id
  Dep-->>Repo: Map<task_id, display_id[]>
  Repo->>Mapper: mapDatabaseTasksToTasks(rows, depMap)
  Mapper-->>Repo: Task with dependencies
  Repo-->>CLI: Task
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • eyaltoledano

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title Check ⚠️ Warning The title only mentions “api-storage improvements” even though the pull request also introduces CLI enhancements for set-status and list commands, metadata handling updates, dependency fetching changes, and subtask display refinements, so it fails to accurately convey the primary scope of the changes. A reviewer seeing the title would miss the breadth of updates beyond API-storage path adjustments. Therefore it does not clearly summarize the main intent of the changeset. Please rename the pull request to succinctly reflect the core updates, for example “feat: improve CLI commands, metadata handling, and dependency fetching” or “feat: enhance subtask display, metadata, and API storage path resolution” so that the title matches the main scope of the changes.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ralph/fix/batch.fixes.for.demo

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eb0177b and 772684b.

📒 Files selected for processing (1)
  • packages/tm-core/src/repositories/supabase/index.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-26T19:05:47.555Z
Learnt from: Crunchyman-ralph
PR: eyaltoledano/claude-task-master#1252
File: packages/ai-sdk-provider-grok-cli/package.json:11-13
Timestamp: 2025-09-26T19:05:47.555Z
Learning: In the eyaltoledano/claude-task-master repository, internal tm/ packages use a specific export pattern where the "exports" field points to TypeScript source files (./src/index.ts) while "main" points to compiled output (./dist/index.js) and "types" points to source files (./src/index.ts). This pattern is used consistently across internal packages like tm/core and tm/ai-sdk-provider-grok-cli because they are consumed directly during build-time bundling with tsdown rather than being published as separate packages.

Applied to files:

  • packages/tm-core/src/repositories/supabase/index.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test
🔇 Additional comments (1)
packages/tm-core/src/repositories/supabase/index.ts (1)

1-5: LGTM – barrel file and imports verified

SupabaseTaskRepository and DependencyFetcher are correctly re-exported in packages/tm-core/src/repositories/supabase/index.ts and imported from packages/tm-core/src/storage/api-storage.ts.


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

Copy link
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.

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/tm-core/src/types/index.ts (1)

230-236: Allow string subtask IDs in the type guard

isSubtask still insists on typeof subtask.id === 'number', so any subtask coming from API storage with a string display_id now fails the guard and gets rejected downstream. Please accept both numeric and string IDs here to match the new Subtask contract.

-		typeof subtask.id === 'number' &&
+		(typeof subtask.id === 'number' || typeof subtask.id === 'string') &&
packages/tm-core/src/mappers/TaskMapper.ts (1)

98-123: Clarify deprecation notice.

The deprecation notice correctly marks this method as legacy but doesn't specify what should be used instead or where the new implementation lives.

Update the deprecation notice to be more specific:

 	/**
 	 * Groups dependencies by task ID (legacy method for backward compatibility)
-	 * @deprecated Use DependencyFetcher.fetchDependenciesWithDisplayIds instead
+	 * @deprecated Use DependencyFetcher.fetchDependenciesWithDisplayIds from '@/repositories/supabase' instead
 	 */
♻️ Duplicate comments (1)
packages/tm-core/src/types/repository-types.ts (1)

18-26: Duplicate type definition (referenced earlier).

This DependencyWithDisplayId interface is identical to the one defined in packages/tm-core/src/repositories/supabase/dependency-fetcher.ts (lines 5-10). As noted in the review of dependency-fetcher.ts, keeping this definition here and importing it there would be the correct approach since this is the types file.

The resolution should be to keep this definition here and remove the duplicate from dependency-fetcher.ts.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7b5a7c4 and 0ee5c55.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (12)
  • apps/cli/src/commands/list.command.ts (2 hunks)
  • apps/cli/src/commands/set-status.command.ts (0 hunks)
  • apps/cli/src/ui/components/task-detail.component.ts (3 hunks)
  • apps/cli/src/utils/ui.ts (2 hunks)
  • packages/tm-core/src/entities/task.entity.ts (1 hunks)
  • packages/tm-core/src/mappers/TaskMapper.ts (5 hunks)
  • packages/tm-core/src/repositories/supabase/dependency-fetcher.ts (1 hunks)
  • packages/tm-core/src/repositories/supabase/index.ts (1 hunks)
  • packages/tm-core/src/repositories/supabase/supabase-task-repository.ts (8 hunks)
  • packages/tm-core/src/storage/api-storage.ts (1 hunks)
  • packages/tm-core/src/types/index.ts (1 hunks)
  • packages/tm-core/src/types/repository-types.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • apps/cli/src/commands/set-status.command.ts
🧰 Additional context used
🧠 Learnings (10)
📚 Learning: 2025-07-18T17:09:45.690Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/dependencies.mdc:0-0
Timestamp: 2025-07-18T17:09:45.690Z
Learning: Applies to scripts/modules/dependency-manager.js : Allow numeric subtask IDs to reference other subtasks within the same parent

Applied to files:

  • apps/cli/src/ui/components/task-detail.component.ts
  • packages/tm-core/src/entities/task.entity.ts
  • packages/tm-core/src/types/index.ts
📚 Learning: 2025-07-18T17:09:45.690Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/dependencies.mdc:0-0
Timestamp: 2025-07-18T17:09:45.690Z
Learning: Applies to scripts/modules/dependency-manager.js : Format task and dependency IDs consistently when adding dependencies

Applied to files:

  • apps/cli/src/ui/components/task-detail.component.ts
  • packages/tm-core/src/mappers/TaskMapper.ts
📚 Learning: 2025-07-18T17:09:40.548Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/dependencies.mdc:0-0
Timestamp: 2025-07-18T17:09:40.548Z
Learning: Applies to scripts/modules/dependency-manager.js : Represent task dependencies as arrays of task IDs

Applied to files:

  • apps/cli/src/ui/components/task-detail.component.ts
  • packages/tm-core/src/repositories/supabase/dependency-fetcher.ts
  • packages/tm-core/src/mappers/TaskMapper.ts
📚 Learning: 2025-07-18T17:09:40.548Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/dependencies.mdc:0-0
Timestamp: 2025-07-18T17:09:40.548Z
Learning: Applies to scripts/modules/dependency-manager.js : Use string IDs with dot notation (e.g., "1.2") for subtask references

Applied to files:

  • apps/cli/src/ui/components/task-detail.component.ts
📚 Learning: 2025-07-18T17:09:45.690Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/dependencies.mdc:0-0
Timestamp: 2025-07-18T17:09:45.690Z
Learning: Applies to scripts/modules/dependency-manager.js : Support both task and subtask dependencies in cycle detection

Applied to files:

  • apps/cli/src/ui/components/task-detail.component.ts
  • packages/tm-core/src/mappers/TaskMapper.ts
📚 Learning: 2025-07-18T17:14:29.399Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/tasks.mdc:0-0
Timestamp: 2025-07-18T17:14:29.399Z
Learning: Applies to scripts/modules/task-manager.js : Allow filtering tasks by status within the current tag context, handle subtask display in lists, and use consistent table formats.

Applied to files:

  • apps/cli/src/ui/components/task-detail.component.ts
📚 Learning: 2025-07-18T17:16:32.622Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/ui.mdc:0-0
Timestamp: 2025-07-18T17:16:32.622Z
Learning: Applies to scripts/modules/ui.js : Use cli-table3 for table rendering, include colored bold headers, and set appropriate column widths for readability

Applied to files:

  • apps/cli/src/utils/ui.ts
📚 Learning: 2025-09-26T19:05:47.555Z
Learnt from: Crunchyman-ralph
PR: eyaltoledano/claude-task-master#1252
File: packages/ai-sdk-provider-grok-cli/package.json:11-13
Timestamp: 2025-09-26T19:05:47.555Z
Learning: In the eyaltoledano/claude-task-master repository, internal tm/ packages use a specific export pattern where the "exports" field points to TypeScript source files (./src/index.ts) while "main" points to compiled output (./dist/index.js) and "types" points to source files (./src/index.ts). This pattern is used consistently across internal packages like tm/core and tm/ai-sdk-provider-grok-cli because they are consumed directly during build-time bundling with tsdown rather than being published as separate packages.

Applied to files:

  • packages/tm-core/src/repositories/supabase/index.ts
📚 Learning: 2025-07-18T17:14:29.399Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/tasks.mdc:0-0
Timestamp: 2025-07-18T17:14:29.399Z
Learning: Applies to scripts/modules/task-manager.js : Subtasks must use consistent properties, maintain simple numeric IDs unique within the parent task, and must not duplicate parent task properties.

Applied to files:

  • packages/tm-core/src/entities/task.entity.ts
  • packages/tm-core/src/types/index.ts
📚 Learning: 2025-09-25T22:08:11.075Z
Learnt from: Crunchyman-ralph
PR: eyaltoledano/claude-task-master#1248
File: packages/tm-core/src/storage/api-storage.ts:509-0
Timestamp: 2025-09-25T22:08:11.075Z
Learning: In API storage backend, subtasks have unique IDs (like "HAM-21") and use a separate parent_id column to establish parent-child relationships, rather than using dotted notation like file storage (e.g., "21.1").

Applied to files:

  • packages/tm-core/src/types/index.ts
🧬 Code graph analysis (4)
packages/tm-core/src/types/repository-types.ts (1)
packages/tm-core/src/types/database.types.ts (2)
  • Tables (413-436)
  • Database (9-411)
packages/tm-core/src/repositories/supabase/dependency-fetcher.ts (1)
packages/tm-core/src/types/database.types.ts (1)
  • Database (9-411)
packages/tm-core/src/repositories/supabase/supabase-task-repository.ts (4)
packages/tm-core/src/repositories/supabase/dependency-fetcher.ts (1)
  • DependencyFetcher (15-75)
packages/tm-core/src/types/database.types.ts (2)
  • Database (9-411)
  • Json (1-7)
packages/tm-core/src/types/repository-types.ts (2)
  • TaskWithRelations (9-16)
  • TaskDatabaseUpdate (40-41)
packages/tm-core/src/mappers/TaskMapper.ts (1)
  • TaskMapper (12-199)
packages/tm-core/src/mappers/TaskMapper.ts (2)
packages/tm-core/src/types/database.types.ts (1)
  • Tables (413-436)
packages/tm-core/src/types/index.ts (1)
  • Task (57-82)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test
🔇 Additional comments (8)
packages/tm-core/src/repositories/supabase/dependency-fetcher.ts (1)

50-74: LGTM with minor note.

The data processing logic correctly handles null/undefined cases and safely extracts display_ids. The Map construction is efficient.

Minor note: Consider adding a comment explaining why entries without task_id are skipped (line 60), as this could help future maintainers understand the data quality expectations.

packages/tm-core/src/mappers/TaskMapper.ts (4)

6-10: LGTM!

The DependencyRow type provides good backward compatibility by supporting both the old depends_on_task_id format and the new depends_on_task.display_id format.


18-30: LGTM!

The backward-compatible approach to handling both Map and array formats for dependencies is well-implemented. The instanceof check cleanly differentiates between the two formats.


63-68: LGTM!

The refactoring to use extractMetadataField improves consistency and maintainability by centralizing metadata access logic.

Also applies to: 82-87


72-72: Remove redundant nullish coalescing.

The ?? undefined operator is redundant when complexity is already number | null. The nullish coalescing operator converts null to undefined, but this conversion is unnecessary if the receiving property accepts undefined already. TypeScript will handle the number | nullnumber | undefined conversion automatically.

Apply this diff to simplify:

-		complexity: subtask.complexity ?? undefined
+		complexity: subtask.complexity || undefined

And similarly on line 92:

-	complexity: dbTask.complexity ?? undefined,
+	complexity: dbTask.complexity || undefined,

Note: Use || undefined instead of ?? undefined only if you want to treat 0 as falsy. If 0 is a valid complexity value, keep ?? undefined or just use subtask.complexity directly if the type signature allows null.

Also applies to: 92-92

⛔ Skipped due to learnings
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/tasks.mdc:0-0
Timestamp: 2025-07-18T17:14:29.399Z
Learning: Applies to scripts/modules/task-manager.js : Use AI to generate detailed subtasks within the current tag context, considering complexity analysis for subtask counts and ensuring proper IDs for newly created subtasks.
packages/tm-core/src/types/repository-types.ts (3)

1-16: LGTM!

The TaskWithRelations interface correctly extends the base task type with an optional document relation, matching the database schema structure.


28-59: LGTM!

The type definitions for TaskMetadata, TaskDatabaseUpdate, TaskQueryConfig, and TaskFetchResult are well-structured and provide clear contracts for repository operations.


61-83: LGTM!

The custom error classes follow best practices by:

  • Extending the base Error class
  • Setting the name property for better error identification
  • Including contextual information (field/value for TaskValidationError)

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