Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
File size: 14,153 Bytes
a8fb296 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 | # App β docs linking Implementation Plan
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
**Goal:** Give every signed-in user one Documentation link from the avatar menu, and show a contextual Guide on admin screens that already have a known Docusaurus page β with batch jobs entering at AI Policy Analysis and drilling down to Data centers in the docs.
**Architecture:** A single `docsLinks.ts` module owns prod/local docs bases, intro URL, and an admin routeβdoc map. `SiteHeader` adds one menu anchor; `AdminLayout` looks up the map and renders at most one Guide link. The hub page `ai-policy-analysis.md` gains a Data centers section that links to the cohort (and sibling) docs.
**Tech Stack:** React + TypeScript (Vite), Vitest, Docusaurus markdown under `web_docs/docs/`.
**Spec / issue:** [app-docs-linking-design](./app-docs-linking-design.md) Β· [#714](https://github.com/getcommunityone/open-navigator/issues/714)
## Global Constraints
- Docs live only under `web_docs/docs/` (kebab-case, YAML frontmatter).
- Calendar years on the wire stay strings; N/A for this change.
- Do not invent metrics or placeholder stats in the hub rewrite.
- Batch jobs Guide must open `/development/ai-policy-analysis`, never deep-link the cohort page from the app.
- Lighthouse has no Guide in this plan.
- Branch: `feat/714-app-docs-linking`; Conventional Commits; `Closes #714`.
- One PR; required CI green before merge.
## File structure
| File | Role |
|---|---|
| `web_app/src/utils/docsLinks.ts` | `docsUrl`, `DOCS_INTRO`, `ADMIN_GUIDE_BY_PATH`, `adminGuideHref(pathname)` |
| `web_app/src/utils/docsLinks.test.ts` | Vitest for URL building and admin lookup |
| `web_app/src/components/SiteHeader.tsx` | Documentation menu item |
| `web_app/src/components/AdminLayout.tsx` | Contextual Guide β |
| `web_docs/docs/development/ai-policy-analysis.md` | Hub + Data centers drill-down |
| `web_docs/docs/development/app-docs-linking-design.md` | Spec (already on branch) |
| `web_docs/docs/development/app-docs-linking-plan.md` | This plan |
---
### Task 1: `docsLinks` helper + Vitest
**Files:**
- Create: `web_app/src/utils/docsLinks.ts`
- Create: `web_app/src/utils/docsLinks.test.ts`
- Test: `web_app/src/utils/docsLinks.test.ts`
**Interfaces:**
- Consumes: `import.meta.env.PROD` (same pattern as `Home.tsx` / `OpenSource.tsx`)
- Produces:
- `docsUrl(path: string): string`
- `DOCS_INTRO: string`
- `ADMIN_GUIDE_BY_PATH: Readonly<Record<string, string>>`
- `adminGuideHref(pathname: string): string | null`
- [ ] **Step 1: Write the failing test**
Create `web_app/src/utils/docsLinks.test.ts`:
```typescript
import { describe, expect, it } from 'vitest'
import {
ADMIN_GUIDE_BY_PATH,
DOCS_INTRO,
adminGuideHref,
docsUrl,
} from './docsLinks'
describe('docsUrl', () => {
it('joins the docs base with a rooted path', () => {
const url = docsUrl('/development/ai-policy-analysis')
expect(url.endsWith('/docs/development/ai-policy-analysis')).toBe(true)
expect(url.includes('//docs/')).toBe(false)
})
it('normalizes a path missing the leading slash', () => {
expect(docsUrl('intro')).toBe(docsUrl('/intro'))
})
})
describe('DOCS_INTRO', () => {
it('points at the docs intro page', () => {
expect(DOCS_INTRO).toBe(docsUrl('/intro'))
})
})
describe('ADMIN_GUIDE_BY_PATH / adminGuideHref', () => {
it('maps the three admin screens from the contract', () => {
expect(ADMIN_GUIDE_BY_PATH['/admin/batch-jobs']).toBe(
'/development/ai-policy-analysis',
)
expect(ADMIN_GUIDE_BY_PATH['/admin/meeting-kinds']).toBe(
'/development/jev-meeting-kind-gate',
)
expect(ADMIN_GUIDE_BY_PATH['/admin/application-links']).toBe(
'/development/data-center-application-links',
)
expect(ADMIN_GUIDE_BY_PATH['/admin/lighthouse-report']).toBeUndefined()
})
it('resolves exact and nested admin paths to absolute guide URLs', () => {
expect(adminGuideHref('/admin/batch-jobs')).toBe(
docsUrl('/development/ai-policy-analysis'),
)
expect(adminGuideHref('/admin/batch-jobs/run/abc')).toBe(
docsUrl('/development/ai-policy-analysis'),
)
expect(adminGuideHref('/admin/lighthouse-report')).toBeNull()
expect(adminGuideHref('/settings')).toBeNull()
})
})
```
- [ ] **Step 2: Run test to verify it fails**
Run: `cd web_app && npm test -- --run src/utils/docsLinks.test.ts`
Expected: FAIL (module not found / cannot resolve `./docsLinks`)
- [ ] **Step 3: Write minimal implementation**
Create `web_app/src/utils/docsLinks.ts`:
```typescript
/** Absolute Docusaurus links for the Vite app (prod vs local docs origin). */
const DOCS_ORIGIN = import.meta.env.PROD
? 'https://www.communityone.com/docs'
: 'http://localhost:3000/docs'
/** Build an absolute docs URL. `path` is under the docs root (e.g. `/intro`). */
export function docsUrl(path: string): string {
const rooted = path.startsWith('/') ? path : `/${path}`
return `${DOCS_ORIGIN}${rooted}`
}
export const DOCS_INTRO = docsUrl('/intro')
/**
* Admin app path β docs path (no `/docs` prefix; `docsUrl` adds the origin).
* Lighthouse intentionally omitted until a dedicated page exists.
*/
export const ADMIN_GUIDE_BY_PATH: Readonly<Record<string, string>> = {
'/admin/batch-jobs': '/development/ai-policy-analysis',
'/admin/meeting-kinds': '/development/jev-meeting-kind-gate',
'/admin/application-links': '/development/data-center-application-links',
}
/** Absolute Guide href for an admin pathname, or null when unmapped. */
export function adminGuideHref(pathname: string): string | null {
const entry = Object.entries(ADMIN_GUIDE_BY_PATH).find(
([appPath]) => pathname === appPath || pathname.startsWith(`${appPath}/`),
)
return entry ? docsUrl(entry[1]) : null
}
```
- [ ] **Step 4: Run test to verify it passes**
Run: `cd web_app && npm test -- --run src/utils/docsLinks.test.ts`
Expected: PASS
- [ ] **Step 5: Commit**
```bash
git add web_app/src/utils/docsLinks.ts web_app/src/utils/docsLinks.test.ts
git commit -m "$(cat <<'EOF'
feat(web): add docsLinks helper for intro and admin guides
Central prod/local docs URLs and ADMIN_GUIDE_BY_PATH for #714.
EOF
)"
```
---
### Task 2: Profile menu Documentation link
**Files:**
- Modify: `web_app/src/components/SiteHeader.tsx` (avatar dropdown, after Settings / before Data explorer)
**Interfaces:**
- Consumes: `DOCS_INTRO` from `../utils/docsLinks`
- Produces: menu anchor labeled `Documentation` opening intro in a new tab
- [ ] **Step 1: Import `DOCS_INTRO`**
At top of `SiteHeader.tsx`, add:
```typescript
import { DOCS_INTRO } from '../utils/docsLinks'
```
Keep existing `adminPaths` / `dataExplorerPaths` imports unchanged.
- [ ] **Step 2: Insert the Documentation menu item**
Inside the authenticated `showLoginMenu` block, **after** the Settings button and **before** the Data explorer button, add:
```tsx
<a
href={DOCS_INTRO}
target="_blank"
rel="noopener noreferrer"
onClick={() => setShowLoginMenu(false)}
style={{ ...menuBtn, textDecoration: 'none' }}
>
Documentation β
</a>
```
Do not admin-gate this item. Do not change Databricks / Sign out blocks.
- [ ] **Step 3: Sanity-check TypeScript**
Run: `cd web_app && npx tsc --noEmit -p tsconfig.json 2>&1 | tail -20`
Expected: no errors from `SiteHeader.tsx` / `docsLinks.ts`
- [ ] **Step 4: Commit**
```bash
git add web_app/src/components/SiteHeader.tsx
git commit -m "$(cat <<'EOF'
feat(web): add Documentation link to avatar menu
Signed-in users open docs intro in a new tab (#714).
EOF
)"
```
---
### Task 3: AdminLayout contextual Guide
**Files:**
- Modify: `web_app/src/components/AdminLayout.tsx`
**Interfaces:**
- Consumes: `adminGuideHref(pathname: string): string | null` from `../utils/docsLinks`
- Produces: at most one `Guide β` anchor in the admin header when mapped
- [ ] **Step 1: Import and resolve guide href**
Add import:
```typescript
import { adminGuideHref } from '../utils/docsLinks'
```
After the `onMeetingKinds` / tab booleans (still inside the component, after the admin gate), add:
```typescript
const guideHref = adminGuideHref(pathname)
```
- [ ] **Step 2: Render Guide in the header**
Change the header title row so Guide sits beside the title when present. Replace the lone `<h1>Admin</h1>` with:
```tsx
<div className="flex items-start justify-between gap-3">
<h1 className="text-lg font-semibold leading-tight text-slate-900 sm:text-xl">
Admin
</h1>
{guideHref ? (
<a
href={guideHref}
target="_blank"
rel="noopener noreferrer"
className="shrink-0 text-sm font-medium text-teal-800 hover:underline"
>
Guide β
</a>
) : null}
</div>
```
Leave tab nav and the existing helper paragraphs unchanged. On Lighthouse, `guideHref` is null β no Guide.
- [ ] **Step 3: Confirm lookup for the three mapped routes**
In a Vitest one-liner already covered by Task 1; optionally re-run:
Run: `cd web_app && npm test -- --run src/utils/docsLinks.test.ts`
Expected: PASS
Manual smoke (optional if docs + app running): open `/admin/batch-jobs` as admin β Guide goes to AI Policy Analysis; `/admin/lighthouse-report` β no Guide.
- [ ] **Step 4: Commit**
```bash
git add web_app/src/components/AdminLayout.tsx
git commit -m "$(cat <<'EOF'
feat(web): show contextual Guide link on admin screens
Batch jobs β ai-policy-analysis; meeting kinds and application links
map via docsLinks (#714).
EOF
)"
```
---
### Task 4: Hub doc β AI Policy Analysis + Data centers drill-down
**Files:**
- Modify: `web_docs/docs/development/ai-policy-analysis.md` (insert near the top, after the existing Overview / before Quick Start)
**Interfaces:**
- Consumes: existing sibling pages under `web_docs/docs/development/`
- Produces: operator-facing hub section with Data centers drill-down links (no fabricated numbers)
- [ ] **Step 1: Insert the operator hub section**
Immediately after the Overview bullet list (before `## Quick Start` / the garbled Quick Start heading), insert:
```markdown
## Operator hub (meeting analyze pipeline)
The live caption β screen β analyze path for jurisdiction meetings is operated
from **Admin β Batch jobs** (`/admin/batch-jobs`). Use this page as the entry
guide from that screen; drill down below for cohort and Jev details.
Related:
- [Jev transcript screening](./jev-transcript-screening.md) β chunked meeting-kind / decision / topic flags
- [Jev meeting-kind analysis gate](./jev-meeting-kind-gate.md) β keep-score gate before Gemini analyze
- [Jev-light cascade](./jev-light-cascade-design.md) β screen everyone, short blurb for keepers, full analyze for high-value keepers
### Data centers
For the **Data centers** cohort on the batch-jobs dashboard (site-belt βͺ mention
jurisdictions), start here then open the cohort contract:
- [Data centers cohort on batch jobs](./batch-jobs-data-centers-cohort.md) β launch `cohort=data_centers`, cascading filters, stage-report scope
Do not invent backlog counts or dollar figures on this page; pull live totals
from Admin β Batch jobs or the warehouse.
```
Keep the rest of the historical Ollama / bill-analysis content below; do not delete it in this task unless a paragraph directly contradicts the hub (if so, add one sentence pointing operators at Batch jobs for the current path).
- [ ] **Step 2: Verify relative links resolve**
Confirm these files exist on the branch:
- `web_docs/docs/development/batch-jobs-data-centers-cohort.md`
- `web_docs/docs/development/jev-meeting-kind-gate.md`
- `web_docs/docs/development/jev-transcript-screening.md`
- `web_docs/docs/development/jev-light-cascade-design.md`
Run: `ls web_docs/docs/development/{batch-jobs-data-centers-cohort,jev-meeting-kind-gate,jev-transcript-screening,jev-light-cascade-design}.md`
Expected: all four listed
- [ ] **Step 3: Docs build smoke (optional locally)**
Run: `cd web_docs && npm run build 2>&1 | tail -30`
Expected: build succeeds (or rely on CI Documentation Build)
- [ ] **Step 4: Commit**
```bash
git add web_docs/docs/development/ai-policy-analysis.md
git commit -m "$(cat <<'EOF'
docs(web_docs): AI policy hub with Data centers drill-down
Batch-jobs Guide lands here; cohort and Jev pages linked as siblings (#714).
EOF
)"
```
---
### Task 5: PR
**Files:**
- None new (push branch + open PR)
- [ ] **Step 1: Push branch**
```bash
git push -u origin HEAD
```
- [ ] **Step 2: Open PR**
```bash
gh pr create --base main --title "feat(web): profile Docs link and admin contextual guides" --body "$(cat <<'EOF'
## Summary
- One **Documentation** item on the avatar menu β docs intro
- Shared `docsLinks` map; Admin **Guide β** on batch jobs / meeting kinds / application links
- Batch jobs Guide β AI Policy Analysis hub with Data centers drill-down in docs
Closes #714
## Design
- [app-docs-linking-design](web_docs/docs/development/app-docs-linking-design.md)
- [app-docs-linking-plan](web_docs/docs/development/app-docs-linking-plan.md)
## Test plan
- [ ] Vitest: `cd web_app && npm test -- --run src/utils/docsLinks.test.ts`
- [ ] Signed in: avatar β Documentation opens intro (new tab)
- [ ] Admin β Batch jobs: Guide β ai-policy-analysis; Lighthouse: no Guide
- [ ] Hub page shows Data centers link to cohort doc
- [ ] CI: Frontend Build + Documentation Build green
EOF
)"
```
- [ ] **Step 3: Wait for required checks; merge when green**
Prefer review; solo maintainer may `gh pr merge <n> --squash --admin` only if that is the repo stopgap.
---
## Spec coverage (self-review)
| Spec requirement | Task |
|---|---|
| Profile Documentation β intro | Task 2 |
| `docsLinks` / `DOCS_INTRO` / map | Task 1 |
| Batch jobs β ai-policy-analysis | Tasks 1, 3 |
| Meeting kinds / application links Guides | Tasks 1, 3 |
| No Lighthouse Guide | Tasks 1, 3 |
| Hub Data centers drill-down | Task 4 |
| Out of scope product-wide Guides | Not scheduled |
| Issue + PR | Task 5 / #714 |
|