Skip to content

refactor(interfaces): T-211 take project_id payload in tasks_list (closes #79)#105

Merged
mpiton merged 1 commit into
mainfrom
feat/i-79-tasks-list-project-id
May 12, 2026
Merged

refactor(interfaces): T-211 take project_id payload in tasks_list (closes #79)#105
mpiton merged 1 commit into
mainfrom
feat/i-79-tasks-list-project-id

Conversation

@mpiton
Copy link
Copy Markdown
Owner

@mpiton mpiton commented May 12, 2026

User description

Summary

  • Drop the Sprint 1 DEFAULT_PROJECT_ID = 1 const from src-tauri/src/interfaces/tauri_commands/tasks.rs and accept project_id: i64 as a flat positional payload parameter on the tasks_list IPC command.
  • Domain port + service::list_tasks + LibsqlTaskRepo::list already accept project_id; this PR only realigns the adapter and the renderer with that contract. Mirrors the tasks_create precedent (T-206) for single-i64 payloads — no TasksListArgs ts-rs struct, no scripts/codegen-types.ts / src/shared/types/ drift-gate change.
  • Frontend wrapper src/shared/ipc/tasks.ts#invokeTasksList gains a projectId: number argument that flat-spreads into invoke("tasks_list", { project_id }). Snake_case key matches the Rust parameter — no #[serde(rename = …)] shim needed.
  • src/App.tsx introduces a transitional DEFAULT_PROJECT_ID = 1 module const passed into invokeTasksList. A future sibling Sprint 2 task lands the renderer-side project picker / useProjectStore and swaps the const for the store-selected id. T-204 closed the projects domain backend; the renderer-side store is the dedicated follow-up the issue body refers to ("the currently selected project from useProjectStore").

Why

  • T-211 closes the T-200 carry-over flagged in the T-118 review note (Sprint 2 (T-200+) will replace it with a project_id argument) and finishes bringing every tasks_* IPC adapter under the payload-driven contract started by T-206 / T-207 / T-208 / T-209.
  • The Rust const was the last hold-out from the Sprint 1 single-project bootstrap — leaving it in place would lock the renderer to a single hardcoded project once the Sprint 2 project picker ships.

Changes

  • src-tauri/src/interfaces/tauri_commands/tasks.rs: drop DEFAULT_PROJECT_ID = 1, add project_id: i64 to tasks_list, rewrite the module-level rustdoc tour to remove the const reference and add the T-211 line. New signature: pub async fn tasks_list(state: tauri::State<'_, Arc<AppContainer>>, project_id: i64) -> Result<Vec<Task>, AppError> — verbatim from the issue spec.
  • src/shared/ipc/tasks.ts: invokeTasksList(projectId: number) flat-spreads { project_id: projectId } into the Tauri payload.
  • src/App.tsx: module-level const DEFAULT_PROJECT_ID = 1 + invokeTasksList(DEFAULT_PROJECT_ID) call.
  • src/shared/ipc/tasks.test.ts: existing happy-path test now passes DEFAULT_PROJECT_ID and asserts the { project_id: 1 } payload; new forwards a non-default project id into the invoke payload test pinning argument-forwarding with NON_DEFAULT_PROJECT_ID = 42.
  • src/App.test.tsx: three toHaveBeenCalledWith / toHaveBeenNthCalledWith assertions (task-store hydration + StrictMode double-mount) updated to { project_id: 1 }.
  • CHANGELOG.md: new ### Changed section under ## [Unreleased] documenting the IPC contract change, renderer wiring, and the transitional renderer const.

Notes on what did not change

  • Domain service::list_tasks + TaskRepository::list + LibsqlTaskRepo::list were already project_id-parameterised since T-111 — no change needed.
  • Module compile-time anchor test tasks_list_is_pub_reachable_from_module_root keeps passing via type-inference: let _command_fn_pointer = super::tasks::tasks_list; captures whatever the current signature is, so no new anchor was added (matches the T-206 / T-207 / T-208 / T-209 pattern of only adding new anchors for new commands).
  • No TasksListArgs ts-rs payload-contract struct is added (single-i64 payload follows the tasks_create / tasks_delete precedent — the <Cmd>Args alias only earns its keep on multi-field payloads carrying a typed newtype like TaskId, cf. TasksUpdateArgs / TasksMoveArgs).
  • bin/specta-export.rs upgrade to a real tauri_specta::Builder is still T-121; until then commands.ts keeps its Sprint 1 placeholder.

Testing

  • cargo test --workspace --manifest-path src-tauri/Cargo.toml — 241/241 pass (was 239/239 before T-211; +2 is auto-generated ts-rs export tests landing as soon as #[derive(TS)] is wired… wait no, no new struct was added — counted re-run gave 241/241 because the pre-T-211 baseline already included T-210's projects_create / projects_list anchor tests landed in commit a46b1f6).
  • cargo clippy --workspace --all-targets --manifest-path src-tauri/Cargo.toml -- -D warnings — 0 errors (10 pre-existing ts-rs serde(transparent) proc-macro parse warnings on newtype IDs, same baseline as T-205 / T-207 / T-208 / T-209 — these are emitted by the ts-rs proc-macro at compile time, not clippy lints).
  • cargo fmt --check --manifest-path src-tauri/Cargo.toml — clean.
  • cargo deny --manifest-path src-tauri/Cargo.toml check — advisories ok, bans ok, licenses ok, sources ok (two pre-existing license-not-encountered hints for AGPL-3.0-or-later and Unicode-DFS-2016, baseline).
  • cargo test --test architecture — 2/2 pass; no infra imports leaked into the adapter.
  • pnpm exec vitest run — 107/107 pass (includes the new forwards a non-default project id into the invoke payload test).
  • pnpm exec tsc -b — clean.
  • pnpm exec oxlint . — 0 warnings 0 errors.
  • pnpm exec oxfmt --check src/ — clean on the project-tracked surface (pre-existing .auto-claude/ artifact noise unchanged).
  • pnpm exec knip — no unused exports / files / deps; only knip.json config tuning hints.

Acceptance criteria

  • Const removed.
  • tasks_list(state, project_id) signature compiled and re-exported.
  • Existing tests updated.
  • CHANGELOG entry under Changed.

Closes #79.


CodeAnt-AI Description

Load tasks for the selected project

What Changed

  • tasks_list now receives a project id from the caller instead of always using the built-in default project
  • The app startup call now passes project id 1 through the IPC request, and the task list tests were updated to expect that payload
  • The shared IPC helper now requires a project id and forwards it in the request body, including non-default project ids

Impact

✅ Tasks load for the chosen project
✅ Fewer hardcoded project mismatches
✅ Clearer task loading behavior in tests

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

Summary by CodeRabbit

  • Changed
    • Task list fetching has been updated to require explicit project specification instead of using a hardcoded default. The system now accepts project identification parameters when retrieving tasks, replacing the previous default-based approach and providing greater control over which project's tasks are loaded.

Review Change Stack

…oses #79)

Drop the Sprint 1 `DEFAULT_PROJECT_ID = 1` const from
`interfaces/tauri_commands/tasks.rs` and accept `project_id: i64` as a
flat positional payload parameter on the `tasks_list` IPC command. Domain
port + `service::list_tasks` + `LibsqlTaskRepo::list` already accept
`project_id`; this commit only realigns the adapter and the renderer
with the contract. Mirrors the `tasks_create` precedent (T-206) for
single-`i64` payloads — no `TasksListArgs` ts-rs struct, no codegen
drift gate change.

`src/shared/ipc/tasks.ts` `invokeTasksList` gains a `projectId: number`
argument that flat-spreads into `invoke("tasks_list", { project_id })`.
`src/App.tsx` introduces a transitional `DEFAULT_PROJECT_ID = 1` module
const that will be swapped for the `useProjectStore`-selected id once
the renderer-side project picker / store lands as a sibling Sprint 2
task (T-204 closed the projects domain backend only).

Tests updated:
- `src/shared/ipc/tasks.test.ts`: existing happy-path asserts the
  payload, plus new `forwards a non-default project id into the invoke
  payload` test pinning the wrapper's argument-forwarding contract.
- `src/App.test.tsx`: three `toHaveBeenCalledWith` /
  `toHaveBeenNthCalledWith` assertions in the task-store hydration +
  StrictMode double-mount tests now expect `{ project_id: 1 }`.

Compile-time anchor test `tasks_list_is_pub_reachable_from_module_root`
keeps passing via type-inference. Domain / service / port / libsql
adapter tests untouched — `list_tasks_returns_inserted_tasks_for_project`
and the four `LibsqlTaskRepo::list` integration tests already exercise
project_id pass-through and project isolation.

CHANGELOG: new `### Changed` section under `## [Unreleased]` documenting
the IPC contract change, renderer wiring, and the transitional renderer
const.

cargo test --workspace 241/241 pass; cargo clippy --workspace
--all-targets -- -D warnings clean (10 pre-existing ts-rs serde
transparent proc-macro warnings, same baseline as T-209); cargo fmt
--check, cargo deny check, pnpm exec vitest run, pnpm exec tsc -b,
pnpm exec oxlint . and pnpm exec oxfmt --check on touched files all
clean.
@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented May 12, 2026

CodeAnt AI is reviewing your PR.

@qodo-code-review
Copy link
Copy Markdown

ⓘ You've reached your Qodo monthly free-tier limit. Reviews pause until next month — upgrade your plan to continue now, or link your paid account if you already have one.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 61480106-c68b-4827-abcd-ef51191dcdd4

📥 Commits

Reviewing files that changed from the base of the PR and between a46b1f6 and 1c074b0.

📒 Files selected for processing (6)
  • CHANGELOG.md
  • src-tauri/src/interfaces/tauri_commands/tasks.rs
  • src/App.test.tsx
  • src/App.tsx
  • src/shared/ipc/tasks.test.ts
  • src/shared/ipc/tasks.ts

📝 Walkthrough

Walkthrough

The PR refactors tasks_list to accept project_id as a flat IPC payload parameter instead of using a Rust-side constant default, updating the TypeScript wrapper, frontend call-site, backend adapter, and all corresponding tests to reflect the new contract.

Changes

Project ID Payload Refactoring

Layer / File(s) Summary
IPC wrapper contract and documentation
src/shared/ipc/tasks.ts, CHANGELOG.md
invokeTasksList now accepts projectId: number and passes it as { project_id } payload to the Tauri command; changelog documents the contract change and removal of the Rust-side default constant.
IPC wrapper test expectations
src/shared/ipc/tasks.test.ts
Tests verify invoke("tasks_list", { project_id: ... }) is called for both default and non-default project IDs, and confirm error propagation from the backend.
App integration and test assertions
src/App.tsx, src/App.test.tsx
App defines DEFAULT_PROJECT_ID = 1 and passes it to invokeTasksList on mount; App tests verify the mocked invoke is called with ("tasks_list", { project_id: 1 }) including for StrictMode double-mount.
Rust backend adapter implementation
src-tauri/src/interfaces/tauri_commands/tasks.rs
The tasks_list command now accepts project_id: i64 and forwards it to service::list_tasks; module docs and comments updated to reflect the Sprint 2 payload-driven contract, removing the hardcoded-default pattern.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • mpiton/forgent#60: Originally added the typed frontend IPC wrapper invokeTasksList() and its tests; this PR updates the same wrapper signature to accept and pass the project_id parameter.
  • mpiton/forgent#53: Originally added the tasks_list Tauri command with a hardcoded DEFAULT_PROJECT_ID; this PR refactors the same command to accept project_id as a flat argument instead of using the default.
  • mpiton/forgent#64: Wired App.tsx to call invokeTasksList() on mount; this PR updates the same call-site to pass DEFAULT_PROJECT_ID as an argument.

Suggested labels

size:M

Poem

🐰 A project ID hops into the call,
No more defaults hardcoded at all,
From backend to button, the contract takes shape—
Each layer now knows which tasks to drape!

🚥 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 change: refactoring tasks_list to accept project_id as a payload parameter, with reference to issue #79.
Linked Issues check ✅ Passed All acceptance criteria from #79 are met: DEFAULT_PROJECT_ID const removed, tasks_list signature updated to take project_id, tests updated, and CHANGELOG entry added.
Out of Scope Changes check ✅ Passed All code changes are directly related to the objective of refactoring tasks_list to accept project_id; no unrelated modifications detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ 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 feat/i-79-tasks-list-project-id

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

@codeant-ai codeant-ai Bot added the size:M This PR changes 30-99 lines, ignoring generated files label May 12, 2026
@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented May 12, 2026

CodeAnt AI finished reviewing your PR.

@codspeed-hq
Copy link
Copy Markdown
Contributor

codspeed-hq Bot commented May 12, 2026

Merging this PR will not alter performance

✅ 7 untouched benchmarks


Comparing feat/i-79-tasks-list-project-id (1c074b0) with main (a46b1f6)

Open in CodSpeed

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 6 files

@mpiton mpiton merged commit f3a2ffc into main May 12, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

T-211: Refactor tasks_list to take project_id payload (closes T-200 carry-over)

1 participant