refactor(interfaces): T-211 take project_id payload in tasks_list (closes #79)#105
Conversation
…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 is reviewing your PR. |
ⓘ 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. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThe PR refactors ChangesProject ID Payload Refactoring
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
CodeAnt AI finished reviewing your PR. |
User description
Summary
DEFAULT_PROJECT_ID = 1const fromsrc-tauri/src/interfaces/tauri_commands/tasks.rsand acceptproject_id: i64as a flat positional payload parameter on thetasks_listIPC command.service::list_tasks+LibsqlTaskRepo::listalready acceptproject_id; this PR only realigns the adapter and the renderer with that contract. Mirrors thetasks_createprecedent (T-206) for single-i64payloads — noTasksListArgsts-rs struct, noscripts/codegen-types.ts/src/shared/types/drift-gate change.src/shared/ipc/tasks.ts#invokeTasksListgains aprojectId: numberargument that flat-spreads intoinvoke("tasks_list", { project_id }). Snake_case key matches the Rust parameter — no#[serde(rename = …)]shim needed.src/App.tsxintroduces a transitionalDEFAULT_PROJECT_ID = 1module const passed intoinvokeTasksList. A future sibling Sprint 2 task lands the renderer-side project picker /useProjectStoreand 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
Sprint 2 (T-200+) will replace it with a project_id argument) and finishes bringing everytasks_*IPC adapter under the payload-driven contract started by T-206 / T-207 / T-208 / T-209.Changes
src-tauri/src/interfaces/tauri_commands/tasks.rs: dropDEFAULT_PROJECT_ID = 1, addproject_id: i64totasks_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-levelconst DEFAULT_PROJECT_ID = 1+invokeTasksList(DEFAULT_PROJECT_ID)call.src/shared/ipc/tasks.test.ts: existing happy-path test now passesDEFAULT_PROJECT_IDand asserts the{ project_id: 1 }payload; newforwards a non-default project id into the invoke payloadtest pinning argument-forwarding withNON_DEFAULT_PROJECT_ID = 42.src/App.test.tsx: threetoHaveBeenCalledWith/toHaveBeenNthCalledWithassertions (task-store hydration + StrictMode double-mount) updated to{ project_id: 1 }.CHANGELOG.md: new### Changedsection under## [Unreleased]documenting the IPC contract change, renderer wiring, and the transitional renderer const.Notes on what did not change
service::list_tasks+TaskRepository::list+LibsqlTaskRepo::listwere alreadyproject_id-parameterised since T-111 — no change needed.tasks_list_is_pub_reachable_from_module_rootkeeps 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).TasksListArgsts-rs payload-contract struct is added (single-i64payload follows thetasks_create/tasks_deleteprecedent — the<Cmd>Argsalias only earns its keep on multi-field payloads carrying a typed newtype likeTaskId, cf.TasksUpdateArgs/TasksMoveArgs).bin/specta-export.rsupgrade to a realtauri_specta::Builderis still T-121; until thencommands.tskeeps 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-rsserde(transparent)proc-macro parse warnings on newtype IDs, same baseline as T-205 / T-207 / T-208 / T-209 — these are emitted by thets-rsproc-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-existinglicense-not-encounteredhints forAGPL-3.0-or-laterandUnicode-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 newforwards a non-default project id into the invoke payloadtest).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; onlyknip.jsonconfig tuning hints.Acceptance criteria
tasks_list(state, project_id)signature compiled and re-exported.Closes #79.
CodeAnt-AI Description
Load tasks for the selected project
What Changed
tasks_listnow receives a project id from the caller instead of always using the built-in default project1through the IPC request, and the task list tests were updated to expect that payloadImpact
✅ 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:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
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:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
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