feat(command-center): autofill empty cells with recent active tasks#2212
Open
richardsolomou wants to merge 2 commits into
Open
feat(command-center): autofill empty cells with recent active tasks#2212richardsolomou wants to merge 2 commits into
richardsolomou wants to merge 2 commits into
Conversation
When the user opens the Command Center and no tasks are attached, populate empty cells with their tasks updated in the past 2 hours, ordered by most recent activity. Generated-By: PostHog Code Task-Id: 427c51ec-695b-4203-9ac2-bb79ea575422
Contributor
Prompt To Fix All With AIFix the following 3 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 3
apps/code/src/renderer/features/command-center/hooks/useAutofillCommandCenter.ts:19-20
The hook guards on `workspacesFetched` but has no equivalent guard for the tasks query. `useTasks()` returns its data defaulted to `[]`, so if workspaces resolve first (common when they are cached from a previous mount), the effect fires immediately with an empty `tasks` array, finds zero candidates, sets `hasRunRef.current = true`, and exits. When the tasks response eventually arrives, the dependency change re-runs the effect — but `hasRunRef.current` is already `true`, so it bails. The autofill silently never runs.
```suggestion
const { data: tasks = [], isFetched: tasksFetched } = useTasks();
const { data: workspaces, isFetched: workspacesFetched } = useWorkspaces();
```
### Issue 2 of 3
apps/code/src/renderer/features/command-center/hooks/useAutofillCommandCenter.ts:30
The `workspacesFetched` guard needs a parallel `tasksFetched` guard so the effect waits for both data sources before proceeding.
```suggestion
if (!workspacesFetched || !workspaces) return;
if (!tasksFetched) return;
```
### Issue 3 of 3
apps/code/src/renderer/features/command-center/stores/commandCenterStore.test.ts:26-73
The five `autofillCells` tests share the same pattern — `setState`, call `autofillCells(input)`, assert `cells`. The team's preference is parameterised tests. The first, third, fourth, and fifth cases could be collapsed into a single `it.each` table covering `(input, expectedCells, expectedActiveTaskId)`, reducing duplication and making it easy to add edge cases in future.
Reviews (1): Last reviewed commit: "feat(command-center): autofill empty cel..." | Re-trigger Greptile |
…ests Address Greptile review on PR #2212: - The hook only waited on workspaces. useTasks() defaults data to [], so if workspaces were cached and resolved first the effect ran with an empty tasks array, found zero candidates, set hasRunRef true and bailed — the later tasks response could never trigger the autofill. Add a tasksFetched guard so both sources must be loaded. - Collapse the autofillCells test trio into an it.each table per repo convention. Generated-By: PostHog Code Task-Id: 427c51ec-695b-4203-9ac2-bb79ea575422
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When opening the Command Center with no tasks attached, users have to manually re-pick the same tasks they were just working on. This adds friction every time they return to the view.
Closes #1630
Changes
commandCenterStore.ts— newautofillCells(taskIds)action; no-op if any cell is already populated.useAutofillCommandCenter.ts— new hook that, on mount, finds tasks updated within the last 2 hours (max oftask.updated_atandlatest_run.updated_at), filters to non-archived tasks with a workspace, sorts by most recent activity, and assigns up to the grid size into the empty cells.CommandCenterView.tsx— calls the hook on mount. AuseRefguard runs the autofill at most once per mount, so manually clearing cells mid-session does not re-trigger it; navigating away and back does.commandCenterStore.test.ts— 5 unit tests covering the empty-cell guard, full-cell short-circuit, cell-count cap, empty-input no-op, and active-task-id non-effect.How did you test this?
pnpm --filter code typecheck— passes.pnpm --filter code test commandCenterStore— 5/5 tests pass.pnpm lint— clean (biome auto-formatted one file).Manual UI verification not run — flagging explicitly per the agent guidelines.
Publish to changelog?
no
Created with PostHog Code