diff --git a/.devspark.work/pr-review/pr-8.md b/.devspark.work/pr-review/pr-8.md new file mode 100644 index 00000000..1ebe8e92 --- /dev/null +++ b/.devspark.work/pr-review/pr-8.md @@ -0,0 +1,377 @@ +--- +pr: 8 +devspark_version: 9.6.0 +reviewed_commit: 6f936707f15f362dbe777bf236957ba5f35226bc +revision: 5 +findings: &id001 + critical: 0 + high: 0 + medium: 1 + low: 2 + con: 0 +historical_findings: *id001 +current_findings: + critical: 0 + high: 0 + medium: 1 + low: 2 +current_state_counts: + open: 0 + remediated: 0 + awaiting-verification: 3 + reopened: 0 + resolved: 0 +unresolved_blockers: 1 +recommendation: request-changes +gate_status: pass +max_severity: medium +risk_rating: high +risk_score: 14 +risk_escalated: false +review_state: + format_version: 1 + findings: + - finding_id: M-01 + aliases: [] + severity: medium + category: testing + blocking: true + description: 'The tests for portfolio detection were removed with UserPicker.test.jsx, + but the behavior moved to usePortfolio and is now untested. usePortfolio decides + public versus self-hosted mode (a static host that answers portfolio.json with + HTML, or a network failure, must yield portfolio null), which sources are listed + (enabled user/org/repo only), their slugs, and which are ready (HEAD check). + The self-hosted loading path in useRepositoryData (choose sources for the scope, + fetch each, merge) is also never exercised: App.test.jsx mocks both hooks. This + is the switch that keeps the public Pages dashboard unchanged.' + expected_outcome: Executable tests cover usePortfolio (HTML response and network + failure give portfolio null; disabled and unsupported sources are dropped; worker + slug wins, derived slug otherwise; uncollected sources are not ready) and the + self-hosted branch of useRepositoryData (fetches only the scope's sources and + merges them; public mode fetches the single profile). + evidence: + - frontend/tests/UserPicker.test.jsx deleted; its useUserOptions cases (static + host HTML, readiness, slug derivation, network failure) have no successor + - 'frontend/src/hooks/usePortfolio.js:54-105 carries the same logic with no direct + test (grep: only App.test.jsx references usePortfolio, as a mock)' + - frontend/tests/App.test.jsx mocks @/hooks/useRepositoryData, so useRepositoryData.js:44-53 + (sourcesForScope + Promise.all + mergeDashboards) never runs under test + recommended_action: Port the removed cases to a usePortfolio test (renderHook + with a stubbed fetch), and add a useRepositoryData test that stubs fetchDashboardData + and asserts the requested users and the merged result for a client scope and + for public mode. + execution_mode: manual + status: awaiting-verification + outcome: '' + provenance: + kind: native + location: frontend/src/hooks/usePortfolio.js:54 + remediation: + correction_commit: 41084831851017145a8897a565aad79a2b4bbe4e + author_context: Claude Code session that authored the PR (same session as the + review) + explanation: 'New tests/DataHooks.test.jsx: usePortfolio returns portfolio null + for an HTML response and for a network failure, keeps only enabled user/org/repo + sources, uses the worker slug or derives one, and marks uncollected sources + not ready; useRepositoryData waits for the portfolio, loads the single profile + in public mode, and in a scope fetches only the needed sources and merges + them (re-fetching only `me` for the Internal client).' + author_validation: './run-validation.ps1 exit 0 at 41084831851017145a8897a565aad79a2b4bbe4e: + pytest 572 passed, vitest 213 passed (23 files), eslint, prettier, build, + pip-audit and npm audit clean.' + proof_obligation: A distinct reviewer confirms the tests exercise the real hooks + (not mocks of them) and would fail if public-mode detection or scope source + selection regressed. + verification: null + disposition: null + reopen_reason: null + - finding_id: L-01 + aliases: [] + severity: low + category: correctness + blocking: false + description: 'Merging sources puts repositories from different owners in one list, + but the list is still keyed and navigated by the short name. Two repositories + with the same name collide: duplicate React keys in the Health table and Overview + grid, and drawer Previous/Next and its position counter find the first match. + Before this PR each list held one owner''s repositories.' + expected_outcome: Lists and drawer navigation identify a repository by its full + name. + evidence: + - frontend/src/hooks/useDashboardShell.js:133,143 and frontend/src/App.jsx:426 + compare `r.name === selectedRepo.name` + - frontend/src/components/Attention/AttentionView.jsx:229 `key={repo.name}`; RepositoryGrid.jsx:341 + `key={repo.name}` + - Server portfolio.json (2026-11-22) lists two repositories named apitestspark + under different owners; the collected files currently hold only one, so the + collision is not yet visible + recommended_action: Compare and key on fullNameOf(repo) (already exported from + utils/scope.js) in useDashboardShell, App and the list keys. + execution_mode: manual + status: awaiting-verification + outcome: '' + provenance: + kind: native + location: frontend/src/hooks/useDashboardShell.js:133 + remediation: + correction_commit: 41084831851017145a8897a565aad79a2b4bbe4e + author_context: Claude Code session that authored the PR (same session as the + review) + explanation: 'useDashboardShell exports sameRepo (full-name comparison via fullNameOf); + drawer Previous/Next and the position counter in App use it, and Health rows, + Overview cards and QualityMatrix rows are keyed by full name. Regression test: + in a list with Acme/api and Me/api, Next from Me/api goes to Me/tool (name + matching would stay on Me/api).' + author_validation: './run-validation.ps1 exit 0 at 41084831851017145a8897a565aad79a2b4bbe4e: + pytest 572 passed, vitest 213 passed (23 files), eslint, prettier, build, + pip-audit and npm audit clean.' + proof_obligation: A distinct reviewer confirms two repositories sharing a name + are distinct in lists and drawer navigation, and that single-owner (public) + lists behave as before. + verification: null + disposition: null + reopen_reason: null + - finding_id: L-02 + aliases: [] + severity: low + category: error-handling + blocking: false + description: A portfolio or client scope now loads several source files with Promise.all, + so one failing file replaces every section with 'Error loading data', and the + message (from fetchDashboardData) does not say which source failed. Principle + III requires errors to include context and actionable guidance. + expected_outcome: A failed source file is named in the error shown to the operator. + evidence: + - frontend/src/hooks/useRepositoryData.js:48-52 `await Promise.all(slugs.map(... + fetchDashboardData ...))` + - 'frontend/src/services/dataService.js:129-130 error text is `Failed to fetch + dashboard data: ${status} ${statusText}` with no source' + recommended_action: 'Smallest: wrap each fetch so a rejection is rethrown as `Could + not load : `. Optional: use Promise.allSettled and show the + loaded sources with a notice naming the failed one.' + execution_mode: manual + status: awaiting-verification + outcome: '' + provenance: + kind: native + location: frontend/src/hooks/useRepositoryData.js:48 + remediation: + correction_commit: 41084831851017145a8897a565aad79a2b4bbe4e + author_context: Claude Code session that authored the PR (same session as the + review) + explanation: 'useRepositoryData rethrows each failed source fetch as `Could + not load the data for source "": `. Test asserts the message + for a 404 on one of two sources.' + author_validation: './run-validation.ps1 exit 0 at 41084831851017145a8897a565aad79a2b4bbe4e: + pytest 572 passed, vitest 213 passed (23 files), eslint, prettier, build, + pip-audit and npm audit clean.' + proof_obligation: A distinct reviewer confirms the error shown names the failing + source and keeps the cause. + verification: null + disposition: null + reopen_reason: null + conditions: [] + last_change: + operation: remediate-and-submit + affected: + - L-02 + event_fingerprint: 5f76b4246051861f35f770ad20b233cfa27d6853b587ddef725ae79692923e3e + actor_role: '' + actor_context: '' + explanation: '' +--- +# Pull Request Review: feat(dashboard): unified operator experience with one scope + +- **PR**: #8 — 002-work-ps-022-unified-operator → main — OPEN +- **Reviewed Commit**: 6f936707f15f362dbe777bf236957ba5f35226bc +- **Review Date**: 2026-11-22 02:57:14 UTC (last updated 2026-11-22 02:57:14 UTC) +- **Constitution Version**: 1.2.0 + +## Revision Log + +| Rev | Commit | Date | Critical | High | Medium | Low | CON | Test Command | Result | +|-----|--------|------|----------|------|--------|-----|-----|--------------|--------| +| 1 | 6f93670 | 2026-11-22 | 0 | 0 | 1 | 2 | 0 | `npx vitest run` (frontend); reused: CI validate on 6f93670 | pass | + +## Test Evidence + +- reused: GitHub Actions `validate` on 6f93670 — pass (run 44977744728; full `run-validation` incl. pytest, vitest, lint, build, audits). +- Reviewer run (trigger: author-reported local evidence on a high-risk delta): `npx vitest run` in `frontend/` at 6f93670, clean tree, exit 0, 22 files / 206 tests passed. +- Author evidence cited in the PR (not re-run): HTML diff of the public dashboard against `main` (identical Overview, Insights, Health; footer label only), and a run of the scope/merge/alert helpers on the server's data files. Neither is committed, so neither is reproducible from the repository. + +## Stats + +| Metric | Value | +|--------|-------| +| Files changed | 62 | +| Commits | 2 | +| Lines | +3439 −2803 | +| Tiers (P0/P1/P2/P3) | 5/48/7/2 | +| Risk | high (14) — p0_files, auth_or_security_path, large_diff; Knowledge absent (live) | + +## Executive Summary + +**Overall Assessment**: The scope model, stored-count overlay and shared components are small, pure where it matters, and well unit-tested; the public views are unchanged by the author's evidence. One blocking gap: the hooks that decide public versus self-hosted mode and that load a multi-source scope lost or never had tests. The reviewer is the authoring session, so this is not an independent review. Knowledge is `absent` (`.knowledge/` holds only the constitution), so tiers come from path patterns alone. + +- Constitution: PASS with one partial (5 applicable principles evaluated) · Durable delta: FAIL (1 open PRD3-class finding, M-01) +- Security: 0 issues · Quality: 2 recommendations · Testing: INADEQUATE (M-01) · Docs: PASS +- Constitution Improvements: 0 CON findings + + +## Action Items + +### Immediate Actions (Blocking) + +- [ ] **M-01** [Pending independent verification] — The tests for portfolio detection were removed with UserPicker.test.jsx, but the behavior moved to usePortfolio and is now untested. usePortfolio decides public versus self-hosted mode (a static host that answers portfolio.json with HTML, or a network failure, must yield portfolio null), which sources are listed (enabled user/org/repo only), their slugs, and which are ready (HEAD check). The self-hosted loading path in useRepositoryData (choose sources for the scope, fetch each, merge) is also never exercised: App.test.jsx mocks both hooks. This is the switch that keeps the public Pages dashboard unchanged. + +### Recommended Improvements + +- [ ] **L-01** [awaiting-verification] — Merging sources puts repositories from different owners in one list, but the list is still keyed and navigated by the short name. Two repositories with the same name collide: duplicate React keys in the Health table and Overview grid, and drawer Previous/Next and its position counter find the first match. Before this PR each list held one owner's repositories. +- [ ] **L-02** [awaiting-verification] — A portfolio or client scope now loads several source files with Promise.all, so one failing file replaces every section with 'Error loading data', and the message (from fetchDashboardData) does not say which source failed. Principle III requires errors to include context and actionable guidance. + +### Constitution Improvements + +- None. + + +## Findings Detail + +| ID | Status | Severity | Blocking | Issue | Expected outcome | Evidence | +| --- | --- | --- | --- | --- | --- | --- | +| M-01 | Pending verification | medium | Yes | The tests for portfolio detection were removed with UserPicker.test.jsx, but the behavior moved to usePortfolio and is now untested. usePortfolio decides public versus self-hosted mode (a static host that answers portfolio.json with HTML, or a network failure, must yield portfolio null), which sources are listed (enabled user/org/repo only), their slugs, and which are ready (HEAD check). The self-hosted loading path in useRepositoryData (choose sources for the scope, fetch each, merge) is also never exercised: App.test.jsx mocks both hooks. This is the switch that keeps the public Pages dashboard unchanged. | Executable tests cover usePortfolio (HTML response and network failure give portfolio null; disabled and unsupported sources are dropped; worker slug wins, derived slug otherwise; uncollected sources are not ready) and the self-hosted branch of useRepositoryData (fetches only the scope's sources and merges them; public mode fetches the single profile). | frontend/tests/UserPicker.test.jsx deleted; its useUserOptions cases (static host HTML, readiness, slug derivation, network failure) have no successor; frontend/src/hooks/usePortfolio.js:54-105 carries the same logic with no direct test (grep: only App.test.jsx references usePortfolio, as a mock); frontend/tests/App.test.jsx mocks @/hooks/useRepositoryData, so useRepositoryData.js:44-53 (sourcesForScope + Promise.all + mergeDashboards) never runs under test | +| L-01 | Pending verification | low | No | Merging sources puts repositories from different owners in one list, but the list is still keyed and navigated by the short name. Two repositories with the same name collide: duplicate React keys in the Health table and Overview grid, and drawer Previous/Next and its position counter find the first match. Before this PR each list held one owner's repositories. | Lists and drawer navigation identify a repository by its full name. | frontend/src/hooks/useDashboardShell.js:133,143 and frontend/src/App.jsx:426 compare `r.name === selectedRepo.name`; frontend/src/components/Attention/AttentionView.jsx:229 `key={repo.name}`; RepositoryGrid.jsx:341 `key={repo.name}`; Server portfolio.json (2026-11-22) lists two repositories named apitestspark under different owners; the collected files currently hold only one, so the collision is not yet visible | +| L-02 | Pending verification | low | No | A portfolio or client scope now loads several source files with Promise.all, so one failing file replaces every section with 'Error loading data', and the message (from fetchDashboardData) does not say which source failed. Principle III requires errors to include context and actionable guidance. | A failed source file is named in the error shown to the operator. | frontend/src/hooks/useRepositoryData.js:48-52 `await Promise.all(slugs.map(... fetchDashboardData ...))`; frontend/src/services/dataService.js:129-130 error text is `Failed to fetch dashboard data: ${status} ${statusText}` with no source | + + +## Constitution Alignment Details + +**Passing**: 4 of 5 applicable principles (I Single Responsibility, II Data Privacy, V Accessibility, VII Self-Hosted Mode). IV and VI are not applicable to this frontend-only delta. + +| Principle | Status | Evidence | Notes | +|-----------|--------|----------|-------| +| III. Fail Fast, Fail Loud | ⚠️ Partial | frontend/src/hooks/useRepositoryData.js:48 | A failed source file is not named in the error (L-02) | + +Notes on passing principles: App.jsx is 444 lines after the split and no new file exceeds 500. No new export, route or file is written; the public build reads no self-hosted file it did not read before. New controls are labelled, the More menu exposes `aria-expanded`/`aria-controls`, tables are captioned with scoped headers. + +## Security + +No issues. CSV export now neutralises formula starters for every table (it previously did so only for Security alerts); no new dependency; the admin API and its auth are unchanged. + +## Testing + +**Status**: INADEQUATE — reviewer-run vitest passes (206), but the mode-detection and multi-source loading hooks are untested (M-01). + +| File | Changes | Type | +|------|---------|------| +| frontend/tests/RepositoryDetail.test.jsx | +75 -0 | Modified | +| frontend/tests/App.test.jsx | +256 -14 | Modified | +| frontend/tests/AttentionView.test.jsx | +20 -2 | Modified | +| frontend/tests/Scope.test.jsx | +401 -0 | Added | +| frontend/tests/SecurityView.test.jsx | +40 -6 | Modified | +| frontend/tests/SharedComponents.test.jsx | +256 -0 | Added | +| frontend/tests/SourcesView.test.jsx | +2 -2 | Modified | +| frontend/tests/UserPicker.test.jsx | +0 -196 | Deleted | + +Removed tests: + +- `tests/UserPicker.test.jsx` — **Unjustified (partly)**: the picker UI is gone, but its `useUserOptions` cases cover behavior that still exists in `usePortfolio` → M-01 + +## Changed Files + +| File | Tier | Changes | Type | +|------|------|---------|------| +| frontend/src/components/DrillDown/RepositoryDetail.jsx | P0 | +10 -0 | Modified | +| frontend/src/components/Security/SecurityView.jsx | P0 | +87 -205 | Modified | +| frontend/src/components/Security/SecurityView.module.css | P0 | +16 -84 | Modified | +| frontend/src/components/Security/alertColumns.jsx | P0 | +115 -0 | Added | +| frontend/tests/RepositoryDetail.test.jsx | P0 | +75 -0 | Modified | +| frontend/src/App.jsx | P1 | +271 -309 | Modified | +| frontend/src/components/Admin/SourcesView.jsx | P1 | +12 -10 | Modified | +| frontend/src/components/Attention/AttentionView.jsx | P1 | +19 -1 | Modified | +| frontend/src/components/Common/CoverageState.jsx | P1 | +92 -0 | Added | +| frontend/src/components/Common/DataTable.jsx | P1 | +76 -0 | Added | +| frontend/src/components/Common/DataViews.module.css | P1 | +106 -0 | Added | +| frontend/src/components/Common/ExportButton.jsx | P1 | +120 -104 | Modified | +| frontend/src/components/Common/FilterBar.jsx | P1 | +63 -0 | Added | +| frontend/src/components/Common/PageHeader.jsx | P1 | +59 -0 | Added | +| frontend/src/components/Common/ScopeSelector.jsx | P1 | +133 -0 | Added | +| frontend/src/components/Common/ScopeSelector.module.css | P1 | +26 -0 | Added | +| frontend/src/components/Common/Tooltip.jsx | P1 | +0 -93 | Deleted | +| frontend/src/components/Common/Tooltip.module.css | P1 | +0 -107 | Deleted | +| frontend/src/components/Common/UserPicker.jsx | P1 | +0 -97 | Deleted | +| frontend/src/components/Common/UserPicker.module.css | P1 | +0 -25 | Deleted | +| frontend/src/components/DrillDown/RepositoryDetail/hooks/useSectionToggles.js | P1 | +1 -0 | Modified | +| frontend/src/components/DrillDown/RepositoryDetail/sections/SecuritySection.jsx | P1 | +61 -0 | Added | +| frontend/src/components/Layout/Container/Container.css | P1 | +0 -51 | Deleted | +| frontend/src/components/Layout/Container/Container.jsx | P1 | +0 -44 | Deleted | +| frontend/src/components/Layout/SafeArea/SafeArea.css | P1 | +0 -8 | Deleted | +| frontend/src/components/Layout/SafeArea/SafeArea.jsx | P1 | +0 -33 | Deleted | +| frontend/src/components/Layout/SkipLink/SkipLink.css | P1 | +0 -39 | Deleted | +| frontend/src/components/Layout/SkipLink/SkipLink.jsx | P1 | +0 -18 | Deleted | +| frontend/src/components/Layout/Stack/Stack.css | P1 | +0 -57 | Deleted | +| frontend/src/components/Layout/Stack/Stack.jsx | P1 | +0 -60 | Deleted | +| frontend/src/components/Mobile/BottomSheet/BottomSheet.css | P1 | +0 -146 | Deleted | +| frontend/src/components/Mobile/BottomSheet/BottomSheet.jsx | P1 | +0 -141 | Deleted | +| frontend/src/components/Mobile/GestureHandler/GestureHandler.css | P1 | +0 -149 | Deleted | +| frontend/src/components/Mobile/GestureHandler/GestureHandler.jsx | P1 | +0 -158 | Deleted | +| frontend/src/components/Mobile/LoadingState/LoadingState.css | P1 | +0 -110 | Deleted | +| frontend/src/components/Mobile/LoadingState/LoadingState.jsx | P1 | +0 -87 | Deleted | +| frontend/src/components/Mobile/TabBar/TabBar.css | P1 | +41 -0 | Modified | +| frontend/src/components/Mobile/TabBar/TabBar.jsx | P1 | +104 -39 | Modified | +| frontend/src/components/Mobile/TouchTarget/TouchTarget.css | P1 | +0 -11 | Deleted | +| frontend/src/components/Mobile/TouchTarget/TouchTarget.jsx | P1 | +0 -76 | Deleted | +| ... 22 more P2/P3 files not listed | | | | + +## Behavioral Changes + +| Change | Before | After | Intentional? | Risk | +|--------|--------|-------|-------------|------| +| Self-hosted landing scope | Default user `makeboldsolutions` | Whole portfolio, merged from every collected source | Yes (PR description) | Overview shows no profile hero until a single source is chosen | +| Health alert cell | `0` when alerts could not be read | Coverage badge (e.g. "No access") | Yes | None; public data normally reads `available` | +| CSV export | Formula starters exported raw; "Dependabot Open Alerts" column always empty (wrong key) | Prefixed with `'`; column filled from `total_open` | Yes | Public CSV output changes for text cells starting with `= + - @` | +| Footer button | "Refresh" / "Force refresh repositories data" | "Reload data" / "Reload data from the published files" | Yes | Public footer text changes | +| Admin hash | `#sources` | `#admin` (`#sources` still resolves) | Yes | None | + +## Deployment & Handoff Notes + +### Deployment Notes + +- After deploy, choose a client and a domain filter on the server and confirm Security and Health follow the scope and show the same alert counts (stated in the PR). + +### Handoff Notes + +None. + +### Observations + +- Until the first security collection after a fresh start, stored coverage is `not_checked`, so Health shows "Not checked yet" instead of the collected count. This follows the one-number rule and clears on the first security run (minutes after start). +- On server data the per-source files hold 38 repositories while the portfolio and Security list 45; the collector writes fewer records than discovery finds. Pre-existing and unrelated to this change. +- The attention score is still computed at collection time from the first-page counts; only displayed counts changed. Documented in the PR and the deployment guide. +- A drawer opened from Security for a repository with no collected record shows a minimal record (name and link). Acceptable; noted for the Sites/Delivery panels that will reuse it. +- `get-pr-context.ps1` returns `number`, `title` and `head_sha` as null for this PR; `commit_sha` was used. + + +## Approval Decision + +**Recommendation**: REQUEST CHANGES — derived from current blockers and applicable review conditions. + +*This local recommendation does not cast a hosted approval vote or authorize merge.* + + +--- + +*Re-review after fixes: `/devspark-pr-review #8 re-review`. Address findings with `/devspark-address-pr-review 8`; commit the review file on its own.* + +--- + + +## Current Review State + +- Historical unique findings: 3 +- Current unresolved findings by severity: {'critical': 0, 'high': 0, 'medium': 1, 'low': 2} +- Current lifecycle state counts: {'open': 0, 'remediated': 0, 'awaiting-verification': 3, 'reopened': 0, 'resolved': 0} +- Unresolved blockers: 1 +- Pending independent verification: 3 +- Review conditions: pass +- Local recommendation: request-changes + diff --git a/.devspark.work/specs/002-work-ps-022-unified-operator/work.md b/.devspark.work/specs/002-work-ps-022-unified-operator/work.md new file mode 100644 index 00000000..a23c746a --- /dev/null +++ b/.devspark.work/specs/002-work-ps-022-unified-operator/work.md @@ -0,0 +1,100 @@ +# Work: ps-022 Unified operator experience + +**Status**: Complete +**Branch**: 002-work-ps-022-unified-operator (from main 54a09ef) +**Source**: roadmap item ps-022 (`.devspark.work/roadmap/specs/ps-022-unified-operator-experience.md`) + +## Intended outcome + +One consistent self-hosted app: a single scope selector (portfolio → client → source → repository, plus +domain filters) that every view honours, fixed sections, shared page building blocks, one source per +number, and views that link to each other. The public GitHub Pages dashboard is unchanged. The whole +item ships in one PR (developer decision, 2026-11-22, chose this over splitting). + +## Acceptance evidence + +- Choosing a client, source, or repository changes every view, Security included, with no page reload, + and the URL restores it. The old `?user=` links and the existing hashes keep working. +- Health, the drawer, and the fix-score prompt show the same open-alert count as Security for a + repository with more than 100 alerts. All three read the ps-006 store in self-hosted mode. +- A Security row opens the repository drawer, and the drawer has a Security panel with that repository's + alerts. +- Every table exports through `ExportButton`. Security drops its own CSV code. +- One shared coverage/state component shows zero, unavailable, unauthorized, unsupported, and stale + distinctly, and every view uses it. +- There is one shared page header, filter bar (including domain filters), and data table. +- Sections: Overview, Health, Security, Sites, Delivery, Presence, Admin. A section appears only when it + has data. The mobile tab bar holds the primary sections and puts the rest behind an overflow. +- No unused component remains. `EmptyState`, `GestureHandler`, `TouchTarget`, `SafeArea`, and the mobile + `LoadingState` are each either adopted or removed, and the two `LoadingState`s become one. +- The refresh actions are labelled "Reload data" (browser cache) and "Collect now" (worker). +- The public Pages build renders Overview, Insights, Health, and the drawer unchanged. +- vitest covers scope switching, cross-links, the shared components, and accessibility. Existing tests + pass, and `./run-validation.ps1` exits 0. + +## Material exclusions + +- No content for undelivered sections: Sites, Delivery, and Presence stay hidden. +- No rebranding. +- No per-client access control. +- No change to the attention-score model beyond its data source. + +## Operating assumptions + +- Self-hosted mode is detected by the existing data files. `portfolio.json` and + `security/dependabot.json` are present only on the self-hosted server. The admin API is optional. +- The decision owner is the developer, a single administrator. + +## Facts verified at start (main 54a09ef) + +- `useDependabot.js` always loads the portfolio-wide `data/security/dependabot.json`. Security ignores + `?user=`. +- `dataService.js` loads `data/users//repositories.json` for the `?user=` source. Choosing a source + calls `window.location.reload()`. +- `FixScorePromptSection.jsx` reads `security.dependabot.total_open`, the fetcher's first-page summary. +- The per-source `repositories.json` is written by `worker/loop.py` without reading the registry, so it + has no classifications. Client, project, application, and domain values exist only in `portfolio.json`. +- The unused mobile/layout components listed in the spec exist under `components/Mobile` and + `components/Layout`. + +## Open design point (decide during implementation, from evidence) + +- **Portfolio and client scope span several sources**, but repository data is stored per source. + - Option A: the frontend loads the needed per-source files and de-duplicates them by `full_name`. + - Option B: the worker writes one portfolio-wide repositories file. + - Prefer A unless loading many sources is measurably slow. + - Classifications are joined from `portfolio.json` by `full_name`, which fills the per-source gap + recorded at ps-023 closeout. + +## Invariants + +- Domain invariant: a repository is identified by its case-insensitive `full_name` in every scope and + view, so the same repository shows the same counts everywhere. +- Architectural constraint: public mode never requests the admin API or self-hosted-only files in a way + that breaks or changes the Pages build. + +## Verification expectations + +- Public Pages build: `verify:snapshot-neutral`. The Overview, Insights, Health, and drawer output must be + unchanged in public mode. +- If the worker export changes (Option B, or added fields): `verify:end-to-end` against a real worker + run. Checking it on the server after deploy is a `stage: post-deploy` item, not pre-merge proof. + +## Material decisions (implementation) + +- Open design point resolved as Option A. The browser loads the per-source files the scope needs and + joins classifications from `portfolio.json`; no worker change. +- Insights is kept as a section (the public view requires it), alongside the listed sections. +- Stored alert counts replace the collected counts everywhere they are shown. The attention score is + still computed at collection time; recomputing it would change the score model, which is out of scope. + +## Known differences (not defects of this change) + +- On server data (2026-11-22), the per-source files hold 38 repositories while the portfolio and + Security list 45. The collector writes fewer records than discovery finds, so Overview and Security + can list different repository sets. + +## Next action + +Commit, then `/devspark-create-pr`. After deploy: pick a client and a domain filter on the server, +and confirm that Security and Health follow the choice and show the same alert counts. diff --git a/.documentation/guides/DOCKER_DEPLOYMENT.md b/.documentation/guides/DOCKER_DEPLOYMENT.md index 8b21bd8a..58193ac2 100644 --- a/.documentation/guides/DOCKER_DEPLOYMENT.md +++ b/.documentation/guides/DOCKER_DEPLOYMENT.md @@ -58,7 +58,7 @@ keeps private data out of this release). Prefer a secret file over `GITHUB_TOKEN 2. Stack variables: `SPARK_USER`, `GITHUB_TOKEN` (or the secret-file approach), `BIND_ADDRESS=192.168.1.197`, `WEB_PORT=8086`. 3. Deploy. Both containers become healthy; the worker collects on start and then every interval. -4. Refresh now: restart the `worker` container in Portainer. +4. To collect immediately, use **Collect now** in Admin, or restart the `worker` container in Portainer. 5. Browse to `http://192.168.1.197:8086` from the LAN. The default bind is `127.0.0.1`; the app has no authentication yet, so keep it on the trusted LAN and do @@ -134,7 +134,25 @@ dashboard shows a **Sources** page only when the API answers; on GitHub Pages it encrypted at rest. A token's expiry is tracked: the page warns when one is within 14 days, and a source whose token has expired reports `connection_unusable` instead of silently using another. Sources without a token use the stack's `GITHUB_TOKEN`. -- **Refresh now:** asks the worker to collect; it starts within seconds. +- **Collect now:** asks the worker to collect; it starts within seconds. + +**Scope and sections** +- **Scope:** the bar under the header chooses what every section shows: the whole portfolio, a + client (repositories with no client are **Internal**), a source, or one repository, filtered by + any domain value. Each list offers only choices within the levels above it. The scope is part of + the URL (`?client=Acme&source=acme&repo=Acme/web&d.tier=core`), so a link or reload restores it; + older `?user=` links still work. Overview, Insights, Health and Security all follow it. +- **Sections:** Overview, Insights, Health, Security and Admin. Sites, Delivery and Presence appear + only once those capabilities collect data. Old `#sources` links open Admin. On a phone, sections + that do not fit in the bottom bar are under **More**. +- **One number per fact:** wherever an open Dependabot alert count appears (Health, the repository + drawer, the fix-score prompt, exports), it comes from the stored alerts behind Security, not the + first-page summary taken during collection. The attention score itself is still computed at + collection time. A repository whose alerts could not be read shows why, never zero. +- **Links:** a repository name in Security opens that repository's details; the details drawer has a + Security panel listing its open alerts. +- **Reload data** (footer) re-reads the published files in the browser. **Collect now** (Admin) asks + the worker to collect from GitHub. **Security notes** - Passwords are stored as Argon2id hashes; session cookies are `HttpOnly`, `SameSite=Strict`, and only @@ -163,7 +181,7 @@ After the first collection, and then every `SPARK_SECURITY_INTERVAL` (default `6 `off` disables it), the worker reads every Dependabot alert (open, dismissed and fixed, all pages) for each **public** repository an enabled source reaches. Alerts are kept in the database, one observation of the counts is added per read, and `/data/security/dependabot.json` is rewritten for the **Security** -view. "Refresh now" also triggers it. The result appears in `/data/status.json` under `security`. +view. "Collect now" also triggers it. The result appears in `/data/status.json` under `security`. The token needs read access to Dependabot alerts: for a fine-grained token, the **Dependabot alerts** repository permission set to read. A repository that cannot be read is listed in the view's Coverage diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index ba1e2193..b7fd7a29 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -1,27 +1,43 @@ -import React, { Suspense, lazy } from "react"; +import React, { Suspense, lazy, useCallback, useMemo } from "react"; import { ViewportProvider } from "@/contexts/ViewportContext"; import { ThemeProvider } from "@/contexts/ThemeContext"; import useRepositoryData from "@/hooks/useRepositoryData"; -import { useDashboardShell } from "@/hooks/useDashboardShell"; +import { sameRepo, useDashboardShell } from "@/hooks/useDashboardShell"; +import usePortfolio from "@/hooks/usePortfolio"; +import useScope from "@/hooks/useScope"; +import useAdminAvailable from "@/hooks/useAdminAvailable"; +import useDependabot from "@/hooks/useDependabot"; import LoadingState from "@/components/Common/LoadingState"; import FilterControls from "@/components/Common/FilterControls"; +import PageHeader from "@/components/Common/PageHeader"; import ContributionHeatmap from "@/components/Visualizations/ContributionHeatmap"; import ProfileHero from "@/components/ProfileHero/ProfileHero"; -import { Eyebrow, Card, Button } from "@/components/Brand"; -import { RefreshCw } from "lucide-react"; +import { Card, Button } from "@/components/Brand"; import RepositoryGrid from "@/components/RepositoryGrid/RepositoryGrid"; import TabBar from "@/components/Mobile/TabBar/TabBar"; -import { OfflineIndicator } from "@/components/Mobile/OfflineIndicator/OfflineIndicator"; -import CollectionStatus from "@/components/Common/CollectionStatus"; -import UserPicker from "@/components/Common/UserPicker"; -import useUserOptions from "@/hooks/useUserOptions"; -import useAdminAvailable from "@/hooks/useAdminAvailable"; -import useDependabot from "@/hooks/useDependabot"; +import EmptyState from "@/components/Mobile/EmptyState/EmptyState"; +import AppHeader from "@/components/Shell/AppHeader"; +import AppFooter from "@/components/Shell/AppFooter"; import { ToastContainer } from "@/components/Mobile/Toast/Toast"; +import { visibleSections } from "@/config/sections"; +import { + EMPTY_SCOPE, + fullNameOf, + isWholePortfolio, + repoKey, + scopeLabel, + scopedRepoKeys, +} from "@/utils/scope"; +import { + alertsForRepository, + scopeAlertFile, + storedCoverage, + withStoredAlerts, +} from "@/utils/storedAlerts"; -// SIZE JUSTIFICATION (Constitution I): App composes routing/layout for the -// three primary views and delegates all cross-cutting state (toasts, view -// routing, active result list, refresh) to useDashboardShell. +// Composes the shell (header, sections, footer, drawer, toasts). Data +// loading lives in the hooks and utils above; cross-cutting view state in +// useDashboardShell, so this file stays compositional. const DashboardView = lazy( () => import("@/components/Visualizations/DashboardView"), @@ -38,23 +54,53 @@ const RepositoryDetail = lazy( /** * GitHub Stats Spark Dashboard - Root App Component * - * Composes the dashboard shell (header/nav, main content, footer, drawer, - * toasts) around the three primary views. All cross-cutting state lives in - * useDashboardShell so this component stays presentational. + * Public (GitHub Pages): one profile, Overview, Insights and Health. + * Self-hosted (a portfolio.json exists): a scope selector that every + * section follows, alert counts from the stored Dependabot alerts, and the + * Security and Admin sections when their data is available. * * @component */ function App() { + const { loading: portfolioLoading, portfolio } = usePortfolio(); + const [scope, setScope] = useScope(); + const selfHosted = Boolean(portfolio); const { - data, + data: collected, loading: dataLoading, error: dataError, refetch, - } = useRepositoryData(); + } = useRepositoryData({ + portfolio, + portfolioLoading, + scope: selfHosted ? scope : null, + }); const adminAvailable = useAdminAvailable(); - const dependabot = useDependabot(); - const userOptions = useUserOptions(); - const showUserPicker = userOptions.length >= 2; + const alertFile = useDependabot(); + + // One source per number: stored alerts replace the collected summary. + const data = useMemo(() => { + if (!collected || !alertFile) return collected; + const coverage = storedCoverage(alertFile); + return { + ...collected, + repositories: collected.repositories.map((repo) => + withStoredAlerts(repo, coverage), + ), + }; + }, [collected, alertFile]); + + const scopeKeys = useMemo( + () => + selfHosted && !isWholePortfolio(scope) + ? scopedRepoKeys(portfolio, scope) + : null, + [selfHosted, portfolio, scope], + ); + const scopedAlerts = useMemo( + () => scopeAlertFile(alertFile, scopeKeys), + [alertFile, scopeKeys], + ); const { toasts, @@ -77,119 +123,72 @@ function App() { handleForceRefresh, } = useDashboardShell({ data, refetch }); - // Admin pages do not depend on dashboard data, so a data failure must not hide them. - const onAdminView = adminAvailable && currentView === "sources"; + const sections = visibleSections({ + security: Boolean(alertFile), + admin: adminAvailable, + }); + const header = selfHosted + ? { + scope: scopeLabel(scope, portfolio), + freshness: [ + { label: "Repository data", at: data?.metadata?.generated_at }, + ...(alertFile + ? [{ label: "Security", at: alertFile.generated_at }] + : []), + ], + } + : {}; + + const openRepository = useCallback( + (fullName) => { + const key = repoKey(fullName); + const list = data?.repositories || []; + const found = list.find((repo) => repoKey(fullNameOf(repo)) === key); + if (found) { + handleRepoClick(found, list); + return; + } + const entry = alertFile?.repositories.find( + (repo) => repoKey(repo.full_name) === key, + ); + handleRepoClick( + { + name: fullName.split("/").pop(), + full_name: fullName, + url: entry?.html_url, + }, + [], + ); + }, + [data, alertFile, handleRepoClick], + ); + + // Admin and Security do not depend on dashboard data, so a data failure must not hide them. + const onAdminView = adminAvailable && currentView === "admin"; const onSecurityView = currentView === "security"; const standaloneView = onAdminView || onSecurityView; - const loading = dataLoading && !standaloneView; + const loading = (dataLoading || portfolioLoading) && !standaloneView; const error = standaloneView ? null : dataError; + const emptyScope = + selfHosted && data && (data.repositories || []).length === 0; return (
- {/* Header */} -
-
-
-
- - -
- GitHubSpark - {!showUserPicker && ( - - {data?.profile?.username || "MakeBoldSolutions"} - - )} -
-
- {/* Outside the link: a control inside an anchor is invalid and would navigate home. */} - -
- - {/* Navigation Menu */} - -
-
- refetch({ cacheBust: false })} /> - -
+ refetch({ cacheBust: false })} + /> - {/* Main Content */}
-
- Security -

Dependabot alerts

-
- {dependabot ? ( + + {scopedAlerts ? ( } > - + ) : (

@@ -228,15 +233,13 @@ function App() { )} - {/* Loading State */} - {loading && ( + {loading && !standaloneView && ( )} - {/* Error State */} {error && !loading && (

Error loading data

@@ -257,205 +260,161 @@ function App() { )} - {/* Data Loaded - Render Current View */} - {!loading && !error && data && ( - <> - {currentView === "table" && ( -
- {/* Profile Hero */} - + {!loading && + !error && + data && + !standaloneView && + emptyScope && ( + setScope(EMPTY_SCOPE)} + /> + )} - {/* Contribution heatmap for trailing 365-day activity */} - {data?.profile?.activity_calendar && ( -
- + {currentView === "table" && ( +
+ {selfHosted && !data.profile && ( + -
- )} - - {/* Repository Grid */} - -
- )} + )} + - {currentView === "visualizations" && ( -
-
- Insights -

- Repository insights -

-

- Showing {processedRepositories.length} repositories - {filterLanguage && ` filtered by ${filterLanguage}`} -

-
+ {data?.profile?.activity_calendar && ( +
+ +
+ )} - {availableLanguages.length > 0 && ( - - )} +
+ )} - - } + {currentView === "visualizations" && ( +
- - handleRepoClick(repo, processedRepositories) + + Showing {processedRepositories.length}{" "} + repositories + {filterLanguage && + ` filtered by ${filterLanguage}`} + } + {...header} /> - -
- )} - {currentView === "attention" && ( -
-
- Health -

- Repositories needing attention -

-

- Ranked by pull request pressure, security findings, - staleness, and dependency health -

-
+ {availableLanguages.length > 0 && ( + + )} - {availableLanguages.length > 0 && ( - - )} + + } + > + + handleRepoClick(repo, processedRepositories) + } + /> + +
+ )} - - } + {currentView === "attention" && ( +
- - -
- )} - - )} + + {availableLanguages.length > 0 && ( + + )} + + + } + > + + + + )} + + )}
- {/* Mobile TabBar Navigation */} - {/* Footer */} - + - {/* Detail Drawer (drill-down) */} {selectedRepo && ( }> r.name === selectedRepo.name, + resultIndex={activeResultList.findIndex((r) => + sameRepo(r, selectedRepo), )} resultTotal={activeResultList.length} + security={alertsForRepository( + alertFile, + fullNameOf(selectedRepo), + )} /> )} - {/* Toast Notifications */}
diff --git a/frontend/src/components/Admin/SourcesView.jsx b/frontend/src/components/Admin/SourcesView.jsx index e1299dc4..1d280ca0 100644 --- a/frontend/src/components/Admin/SourcesView.jsx +++ b/frontend/src/components/Admin/SourcesView.jsx @@ -1,6 +1,7 @@ import { useCallback, useEffect, useState } from "react"; import PropTypes from "prop-types"; -import { Button, Eyebrow } from "@/components/Brand"; +import { Button } from "@/components/Brand"; +import PageHeader from "@/components/Common/PageHeader"; import { adminApi } from "@/services/adminApi"; import LoginForm from "./LoginForm"; import SourcesPanel from "./SourcesPanel"; @@ -44,13 +45,13 @@ export default function SourcesView({ onToast }) { const changed = useCallback(() => setChangeCount((count) => count + 1), []); const openLists = useCallback(() => setTab("lists"), []); - const refreshNow = async () => { + const collectNow = async () => { try { await adminApi.refresh(); setRefreshNote( - "Refresh requested. The worker starts within seconds; watch the status line in the header.", + "Collection requested. The worker starts within seconds; watch the status line in the header.", ); - onToast?.("Refresh requested", "info"); + onToast?.("Collection requested", "info"); } catch (error) { if (error.status === 401) signedOut(); setRefreshNote(error.message); @@ -68,10 +69,11 @@ export default function SourcesView({ onToast }) { aria-labelledby="admin-heading" data-testid="admin-view" > -
- Admin -

Manage sources

-
+ {auth.state === "checking" &&

Checking sign-in…

} @@ -86,8 +88,8 @@ export default function SourcesView({ onToast }) { Signed in as {auth.info.username}
-
)} @@ -256,6 +267,11 @@ ExportButton.propTypes = { label: PropTypes.string, disabled: PropTypes.bool, onToast: PropTypes.func, + columns: PropTypes.arrayOf( + PropTypes.shape({ key: PropTypes.string, label: PropTypes.string }), + ), + noun: PropTypes.string, + jsonDescription: PropTypes.string, }; export default ExportButton; diff --git a/frontend/src/components/Common/FilterBar.jsx b/frontend/src/components/Common/FilterBar.jsx new file mode 100644 index 00000000..aef77fe1 --- /dev/null +++ b/frontend/src/components/Common/FilterBar.jsx @@ -0,0 +1,63 @@ +import PropTypes from "prop-types"; +import styles from "./DataViews.module.css"; + +/** + * A row of labelled select filters. Each field offers "all" (empty value) + * first unless `allLabel` is null. Extra controls (an export menu, a reset + * button) go in `children`, after the fields. + */ +export default function FilterBar({ label, fields, children }) { + return ( +
event.preventDefault()} + > + {fields.map((field) => ( + + ))} + {children} +
+ ); +} + +FilterBar.propTypes = { + label: PropTypes.string.isRequired, + fields: PropTypes.arrayOf( + PropTypes.shape({ + id: PropTypes.string.isRequired, + label: PropTypes.string.isRequired, + value: PropTypes.string.isRequired, + onChange: PropTypes.func.isRequired, + options: PropTypes.arrayOf( + PropTypes.shape({ + value: PropTypes.string.isRequired, + label: PropTypes.string.isRequired, + disabled: PropTypes.bool, + }), + ).isRequired, + allLabel: PropTypes.string, + }), + ).isRequired, + children: PropTypes.node, +}; diff --git a/frontend/src/components/Common/PageHeader.jsx b/frontend/src/components/Common/PageHeader.jsx new file mode 100644 index 00000000..bcae61f7 --- /dev/null +++ b/frontend/src/components/Common/PageHeader.jsx @@ -0,0 +1,59 @@ +import PropTypes from "prop-types"; +import { Eyebrow } from "@/components/Brand"; +import styles from "./DataViews.module.css"; + +const formatTime = (value) => { + const parsed = value ? new Date(value) : null; + return parsed && !Number.isNaN(parsed.getTime()) + ? parsed.toLocaleString() + : "not yet"; +}; + +/** + * The heading every section starts with: eyebrow, title and an optional + * status line. In the self-hosted deployment it also names the scope being + * shown and how fresh each kind of data is. Without `scope` or `freshness` + * it renders exactly the original markup, so the public dashboard is + * unchanged. + */ +export default function PageHeader({ + eyebrow, + title, + titleId, + description = null, + scope = null, + freshness = [], +}) { + return ( +
+ {eyebrow} +

{title}

+ {description && ( +

+ {description} +

+ )} + {(scope || freshness.length > 0) && ( +

+ {scope && Showing: {scope}} + {freshness.map((item) => ( + + {item.label} updated {formatTime(item.at)} + + ))} +

+ )} +
+ ); +} + +PageHeader.propTypes = { + eyebrow: PropTypes.string.isRequired, + title: PropTypes.string.isRequired, + titleId: PropTypes.string.isRequired, + description: PropTypes.node, + scope: PropTypes.string, + freshness: PropTypes.arrayOf( + PropTypes.shape({ label: PropTypes.string, at: PropTypes.string }), + ), +}; diff --git a/frontend/src/components/Common/ScopeSelector.jsx b/frontend/src/components/Common/ScopeSelector.jsx new file mode 100644 index 00000000..122a4b87 --- /dev/null +++ b/frontend/src/components/Common/ScopeSelector.jsx @@ -0,0 +1,133 @@ +import { useMemo } from "react"; +import PropTypes from "prop-types"; +import FilterBar from "./FilterBar"; +import { + clientChoices, + isWholePortfolio, + scopedRepoKeys, + repoKey, + EMPTY_SCOPE, +} from "@/utils/scope"; +import styles from "./ScopeSelector.module.css"; + +const SOURCE_GROUP = { user: "user", org: "organization", repo: "repository" }; + +/** + * Chooses what every view shows: the whole portfolio, a client, a source + * or one repository, optionally filtered by classification values. Each + * list offers only choices that exist within the levels above it. + * Choosing a level clears the levels below it. + */ +export default function ScopeSelector({ portfolio, scope, onChange }) { + const fields = useMemo(() => { + const clients = clientChoices(portfolio); + const withinClient = scopedRepoKeys(portfolio, { + ...EMPTY_SCOPE, + client: scope.client, + }); + const reaching = new Set( + portfolio.repositories + .filter((r) => withinClient.has(repoKey(r.full_name))) + .flatMap((r) => (r.sources || []).map((s) => s.toLowerCase())), + ); + const sources = portfolio.sources + .filter((s) => reaching.has(`${s.type}:${s.identifier}`.toLowerCase())) + .map((s) => ({ + value: s.slug, + label: `${s.identifier} (${SOURCE_GROUP[s.type] || s.type})${ + s.ready ? "" : " - not collected yet" + }`, + disabled: !s.ready && s.slug !== scope.source, + })); + const withinSource = scopedRepoKeys(portfolio, { + ...EMPTY_SCOPE, + client: scope.client, + source: scope.source, + }); + const repositories = portfolio.repositories + .filter((r) => withinSource.has(repoKey(r.full_name))) + .map((r) => ({ value: r.full_name, label: r.full_name })) + .sort((a, b) => a.label.localeCompare(b.label)); + + const list = []; + if (clients.length > 0) { + list.push({ + id: "scope-client", + label: "Client", + value: scope.client, + allLabel: "All clients", + options: clients, + onChange: (client) => + onChange({ ...scope, client, source: "", repo: "" }), + }); + } + list.push( + { + id: "scope-source", + label: "Source", + value: scope.source, + allLabel: "All sources", + options: sources, + onChange: (source) => onChange({ ...scope, source, repo: "" }), + }, + { + id: "scope-repo", + label: "Repository", + value: scope.repo, + allLabel: "All repositories", + options: repositories, + onChange: (repo) => onChange({ ...scope, repo }), + }, + ); + for (const domain of portfolio.domains) { + list.push({ + id: `scope-domain-${domain.key}`, + label: domain.label, + value: scope.filters[domain.key] || "", + allLabel: `Any ${domain.label.toLowerCase()}`, + options: domain.values + .filter((v) => !v.retired || v.key === scope.filters[domain.key]) + .map((v) => ({ value: v.key, label: v.label })), + onChange: (value) => { + const filters = { ...scope.filters, [domain.key]: value }; + if (!value) delete filters[domain.key]; + onChange({ ...scope, filters }); + }, + }); + } + return list; + }, [portfolio, scope, onChange]); + + return ( +
+
+ + {!isWholePortfolio(scope) && ( + + )} + +
+
+ ); +} + +ScopeSelector.propTypes = { + portfolio: PropTypes.shape({ + repositories: PropTypes.array.isRequired, + sources: PropTypes.array.isRequired, + domains: PropTypes.array.isRequired, + }).isRequired, + scope: PropTypes.shape({ + client: PropTypes.string, + source: PropTypes.string, + repo: PropTypes.string, + filters: PropTypes.object, + }).isRequired, + onChange: PropTypes.func.isRequired, +}; diff --git a/frontend/src/components/Common/ScopeSelector.module.css b/frontend/src/components/Common/ScopeSelector.module.css new file mode 100644 index 00000000..c503bbc3 --- /dev/null +++ b/frontend/src/components/Common/ScopeSelector.module.css @@ -0,0 +1,26 @@ +.bar { + background: var(--surface-sunken); + border-bottom: 1px solid var(--border-subtle); +} + +.bar form { + padding-left: 0; + padding-right: 0; +} + +.reset { + min-height: 40px; + padding: 6px 14px; + font: inherit; + font-size: 14px; + color: var(--text-strong); + background: transparent; + border: 1px solid var(--border-default); + border-radius: 6px; + cursor: pointer; +} + +.reset:focus-visible { + outline: 2px solid var(--accent); + outline-offset: 2px; +} diff --git a/frontend/src/components/Common/Tooltip.jsx b/frontend/src/components/Common/Tooltip.jsx deleted file mode 100644 index 3c4c3f24..00000000 --- a/frontend/src/components/Common/Tooltip.jsx +++ /dev/null @@ -1,93 +0,0 @@ -import React, { useState, useRef, useEffect } from "react"; -import styles from "./Tooltip.module.css"; - -/** - * Tooltip Component - * - * Displays contextual information on hover with smooth animations. - * Automatically positions itself to avoid viewport edges. - * - * @component - * @param {Object} props - Component props - * @param {React.ReactNode} props.children - Trigger element that shows tooltip on hover - * @param {string} props.content - Tooltip text content - * @param {string} [props.position='top'] - Preferred tooltip position ('top', 'bottom', 'left', 'right') - * @param {number} [props.delay=300] - Show delay in milliseconds - * - * @example - * - * 1,234 commits - * - */ -export default function Tooltip({ - children, - content, - position = "top", - delay = 300, -}) { - const [isVisible, setIsVisible] = useState(false); - const [showTimeout, setShowTimeout] = useState(null); - const tooltipRef = useRef(null); - const triggerRef = useRef(null); - - /** - * Show tooltip after delay - */ - const handleMouseEnter = () => { - const timeout = setTimeout(() => { - setIsVisible(true); - }, delay); - setShowTimeout(timeout); - }; - - /** - * Hide tooltip and clear delay timeout - */ - const handleMouseLeave = () => { - if (showTimeout) { - clearTimeout(showTimeout); - setShowTimeout(null); - } - setIsVisible(false); - }; - - /** - * Cleanup timeout on unmount - */ - useEffect(() => { - return () => { - if (showTimeout) { - clearTimeout(showTimeout); - } - }; - }, [showTimeout]); - - // Don't render if no content - if (!content) { - return <>{children}; - } - - return ( -
- {children} - {isVisible && ( -
-
{content}
-
-
- )} -
- ); -} diff --git a/frontend/src/components/Common/Tooltip.module.css b/frontend/src/components/Common/Tooltip.module.css deleted file mode 100644 index 20165c52..00000000 --- a/frontend/src/components/Common/Tooltip.module.css +++ /dev/null @@ -1,107 +0,0 @@ -/** - * Tooltip Component Styles - * - * CSS Module for the Tooltip component with positioning and animations. - */ - -.tooltipWrapper { - position: relative; - display: inline-block; -} - -.tooltip { - position: absolute; - z-index: var(--z-index-tooltip); - padding: var(--spacing-sm) var(--spacing-md); - background-color: var(--color-text); - color: var(--color-background); - font-size: var(--font-size-sm); - line-height: var(--line-height-normal); - border-radius: var(--radius-md); - box-shadow: var(--shadow-lg); - white-space: nowrap; - pointer-events: none; - animation: tooltipFadeIn 0.2s ease-in-out; - max-width: 300px; -} - -.tooltipContent { - position: relative; - z-index: 1; -} - -.tooltipArrow { - position: absolute; - width: 8px; - height: 8px; - background-color: var(--color-text); - transform: rotate(45deg); -} - -/* Position variants */ -.tooltip--top { - bottom: calc(100% + 8px); - left: 50%; - transform: translateX(-50%); -} - -.tooltip--top .tooltipArrow { - bottom: -4px; - left: 50%; - transform: translateX(-50%) rotate(45deg); -} - -.tooltip--bottom { - top: calc(100% + 8px); - left: 50%; - transform: translateX(-50%); -} - -.tooltip--bottom .tooltipArrow { - top: -4px; - left: 50%; - transform: translateX(-50%) rotate(45deg); -} - -.tooltip--left { - right: calc(100% + 8px); - top: 50%; - transform: translateY(-50%); -} - -.tooltip--left .tooltipArrow { - right: -4px; - top: 50%; - transform: translateY(-50%) rotate(45deg); -} - -.tooltip--right { - left: calc(100% + 8px); - top: 50%; - transform: translateY(-50%); -} - -.tooltip--right .tooltipArrow { - left: -4px; - top: 50%; - transform: translateY(-50%) rotate(45deg); -} - -/* Animations */ -@keyframes tooltipFadeIn { - from { - opacity: 0; - transform: translateX(-50%) translateY(-4px); - } - to { - opacity: 1; - transform: translateX(-50%) translateY(0); - } -} - -/* Responsive: Hide tooltips on touch devices to avoid UX issues */ -@media (hover: none) and (pointer: coarse) { - .tooltip { - display: none; - } -} diff --git a/frontend/src/components/Common/UserPicker.jsx b/frontend/src/components/Common/UserPicker.jsx deleted file mode 100644 index 4bd8decb..00000000 --- a/frontend/src/components/Common/UserPicker.jsx +++ /dev/null @@ -1,97 +0,0 @@ -import PropTypes from "prop-types"; -import { getSelectedUser } from "@/services/dataService"; -import styles from "./UserPicker.module.css"; - -/** Reload the dashboard for another user (the data service reads ?user=). */ -export function navigateToUser(slug) { - const url = new URL(window.location.href); - url.searchParams.set("user", slug); - window.location.assign(url.toString()); -} - -const GROUPS = [ - ["user", "Users"], - ["org", "Organizations"], - ["repo", "Repositories"], -]; - -const sourceShape = PropTypes.shape({ - login: PropTypes.string.isRequired, - slug: PropTypes.string.isRequired, - type: PropTypes.string, - ready: PropTypes.bool, -}); - -/** - * Presentational picker. Sources whose data has not been collected yet are - * listed but disabled, with the reason in the label. Grouped by type once - * more than one type is registered. - */ -export function UserPickerView({ users, selected, onSelect }) { - const option = (user) => ( - - ); - const types = new Set(users.map((user) => user.type || "user")); - - return ( - - ); -} - -UserPickerView.propTypes = { - users: PropTypes.arrayOf(sourceShape).isRequired, - selected: PropTypes.string.isRequired, - onSelect: PropTypes.func.isRequired, -}; - -/** - * Renders nothing unless at least two sources are registered, so single-user - * and static (GitHub Pages) deployments look exactly as before. `users` - * comes from useUserOptions (the caller also needs the count). - */ -export default function UserPicker({ users }) { - const selected = getSelectedUser(); - if (users.length < 2) return null; - - // Keep the current user selectable even if it is not in the registry. - const known = users.some((user) => user.slug === selected); - const list = known - ? users - : [{ login: selected, slug: selected, ready: true }, ...users]; - - return ( - slug !== selected && navigateToUser(slug)} - /> - ); -} - -UserPicker.propTypes = { - users: PropTypes.arrayOf(sourceShape).isRequired, -}; diff --git a/frontend/src/components/Common/UserPicker.module.css b/frontend/src/components/Common/UserPicker.module.css deleted file mode 100644 index 3d0fc793..00000000 --- a/frontend/src/components/Common/UserPicker.module.css +++ /dev/null @@ -1,25 +0,0 @@ -.picker { - max-width: 180px; - min-height: 24px; - padding: 0 4px; - border: 1px solid var(--color-border); - border-radius: 4px; - background: var(--color-surface); - color: var(--color-text-secondary); - font: inherit; - font-size: 0.75rem; - cursor: pointer; -} - -.picker:focus-visible { - outline: 2px solid var(--color-primary); - outline-offset: 2px; -} - -@media (max-width: 767px) { - /* The header's text subtitle is hidden on small screens; the picker stays. */ - .picker { - min-height: 44px; - max-width: 140px; - } -} diff --git a/frontend/src/components/DrillDown/RepositoryDetail.jsx b/frontend/src/components/DrillDown/RepositoryDetail.jsx index 249eaeb8..80abd154 100644 --- a/frontend/src/components/DrillDown/RepositoryDetail.jsx +++ b/frontend/src/components/DrillDown/RepositoryDetail.jsx @@ -29,6 +29,7 @@ import ActivityMetricsSection from "./RepositoryDetail/sections/ActivityMetricsS import RankingSection from "./RepositoryDetail/sections/RankingSection"; import TechStackSection from "./RepositoryDetail/sections/TechStackSection"; import FixScorePromptSection from "./RepositoryDetail/sections/FixScorePromptSection"; +import SecuritySection from "./RepositoryDetail/sections/SecuritySection"; /** * RepositoryDetail Component @@ -50,6 +51,8 @@ import FixScorePromptSection from "./RepositoryDetail/sections/FixScorePromptSec * @param {Function} props.onClose - Callback to close the modal * @param {Function} [props.onNext] - Callback to navigate to next repository * @param {Function} [props.onPrevious] - Callback to navigate to previous repository + * @param {Object} [props.security] - Stored alerts and coverage for this + * repository (self-hosted only); adds the Security panel */ const STAT_TILES = [ { key: "stars", label: "Stars" }, @@ -99,6 +102,7 @@ function RepositoryDetail({ onPrevious, resultIndex, resultTotal, + security = null, }) { const { expandedSections, toggleSection } = useSectionToggles(); const bind = useRepositoryDetailInteractions({ onClose, onNext, onPrevious }); @@ -184,6 +188,12 @@ function RepositoryDetail({ components={repository.attention_metrics?.components} /> + + +
+

+ Dependabot:{" "} + +

+ {open.length > 0 && ( + + )} +
+ + ); +} + +SecuritySection.propTypes = { + security: PropTypes.shape({ + coverage: PropTypes.object.isRequired, + alerts: PropTypes.array.isRequired, + }), + expanded: PropTypes.bool, + onToggle: PropTypes.func.isRequired, +}; + +export default SecuritySection; diff --git a/frontend/src/components/Layout/Container/Container.css b/frontend/src/components/Layout/Container/Container.css deleted file mode 100644 index 3242f45d..00000000 --- a/frontend/src/components/Layout/Container/Container.css +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Container Component Styles - * Mobile-first responsive container - */ - -.container { - width: 100%; - margin-left: auto; - margin-right: auto; -} - -/* Padding variants */ -.container-padding { - padding-left: 1rem; - padding-right: 1rem; -} - -@media (min-width: 768px) { - .container-padding { - padding-left: 2rem; - padding-right: 2rem; - } -} - -/* Centered content */ -.container-centered { - display: flex; - flex-direction: column; - align-items: center; -} - -/* Max-width variants */ -.container-sm { - max-width: 640px; -} - -.container-md { - max-width: 768px; -} - -.container-lg { - max-width: 1024px; -} - -.container-xl { - max-width: 1280px; -} - -.container-full { - max-width: 100%; -} diff --git a/frontend/src/components/Layout/Container/Container.jsx b/frontend/src/components/Layout/Container/Container.jsx deleted file mode 100644 index d82e0d61..00000000 --- a/frontend/src/components/Layout/Container/Container.jsx +++ /dev/null @@ -1,44 +0,0 @@ -import React from "react"; -import PropTypes from "prop-types"; -import "./Container.css"; - -/** - * Container Component - * Mobile-first responsive container with proper padding and max-width - * - * @param {Object} props - * @param {React.ReactNode} props.children - Content to wrap - * @param {string} props.maxWidth - Maximum width breakpoint ('sm'|'md'|'lg'|'xl'|'full') - * @param {boolean} props.centered - Center content horizontally - * @param {boolean} props.padding - Apply responsive padding - * @param {string} props.className - Additional CSS classes - */ -export function Container({ - children, - maxWidth = "lg", - centered = false, - padding = true, - className = "", -}) { - const classes = [ - "container", - `container-${maxWidth}`, - centered && "container-centered", - padding && "container-padding", - className, - ] - .filter(Boolean) - .join(" "); - - return
{children}
; -} - -Container.propTypes = { - children: PropTypes.node.isRequired, - maxWidth: PropTypes.oneOf(["sm", "md", "lg", "xl", "full"]), - centered: PropTypes.bool, - padding: PropTypes.bool, - className: PropTypes.string, -}; - -export default Container; diff --git a/frontend/src/components/Layout/SafeArea/SafeArea.css b/frontend/src/components/Layout/SafeArea/SafeArea.css deleted file mode 100644 index f502a3d1..00000000 --- a/frontend/src/components/Layout/SafeArea/SafeArea.css +++ /dev/null @@ -1,8 +0,0 @@ -/** - * SafeArea Component Styles - * Uses CSS safe-area-inset-* from safe-area.css - */ - -.safe-area { - /* Styles imported from mobile/safe-area.css */ -} diff --git a/frontend/src/components/Layout/SafeArea/SafeArea.jsx b/frontend/src/components/Layout/SafeArea/SafeArea.jsx deleted file mode 100644 index 1a75fd2d..00000000 --- a/frontend/src/components/Layout/SafeArea/SafeArea.jsx +++ /dev/null @@ -1,33 +0,0 @@ -import PropTypes from "prop-types"; -import "./SafeArea.css"; - -/** - * SafeArea Component - * Applies safe area insets for notched devices (iOS, Android) - * - * @param {Object} props - * @param {React.ReactNode} props.children - Content to wrap - * @param {string[]} props.edges - Which edges to apply insets (['top', 'right', 'bottom', 'left']) - * @param {string} props.className - Additional CSS classes - */ -export function SafeArea({ children, edges = ["all"], className = "" }) { - const edgeClasses = edges.includes("all") - ? "safe-all" - : edges.map((edge) => `safe-${edge}`).join(" "); - - const classes = ["safe-area", edgeClasses, className] - .filter(Boolean) - .join(" "); - - return
{children}
; -} - -SafeArea.propTypes = { - children: PropTypes.node.isRequired, - edges: PropTypes.arrayOf( - PropTypes.oneOf(["top", "right", "bottom", "left", "all"]), - ), - className: PropTypes.string, -}; - -export default SafeArea; diff --git a/frontend/src/components/Layout/SkipLink/SkipLink.css b/frontend/src/components/Layout/SkipLink/SkipLink.css deleted file mode 100644 index fcb403b0..00000000 --- a/frontend/src/components/Layout/SkipLink/SkipLink.css +++ /dev/null @@ -1,39 +0,0 @@ -/** - * SkipLink Styles - * Hidden by default, visible on keyboard focus - */ - -.skip-link { - position: absolute; - top: -9999px; - left: 0; - z-index: 9999; - padding: var(--spacing-md) var(--spacing-lg); - background-color: var(--color-primary); - color: white; - text-decoration: none; - font-weight: 600; - border-radius: 0 0 var(--border-radius-sm) 0; - box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); - transition: top 0.2s; -} - -.skip-link:focus { - top: 0; - outline: 3px solid var(--color-focus); - outline-offset: 2px; -} - -/* Ensure skip link is always readable */ -[data-theme="dark"] { - .skip-link { - background-color: var(--color-primary-dark, #0056b3); - } -} - -/* Reduced motion */ -@media (prefers-reduced-motion: reduce) { - .skip-link { - transition: none; - } -} diff --git a/frontend/src/components/Layout/SkipLink/SkipLink.jsx b/frontend/src/components/Layout/SkipLink/SkipLink.jsx deleted file mode 100644 index a69d0123..00000000 --- a/frontend/src/components/Layout/SkipLink/SkipLink.jsx +++ /dev/null @@ -1,18 +0,0 @@ -/** - * SkipLink Component - * Provides keyboard navigation shortcuts to bypass repetitive navigation - * WCAG 2.1 Level A requirement - */ - -import React from "react"; -import "./SkipLink.css"; - -export function SkipLink({ href, children }) { - return ( - - {children} - - ); -} - -export default SkipLink; diff --git a/frontend/src/components/Layout/Stack/Stack.css b/frontend/src/components/Layout/Stack/Stack.css deleted file mode 100644 index c6fc020e..00000000 --- a/frontend/src/components/Layout/Stack/Stack.css +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Stack Component Styles - * Flexible layout with gap-based spacing - */ - -.stack { - display: flex; - gap: var(--stack-spacing, 16px); -} - -/* Direction */ -.stack-vertical { - flex-direction: column; -} - -.stack-horizontal { - flex-direction: row; - flex-wrap: wrap; -} - -/* Alignment */ -.stack-align-start { - align-items: flex-start; -} - -.stack-align-center { - align-items: center; -} - -.stack-align-end { - align-items: flex-end; -} - -.stack-align-stretch { - align-items: stretch; -} - -/* Justification */ -.stack-justify-start { - justify-content: flex-start; -} - -.stack-justify-center { - justify-content: center; -} - -.stack-justify-end { - justify-content: flex-end; -} - -.stack-justify-space-between { - justify-content: space-between; -} - -.stack-justify-space-around { - justify-content: space-around; -} diff --git a/frontend/src/components/Layout/Stack/Stack.jsx b/frontend/src/components/Layout/Stack/Stack.jsx deleted file mode 100644 index eab33a99..00000000 --- a/frontend/src/components/Layout/Stack/Stack.jsx +++ /dev/null @@ -1,60 +0,0 @@ -import PropTypes from "prop-types"; -import "./Stack.css"; - -/** - * Stack Component - * Flexible layout for vertical/horizontal spacing with mobile-friendly gaps - * - * @param {Object} props - * @param {React.ReactNode} props.children - Content to stack - * @param {string} props.direction - Stack direction ('vertical'|'horizontal') - * @param {number} props.spacing - Gap between items in pixels - * @param {string} props.align - Alignment ('start'|'center'|'end'|'stretch') - * @param {string} props.justify - Justification ('start'|'center'|'end'|'space-between'|'space-around') - * @param {string} props.className - Additional CSS classes - */ -export function Stack({ - children, - direction = "vertical", - spacing = 16, - align = "stretch", - justify = "start", - className = "", -}) { - const style = { - "--stack-spacing": `${spacing}px`, - }; - - const classes = [ - "stack", - `stack-${direction}`, - `stack-align-${align}`, - `stack-justify-${justify}`, - className, - ] - .filter(Boolean) - .join(" "); - - return ( -
- {children} -
- ); -} - -Stack.propTypes = { - children: PropTypes.node.isRequired, - direction: PropTypes.oneOf(["vertical", "horizontal"]), - spacing: PropTypes.number, - align: PropTypes.oneOf(["start", "center", "end", "stretch"]), - justify: PropTypes.oneOf([ - "start", - "center", - "end", - "space-between", - "space-around", - ]), - className: PropTypes.string, -}; - -export default Stack; diff --git a/frontend/src/components/Mobile/BottomSheet/BottomSheet.css b/frontend/src/components/Mobile/BottomSheet/BottomSheet.css deleted file mode 100644 index 1c098661..00000000 --- a/frontend/src/components/Mobile/BottomSheet/BottomSheet.css +++ /dev/null @@ -1,146 +0,0 @@ -/** - * Bottom Sheet Styles - * - * Mobile-native bottom sheet styling with iOS/Android-like appearance - * Includes smooth animations, safe area handling, and accessibility features - */ - -/* Sheet container */ -.react-modal-sheet-container { - background-color: var(--color-background, #ffffff) !important; - border-top-left-radius: 16px !important; - border-top-right-radius: 16px !important; - box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1) !important; - /* Respect safe area insets for devices with notches/home indicators */ - padding-bottom: env(safe-area-inset-bottom, 0px) !important; -} - -/* Dark theme support */ -[data-theme="dark"] { - .react-modal-sheet-container { - background-color: var(--color-background, #1a1a1a) !important; - box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3) !important; - } -} - -/* Header section */ -.bottom-sheet-header { - display: flex; - flex-direction: column; - align-items: center; - padding: 12px 16px 8px; - gap: 8px; -} - -/* Drag indicator (visual affordance for swipe-to-dismiss) */ -.bottom-sheet-drag-indicator { - width: 36px; - height: 4px; - background-color: var(--color-border, #d1d5db); - border-radius: 2px; - flex-shrink: 0; - transition: background-color 0.2s ease; -} - -[data-theme="dark"] { - .bottom-sheet-drag-indicator { - background-color: var(--color-border, #4b5563); - } -} - -/* Title */ -.bottom-sheet-title { - font-size: 1.125rem; - font-weight: 600; - color: var(--color-text, #1f2937); - margin: 0; - width: 100%; - text-align: center; -} - -[data-theme="dark"] { - .bottom-sheet-title { - color: var(--color-text, #f9fafb); - } -} - -/* Body content */ -.bottom-sheet-body { - padding: 16px; - /* Allow scrolling within the sheet */ - overflow-y: auto; - /* Smooth scrolling */ - -webkit-overflow-scrolling: touch; - /* Maximum height to prevent content from being too tall */ - max-height: calc(100vh - 120px); -} - -/* Backdrop (dimmed overlay) */ -.react-modal-sheet-backdrop { - background-color: rgba(0, 0, 0, 0.4) !important; - /* Smooth fade in/out */ - transition: opacity 0.2s ease !important; -} - -[data-theme="dark"] { - .react-modal-sheet-backdrop { - background-color: rgba(0, 0, 0, 0.6) !important; - } -} - -/* Content scrolling behavior */ -.react-modal-sheet-content { - /* Allow content to scroll independently */ - overflow-y: auto; - -webkit-overflow-scrolling: touch; -} - -/* Prevent body scroll when sheet is open */ -body.react-modal-sheet-open { - overflow: hidden !important; -} - -/* Animation states */ -.react-modal-sheet-container[data-rsbs-is-dismissable="true"] { - cursor: grab; -} - -.react-modal-sheet-container[data-rsbs-is-dismissable="true"]:active { - cursor: grabbing; -} - -/* Focus styles for accessibility */ -.bottom-sheet button:focus-visible, -.bottom-sheet input:focus-visible, -.bottom-sheet select:focus-visible, -.bottom-sheet textarea:focus-visible, -.bottom-sheet [tabindex]:focus-visible { - outline: 2px solid var(--color-primary, #3b82f6); - outline-offset: 2px; - border-radius: 4px; -} - -/* Reduced motion support */ -@media (prefers-reduced-motion: reduce) { - .react-modal-sheet-container, - .react-modal-sheet-backdrop, - .bottom-sheet-drag-indicator { - transition: none !important; - animation: none !important; - } -} - -/* Desktop: limit width and center */ -@media (min-width: 768px) { - .react-modal-sheet-container { - max-width: 600px; - margin: 0 auto; - } -} - -/* Touch target optimization for interactive elements */ -.bottom-sheet button, -.bottom-sheet [role="button"] { - min-height: 44px; - min-width: 44px; -} diff --git a/frontend/src/components/Mobile/BottomSheet/BottomSheet.jsx b/frontend/src/components/Mobile/BottomSheet/BottomSheet.jsx deleted file mode 100644 index 34acb958..00000000 --- a/frontend/src/components/Mobile/BottomSheet/BottomSheet.jsx +++ /dev/null @@ -1,141 +0,0 @@ -/** - * BottomSheet Component - * - * A mobile-native bottom sheet component using react-modal-sheet for iOS/Android-like behavior. - * Supports multiple snap points, swipe-to-dismiss, backdrop interaction, and accessibility features. - * - * Features: - * - Configurable snap points (default: [0.4, 0.9] for partial/full height) - * - Swipe-down gesture to dismiss - * - Tap backdrop to close - * - Smooth spring animations - * - Focus trap for keyboard accessibility - * - Prevents browser pull-to-refresh when active - * - Header with visual drag indicator - * - * @example - * - * - * - */ - -import React, { useEffect, useRef } from "react"; -import { Sheet } from "react-modal-sheet"; -import "./BottomSheet.css"; - -export function BottomSheet({ - isOpen, - onClose, - children, - title, - snapPoints = [0.4, 0.9], - initialSnap = 0, - disableDrag = false, - closeOnBackdrop = true, - showHeader = true, - className = "", -}) { - const sheetRef = useRef(null); - const contentRef = useRef(null); - - /** - * Prevent browser pull-to-refresh when bottom sheet is active - * This prevents conflicts between swipe-down-to-dismiss and browser's native pull-to-refresh - */ - useEffect(() => { - if (!isOpen) return; - - const preventRefresh = (e) => { - // Only prevent if the sheet is at the top of its scroll (scrollTop === 0) - // This allows scrolling within the sheet content - if (contentRef.current?.scrollTop === 0) { - e.preventDefault(); - } - }; - - const contentElement = contentRef.current; - if (contentElement?.addEventListener) { - contentElement.addEventListener("touchmove", preventRefresh, { - passive: false, - }); - } - - return () => { - if (contentElement?.removeEventListener) { - contentElement.removeEventListener("touchmove", preventRefresh); - } - }; - }, [isOpen]); - - /** - * Focus trap: Focus the sheet when it opens for keyboard accessibility - */ - useEffect(() => { - if (isOpen) { - const focusRoot = contentRef.current ?? sheetRef.current; - const focusableElements = focusRoot?.querySelectorAll?.( - 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])', - ); - - if (focusableElements?.length > 0) { - // Focus the first focusable element - focusableElements[0]?.focus(); - } - } - }, [isOpen]); - - /** - * Keyboard handler for ESC key to close - */ - useEffect(() => { - if (!isOpen) return; - - const handleKeyDown = (e) => { - if (e.key === "Escape") { - onClose(); - } - }; - - document.addEventListener("keydown", handleKeyDown); - return () => document.removeEventListener("keydown", handleKeyDown); - }, [isOpen, onClose]); - - return ( - - - - {showHeader && ( -
- - )} - - - -
{children}
-
- - - - - ); -} - -export default BottomSheet; diff --git a/frontend/src/components/Mobile/GestureHandler/GestureHandler.css b/frontend/src/components/Mobile/GestureHandler/GestureHandler.css deleted file mode 100644 index 508b791f..00000000 --- a/frontend/src/components/Mobile/GestureHandler/GestureHandler.css +++ /dev/null @@ -1,149 +0,0 @@ -/** - * GestureHandler Styles - * - * Visual feedback for touch gestures - */ - -.gesture-handler { - position: relative; - touch-action: pan-y; /* Allow vertical scrolling but enable gesture detection */ - user-select: none; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; -} - -/* Dragging state */ -.gesture-handler[data-gesture-active="true"] { - cursor: grabbing; -} - -/* Gesture feedback animations */ -.gesture-feedback-left { - animation: swipe-left-feedback 300ms ease-out; -} - -.gesture-feedback-right { - animation: swipe-right-feedback 300ms ease-out; -} - -.gesture-feedback-up { - animation: swipe-up-feedback 300ms ease-out; -} - -.gesture-feedback-down { - animation: swipe-down-feedback 300ms ease-out; -} - -/* Swipe animations */ -@keyframes swipe-left-feedback { - 0% { - transform: translateX(0); - } - 50% { - transform: translateX(-10px); - } - 100% { - transform: translateX(0); - } -} - -@keyframes swipe-right-feedback { - 0% { - transform: translateX(0); - } - 50% { - transform: translateX(10px); - } - 100% { - transform: translateX(0); - } -} - -@keyframes swipe-up-feedback { - 0% { - transform: translateY(0); - } - 50% { - transform: translateY(-10px); - } - 100% { - transform: translateY(0); - } -} - -@keyframes swipe-down-feedback { - 0% { - transform: translateY(0); - } - 50% { - transform: translateY(10px); - } - 100% { - transform: translateY(0); - } -} - -/* Gesture indicator */ -.gesture-indicator { - position: absolute; - top: 50%; - transform: translateY(-50%); - background-color: rgba(0, 0, 0, 0.7); - color: white; - padding: 0.5rem 1rem; - border-radius: 9999px; - font-size: 1.5rem; - font-weight: bold; - pointer-events: none; - z-index: 100; - animation: fade-in-out 300ms ease-out; -} - -.gesture-indicator-left { - left: 1rem; -} - -.gesture-indicator-right { - right: 1rem; -} - -.gesture-indicator-up, -.gesture-indicator-down { - left: 50%; - transform: translate(-50%, -50%); -} - -@keyframes fade-in-out { - 0% { - opacity: 0; - scale: 0.8; - } - 50% { - opacity: 1; - scale: 1; - } - 100% { - opacity: 0; - scale: 0.8; - } -} - -/* Reduced motion support */ -@media (prefers-reduced-motion: reduce) { - .gesture-handler { - animation: none !important; - } - - .gesture-feedback-left, - .gesture-feedback-right, - .gesture-feedback-up, - .gesture-feedback-down { - animation: none; - } - - .gesture-indicator { - animation: none; - opacity: 1; - } -} diff --git a/frontend/src/components/Mobile/GestureHandler/GestureHandler.jsx b/frontend/src/components/Mobile/GestureHandler/GestureHandler.jsx deleted file mode 100644 index 5f9a1b19..00000000 --- a/frontend/src/components/Mobile/GestureHandler/GestureHandler.jsx +++ /dev/null @@ -1,158 +0,0 @@ -/** - * GestureHandler Component - * - * Wraps child elements with swipe gesture detection and visual feedback. - * Provides haptic feedback and animation for touch interactions. - * - * @component - * @example - * console.log('Swiped left')} - * onSwipeRight={() => console.log('Swiped right')} - * > - *
Swipeable content
- *
- */ - -import React, { useState } from "react"; -import { useGesture } from "@/hooks/useGesture"; -import "./GestureHandler.css"; - -export const GestureHandler = ({ - children, - onSwipeLeft, - onSwipeRight, - onSwipeUp, - onSwipeDown, - onTap, - onLongPress, - swipeThreshold = 50, - velocityThreshold = 0.5, - enableHaptics = true, - showFeedback = true, - className = "", - ...props -}) => { - const [gestureState, setGestureState] = useState({ - isDragging: false, - direction: null, - distance: 0, - }); - - const bind = useGesture( - { - onSwipeLeft: (data) => { - if (showFeedback) { - setGestureState({ - isDragging: false, - direction: "left", - distance: data.distance, - }); - setTimeout( - () => - setGestureState({ - isDragging: false, - direction: null, - distance: 0, - }), - 300, - ); - } - onSwipeLeft?.(data); - }, - onSwipeRight: (data) => { - if (showFeedback) { - setGestureState({ - isDragging: false, - direction: "right", - distance: data.distance, - }); - setTimeout( - () => - setGestureState({ - isDragging: false, - direction: null, - distance: 0, - }), - 300, - ); - } - onSwipeRight?.(data); - }, - onSwipeUp: (data) => { - if (showFeedback) { - setGestureState({ - isDragging: false, - direction: "up", - distance: data.distance, - }); - setTimeout( - () => - setGestureState({ - isDragging: false, - direction: null, - distance: 0, - }), - 300, - ); - } - onSwipeUp?.(data); - }, - onSwipeDown: (data) => { - if (showFeedback) { - setGestureState({ - isDragging: false, - direction: "down", - distance: data.distance, - }); - setTimeout( - () => - setGestureState({ - isDragging: false, - direction: null, - distance: 0, - }), - 300, - ); - } - onSwipeDown?.(data); - }, - onTap: (event) => { - onTap?.(event); - }, - onLongPress: (event) => { - onLongPress?.(event); - }, - }, - { - swipeThreshold, - velocityThreshold, - enableHaptics, - }, - ); - - return ( -
- {children} - - {/* Visual feedback indicator */} - {showFeedback && gestureState.direction && ( -
- {gestureState.direction === "left" && ←} - {gestureState.direction === "right" && →} - {gestureState.direction === "up" && ↑} - {gestureState.direction === "down" && ↓} -
- )} -
- ); -}; - -export default GestureHandler; diff --git a/frontend/src/components/Mobile/LoadingState/LoadingState.css b/frontend/src/components/Mobile/LoadingState/LoadingState.css deleted file mode 100644 index ae83f892..00000000 --- a/frontend/src/components/Mobile/LoadingState/LoadingState.css +++ /dev/null @@ -1,110 +0,0 @@ -/** - * LoadingState Component Styles - * Skeleton screens with shimmer animation - */ - -.loading-state-container { - width: 100%; -} - -.loading-state { - padding: 1rem; - margin-bottom: 1rem; - background: #fff; - border-radius: 8px; -} - -/* Skeleton elements */ -.skeleton-title, -.skeleton-badge, -.skeleton-meta, -.skeleton-line, -.skeleton-chart { - background: linear-gradient( - 90deg, - #f0f0f0 0%, - #e0e0e0 20%, - #f0f0f0 40%, - #f0f0f0 100% - ); - background-size: 200% 100%; - animation: shimmer 1.5s ease-in-out infinite; - border-radius: 4px; -} - -@keyframes shimmer { - 0% { - background-position: -200% 0; - } - 100% { - background-position: 200% 0; - } -} - -/* Card skeleton */ -.loading-card .skeleton-title { - width: 60%; - height: 20px; - margin-bottom: 8px; -} - -.loading-card .skeleton-badge { - width: 80px; - height: 24px; - margin-bottom: 8px; -} - -.loading-card .skeleton-meta { - width: 40%; - height: 16px; -} - -/* List skeleton */ -.loading-list .skeleton-line { - height: 16px; - margin-bottom: 8px; -} - -.skeleton-line-full { - width: 100%; -} - -.skeleton-line-long { - width: 80%; -} - -.skeleton-line-medium { - width: 60%; -} - -/* Chart skeleton */ -.loading-chart .skeleton-chart { - width: 100%; - height: 200px; -} - -/* Spinner */ -.loading-spinner-container { - display: flex; - justify-content: center; - align-items: center; - padding: 2rem; -} - -.loading-spinner { - width: 40px; - height: 40px; - border: 4px solid #f3f3f3; - border-top: 4px solid #0066cc; - border-radius: 50%; - animation: spin 1s linear infinite; -} - -@keyframes spin { - 0% { - transform: rotate(0deg); - } - 100% { - transform: rotate(360deg); - } -} diff --git a/frontend/src/components/Mobile/LoadingState/LoadingState.jsx b/frontend/src/components/Mobile/LoadingState/LoadingState.jsx deleted file mode 100644 index 335c9a86..00000000 --- a/frontend/src/components/Mobile/LoadingState/LoadingState.jsx +++ /dev/null @@ -1,87 +0,0 @@ -import PropTypes from "prop-types"; -import "./LoadingState.css"; - -/** - * LoadingState Component - * Skeleton screens for progressive loading - * - * @param {Object} props - * @param {string} props.type - Type of loading indicator ('card'|'list'|'chart'|'text') - * @param {string} props.variant - Visual style ('skeleton'|'spinner') - * @param {number} props.count - Number of skeleton items - * @param {string} props.className - Additional CSS classes - */ -export function LoadingState({ - type = "card", - variant = "skeleton", - count = 1, - className = "", -}) { - const classes = [ - "loading-state", - `loading-${type}`, - `loading-${variant}`, - className, - ] - .filter(Boolean) - .join(" "); - - if (variant === "spinner") { - return ( -
-
-
- ); - } - - const items = Array.from({ length: count }, (_, i) => ( -
- {type === "card" && ( - <> -
-
-
- - )} - {type === "list" && ( - <> -
-
- - )} - {type === "chart" &&
} - {type === "text" && ( - <> -
-
-
- - )} -
- )); - - return ( -
- {items} -
- ); -} - -LoadingState.propTypes = { - type: PropTypes.oneOf(["card", "list", "chart", "text"]), - variant: PropTypes.oneOf(["skeleton", "spinner"]), - count: PropTypes.number, - className: PropTypes.string, -}; - -export default LoadingState; diff --git a/frontend/src/components/Mobile/TabBar/TabBar.css b/frontend/src/components/Mobile/TabBar/TabBar.css index 9dd8e09f..51a8f1c1 100644 --- a/frontend/src/components/Mobile/TabBar/TabBar.css +++ b/frontend/src/components/Mobile/TabBar/TabBar.css @@ -182,3 +182,44 @@ box-shadow: 0 0 0 2px var(--background-primary, #0d1117); } } + +/* "More" menu: the sections that do not fit in the bar. */ +.tab-bar__menu { + position: absolute; + right: 8px; + bottom: calc(64px + env(safe-area-inset-bottom) + 8px); + min-width: 200px; + margin: 0; + padding: 6px; + list-style: none; + background-color: var(--color-background, #ffffff); + border: 1px solid var(--color-border, #e1e4e8); + border-radius: 8px; + box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); +} + +.tab-bar__menu-item { + display: flex; + align-items: center; + gap: 10px; + width: 100%; + min-height: 44px; + padding: 8px 12px; + font: inherit; + color: var(--color-text-secondary, #586069); + text-align: left; + background: none; + border: none; + border-radius: 6px; + cursor: pointer; +} + +.tab-bar__menu-item[aria-current="page"] { + color: var(--color-primary, #0366d6); + font-weight: 600; +} + +.tab-bar__menu-item:focus-visible { + outline: 2px solid var(--color-primary, #0366d6); + outline-offset: -2px; +} diff --git a/frontend/src/components/Mobile/TabBar/TabBar.jsx b/frontend/src/components/Mobile/TabBar/TabBar.jsx index a6f3074a..3c1e7007 100644 --- a/frontend/src/components/Mobile/TabBar/TabBar.jsx +++ b/frontend/src/components/Mobile/TabBar/TabBar.jsx @@ -1,64 +1,129 @@ -import { - LayoutGrid, - BarChart3, - AlertTriangle, - Settings, - ShieldAlert, -} from "lucide-react"; +import { useEffect, useRef, useState } from "react"; +import PropTypes from "prop-types"; +import { MoreHorizontal } from "lucide-react"; +import { visibleSections } from "@/config/sections"; import "./TabBar.css"; +/** Tabs the bar holds before the rest move behind "More". */ +const MAX_TABS = 4; + /** * TabBar - Fixed bottom navigation for mobile devices (<768px) * - * Three tabs: Overview, Insights, Health. Fixed at bottom with safe-area - * insets, 44x44px minimum touch targets, and active-tab highlighting. + * Shows the visible sections ranked for mobile. Up to four fit; with more, + * the top three stay and the rest open from a "More" menu. Fixed at bottom + * with safe-area insets, 44x44px minimum touch targets, and active-tab + * highlighting. */ -const TABS = [ - { id: "table", label: "Overview", Icon: LayoutGrid }, - { id: "visualizations", label: "Insights", Icon: BarChart3 }, - { id: "attention", label: "Health", Icon: AlertTriangle }, -]; - -const SECURITY_TAB = { id: "security", label: "Security", Icon: ShieldAlert }; -const ADMIN_TAB = { id: "sources", label: "Sources", Icon: Settings }; - const TabBar = ({ activeTab = "table", onTabChange, - showAdmin = false, - showSecurity = false, + sections = visibleSections(), }) => { - const tabs = [ - ...TABS, - ...(showSecurity ? [SECURITY_TAB] : []), - ...(showAdmin ? [ADMIN_TAB] : []), - ]; - const handleTabClick = (tabId) => { - if (onTabChange && tabId !== activeTab) { - onTabChange(tabId); - } + const [menuOpen, setMenuOpen] = useState(false); + const rootRef = useRef(null); + // When everything fits, keep the header's order; otherwise rank for mobile. + const overflow = sections.length > MAX_TABS; + const ranked = overflow + ? [...sections].sort((a, b) => a.mobileRank - b.mobileRank) + : sections; + const shown = overflow ? ranked.slice(0, MAX_TABS - 1) : ranked; + const more = overflow ? ranked.slice(MAX_TABS - 1) : []; + const moreActive = more.some((section) => section.id === activeTab); + + useEffect(() => { + if (!menuOpen) return undefined; + const close = (event) => { + if (event.type === "keydown" && event.key !== "Escape") return; + if (event.type === "mousedown" && rootRef.current?.contains(event.target)) + return; + setMenuOpen(false); + }; + document.addEventListener("mousedown", close); + document.addEventListener("keydown", close); + return () => { + document.removeEventListener("mousedown", close); + document.removeEventListener("keydown", close); + }; + }, [menuOpen]); + + const choose = (id) => { + setMenuOpen(false); + if (onTabChange && id !== activeTab) onTabChange(id); }; + const tab = ({ id, label, Icon }) => ( + + ); + return ( -