fix: restore Changes focus on task return (#2091)
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
---
|
||||
spec: docs/specs/ui/task-layout-profiles.md
|
||||
created: 2026-07-31
|
||||
status: complete
|
||||
---
|
||||
|
||||
# Implementation Plan: Restore Returning Task Changes Focus
|
||||
|
||||
## Overview
|
||||
|
||||
Restore the desktop workbench attention behavior for Git or commit updates that arrive while a task is inactive. The confirmed regression is the `hasSavedLayout` branch in `applyChangesPanelAutoFocusState`, introduced by `ba8d99f33`, which deletes pending focus instead of activating Changes for every previously opened task. The repair removes that blanket suppression while retaining first-observation baselining, restore-race deferral, page-refresh focus preservation, and the Agent-group safety check.
|
||||
|
||||
## Frontend
|
||||
|
||||
### Changes attention state
|
||||
|
||||
- `apps/web/components/task/changes-panel-focus.ts`: remove the saved-layout lookup and `hasSavedLayout` branch from `applyChangesPanelAutoFocusState`. A pending environment remains deferred while Dockview is restoring and activates Changes after restoration even when an environment layout exists.
|
||||
- Preserve `markInactiveChangesIncreases` semantics: an already-known non-zero count alone does not create attention on reload; only a count increase or meaningful non-zero fingerprint change while inactive queues attention.
|
||||
- Preserve `activateChangesPanel` semantics: a missing Changes panel is a terminal no-op, while a Changes panel grouped with Agent sessions is not force-activated.
|
||||
|
||||
### Responsive boundary
|
||||
|
||||
- `TaskLayout` mounts `DockviewDesktopLayout` only for the desktop workbench; mobile and tablet use their existing dedicated layouts. This repair changes no mobile composition, touch target, scrolling, navigation, or saved mobile state.
|
||||
- No mobile Playwright case is added because the affected hook is not mounted on mobile or tablet. Existing mobile task navigation remains the applicable parity path.
|
||||
|
||||
## Tests
|
||||
|
||||
- **Returning saved layout with pending changes:** update `apps/web/components/task/changes-panel-focus.test.ts` so a pending environment activates Changes despite having a saved layout. Write and run this expectation before changing production code; it must fail because the current branch clears the pending key.
|
||||
- **Reload with existing changes:** retain the first-observation and active-environment unit coverage proving an already-known non-zero marker does not queue attention.
|
||||
- **Restore race and panel safety:** retain coverage for restore deferral, missing panels, and Agent-group blocking.
|
||||
|
||||
## E2E Tests
|
||||
|
||||
- **Scenario:** GIVEN a desktop task with a saved Agent/Files panel and a Changes panel outside the Agent group, WHEN a Git update is detected while the task is inactive and the user returns, THEN Changes is active after layout restoration.
|
||||
- **File:** `apps/web/e2e/tests/layout/changes-panel-focus.spec.ts`.
|
||||
- Rename and reverse the regression added by `ba8d99f33`; run it against the current implementation before the production change and confirm it fails because the saved panel remains active.
|
||||
- Keep the existing page-refresh scenario to prove already-known changes do not steal focus.
|
||||
|
||||
## Implementation Tasks
|
||||
|
||||
- [x] [Task 01 - Restore pending Changes attention](task-01-restore-pending-changes-attention.md)
|
||||
|
||||
Execution is sequential in the primary conversation. There are no parallel-safe candidates because the unit test, state helper, and E2E scenario encode one behavior and must follow one Red-Green-Refactor cycle.
|
||||
|
||||
## Risks
|
||||
|
||||
- Removing too much baselining could make async Git hydration steal focus on page reload. The repair must remove only the saved-layout suppression.
|
||||
- Activating before Dockview restoration completes can target a stale or missing panel. Existing restore deferral and retry behavior must remain intact.
|
||||
- Changes must not steal focus when it shares a group with Agent session panels.
|
||||
- The worktree currently lacks `apps/node_modules`; run `pnpm install --frozen-lockfile` from `apps/` before the RED checks.
|
||||
|
||||
## Out of Scope
|
||||
|
||||
- Focusing Changes for every task with an already-known dirty workspace.
|
||||
- Changing mobile or tablet task-detail layouts.
|
||||
- Changing Dockview layout persistence, panel placement, or Git-status transport.
|
||||
- Public documentation changes; this restores previously intended workbench behavior without changing a public API or documented workflow.
|
||||
|
||||
## Verification Results
|
||||
|
||||
- RED unit: the saved-layout regression failed with `expected 0 to be 1`; the other 14 tests passed.
|
||||
- RED E2E: Changes remained `dv-inactive-tab` after returning to the saved task.
|
||||
- GREEN unit: `components/task/changes-panel-focus.test.ts` — 16 tests passed after the
|
||||
maximized-layout review regression was added.
|
||||
- Typecheck: `pnpm run typecheck` from `apps/web` — passed.
|
||||
- GREEN E2E: focused Chromium production-build scenario — 1 test passed in 1.9s.
|
||||
- Desktop PR capture:
|
||||
`rtk pnpm e2e:run tests/layout/pr-capture.spec.ts -- --project=chromium` — temporary
|
||||
synthetic capture scenario passed and produced the 1280×720 desktop screenshot.
|
||||
- Mobile PR capture:
|
||||
`rtk pnpm e2e:run tests/layout/mobile-pr-capture.spec.ts -- --project=mobile-chrome` —
|
||||
temporary synthetic Pixel 5 capture scenario passed. The capture specs were removed after
|
||||
producing the ignored PR assets.
|
||||
- PNG compression:
|
||||
`rtk pnpm dlx pngquant-bin@9.0.0 --quality 65-90 --ext .png --force web/.pr-assets/*.png`
|
||||
— passed before both screenshots were embedded in PR #2091.
|
||||
- Whitespace: `git diff --check` — passed.
|
||||
- Mobile: no product E2E regression was added because `useChangesPanelAutoFocus` is mounted
|
||||
only by `DockviewDesktopLayout`; mobile and tablet use separate task layouts and received no
|
||||
state or presentation changes.
|
||||
@@ -0,0 +1,93 @@
|
||||
---
|
||||
id: "01-restore-pending-changes-attention"
|
||||
title: "Restore pending Changes attention"
|
||||
status: done
|
||||
wave: 1
|
||||
depends_on: []
|
||||
plan: "plan.md"
|
||||
spec: "../../specs/ui/task-layout-profiles.md"
|
||||
---
|
||||
|
||||
# Task 01: Restore Pending Changes Attention
|
||||
|
||||
## Intent
|
||||
|
||||
Make a meaningful Git or commit update detected while a desktop task is inactive activate its existing Changes panel after the user returns, even when that task has a saved Dockview layout. Preserve reload baselining and all current restore/panel safety rules.
|
||||
|
||||
## Acceptance
|
||||
|
||||
- A pending inactive-task change activates Changes after Dockview restoration even when an environment-specific layout exists.
|
||||
- Reloading a task with already-known changes does not activate Changes solely because the count is non-zero.
|
||||
- Missing Changes panels and Changes panels grouped with Agent sessions retain their current safe behavior.
|
||||
|
||||
## Files likely touched
|
||||
|
||||
- `apps/web/components/task/changes-panel-focus.test.ts`
|
||||
- `apps/web/components/task/changes-panel-focus.ts`
|
||||
- `apps/web/e2e/tests/layout/changes-panel-focus.spec.ts`
|
||||
|
||||
## Dependencies
|
||||
|
||||
None.
|
||||
|
||||
## Parallelism
|
||||
|
||||
`sequential`. The source and both regression levels describe one focus-state transition and must be changed in a single TDD cycle.
|
||||
|
||||
## Inputs
|
||||
|
||||
- `docs/specs/ui/task-layout-profiles.md`: returning-task attention and reload scenarios.
|
||||
- `docs/plans/returning-task-changes-focus/plan.md`: root cause, responsive boundary, and risks.
|
||||
- Regression commit `ba8d99f33`, which added `hasSavedLayout` suppression and the conflicting E2E expectation.
|
||||
- Existing `applyChangesPanelAutoFocusState`, `activateChangesPanel`, and `markInactiveChangesIncreases` behavior.
|
||||
|
||||
## TDD Sequence
|
||||
|
||||
1. Set this task and its plan item to `in_progress`.
|
||||
2. RED: reverse the saved-layout unit expectation and the returning-task E2E expectation without changing production code.
|
||||
3. Run both focused regressions and confirm they fail because Changes is not activated.
|
||||
4. GREEN: remove only the saved-layout suppression and its now-unused lookup/argument.
|
||||
5. Run the focused unit and E2E checks until green.
|
||||
6. REFACTOR: remove obsolete naming/comments and keep the state transition explicit.
|
||||
7. Run typecheck, mark this task `done`, and update the plan checkbox/status.
|
||||
|
||||
## Verification
|
||||
|
||||
Run `pnpm install --frozen-lockfile` from `apps/` first when `apps/node_modules` is absent.
|
||||
|
||||
```bash
|
||||
# From apps/
|
||||
pnpm --filter @kandev/web test -- --run components/task/changes-panel-focus.test.ts
|
||||
pnpm --filter @kandev/web typecheck
|
||||
|
||||
# From apps/web/
|
||||
pnpm e2e:run tests/layout/changes-panel-focus.spec.ts -- --grep "new git updates focus changes when returning to a task with a saved layout"
|
||||
```
|
||||
|
||||
The unit and E2E regression commands must be observed failing during RED and passing after GREEN. The final reported verification results are the post-change runs.
|
||||
|
||||
## Output contract
|
||||
|
||||
Report the state-transition change, files changed, RED and GREEN command results, any E2E artifacts or blockers, remaining risks, and the synchronized task/plan statuses.
|
||||
|
||||
## Results
|
||||
|
||||
- Removed the environment-layout lookup and blanket `hasSavedLayout` suppression from Changes attention.
|
||||
- Preserved inactive-change detection, first-observation baselining, restore deferral, missing-panel handling, and Agent-group blocking.
|
||||
- Updated the unit scenario and browser regression to require Changes activation on return.
|
||||
- RED unit failed with zero activation calls; RED E2E observed `dv-inactive-tab`.
|
||||
- GREEN unit passed all 16 tests, including the maximized-layout review regression.
|
||||
- Direct web typecheck passed.
|
||||
- GREEN managed E2E passed the focused Chromium production-build scenario in 1.9s.
|
||||
- Desktop screenshot capture passed with
|
||||
`rtk pnpm e2e:run tests/layout/pr-capture.spec.ts -- --project=chromium` and produced the
|
||||
synthetic 1280×720 PR asset.
|
||||
- Mobile screenshot capture passed with
|
||||
`rtk pnpm e2e:run tests/layout/mobile-pr-capture.spec.ts -- --project=mobile-chrome` and
|
||||
produced the synthetic Pixel 5 PR asset; both temporary capture specs were then removed.
|
||||
- PNG compression passed with
|
||||
`rtk pnpm dlx pngquant-bin@9.0.0 --quality 65-90 --ext .png --force web/.pr-assets/*.png`,
|
||||
and both assets were embedded in PR #2091.
|
||||
- `git diff --check` passed.
|
||||
- No mobile product regression test was required because the affected hook is
|
||||
desktop-Dockview-only and no mobile/tablet behavior changed.
|
||||
Reference in New Issue
Block a user