AI Agents SDE Task Viewer
      • Context
      • Plan
      • Prd
  1. Home
  2. AgentSDE
  3. agent-core-control-center
  4. gh-41
  5. plan
  6. plan.md
plan.md(3.0 KB)· Apr 1, 2026· 2 min read
  • Summary
  • Files
  • Steps
  • Verification
  • Risks

Plan — Centralize viewer URL construction and E2E_REPOS#

Summary#

Extract the duplicated viewerUrl() function and E2E_REPOS constant from three page components into a single lib/viewer.ts helper. Add a source-of-truth comment referencing agent-core's ArtefactsService.getArtefactsSubdir(), and add unit tests for the subdir selection logic.

Files#

FileActionDescription
lib/viewer.tscreateShared helper: E2E_REPOS, VIEWER_BASE, getArtefactsSubdir(), getViewerUrl()
lib/viewer.test.tscreateUnit tests for subdir selection (e2e repo, production repo, owner/repo format)
app/pipeline/page.tsxmodifyRemove local E2E_REPOS, VIEWER_BASE, viewerUrl(); import from lib/viewer
app/pipeline/[taskId]/page.tsxmodifyRemove local E2E_REPOS, VIEWER_BASE, viewerUrl(); import from lib/viewer
app/agents/page.tsxmodifyRemove local E2E_REPOS, VIEWER_BASE, viewerUrl(); import from lib/viewer
package.jsonmodifyAdd vitest as dev dependency + test script

Steps#

  1. Add vitest — Install vitest as a dev dependency, add "test": "vitest run" script to package.json. Configure vitest to resolve the @/* path alias matching tsconfig.json.
  2. Create lib/viewer.ts — Export E2E_REPOS array, VIEWER_BASE constant, getArtefactsSubdir(repo) helper returning 'tasks/e2e' or 'tasks/production', and getViewerUrl(issue, repo) composing the full URL. Add a doc comment on E2E_REPOS referencing agent-core/src/artefacts/artefacts.service.ts → E2E_SOURCE_REPOS as the canonical source of truth.
  3. Create lib/viewer.test.ts — Test getArtefactsSubdir: returns tasks/e2e for 'agent-core-e2e', returns tasks/production for 'agent-core', handles 'AgentSDE/agent-core-e2e' owner/repo format. Test getViewerUrl produces expected URL shape.
  4. Refactor app/pipeline/page.tsx — Delete lines 21-28 (local E2E_REPOS, VIEWER_BASE, viewerUrl). Import getViewerUrl from @/lib/viewer. Update call sites (lines 68, 216).
  5. Refactor app/pipeline/[taskId]/page.tsx — Delete lines 25-32 (local constants + function). Import getViewerUrl from @/lib/viewer. Update call site (line 164).
  6. Refactor app/agents/page.tsx — Delete lines 56-63 (local constants + function). Import getViewerUrl from @/lib/viewer. Update call site at line 145 to pass (task.issue, task.repo) instead of (task).

Verification#

  • npm run lint passes with zero warnings
  • npm run build compiles successfully
  • npm test passes — subdir selection tests for e2e and production repos

Risks#

  • Test framework bootstrap — AGENTS.md notes no test runner exists. Adding vitest is required by acceptance criteria (unit tests). Vitest is the lightest option for a Next.js project and requires minimal config.
  • E2E_REPOS drift — The list is still manually mirrored from agent-core. The source-of-truth comment + unit tests make drift detectable during review/CI but don't eliminate it.
ContextPrd