Skip to content

feat(command-center): autofill empty cells with recent active tasks#2212

Open
richardsolomou wants to merge 2 commits into
mainfrom
posthog-code/command-center-autofill-recent-tasks
Open

feat(command-center): autofill empty cells with recent active tasks#2212
richardsolomou wants to merge 2 commits into
mainfrom
posthog-code/command-center-autofill-recent-tasks

Conversation

@richardsolomou
Copy link
Copy Markdown
Member

@richardsolomou richardsolomou commented May 19, 2026

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 — new autofillCells(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 of task.updated_at and latest_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. A useRef guard 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

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
@richardsolomou richardsolomou requested a review from a team May 19, 2026 03:27
@richardsolomou richardsolomou marked this pull request as ready for review May 19, 2026 03:28
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 19, 2026

Prompt To Fix All With AI
Fix 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

Comment thread apps/code/src/renderer/features/command-center/hooks/useAutofillCommandCenter.ts Outdated
Comment thread apps/code/src/renderer/features/command-center/stores/commandCenterStore.test.ts Outdated
…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
@richardsolomou richardsolomou added the Create Release This will trigger a new release label May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Create Release This will trigger a new release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show active and recent tasks in the command center by default instead of requiring manual addition

1 participant