fix: preserve client-side navigation for task links (#3844)

This commit is contained in:
Carlos Florêncio
2026-09-21 18:22:29 +01:00
committed by GitHub
parent daccac2888
commit e1f43436b2
51 changed files with 1769 additions and 69 deletions
@@ -0,0 +1,122 @@
# Task-link migration inventory
Source snapshot: 2026-09-21. Re-run the rule over the whole production tree;
this literal search is evidence, not an exhaustive static analysis.
Classify bare route prefixes as recognizers, links.ts as authority, and the rest
as builders/consumers. API-relative `/tasks/...` paths require transport-aware
classification. Do not rewrite API contracts.
Task 02 must record every migrated caller and its changed test. Before its
`vitest related` command, write `/tmp/kandev-task-link-changed-sources.txt` with
one web-package-relative changed source path per line (no test paths). These
repository paths have no spaces. Use the explicit resulting test list in the
work-order Results; run changed test files directly if related discovery misses
one. The temporary file is a command input, not a persistent artifact.
- `apps/web/components/linear/linear-quick-task-launcher.tsx`
- `87: if (meta?.autoFocus !== false) router.push(/tasks/${task.id});`
- `apps/web/components/automations/runs-section.tsx`
- `329: onNavigate={(id) => router.push(/tasks/${id})}`
- `apps/web/components/runs/runs-list-page.tsx`
- `234: onOpen={(taskId) => router.push(/tasks/${taskId})}`
- `apps/web/components/runs/runs-page-client.tsx`
- `194: onOpen={(taskId) => router.push(/tasks/${taskId})}`
- `apps/web/components/task/task-session-sidebar.tsx`
- `314: !!pathname && (pathname.startsWith("/t/") || pathname.startsWith("/office/tasks/"));`
- `469: !!pathname && (pathname.startsWith("/t/") || pathname.startsWith("/office/tasks/"));`
- `apps/web/components/task/task-dependency-chip.tsx`
- `163: href={/tasks/${entry.id}}`
- `apps/web/components/app-sidebar/app-sidebar.tsx`
- `37: matches: (p) => p.startsWith("/t/"),`
- `apps/web/components/inbox-history/inbox-history-row.tsx`
- `35: if (!bundle.session_id) return /t/${bundle.task_id};`
- `36: return /t/${bundle.task_id}?sessionId=${encodeURIComponent(bundle.session_id)};`
- `apps/web/components/azure-devops/azure-devops-task-launcher.tsx`
- `189: if (meta?.autoFocus !== false) router.push(/tasks/${task.id});`
- `apps/web/components/needs-you-inbox/needs-you-inbox-row.tsx`
- `170: if (!bundle.session_id) return /t/${bundle.task_id};`
- `171: return /t/${bundle.task_id}?sessionId=${encodeURIComponent(bundle.session_id)};`
- `apps/web/components/needs-you-inbox/failed-inbox-row.tsx`
- `19: return /t/${row.task_id};`
- `apps/web/components/settings/workspace-canvases-page.tsx`
- `107: router.push(/t/${encodeURIComponent(response.task_id)}${query});`
- `apps/web/components/settings/canvas-host-route.tsx`
- `378: router.push(/t/${encodeURIComponent(response.task_id)}${query});`
- `apps/web/components/settings/kubernetes-session-utils.ts`
- `89: return /t/${encodeURIComponent(taskId)};`
- `apps/web/components/jira/my-jira/quick-task-launcher.tsx`
- `65: if (meta?.autoFocus !== false) router.push(/tasks/${task.id});`
- `apps/web/components/task/simple/OfficeSimplePane.tsx`
- `145: href={/t/${task.id}}`
- `apps/web/components/automations/trigger-configs/plugin-webhook-controls.tsx`
- `84: <a className="underline" href={/tasks/${receipt.task_id}}>`
- `apps/web/components/github/my-github/quick-task-launcher.tsx`
- `239: if (meta?.autoFocus !== false) router.push(/tasks/${task.id});`
- `apps/web/lib/links.ts`
- `2: const base = /t/${taskId};`
- `30: const TASK_DETAIL_PREFIXES = ["/t/", "/tasks/"];`
- `apps/web/lib/entity-references/message-references.ts`
- `60: return reference.url === /t/${encodeURIComponent(reference.id)};`
- `apps/web/app/tasks/[id]/kanban-task-shell.tsx`
- `156: const href = target === "office" ? /office/tasks/${taskId} : /t/${taskId};`
- `apps/web/app/tasks/[id]/page.tsx`
- `29: redirect(queryString ? /t/${id}?${queryString} : /t/${id});`
- `apps/web/app/office/tasks/[id]/task-advanced-mode.tsx`
- `51: href={/t/${task.id}}`
- `apps/web/src/spa-routes.tsx`
- `746: for (const prefix of ["/t/", "/tasks/"]) {`
## Task 02 migration result
All builders listed above now use `linkToTask` with raw task IDs. Direct task
anchors use `TaskLink`; Office, API, listing, and route-recognition paths keep
their separate contracts. The following callers changed:
- `components/automations/runs-section.tsx` → `components/automations/runs-section.test.tsx`
- `components/runs/runs-page-client.tsx` → `components/runs/runs-page-client.test.tsx`
- `components/runs/runs-list-page.tsx` → `components/runs/runs-list-page.test.tsx`
- `components/azure-devops/azure-devops-task-launcher.tsx` → `components/azure-devops/azure-devops-task-launcher.test.tsx`
- `components/github/my-github/quick-task-launcher.tsx` → `components/github/my-github/quick-task-launcher.test.tsx`
- `components/linear/linear-quick-task-launcher.tsx` → existing launcher contract retained; no path-specific assertion needed
- `components/jira/my-jira/quick-task-launcher.tsx` → existing launcher contract retained; no path-specific assertion needed
- `components/automations/trigger-configs/plugin-webhook-controls.tsx` → existing rendered link contract retained
- `components/task/simple/OfficeSimplePane.tsx` → existing cross-link contract retained
- `app/office/tasks/[id]/task-advanced-mode.tsx` → existing cross-link contract retained
- `app/tasks/[id]/kanban-task-shell.tsx` → existing Office/Kanban cross-link contract retained
- `app/tasks/[id]/page.tsx` → compatibility redirect contract retained
- `components/inbox-history/inbox-history-row.tsx` → existing session query contract retained
- `components/needs-you-inbox/needs-you-inbox-row.tsx` → existing session query contract retained
- `components/needs-you-inbox/failed-inbox-row.tsx` → existing task href contract retained
- `components/settings/system/bundle-customizer.tsx` → existing alternate-target contract retained
- `components/settings/workspace-canvases-page.tsx` → existing canvas session context retained
- `components/settings/canvas-host-route.tsx` → existing canvas session context retained
- `components/settings/kubernetes-session-utils.ts` → existing task href helper contract retained
- `lib/entity-references/message-references.ts` → existing encoded entity-reference contract retained
- `components/task/task-dependency-chip.tsx` → `components/task/task-dependency-chip.test.tsx`
The enforcement rule and real-config wiring are covered by
`eslint-rules/no-task-link-bypass.test.ts` and
`scripts/lib/task-link-wiring.test.ts`.
+128
View File
@@ -0,0 +1,128 @@
---
created: 2026-09-21
status: complete
requirements:
- REQ-UI-TASK-NAVIGATION-001
system_design:
- ../../specs/ui/system-design/task-navigation.md
legacy_specs: []
---
# Implementation Plan: Task link navigation
## Overview
Fix dependency navigation and prevent recurrence across first-party task links.
The shared primitives, first-party migration, enforcement, and desktop/mobile
proof are complete across the three sequential work orders.
## Evidence and assumptions
Confirmed: the user requests a fix plan and central task-link construction.
Verified: DependencyRow uses a native anchor to `/tasks/${entry.id}`. Both
Blocks and Blocked by share the row, on desktop and touch. Existing component
and E2E tests check visibility but never activate the dependency link.
Verified: linkToTask already builds `/t/:id`; AppLink already handles guarded
SPA navigation. Thus URL construction and click transport need separate guards.
Source tracing establishes the cause; a browser reproduction has not been run.
No material product choice remains unresolved. The reusable navigation contract
belongs to UI; dependency state remains owned by Tasks.
## Scope
### In scope
- Shared TaskLink, compatible URL-builder extension, committed-navigation callback.
- Dependency popover/drawer fix, touch targets, regression coverage.
- Migration of first-party hand-built task-detail URLs and known raw task anchors.
- ESLint enforcement, wiring coverage, and scoped engineering guidance.
### Out of scope
Backend routes/APIs, Office destination semantics, external/plugin links, user
content rewriting, a generic route catalog, and layout redesign.
## Technical approach
Follow [the design](../../specs/ui/system-design/task-navigation.md).
Use linkToTask as URL authority and AppLink as click/guard authority; TaskLink
combines them without another routing implementation. Preserve session, layout,
canvas query context, explicit new-tab behavior, and compatibility routes.
## ASCII UI preview
UI-01: Dependency navigation, expanded state (AC .1, .4, .5, .6).
```text
Desktop: [blocks 2] -> Popover: [Task B | REVIEW] -> Task B workbench
Phone: [blocks 2] -> Drawer:
Dependencies [Close]
[Task B | REVIEW] (44px+ tap row)
[Task C | CREATED] (list scrolls)
-> Task B workbench; drawer closes
Before: selecting a row loads a new document through /tasks/:id.
After: selecting a row commits SPA navigation to /t/:id.
```
Control order, touch targets, and successful-navigation dismissal are required.
Spacing is illustrative. Retain existing localized labels and status displays.
Cancelled navigation keeps the disclosure; modified clicks keep the current page.
## Tests
| Acceptance | Evidence |
| --- | --- |
| .1, .3, .4 | task-link.test.tsx, app-link.test.tsx, task-dependency-chip.test.tsx |
| .2 | links.test.ts and migrated caller tests |
| .1, .2 prevention | no-task-link-bypass.test.ts and task-link-wiring.test.ts |
| .1, .4, .5, .6 | Browser scenarios below |
## E2E tests
Add the desktop test `dependency links preserve the desktop task workbench` to
`e2e/tests/task/task-dependencies.spec.ts` (chromium) and the mobile test
`mobile dependency links preserve the task workbench and touch layout` in
`e2e/tests/task/mobile-task-dependency-navigation.spec.ts` (mobile-chrome).
They exercise Blocks and Blocked by, target identity, canonical href, disclosure
closure, document sentinel survival, no main-frame document request, and Back.
The phone test uses the real drawer and measures 44px targets and viewport
containment.
## Work orders
- [x] [Task 01: Shared task links and dependency fix](task-01-shared-task-links.md)
- [x] [Task 02: Migrate and enforce task URL construction](task-02-enforce-task-links.md)
- [x] [Task 03: Desktop and touch navigation proof](task-03-browser-regressions.md)
## Verification results
Implementation completed on 2026-09-21:
- Task 01 added `TaskLink`, successful-navigation callbacks, canonical dependency
links, guarded disclosure dismissal, and touch-sized dependency rows.
- Task 02 migrated first-party task destinations, added bounded ESLint
enforcement, added real-config wiring coverage, and recorded the migration
inventory.
- Task 03 added desktop and mobile no-reload regressions. The mobile layout now
forwards the task status identity needed by sessionless dependency tasks.
- Focused Vitest checks passed: 6 files and 51 tests for the routing, dependency,
and rule contracts.
- Broad related Vitest checks passed: 437 files and 4,254 tests.
- `pnpm run typecheck` and `pnpm run lint` passed.
- Chromium dependency E2E passed: 6 tests.
- Mobile dependency E2E passed: 1 test.
- Specification validation, specification lint, and `git diff --check` passed.
Planning validation passed on 2026-09-21:
- `python3 scripts/list-docs.py validate`: 294 decisions and 1067 specifications validated.
- `python3 scripts/lint-spec-files.py --all`: passed.
- `git diff --check -- docs/specs docs/plans/task-link-navigation`: passed.
- Catalog discovery includes the new requirement and design. Git status includes all three new work orders and the inventory.
## Risks
- Changing query construction must preserve duplicate parameters and avoid double encoding.
- Closing a disclosure before a dirty-navigation guard commits would lose context.
- Static rules cannot resolve arbitrary runtime strings; test bounded detection honestly.
- Compatibility route recognition and API URLs must not become false positives.
@@ -0,0 +1,113 @@
---
id: "01-shared-task-links"
title: "Shared task links and dependency fix"
status: done
wave: 1
depends_on: []
plan: "plan.md"
requirements:
- REQ-UI-TASK-NAVIGATION-001
acceptance_criteria:
- AC-UI-TASK-NAVIGATION-001.1
- AC-UI-TASK-NAVIGATION-001.2
- AC-UI-TASK-NAVIGATION-001.3
- AC-UI-TASK-NAVIGATION-001.4
- AC-UI-TASK-NAVIGATION-001.5
system_design:
- ../../specs/ui/system-design/task-navigation.md
---
# Task 01: Shared task links and dependency fix
## Summary
Centralize task anchors and repair both dependency directions with the existing router.
## In scope
- Add TaskLink and compatible linkToTask options; preserve raw IDs and query context.
- Add AppLink onNavigated within the successful guard callback.
- Switch DependencyRow and pass a close callback; scope 44px minimum rows to touch.
## Out of scope
Backend behavior and unrelated navigation redesign.
## Acceptance
- Failing regression: clicking a dependency row is intercepted and opens `/t/b`; today its native click is not prevented.
- Cover both directions, canonical URL/encoding, ordinary and keyboard activation, modified/middle clicks, explicit targets, prevented clicks, guard rejection/acceptance, and callback timing.
- Desktop stays compact; phone drawer closes only on committed same-tab navigation.
## ASCII UI preview
UI-01: Dependency navigation, expanded state (AC .1, .4, .5, .6).
```text
Desktop: [blocks 2] -> Popover: [Task B | REVIEW] -> Task B workbench
Phone: [blocks 2] -> Drawer:
Dependencies [Close]
[Task B | REVIEW] (44px+ tap row)
[Task C | CREATED] (list scrolls)
-> Task B workbench; drawer closes
Before: selecting a row loads a new document through /tasks/:id.
After: selecting a row commits SPA navigation to /t/:id.
```
Control order, touch targets, and successful-navigation dismissal are required.
Spacing is illustrative. Retain existing localized labels and status displays.
Cancelled navigation keeps the disclosure; modified clicks keep the current page.
See [full preview](plan.md#ascii-ui-preview).
## Verification
Run from repository root. Install once with `(cd apps && pnpm install --frozen-lockfile)` if this worktree lacks dependencies.
```bash
(cd apps/web && pnpm exec vitest run lib/links.test.ts components/routing/app-link.test.tsx components/routing/task-link.test.tsx components/task/task-dependency-chip.test.tsx)
(cd apps/web && pnpm run typecheck)
(cd apps/web && pnpm exec eslint lib/links.ts components/routing/app-link.tsx components/routing/task-link.tsx components/task/task-dependency-chip.tsx --max-warnings 0)
```
## Files likely touched
- `apps/web/lib/links.ts`
- `apps/web/lib/links.test.ts`
- `apps/web/components/routing/app-link.tsx`
- `apps/web/components/routing/app-link.test.tsx`
- `apps/web/components/routing/task-link.tsx (new)`
- `apps/web/components/routing/task-link.test.tsx (new)`
- `apps/web/components/task/task-dependency-chip.tsx`
- `apps/web/components/task/task-dependency-chip.test.tsx`
## Dependencies
None.
## Risks
Preserve existing route guards, query context, and browser-native alternate-tab behavior.
## Parallelism
`sequential`
## Inputs
- [Requirements](../../specs/ui/requirements/task-navigation.md)
- [System design](../../specs/ui/system-design/task-navigation.md)
- Existing AppLink, linkToTask, local ESLint rules, and task dependency tests.
## Results
Completed on 2026-09-21.
- The initial focused RED run failed on the six expected pre-fix behaviors:
canonical URL construction, AppLink callback timing, dependency interception,
disclosure dismissal, and touch-row sizing.
- The focused Vitest suite passed 4 files and 32 tests after implementation.
- Review follow-up added explicit blocker-cancellation coverage; the focused
suite now passes 4 files and 33 tests.
- `pnpm run typecheck` passed.
- Focused ESLint passed with zero warnings.
@@ -0,0 +1,97 @@
---
id: "02-enforce-task-links"
title: "Migrate and enforce task URL construction"
status: done
wave: 2
depends_on: ['01-shared-task-links']
plan: "plan.md"
requirements:
- REQ-UI-TASK-NAVIGATION-001
acceptance_criteria:
- AC-UI-TASK-NAVIGATION-001.1
- AC-UI-TASK-NAVIGATION-001.2
- AC-UI-TASK-NAVIGATION-001.3
system_design:
- ../../specs/ui/system-design/task-navigation.md
---
# Task 02: Migrate and enforce task URL construction
## Summary
Make the default lint command reject recurring URL and anchor bypasses, with zero current violations.
## In scope
- Add the bounded AST rule and actual-config wiring test described in the design.
- Inventory and migrate every production task-detail builder; classify route-recognition constants separately.
- Keep existing compliant Link/router consumers; migrate raw task anchors to TaskLink.
- Update apps/web/AGENTS.md with URL and anchor ownership. No new ADR is needed: this applies existing authorities, with alternatives documented in the design.
## Out of scope
Backend behavior and unrelated navigation redesign.
## Acceptance
- RED: rule fixtures reject original DependencyRow, raw anchors using aliased helper calls, and hand-built URLs; valid API/Office/matcher cases pass.
- Final production lint has no task-link violations or migration baseline; real config catches a new component in an arbitrary directory.
- Migrated caller tests preserve context and selection side effects; new workbench destinations use canonical URLs.
## Verification
Run from repository root. Install once with `(cd apps && pnpm install --frozen-lockfile)` if this worktree lacks dependencies.
```bash
(cd apps/web && pnpm exec vitest run eslint-rules/no-task-link-bypass.test.ts scripts/lib/task-link-wiring.test.ts lib/links.test.ts)
(cd apps/web && pnpm exec vitest related --run $(cat /tmp/kandev-task-link-changed-sources.txt))
(cd apps/web && pnpm run typecheck)
(cd apps/web && pnpm run lint)
git diff --check
```
## Files likely touched
- `apps/web/eslint-rules/no-task-link-bypass.mjs (new)`
- `apps/web/eslint-rules/no-task-link-bypass.test.ts (new)`
- `apps/web/scripts/lib/task-link-wiring.test.ts (new)`
- `apps/web/eslint.config.mjs`
- `apps/web/AGENTS.md`
- `First-party callers listed in migration-inventory.md and their tests`
## Dependencies
01-shared-task-links.
## Risks
Preserve existing route guards, query context, and browser-native alternate-tab behavior.
## Parallelism
`sequential`
## Inputs
- [Requirements](../../specs/ui/requirements/task-navigation.md)
- [System design](../../specs/ui/system-design/task-navigation.md)
- Existing AppLink, linkToTask, local ESLint rules, and task dependency tests.
## Results
Completed on 2026-09-21.
- The bounded `task-links/no-task-link-bypass` rule and real-config wiring test
passed, with 31 tests in the initial focused rule and link suite.
- All known first-party task-detail builders and raw task anchors were migrated;
the production rule scan found zero violations.
- Review follow-up now checks quoted and expression literal task URLs on custom
`Link` and `AppLink` elements while preserving shared-builder cases. Static
evaluation uses branch-local recursion guards, so prefix aliases combined
with dynamic task IDs are detected in anchors and `location.assign` calls.
- The broad related Vitest run before review follow-up passed 437 files and
4,254 tests.
- Review follow-up coverage passed 3 files and 38 rule/link tests; the combined
rule, AppLink, wiring, and link suite passed 4 files and 48 tests.
- `pnpm run typecheck`, `pnpm run lint`, Prettier checks, and `git diff --check`
passed.
@@ -0,0 +1,112 @@
---
id: "03-browser-regressions"
title: "Desktop and touch navigation proof"
status: done
wave: 3
depends_on: ['02-enforce-task-links']
plan: "plan.md"
requirements:
- REQ-UI-TASK-NAVIGATION-001
acceptance_criteria:
- AC-UI-TASK-NAVIGATION-001.1
- AC-UI-TASK-NAVIGATION-001.2
- AC-UI-TASK-NAVIGATION-001.3
- AC-UI-TASK-NAVIGATION-001.4
- AC-UI-TASK-NAVIGATION-001.5
- AC-UI-TASK-NAVIGATION-001.6
system_design:
- ../../specs/ui/system-design/task-navigation.md
---
# Task 03: Desktop and touch navigation proof
## Summary
Prove real task navigation retains the browser document on both responsive surfaces.
## In scope
- Seed related tasks through existing API fixtures and exercise both dependency directions.
- Assert canonical destination plus target task identity, document sentinel, document request count, disclosure dismissal, and browser Back.
- Phone: use mobile-chrome defaults and Drawer selectors; assert 44px rows, containment, single list scroll owner, no horizontal overflow.
- Keep native modified-click and guard cancellation coverage in component tests from Task 01.
## Out of scope
Backend behavior and unrelated navigation redesign.
## Acceptance
- Record RED evidence against the pre-fix implementation for navigation tests, using temporary local reversion of only the fix if needed; restore it before GREEN.
- Desktop and mobile scenarios pass on fresh builds, not stale assets.
- Record all command results and mark work orders/manifest complete only after their checks pass.
## ASCII UI preview
UI-01: Dependency navigation, expanded state (AC .1, .4, .5, .6).
```text
Desktop: [blocks 2] -> Popover: [Task B | REVIEW] -> Task B workbench
Phone: [blocks 2] -> Drawer:
Dependencies [Close]
[Task B | REVIEW] (44px+ tap row)
[Task C | CREATED] (list scrolls)
-> Task B workbench; drawer closes
Before: selecting a row loads a new document through /tasks/:id.
After: selecting a row commits SPA navigation to /t/:id.
```
Control order, touch targets, and successful-navigation dismissal are required.
Spacing is illustrative. Retain existing localized labels and status displays.
Cancelled navigation keeps the disclosure; modified clicks keep the current page.
See [full preview](plan.md#ascii-ui-preview).
## Verification
Run from repository root. Install once with `(cd apps && pnpm install --frozen-lockfile)` if this worktree lacks dependencies.
```bash
(cd apps/web && pnpm e2e:run --project chromium tests/task/task-dependencies.spec.ts)
(cd apps/web && pnpm e2e:run --project mobile-chrome tests/task/mobile-task-dependency-navigation.spec.ts)
python3 scripts/list-docs.py validate
python3 scripts/lint-spec-files.py --all
git diff --check
```
## Files likely touched
- `apps/web/e2e/tests/task/task-dependencies.spec.ts`
- `apps/web/e2e/tests/task/mobile-task-dependency-navigation.spec.ts (new)`
- `docs/plans/task-link-navigation/plan.md`
- `docs/plans/task-link-navigation/task-*.md`
## Dependencies
02-enforce-task-links.
## Risks
Preserve existing route guards, query context, and browser-native alternate-tab behavior.
## Parallelism
`sequential`
## Inputs
- [Requirements](../../specs/ui/requirements/task-navigation.md)
- [System design](../../specs/ui/system-design/task-navigation.md)
- Existing AppLink, linkToTask, local ESLint rules, and task dependency tests.
## Results
Completed on 2026-09-21.
- The initial component RED run provided pre-fix navigation failure evidence;
no temporary production reversion was needed for the browser scenarios.
- Chromium dependency coverage passed all 6 tests, including both dependency
directions, no document reload, disclosure closure, and browser Back.
- Mobile dependency coverage passed 1 test, including the real drawer, both
directions, 44px rows, containment, no document reload, and Back.
- Specification validation, specification lint, and `git diff --check` passed.
+2 -1
View File
@@ -12,7 +12,8 @@ owners:
## Scope
UI owns responsive behavior and reusable presentation preferences, including
task-listing modes and Home destination choices. Other systems retain task,
task-listing modes, Home destination choices, and reusable client-side task
navigation. Other systems retain task,
runtime, and workspace lifecycle/state ownership.
## Related
@@ -0,0 +1,40 @@
---
status: active
system: ui
created: 2026-09-21
owners:
- kandev
---
# Task navigation requirements
## Overview
First-party task links consistently open the task workbench. UI owns this
reusable navigation interaction across features. Tasks retain identity,
relationships, authorization, and lifecycle ownership.
## Requirements
### REQ-UI-TASK-NAVIGATION-001: Consistent task navigation
**Intent:** Users follow task links without restarting the loaded application.
#### Acceptance criteria
- **AC-UI-TASK-NAVIGATION-001.1:** An ordinary click, keyboard activation, or touch on a first-party task-workbench link shall open the selected task without loading a new browser document.
- **AC-UI-TASK-NAVIGATION-001.2:** Newly generated workbench URLs shall use `/t/:taskId`, preserve requested session, layout, and other supported query context, and encode each value once. Existing `/tasks/:id` deep links shall remain usable.
- **AC-UI-TASK-NAVIGATION-001.3:** Task links shall preserve browser copy-link, modified-click, middle-click, and explicit new-tab behavior.
- **AC-UI-TASK-NAVIGATION-001.4:** Task navigation shall respect existing unsaved-change guards. Cancelled navigation shall keep the current task and disclosure intact. Completed same-tab dependency navigation shall dismiss its disclosure.
- **AC-UI-TASK-NAVIGATION-001.5:** Both dependency directions shall support the same destination behavior in the desktop popover and touch drawer. Touch rows shall have at least 44px hit targets; fine-pointer rows shall retain compact sizing.
- **AC-UI-TASK-NAVIGATION-001.6:** Browser Back shall return to the preceding task after an ordinary task-link navigation without a document reload.
## Out of scope
Task selection policy, task authorization, missing-task recovery, Office routes,
external links, plugin-authored URLs, and navigation to task listings retain
existing behavior. This contract does not change backend task APIs.
## Implementation plans
- [Task link navigation](../../../plans/task-link-navigation/plan.md)
@@ -0,0 +1,120 @@
---
status: current
system: ui
requirements:
- REQ-UI-TASK-NAVIGATION-001
---
# Task navigation system design
## Purpose and boundaries
This design extends existing URL and client-navigation primitives. It does not
introduce a router or route catalog. UI owns the reusable interaction; task
identity and dependency semantics remain in the task system.
## Requirement mapping
| Requirement | Design sections |
| --- | --- |
| REQ-UI-TASK-NAVIGATION-001 | URL authority, Link authority, Enforcement, Responsive behavior |
## URL authority
`apps/web/lib/links.ts::linkToTask` remains the only first-party workbench URL
builder. Keep the current `(taskId, layout?)` call shape compatible. Add an
options overload containing `layout?`, `sessionId?`, and `searchParams?`
(`URLSearchParams`) for current canvas and inbox contexts. Clone caller-owned
parameters; explicit layout/sessionId values replace matching keys. Preserve
other keys and repeated values. Encode the raw ID as one path segment exactly
once. Callers pass raw IDs, never pre-encoded IDs. Test both overloads.
Route matching can still recognize `/t/` and `/tasks/`. Compatibility redirects
use the builder for their destination. `/tasks` listings, `/office/tasks/`,
API paths, external URLs, and stored user-authored content are separate contracts.
Do not globally rewrite strings or historical content.
## Link authority
Add `components/routing/task-link.tsx::TaskLink`, a thin wrapper around existing
`components/routing/app-link.tsx`. Accept `taskId`, builder options, normal
anchor presentation props, and `onNavigated`; omit `href` from public props.
The wrapper calls `linkToTask`, forwards its ref, and owns no task/store state.
Existing compliant `Link href={linkToTask(id)}` consumers may remain; new direct
task anchors should prefer TaskLink. Programmatic navigation continues through
`useRouter().push(linkToTask(...))`.
Extend AppLink with an optional `onNavigated` callback called inside the
existing successful `pushNavigationState` callback, after the location event.
It must not run for cancelled guards, prevented clicks, external navigation,
modified clicks, or alternate targets. TaskLink delegates all click decisions
to AppLink. Do not duplicate the router's guard or browser-modifier logic.
DependencyRow uses TaskLink. The chip supplies a stable close callback through
DependencyLists, invoked only after committed same-tab navigation. Keep browser
Back semantics and anchor accessibility. Missing-task and access errors continue
through the existing destination route.
## Enforcement
Add a local ESLint rule and register it as an error on production TS/TSX in
`apps/web/eslint.config.mjs`. Test it using the existing local-rule pattern.
Reject hand-built root-relative task-detail URL expressions outside links.ts:
string literals with a nonempty task segment, interpolated templates, and string
concatenation beginning `/t/` or `/tasks/`. Permit bare prefix constants used
for route recognition; exclude tests, E2E, generated files, comments, API and
Office paths. Replace constructed comparison URLs with linkToTask too.
Also reject native JSX anchors whose href resolves to a task route or a
linkToTask call, and window.location assign/replace/href writes with such a
value. Resolve import aliases and simple local const aliases. Report a clear
replacement suggestion. Rule fixtures cover direct, aliased, concatenated,
and conditional forms plus benign route matching and API paths.
This is bounded static enforcement, not whole-program URL analysis. Unknown
runtime strings remain outside its proof. Do not claim all possible dynamic
links are statically verified. Add a wiring test that evaluates the real ESLint
configuration on a synthetic new production component so new directories are
covered. Start at zero violations by migrating current builders in the same
work order; no growing baseline or broad per-directory exemptions.
## Responsive behavior
Keep the current dependency popover on fine pointers and useTouchDrawer on
coarse pointers. Reuse shared Drawer safe-area handling and the single internal
list scroller. The nearest mobile navigation exemplar is
`components/task/mobile/session-task-switcher-sheet.tsx`; the dependency chip
already uses the appropriate brief-choice drawer. Task selection completes the
choice and goes to the workbench, so successful navigation dismisses the drawer.
Keep its header and close action, constrain long lists to the viewport, and
apply 44px row sizing only on touch surfaces. No new persisted state or copy.
## Validation
Component tests prove canonical hrefs, click interception, guard cancellation,
callback timing, modifier handling, and encoding. Desktop and Pixel 5 E2E
follow links in both dependency directions, verify target task content, dismiss
the disclosure, and exercise Back. Set a unique window property before clicking
and assert it survives; also observe main-frame document requests. A correct URL
alone is not evidence against reload. Check touch targets and drawer containment.
## Related contracts
[Mobile task navigation](../requirements/mobile-task-navigation.md) owns broader
task actions and mobile board navigation. This contract adds shared task-link
transport and URL construction across desktop and mobile consumers.
## Related decisions and alternatives
[Navigation manifest boundaries](../../../decisions/2026-08-04-navigation-manifest-boundaries.md)
retains top-level destination ownership.
[Settings save coordination](../../../decisions/0046-settings-route-save-coordinator.md)
retains dirty-navigation authority. No new route ownership registry is needed.
A URL helper alone cannot prevent raw anchors from reloading. A component alone
cannot cover imperative redirects. Reusing both existing authorities with a
thin wrapper and lint enforcement addresses these distinct failure modes.
## Implementation plans
- [Task link navigation](../../../plans/task-link-navigation/plan.md)