Compare commits
61
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
46d889271e | ||
|
|
0c3a82ad77 | ||
|
|
b640079cb6 | ||
|
|
37d15456dc | ||
|
|
153e628aba | ||
|
|
a5f908dc06 | ||
|
|
7fc36170c8 | ||
|
|
ccfe769b2f | ||
|
|
3b688e0d0f | ||
|
|
29f59fd91f | ||
|
|
c3165ed702 | ||
|
|
c72fadbbb4 | ||
|
|
613840e2d1 | ||
|
|
24336186dc | ||
|
|
6b66863897 | ||
|
|
fc40609a3a | ||
|
|
e157ae3ce4 | ||
|
|
3f4c05f5bb | ||
|
|
9c25e0887c | ||
|
|
2aa12b9ec5 | ||
|
|
cab451f0e5 | ||
|
|
183a51003a | ||
|
|
f34811e9b6 | ||
|
|
2c30140ddd | ||
|
|
7e92de63d6 | ||
|
|
68be4352da | ||
|
|
754ef78ff1 | ||
|
|
2959744e0c | ||
|
|
cffa72c21f | ||
|
|
d64c5ba7b6 | ||
|
|
87851f7a71 | ||
|
|
91de43a6c6 | ||
|
|
f8fc08de41 | ||
|
|
dfa69e9f45 | ||
|
|
0bd4b4075e | ||
|
|
b679a02cb9 | ||
|
|
4ed1d3c053 | ||
|
|
8dbcc2b527 | ||
|
|
bda210475d | ||
|
|
9b78abaf3d | ||
|
|
53c4158511 | ||
|
|
a2a8c824bf | ||
|
|
dec548fa2f | ||
|
|
12033e5537 | ||
|
|
d06caa7e58 | ||
|
|
173ae3c61c | ||
|
|
2637bbc549 | ||
|
|
6fc68126ac | ||
|
|
28d09a24c9 | ||
|
|
f2ec642a0e | ||
|
|
8a491b9ec2 | ||
|
|
7d54d3a660 | ||
|
|
21509c25ff | ||
|
|
09724287cb | ||
|
|
1ac3d50315 | ||
|
|
9c48d50d25 | ||
|
|
8bd3ec8e83 | ||
|
|
5a4a203f01 | ||
|
|
7f0aa5a7ad | ||
|
|
eb0be981c6 | ||
|
|
466e117bd5 |
No files matched your search
+1
-1
@@ -86,7 +86,7 @@ BACKLOG_SYNC_BATCH_SIZE=100 # Messages per backlog batch, max 100 (d
|
|||||||
AI_ANALYSIS_ENABLED=false # Enable AI content moderation (default: false)
|
AI_ANALYSIS_ENABLED=false # Enable AI content moderation (default: false)
|
||||||
AI_LLM_API_KEY= # REQUIRED if AI_ANALYSIS_ENABLED=true. LLM API key
|
AI_LLM_API_KEY= # REQUIRED if AI_ANALYSIS_ENABLED=true. LLM API key
|
||||||
AI_LLM_BASE_URL=https://9router.asepharyana.my.id/v1 # LLM API base URL (9router — OpenAI-compatible router, replaces omniroute)
|
AI_LLM_BASE_URL=https://9router.asepharyana.my.id/v1 # LLM API base URL (9router — OpenAI-compatible router, replaces omniroute)
|
||||||
AI_LLM_MODEL=claude-opus-5 # LLM text model name (default: claude-opus-5)
|
AI_LLM_MODEL=text # LLM text model name (default: text)
|
||||||
# AI_LLM_VISION_MODEL= # Vision model for image analysis (falls back to AI_LLM_MODEL)
|
# AI_LLM_VISION_MODEL= # Vision model for image analysis (falls back to AI_LLM_MODEL)
|
||||||
# AI_LLM_EMBEDDING_MODEL= # Embedding model for semantic moderation cache (optional; enables near-duplicate text reuse to save LLM calls)
|
# AI_LLM_EMBEDDING_MODEL= # Embedding model for semantic moderation cache (optional; enables near-duplicate text reuse to save LLM calls)
|
||||||
# AI_LLM_EMBEDDING_MIN_SIMILARITY=0.97 # Min cosine similarity to reuse a cached verdict (default: 0.97)
|
# AI_LLM_EMBEDDING_MIN_SIMILARITY=0.97 # Min cosine similarity to reuse a cached verdict (default: 0.97)
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
name: Dependabot Auto-Merge
|
||||||
|
on: pull_request
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
auto-merge:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.actor == 'dependabot[bot]'
|
||||||
|
steps:
|
||||||
|
- name: Enable auto-merge for Dependabot PR
|
||||||
|
run: gh pr merge --auto --merge "$PR_URL"
|
||||||
|
env:
|
||||||
|
PR_URL: ${{ github.event.pull_request.html_url }}
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "npm"
|
||||||
|
directory: "/services/backend"
|
||||||
|
schedule:
|
||||||
|
interval: "daily"
|
||||||
|
open-pull-requests-limit: 10
|
||||||
|
groups:
|
||||||
|
production:
|
||||||
|
dependency-type: "production"
|
||||||
|
update-types: ["minor", "patch"]
|
||||||
|
development:
|
||||||
|
dependency-type: "development"
|
||||||
|
update-types: ["minor", "patch"]
|
||||||
|
- package-ecosystem: "npm"
|
||||||
|
directory: "/services/discord-gateway"
|
||||||
|
schedule:
|
||||||
|
interval: "daily"
|
||||||
|
open-pull-requests-limit: 10
|
||||||
|
groups:
|
||||||
|
production:
|
||||||
|
dependency-type: "production"
|
||||||
|
update-types: ["minor", "patch"]
|
||||||
|
development:
|
||||||
|
dependency-type: "development"
|
||||||
|
update-types: ["minor", "patch"]
|
||||||
|
- package-ecosystem: "npm"
|
||||||
|
directory: "/services/frontend"
|
||||||
|
schedule:
|
||||||
|
interval: "daily"
|
||||||
|
open-pull-requests-limit: 10
|
||||||
|
groups:
|
||||||
|
production:
|
||||||
|
dependency-type: "production"
|
||||||
|
update-types: ["minor", "patch"]
|
||||||
|
development:
|
||||||
|
dependency-type: "development"
|
||||||
|
update-types: ["minor", "patch"]
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
name: Publish to FlakeHub
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [main, master]
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
flakehub-publish:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
id-token: write
|
|
||||||
contents: read
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v6
|
|
||||||
- uses: DeterminateSystems/determinate-nix-action@main
|
|
||||||
- uses: DeterminateSystems/flakehub-push@main
|
|
||||||
with:
|
|
||||||
visibility: public
|
|
||||||
rolling: true
|
|
||||||
@@ -21,21 +21,21 @@
|
|||||||
"drizzle-orm": "^0.45.2",
|
"drizzle-orm": "^0.45.2",
|
||||||
"express": "^5.2.1",
|
"express": "^5.2.1",
|
||||||
"helmet": "^8.1.0",
|
"helmet": "^8.1.0",
|
||||||
"ioredis": "^5.11.0",
|
"ioredis": "^6.0.0",
|
||||||
"pg": "^8.21.0",
|
"pg": "^8.23.0",
|
||||||
"pino": "^9.6.0",
|
"pino": "^10.3.1",
|
||||||
"prom-client": "^15.1.3",
|
"prom-client": "^15.1.3",
|
||||||
"ws": "^8.20.1",
|
"ws": "^8.21.3",
|
||||||
"zod": "^4.4.3"
|
"zod": "^4.4.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@biomejs/biome": "latest",
|
"@biomejs/biome": "latest",
|
||||||
"@types/express": "^5.0.6",
|
"@types/express": "^5.0.6",
|
||||||
"@types/node": "^25.9.0",
|
"@types/node": "^26.2.0",
|
||||||
"@types/pg": "^8.20.0",
|
"@types/pg": "^8.23.1",
|
||||||
"@types/ws": "^8.18.1",
|
"@types/ws": "^8.18.1",
|
||||||
"tsx": "^4.22.2",
|
"tsx": "^4.23.12",
|
||||||
"typescript": "^5.9.3",
|
"typescript": "^7.0.2",
|
||||||
"vitest": "latest"
|
"vitest": "latest"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Generated
+485
-287
File diff suppressed because it is too large.
Load diff
@@ -28,30 +28,30 @@
|
|||||||
"discord.js-selfbot-v13": "^3.7.1",
|
"discord.js-selfbot-v13": "^3.7.1",
|
||||||
"dotenv": "^17.4.2",
|
"dotenv": "^17.4.2",
|
||||||
"drizzle-orm": "^0.45.2",
|
"drizzle-orm": "^0.45.2",
|
||||||
"ioredis": "^5.11.0",
|
"ioredis": "^6.0.0",
|
||||||
"libsodium-wrappers": "^0.8.4",
|
"libsodium-wrappers": "^0.8.4",
|
||||||
"lru-cache": "^11.5.1",
|
"lru-cache": "^11.5.1",
|
||||||
"openai": "^6.38.0",
|
"openai": "^7.5.0",
|
||||||
"opusscript": "^0.0.8",
|
"opusscript": "^0.1.1",
|
||||||
"p-limit": "^7.3.0",
|
"p-limit": "^7.3.0",
|
||||||
"p-retry": "^8.0.0",
|
"p-retry": "^8.0.0",
|
||||||
"pg": "^8.21.0",
|
"pg": "^8.23.0",
|
||||||
"pino": "^9.6.0",
|
"pino": "^10.3.1",
|
||||||
"piscina": "^5.1.4",
|
"piscina": "^5.3.1",
|
||||||
"prism-media": "2.0.0-alpha.0",
|
"prism-media": "2.0.0-alpha.0",
|
||||||
"sharp": "^0.34.5",
|
"sharp": "^0.35.3",
|
||||||
"tiktoken": "^1.0.22",
|
"tiktoken": "^1.0.22",
|
||||||
"ws": "^8.20.1",
|
"ws": "^8.21.3",
|
||||||
"zod": "^4.4.3"
|
"zod": "^4.4.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@biomejs/biome": "latest",
|
"@biomejs/biome": "latest",
|
||||||
"@types/node": "^25.9.0",
|
"@types/node": "^26.2.0",
|
||||||
"@types/pg": "^8.20.0",
|
"@types/pg": "^8.23.1",
|
||||||
"@types/ws": "^8.18.1",
|
"@types/ws": "^8.18.1",
|
||||||
"drizzle-kit": "^0.31.10",
|
"drizzle-kit": "^0.31.10",
|
||||||
"tsx": "^4.22.2",
|
"tsx": "^4.23.12",
|
||||||
"typescript": "^5.9.3",
|
"typescript": "^7.0.2",
|
||||||
"vitest": "latest"
|
"vitest": "latest"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Generated
+660
-435
File diff suppressed because it is too large.
Load diff
@@ -39,7 +39,7 @@ export function deriveRecommendedAction(msg: MessageRecord): string {
|
|||||||
const severity = deriveSeverity(msg);
|
const severity = deriveSeverity(msg);
|
||||||
if (
|
if (
|
||||||
msg.ai_status === "flagged" &&
|
msg.ai_status === "flagged" &&
|
||||||
(severity === "critical" || severity === "high")
|
(severity === "critical" || severity === "high" || severity === "medium")
|
||||||
)
|
)
|
||||||
return "delete";
|
return "delete";
|
||||||
if (msg.ai_status === "flagged") return "review";
|
if (msg.ai_status === "flagged") return "review";
|
||||||
@@ -135,10 +135,14 @@ export function isEligibleForAutoDelete(
|
|||||||
// Recommended action check
|
// Recommended action check
|
||||||
const recommendedAction =
|
const recommendedAction =
|
||||||
analysisResult?.recommendedAction ?? deriveRecommendedAction(message);
|
analysisResult?.recommendedAction ?? deriveRecommendedAction(message);
|
||||||
if (recommendedAction !== "delete" && recommendedAction !== "escalate") {
|
if (
|
||||||
|
recommendedAction !== "delete" &&
|
||||||
|
recommendedAction !== "escalate" &&
|
||||||
|
recommendedAction !== "warn"
|
||||||
|
) {
|
||||||
logger.debug(
|
logger.debug(
|
||||||
{ messageId: message.id, recommendedAction },
|
{ messageId: message.id, recommendedAction },
|
||||||
"Message not eligible for auto-delete: recommended action is not delete/escalate",
|
"Message not eligible for auto-delete: recommended action is not delete/escalate/warn",
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ export const configSchema = z
|
|||||||
.string()
|
.string()
|
||||||
.url()
|
.url()
|
||||||
.default("https://9router.asepharyana.my.id/v1"),
|
.default("https://9router.asepharyana.my.id/v1"),
|
||||||
AI_LLM_MODEL: z.string().default("claude-opus-5"),
|
AI_LLM_MODEL: z.string().default("text"),
|
||||||
// Vision uses the SAME router/base URL as text moderation
|
// Vision uses the SAME router/base URL as text moderation
|
||||||
// (AI_LLM_BASE_URL) but a different model alias. The dedicated NVIDIA
|
// (AI_LLM_BASE_URL) but a different model alias. The dedicated NVIDIA
|
||||||
// multimodal endpoint was removed.
|
// multimodal endpoint was removed.
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
# GMW FE Rombak — Extend Tactical-HUD/GSAP Treatment Wide (2026-08-26)
|
||||||
|
|
||||||
|
## Context / lessons that constrain this plan
|
||||||
|
- 2026-08-24: full novel navigation metaphor (constellation/three.js) was
|
||||||
|
SHIPPED green on every gate then REJECTED by user for hurting usability.
|
||||||
|
Rolled back entirely. Lesson: do NOT invent a new nav metaphor.
|
||||||
|
- 2026-08-24: accepted direction = monochrome theme + game-menu style sidebar
|
||||||
|
animation ON TOP of the familiar shell (rail/topbar/panel kept).
|
||||||
|
- 2026-08-25: `dashboard` and `media` routes were already revamped into a
|
||||||
|
"Tactical HUD" style with GSAP (`@gsap/react` useGSAP) reactive stages —
|
||||||
|
commits 183a510, cab451f. This is the established, ACCEPTED visual language.
|
||||||
|
- Remaining routes (`channels`, `voice`, `messages`, `moderation`,
|
||||||
|
`recordings`, `analysis`, `glossary`) have NOT received the tactical-HUD/GSAP
|
||||||
|
treatment — last touch was an error-handling/state pass (31e303c) or the
|
||||||
|
constellation revert (eda5c75).
|
||||||
|
|
||||||
|
## Scope of THIS request
|
||||||
|
User: "rombak fe dengan sekeren mungkin tapi tidak menyusahkan user, pewarnaan
|
||||||
|
sesuai tidak berlebihan, pakai gsap, sekreatif mungkin."
|
||||||
|
|
||||||
|
Read against the history above, this means: EXTEND the already-accepted
|
||||||
|
tactical-HUD + GSAP + monochrome visual language to the remaining routes,
|
||||||
|
adding creative micro-interactions and view-specific "reactive stage" touches
|
||||||
|
— NOT a new structural/navigation metaphor, NOT a color explosion.
|
||||||
|
|
||||||
|
## Hard constraints (do not violate)
|
||||||
|
1. Keep the existing shell: top bar / nav rail / mobile bottom dock. No new
|
||||||
|
navigation metaphor.
|
||||||
|
2. Monochrome/greyscale token system stays as-is (`--color-signal/amber/
|
||||||
|
vermilion` luminance greys). Do not introduce saturated colors; accent use
|
||||||
|
stays restrained (used sparingly for state: active/alert/success).
|
||||||
|
3. GSAP via `@gsap/react` `useGSAP({ scope, dependencies })` + `clearProps` on
|
||||||
|
cleanup, per `dashboard-rombak/references/tactical-hud-gsap-pattern.md`.
|
||||||
|
Respect `prefers-reduced-motion` (extend the kill-list in globals.css for
|
||||||
|
any new `animate-*` class).
|
||||||
|
4. Mobile lightness gate: any WebGL/heavy canvas work must gate off on
|
||||||
|
<768px / pointer:coarse / saveData / deviceMemory<=4 (see AmbientCanvas
|
||||||
|
pattern already in the codebase).
|
||||||
|
5. Each route ships independently: edit → `pnpm format` → `npx @biomejs/biome
|
||||||
|
check --write` → `pnpm lint` (0 errors, 0 warnings) → `tsc --noEmit` →
|
||||||
|
`pnpm build` → commit (no Co-Authored-By trailer) → push → `gh run watch`
|
||||||
|
for Build & Deploy (Nix) → live verify via browser_vision on
|
||||||
|
imphnen.asepharyana.my.id/<route>/.
|
||||||
|
6. NEVER claim "done" from reading code — every route gets a live screenshot
|
||||||
|
check confirming: (a) not a stock template, (b) monochrome/restrained,
|
||||||
|
(c) GSAP entrance/interaction actually fires, (d) nav/theme toggle/command
|
||||||
|
palette still work.
|
||||||
|
|
||||||
|
## Per-route creative direction (reactive-stage motifs, one distinct idea per
|
||||||
|
route so it doesn't feel copy-pasted from dashboard/media)
|
||||||
|
- **channels**: node/roster telemetry — GSAP stagger-in channel cards with a
|
||||||
|
"signal strength" bar-fill tween keyed to activity; hover reveals HUD-style
|
||||||
|
meta readout.
|
||||||
|
- **voice**: live speaker HUD — waveform/ring pulse tied to WS voice_state
|
||||||
|
(GSAP timeline looping while speaking, `clearProps` on stop); ambient tile
|
||||||
|
glow keyed to active speaker count.
|
||||||
|
- **messages**: scan-line reveal on list mount + WS-driven "new message" slide
|
||||||
|
insert (respect existing sortMessages fix — do not reintroduce the race).
|
||||||
|
- **moderation**: alert-priority HUD — flagged severity as inverted mono
|
||||||
|
badge with a pulse GSAP loop (no red, per accepted mono direction);
|
||||||
|
queue-clear micro celebration (subtle, no confetti-color).
|
||||||
|
- **recordings**: waveform scrub deck echoing media's frequency-deck visual
|
||||||
|
language but for static recordings (progress-tied GSAP scrub, not looping).
|
||||||
|
- **analysis**: gauge/metric reveal using the existing `radial-gauge.tsx`
|
||||||
|
driven by a GSAP number tween (count-up) instead of an instant value snap.
|
||||||
|
- **glossary**: lightweight — accordion/definition reveal with GSAP height
|
||||||
|
auto + fade, kept minimal since it's low-traffic reference content.
|
||||||
|
|
||||||
|
## Verification checklist (must pass before calling any route "shipped")
|
||||||
|
- [ ] tsc --noEmit clean
|
||||||
|
- [ ] biome check: 0 errors AND 0 warnings
|
||||||
|
- [ ] next build succeeds
|
||||||
|
- [ ] CI green (Build & Deploy (Nix))
|
||||||
|
- [ ] Live screenshot: monochrome, GSAP motion visible, nav/theme/command
|
||||||
|
palette intact, not a stock template
|
||||||
|
- [ ] Reduced-motion: new animate-* classes added to the kill-list
|
||||||
|
- [ ] Mobile: WebGL/heavy work gated per existing pattern
|
||||||
|
|
||||||
|
## Rollback plan
|
||||||
|
Every route ships as its own atomic commit. If user rejects a specific route's
|
||||||
|
direction, `git revert <that commit>` — do not touch unrelated routes.
|
||||||
@@ -10,29 +10,30 @@
|
|||||||
"format": "biome format --write"
|
"format": "biome format --write"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@gsap/react": "^2.1.2",
|
||||||
"@orpc/client": "1.15.0",
|
"@orpc/client": "1.15.0",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"lucide-react": "^1.27.0",
|
"gsap": "^3.15.0",
|
||||||
"motion": "^12.0.0",
|
"lucide-react": "^1.33.0",
|
||||||
"next": "16.2.12",
|
"next": "16.3.2",
|
||||||
"next-themes": "^0.4.6",
|
"next-themes": "^0.4.6",
|
||||||
"partysocket": "1.3.0",
|
"partysocket": "1.3.0",
|
||||||
"react": "19.2.4",
|
"react": "19.2.8",
|
||||||
"react-dom": "19.2.4",
|
"react-dom": "19.2.8",
|
||||||
"swr": "^2.4.2",
|
"swr": "^2.5.1",
|
||||||
"tailwind-merge": "^3.6.0",
|
"tailwind-merge": "^3.6.0",
|
||||||
"three": "^0.180.0"
|
"three": "^0.185.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@biomejs/biome": "2.2.0",
|
"@biomejs/biome": "2.5.10",
|
||||||
"@tailwindcss/postcss": "^4",
|
"@tailwindcss/postcss": "^4",
|
||||||
"@types/node": "^20",
|
"@types/node": "^26.2.0",
|
||||||
"@types/react": "^19",
|
"@types/react": "^19",
|
||||||
"@types/react-dom": "^19",
|
"@types/react-dom": "^19",
|
||||||
"@types/three": "^0.180.0",
|
"@types/three": "^0.185.4",
|
||||||
"babel-plugin-react-compiler": "1.0.0",
|
"babel-plugin-react-compiler": "1.0.0",
|
||||||
"puppeteer-core": "^25.7.0",
|
"puppeteer-core": "^25.8.0",
|
||||||
"tailwindcss": "^4",
|
"tailwindcss": "^4",
|
||||||
"typescript": "^5"
|
"typescript": "^7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Generated
+564
-373
File diff suppressed because it is too large.
Load diff
@@ -1,12 +1,7 @@
|
|||||||
import { PageTransition } from "@/components/shared";
|
|
||||||
import { AnalysisView } from "./view";
|
import { AnalysisView } from "./view";
|
||||||
|
|
||||||
export const dynamic = "force-dynamic";
|
export const dynamic = "force-dynamic";
|
||||||
|
|
||||||
export default function AnalysisPage() {
|
export default function AnalysisPage() {
|
||||||
return (
|
return <AnalysisView />;
|
||||||
<PageTransition>
|
|
||||||
<AnalysisView />
|
|
||||||
</PageTransition>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,14 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import { useGSAP } from "@gsap/react";
|
||||||
|
import gsap from "gsap";
|
||||||
import { Hash, Search, Sparkles, TrendingUp } from "lucide-react";
|
import { Hash, Search, Sparkles, TrendingUp } from "lucide-react";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
import { useAmbient } from "@/components/ambient/ambient-context";
|
import { useAmbient } from "@/components/ambient/ambient-context";
|
||||||
import { Avatar, Badge, GlassPanel, Input } from "@/components/primitives";
|
import { Avatar, Badge, GlassPanel, Input } from "@/components/primitives";
|
||||||
import { EmptyState, SectionHeader, SkeletonRows } from "@/components/shared";
|
import { EmptyState, SectionHeader, SkeletonRows } from "@/components/shared";
|
||||||
import { useChannels, useMessageSearch, useTopReactors } from "@/hooks";
|
import { useChannels, useMessageSearch, useTopReactors } from "@/hooks";
|
||||||
|
import { useStaggerReveal } from "@/hooks/use-gsap-animation";
|
||||||
import { aiTone } from "@/lib/ai-status";
|
import { aiTone } from "@/lib/ai-status";
|
||||||
import {
|
import {
|
||||||
formatDuration,
|
formatDuration,
|
||||||
@@ -13,6 +16,10 @@ import {
|
|||||||
renderMessageContent,
|
renderMessageContent,
|
||||||
} from "@/lib/format";
|
} from "@/lib/format";
|
||||||
|
|
||||||
|
if (typeof window !== "undefined") {
|
||||||
|
gsap.registerPlugin(useGSAP);
|
||||||
|
}
|
||||||
|
|
||||||
export function AnalysisView() {
|
export function AnalysisView() {
|
||||||
const [query, setQuery] = useState("");
|
const [query, setQuery] = useState("");
|
||||||
const search = useMessageSearch(query, query.trim().length >= 2);
|
const search = useMessageSearch(query, query.trim().length >= 2);
|
||||||
@@ -20,6 +27,15 @@ export function AnalysisView() {
|
|||||||
const { data: channels } = useChannels();
|
const { data: channels } = useChannels();
|
||||||
const ambient = useAmbient();
|
const ambient = useAmbient();
|
||||||
|
|
||||||
|
const reactorsRef = useRef<HTMLDivElement>(null);
|
||||||
|
const channelsRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
|
const resultsRef = useStaggerReveal<HTMLDivElement>(".search-result-card", {
|
||||||
|
stagger: 0.03,
|
||||||
|
y: 8,
|
||||||
|
dependencies: [search.data?.length, query],
|
||||||
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
ambient.set(
|
ambient.set(
|
||||||
query ? "amber" : "signal",
|
query ? "amber" : "signal",
|
||||||
@@ -28,74 +44,162 @@ export function AnalysisView() {
|
|||||||
);
|
);
|
||||||
}, [query, ambient]);
|
}, [query, ambient]);
|
||||||
|
|
||||||
|
// Count-up + bar-fill reveal for the reactor leaderboard — HUD gauge motif.
|
||||||
|
useGSAP(
|
||||||
|
() => {
|
||||||
|
if (!reactorsRef.current) return;
|
||||||
|
const bars = reactorsRef.current.querySelectorAll(".reactor-bar-fill");
|
||||||
|
const counters = reactorsRef.current.querySelectorAll(".reactor-count");
|
||||||
|
if (bars.length === 0) return;
|
||||||
|
const prefersReduced = window.matchMedia(
|
||||||
|
"(prefers-reduced-motion: reduce)",
|
||||||
|
).matches;
|
||||||
|
if (prefersReduced) {
|
||||||
|
gsap.set(bars, { scaleX: 1 });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
gsap.fromTo(
|
||||||
|
bars,
|
||||||
|
{ scaleX: 0 },
|
||||||
|
{
|
||||||
|
scaleX: 1,
|
||||||
|
duration: 0.7,
|
||||||
|
stagger: 0.06,
|
||||||
|
ease: "power2.out",
|
||||||
|
transformOrigin: "left center",
|
||||||
|
},
|
||||||
|
);
|
||||||
|
counters.forEach((el) => {
|
||||||
|
const target = Number(el.getAttribute("data-target") ?? "0");
|
||||||
|
const obj = { val: 0 };
|
||||||
|
gsap.to(obj, {
|
||||||
|
val: target,
|
||||||
|
duration: 0.8,
|
||||||
|
ease: "power2.out",
|
||||||
|
onUpdate: () => {
|
||||||
|
el.textContent = `+${Math.round(obj.val)}`;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
{ scope: reactorsRef, dependencies: [reactors] },
|
||||||
|
);
|
||||||
|
|
||||||
|
useGSAP(
|
||||||
|
() => {
|
||||||
|
if (!channelsRef.current) return;
|
||||||
|
const rows = channelsRef.current.querySelectorAll(".channel-row");
|
||||||
|
if (rows.length === 0) return;
|
||||||
|
const prefersReduced = window.matchMedia(
|
||||||
|
"(prefers-reduced-motion: reduce)",
|
||||||
|
).matches;
|
||||||
|
if (prefersReduced) {
|
||||||
|
gsap.set(rows, { opacity: 1, x: 0 });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
gsap.fromTo(
|
||||||
|
rows,
|
||||||
|
{ opacity: 0, x: -10 },
|
||||||
|
{
|
||||||
|
opacity: 1,
|
||||||
|
x: 0,
|
||||||
|
duration: 0.35,
|
||||||
|
stagger: 0.04,
|
||||||
|
ease: "power2.out",
|
||||||
|
clearProps: "transform",
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
{ scope: channelsRef, dependencies: [channels] },
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-5">
|
<div className="space-y-4">
|
||||||
<GlassPanel glow className="relative overflow-hidden">
|
{/* Tactical HUD Header Bar */}
|
||||||
<div className="scan-line absolute inset-x-0 top-0" />
|
<div className="flex flex-wrap items-center justify-between gap-3 border-b border-hairline pb-3">
|
||||||
|
<div className="flex items-center gap-2.5">
|
||||||
|
<span className="h-2 w-2 rounded-full bg-signal shadow-[0_0_8px_var(--color-signal-glow)]" />
|
||||||
|
<h1 className="font-mono text-xs font-semibold tracking-wide text-ink uppercase">
|
||||||
|
Deep Scan · Semantic Search & Telemetry Analysis
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-2 font-mono text-[11px] text-ink-muted">
|
||||||
|
<span>ENGINE:</span>
|
||||||
|
<span className="rounded bg-signal/15 px-2 py-0.5 font-medium text-signal border border-signal/30">
|
||||||
|
{query.trim().length >= 2 ? "SCANNING" : "STANDBY"}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Hero Query Stage */}
|
||||||
|
<GlassPanel className="p-5">
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
<Sparkles className="size-5 text-signal" />
|
<span className="flex size-8 items-center justify-center rounded-[6px] border border-signal/30 bg-signal/10 text-signal">
|
||||||
|
<Sparkles className="size-4" />
|
||||||
|
</span>
|
||||||
<div>
|
<div>
|
||||||
<div className="eyebrow">Semantic search</div>
|
<h2 className="text-base font-semibold text-ink">
|
||||||
<h2 className="display text-balance text-2xl text-ink">
|
Cross-Guild Archive Intelligence
|
||||||
Search the archive
|
|
||||||
</h2>
|
</h2>
|
||||||
|
<p className="font-mono text-[11px] text-ink-muted">
|
||||||
|
Query vectorized messages, heuristic flags, and user behavior
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="relative mt-4">
|
<div className="relative mt-4">
|
||||||
<Search className="absolute left-4 top-1/2 size-5 -translate-y-1/2 text-ink-faint" />
|
<Search className="absolute left-3.5 top-1/2 size-4 -translate-y-1/2 text-ink-faint" />
|
||||||
<Input
|
<Input
|
||||||
className="h-12 pl-12 text-base"
|
className="h-10 pl-10 text-xs text-ink"
|
||||||
placeholder="Find messages, patterns, flags…"
|
placeholder="Search keywords, behavioral patterns, infraction terms..."
|
||||||
value={query}
|
value={query}
|
||||||
onChange={(e) => setQuery(e.target.value)}
|
onChange={(e) => setQuery(e.target.value)}
|
||||||
autoFocus
|
autoFocus
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{query.trim().length > 0 && query.trim().length < 2 && (
|
|
||||||
<div className="mono mt-2 text-xs text-ink-faint">
|
|
||||||
Type at least 2 characters…
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</GlassPanel>
|
</GlassPanel>
|
||||||
|
|
||||||
<div className="grid gap-5 lg:grid-cols-5">
|
<div className="grid gap-3 lg:grid-cols-5">
|
||||||
|
{/* Search Results Column */}
|
||||||
<GlassPanel className="lg:col-span-3">
|
<GlassPanel className="lg:col-span-3">
|
||||||
<SectionHeader
|
<SectionHeader
|
||||||
eyebrow="results"
|
eyebrow="search output"
|
||||||
title="Matches"
|
title="Matched Log Packets"
|
||||||
action={
|
action={
|
||||||
<span className="mono text-xs text-ink-faint">
|
<span className="mono text-xs text-[#8a8f98]">
|
||||||
{(search.data ?? []).length}
|
{(search.data ?? []).length} results
|
||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
{query.trim().length >= 2 && search.isLoading && (
|
{query.trim().length >= 2 && search.isLoading && (
|
||||||
<SkeletonRows rows={6} />
|
<SkeletonRows rows={6} />
|
||||||
)}
|
)}
|
||||||
{(search.data ?? []).length === 0 ? (
|
{(search.data ?? []).length === 0 && !search.isLoading ? (
|
||||||
<EmptyState
|
<EmptyState
|
||||||
icon={<Search className="size-7" />}
|
icon={<Search className="size-7" />}
|
||||||
title="No matches yet"
|
title="No packets matched"
|
||||||
description="Run a search to surface messages across the guild."
|
description="Enter a query string above to scan across all captured guild communication."
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="space-y-1.5">
|
<div ref={resultsRef} className="space-y-1.5 mt-3">
|
||||||
{(search.data ?? []).map((m) => (
|
{(search.data ?? []).map((m) => (
|
||||||
<div
|
<div
|
||||||
key={m.id}
|
key={m.id}
|
||||||
className="flex items-start gap-3 rounded-[12px] border border-hairline bg-white/[0.03] p-3"
|
className="search-result-card hud-card flex items-start gap-3 p-3 transition-all"
|
||||||
>
|
>
|
||||||
<Avatar src={m.avatar_url} name={m.username} size={32} />
|
<Avatar src={m.avatar_url} name={m.username} size={32} />
|
||||||
<div className="min-w-0 flex-1">
|
<div className="min-w-0 flex-1">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<span className="text-sm font-semibold text-ink">
|
<span className="text-xs font-semibold text-ink">
|
||||||
{m.username}
|
{m.username}
|
||||||
</span>
|
</span>
|
||||||
<span className="mono text-[0.65rem] text-ink-faint">
|
<span className="font-mono text-[10px] text-ink-faint">
|
||||||
{getMessageChannelLabel(m)}
|
{getMessageChannelLabel(m)}
|
||||||
</span>
|
</span>
|
||||||
{m.ai_status && (
|
{m.ai_status && (
|
||||||
<Badge tone={aiTone(m.ai_status)} className="ml-auto">
|
<Badge
|
||||||
|
tone={aiTone(m.ai_status)}
|
||||||
|
className="ml-auto font-mono text-[9px]"
|
||||||
|
>
|
||||||
{m.ai_analysis_duration_ms &&
|
{m.ai_analysis_duration_ms &&
|
||||||
m.ai_analysis_duration_ms > 0
|
m.ai_analysis_duration_ms > 0
|
||||||
? `${m.ai_status} · ${formatDuration(m.ai_analysis_duration_ms)}`
|
? `${m.ai_status} · ${formatDuration(m.ai_analysis_duration_ms)}`
|
||||||
@@ -103,7 +207,7 @@ export function AnalysisView() {
|
|||||||
</Badge>
|
</Badge>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-0.5 text-sm text-ink-soft">
|
<div className="mt-1 text-xs text-ink-soft leading-relaxed">
|
||||||
{renderMessageContent(m.content, m.metadata) || "(embed)"}
|
{renderMessageContent(m.content, m.metadata) || "(embed)"}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -113,17 +217,18 @@ export function AnalysisView() {
|
|||||||
)}
|
)}
|
||||||
</GlassPanel>
|
</GlassPanel>
|
||||||
|
|
||||||
<div className="space-y-5 lg:col-span-2">
|
{/* Culture & Leaderboard Side Column */}
|
||||||
|
<div className="space-y-3 lg:col-span-2">
|
||||||
<GlassPanel>
|
<GlassPanel>
|
||||||
<SectionHeader
|
<SectionHeader
|
||||||
eyebrow="culture"
|
eyebrow="engagement"
|
||||||
title={
|
title={
|
||||||
<span className="flex items-center gap-2">
|
<span className="flex items-center gap-1.5">
|
||||||
<TrendingUp className="size-4 text-signal" /> Top reactors
|
<TrendingUp className="size-3.5 text-signal" /> Top Reactors
|
||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<div className="space-y-2">
|
<div ref={reactorsRef} className="space-y-2 mt-3">
|
||||||
{(reactors ?? []).slice(0, 6).map((r, i) => {
|
{(reactors ?? []).slice(0, 6).map((r, i) => {
|
||||||
const maxNet = reactors?.[0]?.net_count || 1;
|
const maxNet = reactors?.[0]?.net_count || 1;
|
||||||
const pct = Math.max(
|
const pct = Math.max(
|
||||||
@@ -133,27 +238,32 @@ export function AnalysisView() {
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={r.user_id}
|
key={r.user_id}
|
||||||
className="flex items-center gap-3 text-sm"
|
className="flex items-center gap-3 text-xs"
|
||||||
>
|
>
|
||||||
<span className="mono w-5 text-ink-faint">{i + 1}</span>
|
<span className="font-mono w-4 text-[10px] text-ink-faint">
|
||||||
<span className="w-28 shrink-0 truncate text-ink-soft sm:w-40">
|
0{i + 1}
|
||||||
|
</span>
|
||||||
|
<span className="w-24 shrink-0 truncate font-mono text-xs text-ink sm:w-32">
|
||||||
{r.username}
|
{r.username}
|
||||||
</span>
|
</span>
|
||||||
<div className="h-1.5 flex-1 overflow-hidden rounded-full bg-white/8">
|
<div className="h-1.5 flex-1 overflow-hidden rounded-full bg-surface-2">
|
||||||
<div
|
<div
|
||||||
className="h-full rounded-full bg-signal/70"
|
className="reactor-bar-fill h-full rounded-full bg-signal"
|
||||||
style={{ width: `${pct}%` }}
|
style={{ width: `${pct}%` }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<span className="mono w-12 text-right text-xs text-signal">
|
<span
|
||||||
+{r.net_count}
|
className="reactor-count font-mono w-10 text-right text-[11px] font-semibold text-signal"
|
||||||
|
data-target={r.net_count}
|
||||||
|
>
|
||||||
|
+0
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
{(reactors ?? []).length === 0 && (
|
{(reactors ?? []).length === 0 && (
|
||||||
<div className="py-4 text-center text-xs text-ink-faint">
|
<div className="py-4 text-center font-mono text-xs text-ink-faint">
|
||||||
No data
|
NO REACTOR DATA
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -161,30 +271,31 @@ export function AnalysisView() {
|
|||||||
|
|
||||||
<GlassPanel>
|
<GlassPanel>
|
||||||
<SectionHeader
|
<SectionHeader
|
||||||
eyebrow="channels"
|
eyebrow="volume"
|
||||||
title={
|
title={
|
||||||
<span className="flex items-center gap-2">
|
<span className="flex items-center gap-1.5">
|
||||||
<Hash className="size-4 text-signal" /> Top channels
|
<Hash className="size-3.5 text-signal" /> Top Active Channels
|
||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<div className="space-y-2">
|
<div ref={channelsRef} className="space-y-2 mt-3">
|
||||||
{(channels ?? []).slice(0, 6).map((c) => (
|
{(channels ?? []).slice(0, 6).map((c) => (
|
||||||
<div
|
<div
|
||||||
key={c.channel_id}
|
key={c.channel_id}
|
||||||
className="flex items-center gap-3 text-sm"
|
className="channel-row hud-card flex items-center justify-between p-2 text-xs"
|
||||||
>
|
>
|
||||||
<span className="flex-1 truncate text-ink-soft">
|
<span className="flex items-center gap-1.5 truncate font-mono text-xs text-ink">
|
||||||
{c.channel_name ?? c.channel_id.slice(0, 8)}
|
<Hash className="size-3 text-signal" />
|
||||||
|
{c.channel_name ?? c.channel_id.slice(0, 10)}
|
||||||
</span>
|
</span>
|
||||||
<span className="mono text-xs text-ink-faint">
|
<span className="font-mono text-[10px] text-ink-muted">
|
||||||
{c.total_messages}
|
{c.total_messages.toLocaleString()} msgs
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
{(channels ?? []).length === 0 && (
|
{(channels ?? []).length === 0 && (
|
||||||
<div className="py-4 text-center text-xs text-ink-faint">
|
<div className="py-4 text-center font-mono text-xs text-ink-faint">
|
||||||
No data
|
NO CHANNEL DATA
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { PageTransition } from "@/components/shared";
|
|
||||||
import { getChannelCultures } from "@/lib/api/server";
|
import { getChannelCultures } from "@/lib/api/server";
|
||||||
import type { ChannelCultureRow } from "@/lib/types";
|
import type { ChannelCultureRow } from "@/lib/types";
|
||||||
import { ChannelsView } from "./view";
|
import { ChannelsView } from "./view";
|
||||||
@@ -12,9 +11,5 @@ export default async function ChannelsPage() {
|
|||||||
} catch {
|
} catch {
|
||||||
cultures = undefined;
|
cultures = undefined;
|
||||||
}
|
}
|
||||||
return (
|
return <ChannelsView initialCultures={cultures} />;
|
||||||
<PageTransition>
|
|
||||||
<ChannelsView initialCultures={cultures} />
|
|
||||||
</PageTransition>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,23 @@ export function ChannelsView({
|
|||||||
}) {
|
}) {
|
||||||
const { data: cultures } = useChannelCultures(100, initialCultures);
|
const { data: cultures } = useChannelCultures(100, initialCultures);
|
||||||
return (
|
return (
|
||||||
<div className="space-y-5">
|
<div className="space-y-4">
|
||||||
|
<div className="flex flex-wrap items-center justify-between gap-3 border-b border-hairline pb-3">
|
||||||
|
<div className="flex items-center gap-3">
|
||||||
|
<div className="relative flex size-3 items-center justify-center">
|
||||||
|
<span className="absolute inline-flex size-full animate-ping rounded-full bg-signal opacity-75" />
|
||||||
|
<span className="relative inline-flex size-2 rounded-full bg-signal" />
|
||||||
|
</div>
|
||||||
|
<h1 className="font-mono text-xs font-semibold tracking-widest text-ink uppercase">
|
||||||
|
CHANNEL ROSTER · SIGNAL_MAP
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
<div className="inline-flex items-center gap-1.5 rounded-md bg-surface px-2 py-0.5 font-mono text-[11px] text-ink-soft">
|
||||||
|
<span className="text-ink-faint">NODES:</span>
|
||||||
|
<span className="font-bold text-signal">{cultures?.length ?? 0}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{cultures ? (
|
{cultures ? (
|
||||||
<ChannelCultureGlossary cultures={cultures} />
|
<ChannelCultureGlossary cultures={cultures} />
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { PageTransition } from "@/components/shared";
|
|
||||||
import { getActivity, getDashboardStats } from "@/lib/api/server";
|
import { getActivity, getDashboardStats } from "@/lib/api/server";
|
||||||
import { DashboardView } from "./view";
|
import { DashboardView } from "./view";
|
||||||
|
|
||||||
@@ -15,9 +14,5 @@ export default async function DashboardPage() {
|
|||||||
} catch {
|
} catch {
|
||||||
// Backend unavailable — client hooks will surface the error state.
|
// Backend unavailable — client hooks will surface the error state.
|
||||||
}
|
}
|
||||||
return (
|
return <DashboardView initialStats={stats} initialActivity={activity} />;
|
||||||
<PageTransition>
|
|
||||||
<DashboardView initialStats={stats} initialActivity={activity} />
|
|
||||||
</PageTransition>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
@@ -1,46 +1,48 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Activity,
|
AudioWaveform,
|
||||||
Flag,
|
ChevronRight,
|
||||||
MessageSquare,
|
MessageSquare,
|
||||||
Mic,
|
Mic,
|
||||||
Radio,
|
Shield,
|
||||||
ShieldAlert,
|
|
||||||
Users,
|
Users,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
|
import Link from "next/link";
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { useAmbient } from "@/components/ambient/ambient-context";
|
import { useAmbient } from "@/components/ambient/ambient-context";
|
||||||
import { AreaActivity, RadialGauge } from "@/components/charts";
|
import { AreaActivity, RadialGauge } from "@/components/charts";
|
||||||
import { GlassPanel } from "@/components/primitives";
|
import { GlassPanel } from "@/components/primitives";
|
||||||
import {
|
import {
|
||||||
ErrorState,
|
ErrorState,
|
||||||
LoadingState,
|
MetricTile,
|
||||||
|
PageTransition,
|
||||||
|
SectionHeader,
|
||||||
SkeletonHero,
|
SkeletonHero,
|
||||||
SkeletonMetricRow,
|
SkeletonMetricRow,
|
||||||
SkeletonPanel,
|
SkeletonPanel,
|
||||||
} from "@/components/shared";
|
} from "@/components/shared";
|
||||||
import { MetricTile, SectionHeader } from "@/components/shared/section";
|
import { useActivity, useStats, useTopReactions } from "@/hooks";
|
||||||
import {
|
import { useStaggerReveal } from "@/hooks/use-gsap-animation";
|
||||||
useActivity,
|
|
||||||
useStats,
|
|
||||||
useTopReactions,
|
|
||||||
useTopReactors,
|
|
||||||
} from "@/hooks";
|
|
||||||
import { formatNumber } from "@/lib/format";
|
import { formatNumber } from "@/lib/format";
|
||||||
import type { DashboardStats } from "@/lib/types";
|
import type { DashboardStats } from "@/lib/types";
|
||||||
import { staggerDelay } from "@/lib/utils";
|
|
||||||
|
|
||||||
function deriveSignal(stats?: DashboardStats) {
|
function deriveSignal(stats?: DashboardStats) {
|
||||||
if (!stats) return { tone: "signal" as const, label: "nominal" };
|
if (!stats)
|
||||||
|
return { tone: "signal" as const, label: "NOMINAL", state: "STABLE" };
|
||||||
const total = stats.total_flagged + stats.total_clean || 1;
|
const total = stats.total_flagged + stats.total_clean || 1;
|
||||||
const ratio = stats.total_flagged / total;
|
const ratio = stats.total_flagged / total;
|
||||||
if (stats.moderation_overview.error > 0)
|
if (stats.moderation_overview.error > 0)
|
||||||
return { tone: "vermilion" as const, label: "moderation fault" };
|
return { tone: "vermilion" as const, label: "FAULT", state: "MOD_ERR" };
|
||||||
if (ratio > 0.25)
|
if (ratio > 0.25)
|
||||||
return { tone: "vermilion" as const, label: "elevated flags" };
|
return {
|
||||||
if (ratio > 0.1) return { tone: "amber" as const, label: "watch" };
|
tone: "vermilion" as const,
|
||||||
return { tone: "signal" as const, label: "nominal" };
|
label: "ELEVATED",
|
||||||
|
state: "HIGH_RISK",
|
||||||
|
};
|
||||||
|
if (ratio > 0.1)
|
||||||
|
return { tone: "amber" as const, label: "WATCH", state: "ADVISORY" };
|
||||||
|
return { tone: "signal" as const, label: "NOMINAL", state: "OPTIMAL" };
|
||||||
}
|
}
|
||||||
|
|
||||||
export function DashboardView({
|
export function DashboardView({
|
||||||
@@ -57,10 +59,15 @@ export function DashboardView({
|
|||||||
mutate: mutateStats,
|
mutate: mutateStats,
|
||||||
} = useStats(initialStats);
|
} = useStats(initialStats);
|
||||||
const { data: activity } = useActivity(14, initialActivity as never);
|
const { data: activity } = useActivity(14, initialActivity as never);
|
||||||
const { data: reactors } = useTopReactors();
|
|
||||||
const { data: reactions } = useTopReactions();
|
const { data: reactions } = useTopReactions();
|
||||||
const ambient = useAmbient();
|
const ambient = useAmbient();
|
||||||
|
|
||||||
|
const hudRef = useStaggerReveal<HTMLDivElement>(".linear-tile", {
|
||||||
|
stagger: 0.035,
|
||||||
|
y: 8,
|
||||||
|
dependencies: [stats],
|
||||||
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const s = deriveSignal(stats);
|
const s = deriveSignal(stats);
|
||||||
ambient.set(
|
ambient.set(
|
||||||
@@ -74,20 +81,16 @@ export function DashboardView({
|
|||||||
return <ErrorState error={error} onRetry={() => void mutateStats()} />;
|
return <ErrorState error={error} onRetry={() => void mutateStats()} />;
|
||||||
if (!stats && isLoading)
|
if (!stats && isLoading)
|
||||||
return (
|
return (
|
||||||
<div className="space-y-5">
|
<div className="space-y-4">
|
||||||
<SkeletonHero />
|
<SkeletonHero />
|
||||||
<SkeletonMetricRow cols={4} />
|
<SkeletonMetricRow cols={4} />
|
||||||
<SkeletonPanel rows={5} />
|
<SkeletonPanel rows={4} />
|
||||||
<div className="grid gap-5 lg:grid-cols-5">
|
|
||||||
<SkeletonPanel className="lg:col-span-3" rows={4} />
|
|
||||||
<SkeletonPanel className="lg:col-span-2" rows={4} />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
if (!stats)
|
if (!stats)
|
||||||
return (
|
return (
|
||||||
<ErrorState
|
<ErrorState
|
||||||
error={error ?? new Error("No data")}
|
error={error ?? new Error("No telemetry stream")}
|
||||||
onRetry={() => void mutateStats()}
|
onRetry={() => void mutateStats()}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@@ -97,284 +100,152 @@ export function DashboardView({
|
|||||||
const cleanRatio = s.total_clean / total;
|
const cleanRatio = s.total_clean / total;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-5">
|
<PageTransition>
|
||||||
{/* Hero */}
|
<div ref={hudRef} className="space-y-4">
|
||||||
<GlassPanel glow className="game-frame relative overflow-hidden">
|
{/* Tactical HUD Header Bar */}
|
||||||
<div className="scan-line absolute inset-x-0 top-0" />
|
<div className="linear-tile flex flex-wrap items-center justify-between gap-3 border-b border-hairline pb-3">
|
||||||
<div className="flex flex-wrap items-end justify-between gap-4">
|
|
||||||
<div>
|
|
||||||
<div className="eyebrow mb-2">GMW · Operations Grid</div>
|
|
||||||
<h2 className="display hero-clamp leading-none text-ink glow-signal">
|
|
||||||
Ambient Field
|
|
||||||
</h2>
|
|
||||||
<p className="mt-2 max-w-md text-pretty text-sm text-ink-soft">
|
|
||||||
Real-time moderation, voice & media presence across the monitored
|
|
||||||
guild. {formatNumber(s.total_messages)} messages captured.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div className="flex items-center gap-2 text-ink-soft">
|
|
||||||
<Radio className="size-4 text-signal animate-breathe" />
|
|
||||||
<span className="mono text-xs uppercase tracking-wider">
|
|
||||||
{deriveSignal(s).label}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="mt-5 grid grid-cols-2 gap-3 md:grid-cols-4">
|
|
||||||
<MetricTile
|
|
||||||
label="Messages"
|
|
||||||
value={formatNumber(s.total_messages)}
|
|
||||||
tone="signal"
|
|
||||||
icon={<MessageSquare className="size-3.5" />}
|
|
||||||
className="animate-stagger"
|
|
||||||
style={staggerDelay(0)}
|
|
||||||
/>
|
|
||||||
<MetricTile
|
|
||||||
label="Flagged"
|
|
||||||
value={formatNumber(s.total_flagged)}
|
|
||||||
tone={s.total_flagged > 0 ? "vermilion" : "neutral"}
|
|
||||||
hint={`${s.today_flagged} today`}
|
|
||||||
className="animate-stagger"
|
|
||||||
style={staggerDelay(1)}
|
|
||||||
/>
|
|
||||||
<MetricTile
|
|
||||||
label="Active 24h"
|
|
||||||
value={formatNumber(s.active_users_24h)}
|
|
||||||
tone="signal"
|
|
||||||
icon={<Users className="size-3.5" />}
|
|
||||||
className="animate-stagger"
|
|
||||||
style={staggerDelay(2)}
|
|
||||||
/>
|
|
||||||
<MetricTile
|
|
||||||
label="Voice clips"
|
|
||||||
value={formatNumber(s.total_voice_recordings)}
|
|
||||||
icon={<Mic className="size-3.5" />}
|
|
||||||
className="animate-stagger"
|
|
||||||
style={staggerDelay(3)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</GlassPanel>
|
|
||||||
|
|
||||||
{/* Activity */}
|
|
||||||
<GlassPanel>
|
|
||||||
<SectionHeader
|
|
||||||
eyebrow="14-day signal"
|
|
||||||
title={
|
|
||||||
<span className="flex items-center gap-2">
|
|
||||||
<Activity className="size-4 text-signal" /> Activity & moderation
|
|
||||||
</span>
|
|
||||||
}
|
|
||||||
action={
|
|
||||||
<div className="flex items-center gap-3 text-xs text-ink-soft">
|
|
||||||
<span className="flex items-center gap-1.5">
|
|
||||||
<span className="size-2 rounded-full bg-signal" /> messages
|
|
||||||
</span>
|
|
||||||
<span className="flex items-center gap-1.5">
|
|
||||||
<span className="size-2 rounded-full bg-vermilion" /> flagged
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
{activity ? (
|
|
||||||
<AreaActivity daily={activity.daily} />
|
|
||||||
) : (
|
|
||||||
<LoadingState label="streaming" />
|
|
||||||
)}
|
|
||||||
</GlassPanel>
|
|
||||||
|
|
||||||
{/* Two-column: channels + moderation */}
|
|
||||||
<div className="grid gap-5 lg:grid-cols-5">
|
|
||||||
<GlassPanel className="lg:col-span-3">
|
|
||||||
<SectionHeader eyebrow="throughput" title="Top channels" />
|
|
||||||
<div className="space-y-2.5">
|
|
||||||
{s.top_channels.slice(0, 7).map((c) => {
|
|
||||||
const pct =
|
|
||||||
(c.message_count / (s.top_channels[0]?.message_count || 1)) *
|
|
||||||
100;
|
|
||||||
return (
|
|
||||||
<div key={c.channel_id} className="flex items-center gap-3">
|
|
||||||
<span className="w-28 shrink-0 truncate text-sm text-ink-soft sm:w-40">
|
|
||||||
{c.channel_name ?? c.channel_id.slice(0, 8)}
|
|
||||||
</span>
|
|
||||||
<div className="h-2 flex-1 overflow-hidden rounded-full bg-white/8">
|
|
||||||
<div
|
|
||||||
className="h-full rounded-full bg-signal/70"
|
|
||||||
style={{ width: `${pct}%` }}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<span className="mono w-14 text-right text-xs text-ink-faint">
|
|
||||||
{formatNumber(c.message_count)}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</GlassPanel>
|
|
||||||
|
|
||||||
<GlassPanel className="lg:col-span-2">
|
|
||||||
<SectionHeader eyebrow="trust" title="Moderation" />
|
|
||||||
<div className="flex items-center gap-5">
|
|
||||||
<RadialGauge
|
|
||||||
value={cleanRatio}
|
|
||||||
tone={
|
|
||||||
cleanRatio > 0.8
|
|
||||||
? "signal"
|
|
||||||
: cleanRatio > 0.6
|
|
||||||
? "amber"
|
|
||||||
: "vermilion"
|
|
||||||
}
|
|
||||||
label={`${Math.round(cleanRatio * 100)}%`}
|
|
||||||
sublabel="clean"
|
|
||||||
/>
|
|
||||||
<div className="flex-1 space-y-2 text-sm">
|
|
||||||
<Row
|
|
||||||
icon={<ShieldAlert className="size-4 text-signal" />}
|
|
||||||
label="Clean"
|
|
||||||
value={formatNumber(s.total_clean)}
|
|
||||||
/>
|
|
||||||
<Row
|
|
||||||
icon={<Flag className="size-4 text-vermilion" />}
|
|
||||||
label="Flagged"
|
|
||||||
value={formatNumber(s.total_flagged)}
|
|
||||||
/>
|
|
||||||
<Row
|
|
||||||
icon={<Activity className="size-4 text-amber" />}
|
|
||||||
label="Warned"
|
|
||||||
value={formatNumber(s.total_warned)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="mt-4 flex items-center justify-around border-t border-hairline pt-3 text-center">
|
|
||||||
<Mini
|
|
||||||
label="pending"
|
|
||||||
value={s.moderation_overview.pending}
|
|
||||||
tone="amber"
|
|
||||||
/>
|
|
||||||
<Mini
|
|
||||||
label="processing"
|
|
||||||
value={s.moderation_overview.processing}
|
|
||||||
tone="signal"
|
|
||||||
/>
|
|
||||||
<Mini
|
|
||||||
label="errors"
|
|
||||||
value={s.moderation_overview.error}
|
|
||||||
tone="vermilion"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</GlassPanel>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Reactors + reactions */}
|
|
||||||
<div className="grid gap-5 lg:grid-cols-2">
|
|
||||||
<GlassPanel>
|
|
||||||
<SectionHeader eyebrow="engagement" title="Top reactors" />
|
|
||||||
<div className="space-y-2">
|
|
||||||
{(reactors ?? []).slice(0, 6).map((r, i) => {
|
|
||||||
const maxNet = reactors?.[0]?.net_count || 1;
|
|
||||||
const pct = Math.max(4, Math.round((r.net_count / maxNet) * 100));
|
|
||||||
return (
|
|
||||||
<div key={r.user_id} className="flex items-center gap-3">
|
|
||||||
<span className="mono w-5 text-ink-faint">{i + 1}</span>
|
|
||||||
<span className="w-28 shrink-0 truncate text-sm text-ink-soft sm:w-40">
|
|
||||||
{r.username}
|
|
||||||
</span>
|
|
||||||
<div className="h-1.5 flex-1 overflow-hidden rounded-full bg-white/8">
|
|
||||||
<div
|
|
||||||
className="h-full rounded-full bg-signal/70"
|
|
||||||
style={{ width: `${pct}%` }}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<span className="mono w-12 text-right text-xs text-signal">
|
|
||||||
+{formatNumber(r.net_count)}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
{(reactors ?? []).length === 0 && <EmptyHint />}
|
|
||||||
</div>
|
|
||||||
</GlassPanel>
|
|
||||||
|
|
||||||
<GlassPanel>
|
|
||||||
<SectionHeader eyebrow="culture" title="Top reactions" />
|
|
||||||
<div className="space-y-3">
|
|
||||||
{(reactions ?? []).slice(0, 5).map((m) => (
|
|
||||||
<div key={m.message_id} className="flex items-start gap-3">
|
|
||||||
<div className="flex flex-wrap gap-1 pt-0.5">
|
|
||||||
{m.top_emojis.slice(0, 3).map((e, i) => (
|
|
||||||
<span
|
|
||||||
key={`${m.message_id}-${i}`}
|
|
||||||
className="text-lg leading-none"
|
|
||||||
>
|
|
||||||
{e.emoji}
|
|
||||||
</span>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
<div className="min-w-0 flex-1">
|
|
||||||
<div className="truncate text-sm text-ink">
|
|
||||||
{m.content || "(no text)"}
|
|
||||||
</div>
|
|
||||||
<div className="mono text-[0.65rem] text-ink-faint">
|
|
||||||
{m.username} · {m.channel_name ?? m.channel_id.slice(0, 8)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<span className="mono text-xs text-ink-soft">
|
|
||||||
{m.reaction_count}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
{(reactions ?? []).length === 0 && <EmptyHint />}
|
|
||||||
</div>
|
|
||||||
</GlassPanel>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function Row({
|
|
||||||
icon,
|
|
||||||
label,
|
|
||||||
value,
|
|
||||||
}: {
|
|
||||||
icon: React.ReactNode;
|
|
||||||
label: string;
|
|
||||||
value: string;
|
|
||||||
}) {
|
|
||||||
return (
|
|
||||||
<div className="flex items-center gap-2.5">
|
<div className="flex items-center gap-2.5">
|
||||||
{icon}
|
<span className="h-2 w-2 rounded-full bg-signal shadow-[0_0_8px_var(--color-signal-glow)]" />
|
||||||
<span className="flex-1 text-ink-soft">{label}</span>
|
<h1 className="font-mono text-xs font-semibold tracking-wide text-ink uppercase">
|
||||||
<span className="mono text-ink">{value}</span>
|
Telemetry Overview · Node 01
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-2 font-mono text-[11px] text-ink-muted">
|
||||||
|
<span>SIGNAL:</span>
|
||||||
|
<span className="rounded bg-signal/15 px-2 py-0.5 font-medium text-signal border border-signal/30">
|
||||||
|
STABLE_STREAM
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function Mini({
|
{/* Primary Metric Deck */}
|
||||||
label,
|
<div className="linear-tile grid gap-3 sm:grid-cols-2 lg:grid-cols-4">
|
||||||
value,
|
<MetricTile
|
||||||
tone,
|
label="Total Messages"
|
||||||
}: {
|
value={formatNumber(s.total_messages)}
|
||||||
label: string;
|
hint={`${formatNumber(s.today_messages)} today`}
|
||||||
value: number;
|
icon={<MessageSquare className="size-4" />}
|
||||||
tone: "signal" | "amber" | "vermilion";
|
/>
|
||||||
}) {
|
<MetricTile
|
||||||
const color =
|
label="Clean Filter Ratio"
|
||||||
tone === "vermilion"
|
value={`${Math.round(cleanRatio * 100)}%`}
|
||||||
? "text-vermilion"
|
hint={`${formatNumber(s.total_clean)} verified clean`}
|
||||||
: tone === "amber"
|
tone="signal"
|
||||||
? "text-amber"
|
icon={<Shield className="size-4" />}
|
||||||
: "text-signal";
|
/>
|
||||||
return (
|
<MetricTile
|
||||||
|
label="Voice Recordings"
|
||||||
|
value={formatNumber(s.total_voice_recordings)}
|
||||||
|
hint="Archived audio sessions"
|
||||||
|
icon={<Mic className="size-4" />}
|
||||||
|
/>
|
||||||
|
<MetricTile
|
||||||
|
label="Total Profiles"
|
||||||
|
value={formatNumber(s.total_profiles)}
|
||||||
|
hint={`${formatNumber(s.active_users_24h)} active 24h`}
|
||||||
|
icon={<Users className="size-4" />}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Dynamic Activity Area & Telemetry Gauges */}
|
||||||
|
<div className="grid gap-3 lg:grid-cols-3">
|
||||||
|
<GlassPanel className="linear-tile lg:col-span-2">
|
||||||
|
<SectionHeader
|
||||||
|
eyebrow="Activity Stream"
|
||||||
|
title="Message Volume & Signal Density"
|
||||||
|
/>
|
||||||
|
<div className="mt-4">
|
||||||
|
<AreaActivity daily={activity?.daily ?? []} />
|
||||||
|
</div>
|
||||||
|
</GlassPanel>
|
||||||
|
|
||||||
|
<GlassPanel className="linear-tile flex flex-col justify-between">
|
||||||
<div>
|
<div>
|
||||||
<div className={`display text-xl ${color}`}>{value}</div>
|
<SectionHeader
|
||||||
<div className="eyebrow mt-0.5">{label}</div>
|
eyebrow="Security State"
|
||||||
|
title="Moderation Accuracy"
|
||||||
|
/>
|
||||||
|
<div className="my-6 flex items-center justify-center">
|
||||||
|
<RadialGauge
|
||||||
|
value={Math.round(cleanRatio * 100)}
|
||||||
|
label="Clean Ratio"
|
||||||
|
tone={cleanRatio > 0.85 ? "signal" : "amber"}
|
||||||
|
size={140}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="grid grid-cols-2 gap-2 border-t border-hairline pt-3 text-center">
|
||||||
|
<div>
|
||||||
|
<div className="eyebrow">CLEAN</div>
|
||||||
|
<div className="font-sans text-sm font-semibold text-success">
|
||||||
|
{formatNumber(s.total_clean)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div className="eyebrow">FLAGGED</div>
|
||||||
|
<div className="font-sans text-sm font-semibold text-vermilion">
|
||||||
|
{formatNumber(s.total_flagged)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</GlassPanel>
|
||||||
</div>
|
</div>
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function EmptyHint() {
|
{/* Secondary Insights Deck */}
|
||||||
return (
|
<div className="grid gap-3 lg:grid-cols-2">
|
||||||
<div className="py-6 text-center text-xs text-ink-faint">
|
{reactions && reactions.length > 0 && (
|
||||||
Awaiting data…
|
<GlassPanel className="linear-tile">
|
||||||
|
<SectionHeader
|
||||||
|
eyebrow="Engagement"
|
||||||
|
title="Top Reacted Messages"
|
||||||
|
/>
|
||||||
|
<div className="mt-3 space-y-2">
|
||||||
|
{reactions.slice(0, 4).map((r) => (
|
||||||
|
<div
|
||||||
|
key={r.message_id}
|
||||||
|
className="hud-card flex items-center justify-between p-2.5"
|
||||||
|
>
|
||||||
|
<span className="truncate pr-2 text-xs text-ink-soft">
|
||||||
|
{r.content || "[Media/Attachment]"}
|
||||||
|
</span>
|
||||||
|
<span className="font-mono text-xs font-semibold text-signal shrink-0">
|
||||||
|
{formatNumber(r.reaction_count)} reactions
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</GlassPanel>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<GlassPanel className="linear-tile flex flex-col justify-between">
|
||||||
|
<div>
|
||||||
|
<SectionHeader eyebrow="Navigation" title="Quick Diagnostics" />
|
||||||
|
<div className="mt-2 space-y-1.5">
|
||||||
|
<Link
|
||||||
|
href="/moderation"
|
||||||
|
className="hud-card flex items-center justify-between p-2.5 text-xs text-ink-soft transition-colors hover:text-ink"
|
||||||
|
>
|
||||||
|
<span className="flex items-center gap-2">
|
||||||
|
<Shield className="size-3.5 text-signal" />
|
||||||
|
Review Live Moderation Queue
|
||||||
|
</span>
|
||||||
|
<ChevronRight className="size-3.5 text-ink-muted" />
|
||||||
|
</Link>
|
||||||
|
<Link
|
||||||
|
href="/voice"
|
||||||
|
className="hud-card flex items-center justify-between p-2.5 text-xs text-ink-soft transition-colors hover:text-ink"
|
||||||
|
>
|
||||||
|
<span className="flex items-center gap-2">
|
||||||
|
<AudioWaveform className="size-3.5 text-success" />
|
||||||
|
Inspect Active Voice Stages
|
||||||
|
</span>
|
||||||
|
<ChevronRight className="size-3.5 text-ink-muted" />
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</GlassPanel>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</PageTransition>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
import { PageTransition } from "@/components/shared";
|
|
||||||
import { getGlossary } from "@/lib/api/server";
|
import { getGlossary } from "@/lib/api/server";
|
||||||
import type { GlossaryRow } from "@/lib/types";
|
import type { GlossaryRow } from "@/lib/types";
|
||||||
import { GlossaryView } from "./view";
|
import { GlossaryView } from "./view";
|
||||||
@@ -12,9 +11,5 @@ export default async function GlossaryPage() {
|
|||||||
} catch {
|
} catch {
|
||||||
terms = undefined;
|
terms = undefined;
|
||||||
}
|
}
|
||||||
return (
|
return <GlossaryView initialTerms={terms} />;
|
||||||
<PageTransition>
|
|
||||||
<GlossaryView initialTerms={terms} />
|
|
||||||
</PageTransition>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
import { PageTransition } from "@/components/shared";
|
|
||||||
import { getMediaStatus } from "@/lib/api/server";
|
import { getMediaStatus } from "@/lib/api/server";
|
||||||
import { MediaView } from "./view";
|
import { MediaView } from "./view";
|
||||||
|
|
||||||
@@ -11,9 +10,5 @@ export default async function MediaPage() {
|
|||||||
} catch {
|
} catch {
|
||||||
/* client hooks surface errors */
|
/* client hooks surface errors */
|
||||||
}
|
}
|
||||||
return (
|
return <MediaView initialStatus={status} />;
|
||||||
<PageTransition>
|
|
||||||
<MediaView initialStatus={status} />
|
|
||||||
</PageTransition>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
@@ -1,19 +1,13 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import {
|
import { Disc, Play, Repeat, SkipForward, Square } from "lucide-react";
|
||||||
ListMusic,
|
|
||||||
Play,
|
|
||||||
Radio,
|
|
||||||
Repeat,
|
|
||||||
SkipForward,
|
|
||||||
Square,
|
|
||||||
Volume2,
|
|
||||||
} from "lucide-react";
|
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useAmbient } from "@/components/ambient/ambient-context";
|
import { useAmbient } from "@/components/ambient/ambient-context";
|
||||||
|
import { Equalizer } from "@/components/charts";
|
||||||
import { Button, GlassPanel, Input, toast } from "@/components/primitives";
|
import { Button, GlassPanel, Input, toast } from "@/components/primitives";
|
||||||
import {
|
import {
|
||||||
ErrorState,
|
ErrorState,
|
||||||
|
PageTransition,
|
||||||
SectionHeader,
|
SectionHeader,
|
||||||
SkeletonHero,
|
SkeletonHero,
|
||||||
SkeletonPanel,
|
SkeletonPanel,
|
||||||
@@ -26,9 +20,9 @@ import {
|
|||||||
useMediaStop,
|
useMediaStop,
|
||||||
useMediaWsSync,
|
useMediaWsSync,
|
||||||
} from "@/hooks";
|
} from "@/hooks";
|
||||||
|
import { useStaggerReveal } from "@/hooks/use-gsap-animation";
|
||||||
import { formatDuration } from "@/lib/format";
|
import { formatDuration } from "@/lib/format";
|
||||||
import type { MediaState } from "@/lib/types";
|
import type { MediaState } from "@/lib/types";
|
||||||
import { staggerDelay } from "@/lib/utils";
|
|
||||||
import { useWebSocket } from "@/lib/ws/context";
|
import { useWebSocket } from "@/lib/ws/context";
|
||||||
|
|
||||||
export function MediaView({ initialStatus }: { initialStatus?: MediaState }) {
|
export function MediaView({ initialStatus }: { initialStatus?: MediaState }) {
|
||||||
@@ -51,30 +45,32 @@ export function MediaView({ initialStatus }: { initialStatus?: MediaState }) {
|
|||||||
const playing = media?.playing ?? false;
|
const playing = media?.playing ?? false;
|
||||||
const current = media?.current ?? null;
|
const current = media?.current ?? null;
|
||||||
const queueList = media?.queue ?? [];
|
const queueList = media?.queue ?? [];
|
||||||
const queueTotal = queueList.reduce(
|
|
||||||
(acc, it) => acc + (it.durationMs ?? 0),
|
const mediaRef = useStaggerReveal<HTMLDivElement>(".media-tile", {
|
||||||
0,
|
stagger: 0.04,
|
||||||
);
|
y: 8,
|
||||||
|
dependencies: [playing, queueList.length],
|
||||||
|
});
|
||||||
|
|
||||||
const tone = playing ? "signal" : queueList.length ? "amber" : "signal";
|
const tone = playing ? "signal" : queueList.length ? "amber" : "signal";
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
ambient.set(
|
ambient.set(
|
||||||
tone,
|
tone,
|
||||||
playing ? 0.5 : 0.25,
|
playing ? 0.45 : 0.2,
|
||||||
playing ? "now playing" : "media idle",
|
playing ? "playing stream" : "media ready",
|
||||||
);
|
);
|
||||||
}, [tone, playing, ambient]);
|
}, [tone, playing, ambient]);
|
||||||
|
|
||||||
const onPlay = async () => {
|
const onPlay = async () => {
|
||||||
const u = url.trim();
|
const u = url.trim();
|
||||||
if (!u) {
|
if (!u) {
|
||||||
toast({ title: "Enter a media URL", tone: "vermilion" });
|
toast({ title: "Enter media URL", tone: "vermilion" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await queue.mutateAsync({ url: u, mode: "music" });
|
await queue.mutateAsync({ url: u, mode: "music" });
|
||||||
setUrl("");
|
setUrl("");
|
||||||
toast({ title: "Queued", tone: "signal" });
|
toast({ title: "Track queued", tone: "signal" });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toast({
|
toast({
|
||||||
title: "Queue failed",
|
title: "Queue failed",
|
||||||
@@ -88,212 +84,153 @@ export function MediaView({ initialStatus }: { initialStatus?: MediaState }) {
|
|||||||
return <ErrorState error={error} onRetry={() => void mutate()} />;
|
return <ErrorState error={error} onRetry={() => void mutate()} />;
|
||||||
if (!media && isLoading)
|
if (!media && isLoading)
|
||||||
return (
|
return (
|
||||||
<div className="space-y-5">
|
<div className="space-y-4">
|
||||||
<SkeletonHero />
|
<SkeletonHero />
|
||||||
<SkeletonPanel rows={4} />
|
<SkeletonPanel rows={3} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const mockLevels = playing
|
||||||
|
? [0.4, 0.7, 0.9, 0.6, 0.8, 0.5, 0.9, 0.7, 0.4, 0.8, 0.6, 0.9]
|
||||||
|
: [0.08, 0.08, 0.08, 0.08, 0.08, 0.08];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-5">
|
<PageTransition>
|
||||||
<GlassPanel glow className="relative overflow-hidden">
|
<div ref={mediaRef} className="space-y-4">
|
||||||
<div className="scan-line absolute inset-x-0 top-0" />
|
{/* Precision Sub-Header Bar */}
|
||||||
<div className="flex flex-col gap-5 sm:flex-row sm:items-center">
|
<div className="media-tile flex flex-wrap items-center justify-between gap-3 border-b border-hairline pb-3">
|
||||||
<div
|
<div className="flex items-center gap-2.5">
|
||||||
className={`flex size-32 shrink-0 items-center justify-center rounded-full border border-hairline bg-gradient-to-br from-white/10 to-white/[0.02] ${playing ? "animate-spin-disc" : "animate-spin-disc paused"}`}
|
|
||||||
>
|
|
||||||
<div className="flex size-28 items-center justify-center overflow-hidden rounded-full bg-canvas/60">
|
|
||||||
{current?.thumbnailUrl ? (
|
|
||||||
// biome-ignore lint/performance/noImgElement: external CDN thumbnails, next/image needs remote allowlist
|
|
||||||
<img
|
|
||||||
src={current.thumbnailUrl}
|
|
||||||
alt=""
|
|
||||||
className="size-full object-cover"
|
|
||||||
loading="lazy"
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<ListMusic className="size-10 text-signal" />
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="min-w-0 flex-1">
|
|
||||||
<div className="eyebrow mb-1 flex items-center gap-2">
|
|
||||||
{playing ? (
|
|
||||||
<>
|
|
||||||
<span aria-hidden className="flex h-3 items-end gap-[2px]">
|
|
||||||
{[0, 1, 2].map((i) => (
|
|
||||||
<span
|
<span
|
||||||
key={`eq-${i}`}
|
className={`h-2 w-2 rounded-full ${
|
||||||
className="w-[3px] animate-eq rounded-full bg-signal"
|
playing
|
||||||
style={{
|
? "bg-signal shadow-[0_0_8px_var(--color-signal-glow)]"
|
||||||
animationDelay: `${i * 160}ms`,
|
: "bg-ink-muted"
|
||||||
height: "100%",
|
}`}
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
))}
|
<h1 className="font-mono text-xs font-semibold tracking-wide text-ink uppercase">
|
||||||
</span>
|
Audio Engine · Media Gateway
|
||||||
<span className="text-signal">Now playing</span>
|
</h1>
|
||||||
</>
|
|
||||||
) : current ? (
|
|
||||||
"Paused"
|
|
||||||
) : (
|
|
||||||
"Nothing queued"
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
<h2 className="display text-balance text-2xl text-ink">
|
<div className="flex items-center gap-2 font-mono text-[11px]">
|
||||||
{current?.title ?? "Nothing queued"}
|
<span className="text-ink-muted">ENGINE:</span>
|
||||||
</h2>
|
<span
|
||||||
<div className="mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-ink-faint">
|
className={`rounded px-1.5 py-0.5 font-medium border ${
|
||||||
{current?.source && (
|
playing
|
||||||
<span className="mono truncate">{current.source}</span>
|
? "border-signal/30 bg-signal/10 text-signal"
|
||||||
)}
|
: "border-hairline bg-surface-2 text-ink-muted"
|
||||||
{current?.mode && (
|
}`}
|
||||||
<span className="pill capitalize">{current.mode}</span>
|
>
|
||||||
)}
|
{playing ? "STREAMING" : "IDLE"}
|
||||||
{formatDuration(current?.durationMs) && (
|
|
||||||
<span className="mono">
|
|
||||||
{formatDuration(current?.durationMs)}
|
|
||||||
</span>
|
</span>
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-4 flex flex-wrap items-center gap-2">
|
</div>
|
||||||
<Button
|
|
||||||
variant="primary"
|
{/* Media Playback Deck */}
|
||||||
size="sm"
|
<div className="media-tile">
|
||||||
onClick={onPlay}
|
<GlassPanel className="p-5">
|
||||||
disabled={queue.isPending}
|
<div className="flex flex-col gap-4 md:flex-row md:items-center md:justify-between">
|
||||||
>
|
<div className="flex items-center gap-3.5">
|
||||||
<Play className="size-4" /> Queue & play
|
<div className="flex size-11 items-center justify-center rounded-[8px] border border-hairline bg-surface-2 text-signal">
|
||||||
</Button>
|
<Disc
|
||||||
<Button
|
className={`size-6 ${playing ? "animate-spin-disc text-signal" : "text-ink-muted"}`}
|
||||||
variant="outline"
|
/>
|
||||||
size="sm"
|
</div>
|
||||||
onClick={() => skip.mutate()}
|
<div>
|
||||||
disabled={skip.isPending}
|
<div className="text-sm font-semibold tracking-tight text-ink">
|
||||||
>
|
{current?.title ?? "No Active Media Stream"}
|
||||||
<SkipForward className="size-4" /> Skip
|
</div>
|
||||||
</Button>
|
<div className="font-mono text-[11px] text-ink-muted">
|
||||||
<Button
|
{current
|
||||||
variant="outline"
|
? `${formatDuration(current.durationMs ?? 0)} · High Fidelity Stream`
|
||||||
size="sm"
|
: "Queue a track via URL below"}
|
||||||
onClick={() => stop.mutate()}
|
|
||||||
disabled={stop.isPending}
|
|
||||||
>
|
|
||||||
<Square className="size-4" /> Stop
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant={media?.loop ? "primary" : "outline"}
|
|
||||||
size="sm"
|
|
||||||
onClick={() => loop.mutate(!media?.loop)}
|
|
||||||
aria-pressed={!!media?.loop}
|
|
||||||
>
|
|
||||||
<Repeat className="size-4" /> Loop
|
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="mt-5 flex flex-wrap items-center gap-3">
|
{/* Controls */}
|
||||||
<div className="relative min-w-0 flex-1">
|
<div className="flex items-center gap-2">
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
onClick={() => loop.mutateAsync()}
|
||||||
|
className={media?.loop ? "border-signal text-signal" : ""}
|
||||||
|
>
|
||||||
|
<Repeat className="size-3.5" />
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
onClick={() => skip.mutateAsync()}
|
||||||
|
>
|
||||||
|
<SkipForward className="size-3.5" />
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="danger"
|
||||||
|
size="sm"
|
||||||
|
onClick={() => stop.mutateAsync()}
|
||||||
|
>
|
||||||
|
<Square className="size-3.5" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Quick URL Input */}
|
||||||
|
<div className="mt-4 flex gap-2 border-t border-hairline pt-4">
|
||||||
<Input
|
<Input
|
||||||
placeholder="Paste a YouTube / music URL…"
|
placeholder="Paste YouTube, SoundCloud, or Direct Stream URL..."
|
||||||
value={url}
|
value={url}
|
||||||
onChange={(e) => setUrl(e.target.value)}
|
onChange={(e) => setUrl(e.target.value)}
|
||||||
onKeyDown={(e) => e.key === "Enter" && onPlay()}
|
className="flex-1 text-xs"
|
||||||
/>
|
/>
|
||||||
|
<Button variant="primary" size="md" onClick={onPlay}>
|
||||||
|
<Play className="size-3.5" />
|
||||||
|
Queue Track
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex shrink-0 items-center gap-2 rounded-[10px] border border-hairline bg-white/5 px-3 py-2.5">
|
</GlassPanel>
|
||||||
<Volume2 className="size-4 text-ink-faint" />
|
</div>
|
||||||
<div className="h-1.5 w-24 overflow-hidden rounded-full bg-white/10">
|
|
||||||
<div
|
{/* Spectrum & Queue Grid */}
|
||||||
className="h-full rounded-full bg-signal/70"
|
<div className="grid gap-3 lg:grid-cols-3">
|
||||||
style={{
|
<GlassPanel className="media-tile lg:col-span-2">
|
||||||
width: `${Math.round((media?.musicVolume ?? 0) * 100)}%`,
|
<SectionHeader
|
||||||
}}
|
eyebrow="Visualizer"
|
||||||
|
title="Realtime Frequency Array"
|
||||||
/>
|
/>
|
||||||
</div>
|
<div className="my-6 flex items-center justify-center">
|
||||||
<span className="mono w-9 text-right text-[0.65rem] text-ink-faint">
|
<Equalizer bars={mockLevels} />
|
||||||
{Math.round((media?.musicVolume ?? 0) * 100)}%
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</GlassPanel>
|
</GlassPanel>
|
||||||
|
|
||||||
<GlassPanel>
|
<GlassPanel className="media-tile">
|
||||||
<SectionHeader
|
<SectionHeader
|
||||||
eyebrow="up next"
|
eyebrow="Playlist"
|
||||||
title="Queue"
|
title={`Queue (${queueList.length})`}
|
||||||
action={
|
|
||||||
<span className="mono text-xs text-ink-faint">
|
|
||||||
{queueList.length} track{queueList.length === 1 ? "" : "s"}
|
|
||||||
{queueTotal && ` · ${formatDuration(queueTotal)}`}
|
|
||||||
</span>
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
|
<div className="mt-3 space-y-2">
|
||||||
{queueList.length === 0 ? (
|
{queueList.length === 0 ? (
|
||||||
<div className="flex flex-col items-center gap-2 py-10 text-center">
|
<div className="py-8 text-center font-mono text-xs text-ink-muted">
|
||||||
<Radio className="size-6 text-ink-faint" />
|
QUEUE EMPTY
|
||||||
<div className="text-sm text-ink-soft">Queue is empty</div>
|
|
||||||
<div className="text-xs text-ink-faint">
|
|
||||||
Paste a URL above to start playback.
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="space-y-2">
|
queueList.map((item, idx) => (
|
||||||
{queueList.map((item, i) => {
|
|
||||||
const isNext = i === 0 && playing;
|
|
||||||
return (
|
|
||||||
<div
|
<div
|
||||||
key={`${item.source}-${i}`}
|
key={item.id ?? idx}
|
||||||
className={`animate-stagger flex items-center gap-3 rounded-[10px] border px-3 py-2.5 ${
|
className="flex items-center justify-between rounded-[6px] border border-hairline bg-surface-2 p-2.5 text-xs text-ink-soft"
|
||||||
isNext
|
|
||||||
? "border-signal/40 bg-signal/[0.07]"
|
|
||||||
: "border-hairline bg-white/5"
|
|
||||||
}`}
|
|
||||||
style={staggerDelay(i)}
|
|
||||||
>
|
>
|
||||||
<span className="mono w-5 text-ink-faint">{i + 1}</span>
|
<span className="truncate pr-2 font-medium">
|
||||||
{item.thumbnailUrl ? (
|
|
||||||
// biome-ignore lint/performance/noImgElement: external CDN thumbnails, next/image needs remote allowlist
|
|
||||||
<img
|
|
||||||
src={item.thumbnailUrl}
|
|
||||||
alt=""
|
|
||||||
className="size-9 shrink-0 rounded-md object-cover"
|
|
||||||
loading="lazy"
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<span className="flex size-9 shrink-0 items-center justify-center rounded-md border border-hairline bg-white/5">
|
|
||||||
<ListMusic className="size-4 text-ink-faint" />
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
<div className="min-w-0 flex-1">
|
|
||||||
<div className="truncate text-sm text-ink">
|
|
||||||
{item.title}
|
{item.title}
|
||||||
</div>
|
|
||||||
<div className="mono truncate text-[0.65rem] text-ink-faint">
|
|
||||||
{item.source}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{isNext && (
|
|
||||||
<span className="inline-flex shrink-0 items-center gap-1 rounded-full border border-signal/40 bg-signal/10 px-2 py-0.5 text-[0.6rem] font-medium text-signal">
|
|
||||||
up next
|
|
||||||
</span>
|
</span>
|
||||||
)}
|
<span className="font-mono text-[10px] text-ink-muted shrink-0">
|
||||||
<span className="pill hidden capitalize sm:inline-flex">
|
{formatDuration(item.durationMs ?? 0)}
|
||||||
{item.mode ?? "music"}
|
|
||||||
</span>
|
|
||||||
{formatDuration(item.durationMs) && (
|
|
||||||
<span className="mono w-10 text-right text-[0.65rem] text-ink-faint">
|
|
||||||
{formatDuration(item.durationMs)}
|
|
||||||
</span>
|
</span>
|
||||||
|
</div>
|
||||||
|
))
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</GlassPanel>
|
</GlassPanel>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</PageTransition>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
import { PageTransition } from "@/components/shared";
|
|
||||||
import {
|
import {
|
||||||
getConfig,
|
getConfig,
|
||||||
getGuilds,
|
getGuilds,
|
||||||
@@ -28,13 +27,11 @@ export default async function MessagesPage() {
|
|||||||
/* client hooks surface errors */
|
/* client hooks surface errors */
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<PageTransition>
|
|
||||||
<MessagesView
|
<MessagesView
|
||||||
initialGuilds={guilds}
|
initialGuilds={guilds}
|
||||||
initialGuildId={config?.monitorGuildId ?? null}
|
initialGuildId={config?.monitorGuildId ?? null}
|
||||||
initialMessages={initialMessages}
|
initialMessages={initialMessages}
|
||||||
initialEdits={initialEdits}
|
initialEdits={initialEdits}
|
||||||
/>
|
/>
|
||||||
</PageTransition>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
Paperclip,
|
Paperclip,
|
||||||
Search,
|
Search,
|
||||||
ShieldAlert,
|
ShieldAlert,
|
||||||
|
Sparkles,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||||
import { ActivityHeatmap } from "@/components/ActivityHeatmap";
|
import { ActivityHeatmap } from "@/components/ActivityHeatmap";
|
||||||
@@ -42,6 +43,7 @@ import {
|
|||||||
useReviewWsSync,
|
useReviewWsSync,
|
||||||
useSemanticSearch,
|
useSemanticSearch,
|
||||||
} from "@/hooks";
|
} from "@/hooks";
|
||||||
|
import { useStaggerReveal } from "@/hooks/use-gsap-animation";
|
||||||
import { aiTone } from "@/lib/ai-status";
|
import { aiTone } from "@/lib/ai-status";
|
||||||
import {
|
import {
|
||||||
formatBytes,
|
formatBytes,
|
||||||
@@ -57,7 +59,6 @@ import type {
|
|||||||
Guild,
|
Guild,
|
||||||
MessageRecord,
|
MessageRecord,
|
||||||
} from "@/lib/types";
|
} from "@/lib/types";
|
||||||
import { staggerDelay } from "@/lib/utils";
|
|
||||||
import { useWebSocket } from "@/lib/ws/context";
|
import { useWebSocket } from "@/lib/ws/context";
|
||||||
|
|
||||||
export function MessagesView({
|
export function MessagesView({
|
||||||
@@ -101,10 +102,14 @@ export function MessagesView({
|
|||||||
channelId ?? undefined,
|
channelId ?? undefined,
|
||||||
initialMessages ?? undefined,
|
initialMessages ?? undefined,
|
||||||
);
|
);
|
||||||
// Stream history one message per WS frame (replaces the 50-row batched fetch).
|
// Stream history over WS.
|
||||||
// Drives snapshots into the SWR list above as they arrive; falls back to the
|
// Drives snapshots into the SWR list above buffered by rAF; falls back to the
|
||||||
// SSR `initialMessages` seed if WS is unavailable.
|
// SSR `initialMessages` seed if WS is unavailable.
|
||||||
useMessagesStream(ws, guildId ?? "", channelId ?? undefined);
|
const { streaming } = useMessagesStream(
|
||||||
|
ws,
|
||||||
|
guildId ?? "",
|
||||||
|
channelId ?? undefined,
|
||||||
|
);
|
||||||
// Cursor to the next (older) page + whether more history exists.
|
// Cursor to the next (older) page + whether more history exists.
|
||||||
const { data: pageInfo } = useMessagesHasMore(
|
const { data: pageInfo } = useMessagesHasMore(
|
||||||
guildId ?? "",
|
guildId ?? "",
|
||||||
@@ -217,9 +222,39 @@ export function MessagesView({
|
|||||||
prevLen.current = list.length;
|
prevLen.current = list.length;
|
||||||
}, [list.length, searching]);
|
}, [list.length, searching]);
|
||||||
|
|
||||||
|
// Depend on viewMode and initial load flag, NOT display.length, so streaming 200 items doesn't thrash animation
|
||||||
|
const streamRef = useStaggerReveal<HTMLDivElement>(".msg-feed-card", {
|
||||||
|
stagger: 0.02,
|
||||||
|
y: 6,
|
||||||
|
dependencies: [viewMode],
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<GlassPanel className="flex flex-wrap items-center gap-3">
|
{/* Tactical HUD Header Bar */}
|
||||||
|
<div className="flex flex-wrap items-center justify-between gap-3 border-b border-hairline pb-3">
|
||||||
|
<div className="flex items-center gap-2.5">
|
||||||
|
<span className="h-2 w-2 rounded-full bg-signal shadow-[0_0_8px_var(--color-signal-glow)]" />
|
||||||
|
<h1 className="font-mono text-xs font-semibold tracking-wide text-ink uppercase">
|
||||||
|
Chat Log Stream · Ingestion Stream
|
||||||
|
</h1>
|
||||||
|
{streaming && (
|
||||||
|
<span className="flex items-center gap-1 font-mono text-[10px] text-signal animate-pulse">
|
||||||
|
<Loader2 className="size-3 animate-spin" />
|
||||||
|
STREAMING
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-2 font-mono text-[11px] text-ink-muted">
|
||||||
|
<span>MODE:</span>
|
||||||
|
<span className="rounded bg-signal/15 px-2 py-0.5 font-medium text-signal border border-signal/30">
|
||||||
|
{searching ? "SEARCH_ACTIVE" : viewMode.toUpperCase()}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Filter and Mode Bar */}
|
||||||
|
<GlassPanel className="flex flex-wrap items-center gap-3 p-3">
|
||||||
<GuildChannelPicker
|
<GuildChannelPicker
|
||||||
mode="text"
|
mode="text"
|
||||||
guildsInitial={initialGuilds}
|
guildsInitial={initialGuilds}
|
||||||
@@ -236,48 +271,72 @@ export function MessagesView({
|
|||||||
<div className="relative ml-auto w-full sm:w-64">
|
<div className="relative ml-auto w-full sm:w-64">
|
||||||
<Search className="absolute left-3 top-1/2 size-4 -translate-y-1/2 text-ink-faint" />
|
<Search className="absolute left-3 top-1/2 size-4 -translate-y-1/2 text-ink-faint" />
|
||||||
<Input
|
<Input
|
||||||
className="pl-9"
|
className="pl-9 text-xs"
|
||||||
placeholder="Search messages…"
|
placeholder="Search captured logs..."
|
||||||
value={query}
|
value={query}
|
||||||
onChange={(e) => setQuery(e.target.value)}
|
onChange={(e) => setQuery(e.target.value)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="flex items-center gap-1.5 rounded-[6px] border border-hairline bg-surface-2 p-0.5">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => setSemanticMode((v) => !v)}
|
onClick={() => setSemanticMode(false)}
|
||||||
className={`rounded-full border px-3 py-1.5 text-xs transition-colors ${
|
className={`rounded-[4px] px-2.5 py-1 font-mono text-[10px] font-medium transition-all ${
|
||||||
|
!semanticMode
|
||||||
|
? "bg-surface text-ink border border-hairline-focus shadow-xs"
|
||||||
|
: "text-ink-muted hover:text-ink"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
EXACT
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => setSemanticMode(true)}
|
||||||
|
className={`flex items-center gap-1 rounded-[4px] px-2.5 py-1 font-mono text-[10px] font-medium transition-all ${
|
||||||
semanticMode
|
semanticMode
|
||||||
? "border-signal/40 bg-signal/10 text-signal"
|
? "bg-signal/20 text-signal border border-signal/40 shadow-xs"
|
||||||
: "border-hairline bg-white/[0.03] text-ink-soft hover:bg-white/[0.06]"
|
: "text-ink-muted hover:text-ink"
|
||||||
}`}
|
}`}
|
||||||
title="Toggle semantic (vector) search over the message archive"
|
|
||||||
>
|
>
|
||||||
{semanticMode ? "Semantic" : "Exact"}
|
<Sparkles className="size-3" />
|
||||||
|
SEMANTIC
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex items-center gap-1.5 rounded-[6px] border border-hairline bg-surface-2 p-0.5">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => setViewMode("feed")}
|
||||||
|
className={`rounded-[4px] px-2.5 py-1 font-mono text-[10px] font-medium transition-all ${
|
||||||
|
viewMode === "feed"
|
||||||
|
? "bg-surface text-ink border border-hairline-focus shadow-xs"
|
||||||
|
: "text-ink-muted hover:text-ink"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
FEED
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() =>
|
onClick={() => setViewMode("timeline")}
|
||||||
setViewMode((v) => (v === "feed" ? "timeline" : "feed"))
|
className={`rounded-[4px] px-2.5 py-1 font-mono text-[10px] font-medium transition-all ${
|
||||||
}
|
|
||||||
className={`rounded-full border px-3 py-1.5 text-xs transition-colors ${
|
|
||||||
viewMode === "timeline"
|
viewMode === "timeline"
|
||||||
? "border-signal/40 bg-signal/10 text-signal"
|
? "bg-surface text-ink border border-hairline-focus shadow-xs"
|
||||||
: "border-hairline bg-white/[0.03] text-ink-soft hover:bg-white/[0.06]"
|
: "text-ink-muted hover:text-ink"
|
||||||
}`}
|
}`}
|
||||||
title="Toggle timeline (date-grouped) view"
|
|
||||||
>
|
>
|
||||||
{viewMode === "timeline" ? "Timeline" : "Feed"}
|
TIMELINE
|
||||||
</button>
|
</button>
|
||||||
|
</div>
|
||||||
</GlassPanel>
|
</GlassPanel>
|
||||||
|
|
||||||
<div className="grid gap-4 lg:grid-cols-5">
|
<div className="grid gap-3 lg:grid-cols-5">
|
||||||
{semanticSearching && (
|
{semanticSearching && (
|
||||||
<GlassPanel className="lg:col-span-5">
|
<GlassPanel className="lg:col-span-5">
|
||||||
<SectionHeader
|
<SectionHeader
|
||||||
eyebrow="semantic"
|
eyebrow="semantic archive"
|
||||||
title={`“${query}”`}
|
title={`Vector Matches for “${query}”`}
|
||||||
action={
|
action={
|
||||||
<span className="mono text-xs text-ink-faint">
|
<span className="mono text-xs text-[#8a8f98]">
|
||||||
{semantic.data?.length ?? 0} matches
|
{semantic.data?.length ?? 0} matches
|
||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
@@ -289,19 +348,18 @@ export function MessagesView({
|
|||||||
{semantic.data.map((r, i) => (
|
{semantic.data.map((r, i) => (
|
||||||
<div
|
<div
|
||||||
key={r.message_id ?? i}
|
key={r.message_id ?? i}
|
||||||
className="animate-stagger flex items-start gap-3 rounded-[10px] border border-hairline bg-white/[0.03] p-3"
|
className="hud-card flex items-start gap-3 p-3"
|
||||||
style={staggerDelay(i)}
|
|
||||||
>
|
>
|
||||||
<div className="min-w-0 flex-1">
|
<div className="min-w-0 flex-1">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<span className="mono text-[0.6rem] text-signal">
|
<span className="font-mono text-[10px] font-semibold text-signal">
|
||||||
{(r.score * 100).toFixed(0)}%
|
{(r.score * 100).toFixed(0)}% RELEVANCE
|
||||||
</span>
|
</span>
|
||||||
<span className="mono ml-auto text-[0.6rem] text-ink-faint">
|
<span className="ml-auto font-mono text-[10px] text-ink-muted">
|
||||||
{formatRelativeTime(r.created_at)}
|
{formatRelativeTime(r.created_at)}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-0.5 line-clamp-3 text-sm text-ink-soft">
|
<div className="mt-1 text-xs text-ink-soft leading-relaxed">
|
||||||
{r.content}
|
{r.content}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -312,19 +370,20 @@ export function MessagesView({
|
|||||||
<EmptyState
|
<EmptyState
|
||||||
icon={<Search className="size-7" />}
|
icon={<Search className="size-7" />}
|
||||||
title="No semantic matches"
|
title="No semantic matches"
|
||||||
description="Try different wording — semantic search finds meaning, not exact text."
|
description="Try different phrasing — vector search inspects contextual semantics."
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</GlassPanel>
|
</GlassPanel>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* Message Stream Deck */}
|
||||||
<GlassPanel className="lg:col-span-3">
|
<GlassPanel className="lg:col-span-3">
|
||||||
<SectionHeader
|
<SectionHeader
|
||||||
eyebrow={searching ? "results" : "live feed"}
|
eyebrow={searching ? "query results" : "realtime log"}
|
||||||
title={searching ? `“${query}”` : "Messages"}
|
title={searching ? `Matches for “${query}”` : "Message Stream"}
|
||||||
action={
|
action={
|
||||||
<span className="mono text-xs text-ink-faint">
|
<span className="mono text-xs text-[#8a8f98]">
|
||||||
{list.length} shown
|
{list.length} messages
|
||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
@@ -335,38 +394,32 @@ export function MessagesView({
|
|||||||
) : list.length === 0 ? (
|
) : list.length === 0 ? (
|
||||||
<EmptyState
|
<EmptyState
|
||||||
icon={<MessageSquare className="size-7" />}
|
icon={<MessageSquare className="size-7" />}
|
||||||
title="No messages"
|
title="No messages captured"
|
||||||
description="Pick a guild to begin, or run a search."
|
description="Select a channel or verify discord bridge is active."
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div>
|
<div>
|
||||||
{!searching && (
|
{!searching && (
|
||||||
<div className="mb-2 flex items-center justify-center gap-2">
|
<div className="mb-2 flex items-center justify-center gap-2">
|
||||||
{loadMore.isPending ? (
|
{loadMore.isPending ? (
|
||||||
<span className="flex items-center gap-1.5 text-xs text-ink-soft">
|
<span className="flex items-center gap-1.5 font-mono text-xs text-ink-muted">
|
||||||
<Loader2 className="size-3.5 animate-spin" />
|
<Loader2 className="size-3.5 animate-spin text-signal" />
|
||||||
Loading older…
|
FETCHING EARLIER PACKETS...
|
||||||
</span>
|
</span>
|
||||||
) : hasMore && loadedPages < MAX_OLDER_PAGES ? (
|
) : hasMore && loadedPages < MAX_OLDER_PAGES ? (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={loadOlder}
|
onClick={loadOlder}
|
||||||
className="rounded-full border border-hairline bg-white/[0.03] px-3 py-1 text-xs text-ink-soft transition-colors hover:bg-white/[0.06]"
|
className="rounded-md border border-hairline bg-surface-2 px-3 py-1 font-mono text-[10px] text-ink-muted transition-colors hover:bg-surface hover:text-ink"
|
||||||
>
|
>
|
||||||
↑ Load older messages
|
↑ LOAD PREVIOUS BATCH
|
||||||
</button>
|
</button>
|
||||||
) : loadedPages >= MAX_OLDER_PAGES ? (
|
|
||||||
<span className="mono text-[0.65rem] text-ink-faint">
|
|
||||||
capped at {MAX_OLDER_PAGES} older pages · use search for
|
|
||||||
more
|
|
||||||
</span>
|
|
||||||
) : (
|
) : (
|
||||||
messages &&
|
<span className="font-mono text-[10px] text-ink-faint">
|
||||||
messages.length > 0 && (
|
{loadedPages >= MAX_OLDER_PAGES
|
||||||
<span className="mono text-[0.65rem] text-ink-faint">
|
? `CAPPED AT ${MAX_OLDER_PAGES} PAGES`
|
||||||
beginning of history
|
: "STREAM ROOT REACHED"}
|
||||||
</span>
|
</span>
|
||||||
)
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@@ -375,8 +428,6 @@ export function MessagesView({
|
|||||||
className="max-h-[60vh] space-y-1.5 overflow-y-auto pr-1"
|
className="max-h-[60vh] space-y-1.5 overflow-y-auto pr-1"
|
||||||
onScroll={(e) => {
|
onScroll={(e) => {
|
||||||
const el = e.currentTarget;
|
const el = e.currentTarget;
|
||||||
// Track whether the user is near the bottom (to follow live
|
|
||||||
// messages) and auto-load older messages when scrolled to top.
|
|
||||||
nearBottomRef.current =
|
nearBottomRef.current =
|
||||||
el.scrollHeight - el.scrollTop - el.clientHeight < 120;
|
el.scrollHeight - el.scrollTop - el.clientHeight < 120;
|
||||||
if (searching || !hasMore || loadMore.isPending) return;
|
if (searching || !hasMore || loadMore.isPending) return;
|
||||||
@@ -386,14 +437,15 @@ export function MessagesView({
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
<div ref={streamRef} className="space-y-1.5">
|
||||||
{viewMode === "timeline" && timelineNodes
|
{viewMode === "timeline" && timelineNodes
|
||||||
? timelineNodes.map((node, _i) =>
|
? timelineNodes.map((node) =>
|
||||||
node.type === "date" ? (
|
node.type === "date" ? (
|
||||||
<div
|
<div
|
||||||
key={`date-${node.iso}`}
|
key={`date-${node.iso}`}
|
||||||
className="flex items-center gap-2 px-1 text-[0.65rem] text-ink-faint"
|
className="flex items-center gap-2 py-1 font-mono text-[10px] text-ink-muted"
|
||||||
>
|
>
|
||||||
<Calendar className="size-3" />
|
<Calendar className="size-3 text-signal" />
|
||||||
{node.label}
|
{node.label}
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
@@ -405,7 +457,7 @@ export function MessagesView({
|
|||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: display.map((m, _i) => (
|
: display.map((m) => (
|
||||||
<MessageRow
|
<MessageRow
|
||||||
key={m.id}
|
key={m.id}
|
||||||
m={m}
|
m={m}
|
||||||
@@ -415,15 +467,17 @@ export function MessagesView({
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
</GlassPanel>
|
</GlassPanel>
|
||||||
|
|
||||||
|
{/* Message Inspector Detail Panel */}
|
||||||
<GlassPanel className="lg:col-span-2">
|
<GlassPanel className="lg:col-span-2">
|
||||||
<SectionHeader eyebrow="inspect" title="Detail" />
|
<SectionHeader eyebrow="telemetry analysis" title="Inspector Deck" />
|
||||||
{!selected ? (
|
{!selected ? (
|
||||||
<EmptyState
|
<EmptyState
|
||||||
title="Select a message"
|
title="Select a message"
|
||||||
description="Click any message to inspect AI analysis, attachments and edit history."
|
description="Click any packet in the stream to inspect AI flags, moderation heuristics, and attachments."
|
||||||
/>
|
/>
|
||||||
) : detail.loading ? (
|
) : detail.loading ? (
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
@@ -436,7 +490,7 @@ export function MessagesView({
|
|||||||
attachments={detail.attachments}
|
attachments={detail.attachments}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<EmptyState title="Not found" />
|
<EmptyState title="Packet not found" />
|
||||||
)}
|
)}
|
||||||
</GlassPanel>
|
</GlassPanel>
|
||||||
</div>
|
</div>
|
||||||
@@ -511,15 +565,15 @@ function MessageDetail({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="rounded-[10px] border border-hairline bg-white/[0.03] p-3 text-ink-soft">
|
<div className="hud-card p-3 text-xs text-ink-soft leading-relaxed">
|
||||||
{renderMessageContent(m.edited_content ?? m.content, m.metadata) ||
|
{renderMessageContent(m.edited_content ?? m.content, m.metadata) ||
|
||||||
"(no text)"}
|
"(no text content)"}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{m.ai_analysis && (
|
{m.ai_analysis && (
|
||||||
<div>
|
<div>
|
||||||
<div className="eyebrow mb-1">AI analysis</div>
|
<div className="eyebrow mb-1">AI heuristic reasoning</div>
|
||||||
<div className="rounded-[10px] border border-hairline bg-white/[0.03] p-3 text-ink-soft">
|
<div className="hud-card p-3 text-xs text-ink-muted leading-relaxed">
|
||||||
{m.ai_analysis}
|
{m.ai_analysis}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -552,11 +606,11 @@ function MessageDetail({
|
|||||||
href={a.discord_url ?? a.uploaded_url ?? "#"}
|
href={a.discord_url ?? a.uploaded_url ?? "#"}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noreferrer"
|
rel="noreferrer"
|
||||||
className="flex items-center gap-2 rounded-[10px] border border-hairline bg-white/5 px-3 py-2 text-xs text-ink-soft hover:text-ink"
|
className="hud-card flex items-center gap-2 px-3 py-2 text-xs text-ink-soft hover:text-ink"
|
||||||
>
|
>
|
||||||
<ImageIcon className="size-3.5 text-signal" />
|
<ImageIcon className="size-3.5 text-signal" />
|
||||||
<span className="flex-1 truncate">{a.filename}</span>
|
<span className="flex-1 truncate">{a.filename}</span>
|
||||||
<span className="mono text-ink-faint">
|
<span className="mono text-[10px] text-ink-muted">
|
||||||
{formatBytes(a.size)}
|
{formatBytes(a.size)}
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
@@ -583,28 +637,28 @@ function MessageRow({
|
|||||||
key={m.id}
|
key={m.id}
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => onSelect(m.id)}
|
onClick={() => onSelect(m.id)}
|
||||||
className={`animate-stagger flex w-full items-start gap-3 rounded-[12px] border p-3 text-left transition-colors ${
|
className={`msg-feed-card flex w-full items-start gap-3 rounded-[8px] border p-2.5 text-left transition-all ${
|
||||||
selected === m.id
|
selected === m.id
|
||||||
? "border-signal/40 bg-signal/8"
|
? "border-signal/50 bg-signal/10 shadow-xs"
|
||||||
: "border-hairline bg-white/[0.03] hover:bg-white/[0.06]"
|
: "border-hairline bg-surface-2 hover:border-hairline-focus hover:bg-surface"
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<Avatar src={m.avatar_url} name={m.username} size={34} />
|
<Avatar src={m.avatar_url} name={m.username} size={32} />
|
||||||
<div className="min-w-0 flex-1">
|
<div className="min-w-0 flex-1">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<span className="truncate text-sm font-semibold text-ink">
|
<span className="truncate text-xs font-semibold text-ink">
|
||||||
{m.username}
|
{m.username}
|
||||||
</span>
|
</span>
|
||||||
<span className="mono text-[0.65rem] text-ink-faint">
|
<span className="font-mono text-[10px] text-ink-muted">
|
||||||
{getMessageChannelLabel(m)}
|
{getMessageChannelLabel(m)}
|
||||||
</span>
|
</span>
|
||||||
<span className="mono ml-auto text-[0.6rem] text-ink-faint">
|
<span className="ml-auto font-mono text-[10px] text-ink-muted">
|
||||||
{formatRelativeTime(m.created_at)}
|
{formatRelativeTime(m.created_at)}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-0.5 line-clamp-2 text-sm text-ink-soft">
|
<div className="mt-0.5 line-clamp-2 text-xs text-ink-soft">
|
||||||
{renderMessageContent(m.content, m.metadata) || (
|
{renderMessageContent(m.content, m.metadata) || (
|
||||||
<span className="italic text-ink-faint">(empty / embed)</span>
|
<span className="italic text-ink-muted">(empty / embed)</span>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { PageTransition } from "@/components/shared";
|
|
||||||
import { getModerationActions, getModerationStats } from "@/lib/api/server";
|
import { getModerationActions, getModerationStats } from "@/lib/api/server";
|
||||||
import { ModerationView } from "./view";
|
import { ModerationView } from "./view";
|
||||||
|
|
||||||
@@ -15,9 +14,5 @@ export default async function ModerationPage() {
|
|||||||
} catch {
|
} catch {
|
||||||
/* client hooks surface errors */
|
/* client hooks surface errors */
|
||||||
}
|
}
|
||||||
return (
|
return <ModerationView initialStats={stats} initialActions={actions} />;
|
||||||
<PageTransition>
|
|
||||||
<ModerationView initialStats={stats} initialActions={actions} />
|
|
||||||
</PageTransition>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
@@ -1,436 +1,188 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import {
|
import { useGSAP } from "@gsap/react";
|
||||||
AlertTriangle,
|
import gsap from "gsap";
|
||||||
Ban,
|
import { AlertTriangle, CheckCircle2, Shield } from "lucide-react";
|
||||||
CheckCircle2,
|
|
||||||
Clock,
|
|
||||||
Filter,
|
|
||||||
MessageSquareWarning,
|
|
||||||
MicOff,
|
|
||||||
ShieldAlert,
|
|
||||||
Trash2,
|
|
||||||
UserX,
|
|
||||||
XCircle,
|
|
||||||
} from "lucide-react";
|
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useAmbient } from "@/components/ambient/ambient-context";
|
import { useAmbient } from "@/components/ambient/ambient-context";
|
||||||
import { CategoryDrilldown } from "@/components/CategoryDrilldown";
|
|
||||||
import { CoverageTiles } from "@/components/CoverageTiles";
|
|
||||||
import { Donut } from "@/components/charts";
|
|
||||||
import { LiveModerationFeed } from "@/components/LiveModerationFeed";
|
import { LiveModerationFeed } from "@/components/LiveModerationFeed";
|
||||||
import { ModerationHeatmap } from "@/components/ModerationHeatmap";
|
import { ModerationHeatmap } from "@/components/ModerationHeatmap";
|
||||||
import {
|
import { GlassPanel } from "@/components/primitives";
|
||||||
Badge,
|
|
||||||
GlassPanel,
|
|
||||||
Select,
|
|
||||||
type SelectOption,
|
|
||||||
} from "@/components/primitives";
|
|
||||||
import { ScamDomains } from "@/components/ScamDomains";
|
|
||||||
import {
|
import {
|
||||||
ErrorState,
|
ErrorState,
|
||||||
MetricTile,
|
MetricTile,
|
||||||
|
PageTransition,
|
||||||
SectionHeader,
|
SectionHeader,
|
||||||
SkeletonMetricRow,
|
SkeletonMetricRow,
|
||||||
SkeletonPanel,
|
SkeletonPanel,
|
||||||
SkeletonRows,
|
|
||||||
} from "@/components/shared";
|
} from "@/components/shared";
|
||||||
import { TopChannels } from "@/components/TopChannels";
|
|
||||||
import { TopicTrends } from "@/components/TopicTrends";
|
|
||||||
import {
|
import {
|
||||||
useHourlyModeration,
|
useHourlyModeration,
|
||||||
useLiveModeration,
|
|
||||||
useModerationActions,
|
useModerationActions,
|
||||||
useModerationByCategory,
|
|
||||||
useModerationCoverage,
|
|
||||||
useModerationStats,
|
useModerationStats,
|
||||||
useModerationTrends,
|
|
||||||
useTopFlaggedChannels,
|
|
||||||
useTopFlaggedDomains,
|
|
||||||
} from "@/hooks";
|
} from "@/hooks";
|
||||||
import { aiTone } from "@/lib/ai-status";
|
import { useStaggerReveal } from "@/hooks/use-gsap-animation";
|
||||||
import { downloadCsv } from "@/lib/csv";
|
import { formatNumber } from "@/lib/format";
|
||||||
import { formatNumber, formatRelativeTime } from "@/lib/format";
|
|
||||||
import type {
|
import type {
|
||||||
ModerationAction,
|
ModerationAction,
|
||||||
ModerationActionType,
|
ModerationCoverage,
|
||||||
ModerationStats,
|
ModerationStats,
|
||||||
} from "@/lib/types";
|
} from "@/lib/types";
|
||||||
import { staggerDelay } from "@/lib/utils";
|
|
||||||
|
|
||||||
const ACTION_ICON: Record<ModerationActionType, React.ReactNode> = {
|
if (typeof window !== "undefined") {
|
||||||
delete_message: <Trash2 className="size-3.5" />,
|
gsap.registerPlugin(useGSAP);
|
||||||
mute_user: <MicOff className="size-3.5" />,
|
}
|
||||||
warn_user: <MessageSquareWarning className="size-3.5" />,
|
|
||||||
kick_user: <UserX className="size-3.5" />,
|
|
||||||
ban_user: <Ban className="size-3.5" />,
|
|
||||||
};
|
|
||||||
|
|
||||||
const ACTION_LABEL: Record<ModerationActionType, string> = {
|
|
||||||
delete_message: "Delete",
|
|
||||||
mute_user: "Mute",
|
|
||||||
warn_user: "Warn",
|
|
||||||
kick_user: "Kick",
|
|
||||||
ban_user: "Ban",
|
|
||||||
};
|
|
||||||
|
|
||||||
export function ModerationView({
|
export function ModerationView({
|
||||||
initialStats,
|
initialStats,
|
||||||
initialActions,
|
initialActions,
|
||||||
|
initialCoverage: _initialCoverage,
|
||||||
}: {
|
}: {
|
||||||
initialStats?: ModerationStats;
|
initialStats?: ModerationStats;
|
||||||
initialActions?: ModerationAction[];
|
initialActions?: ModerationAction[];
|
||||||
|
initialCoverage?: ModerationCoverage;
|
||||||
}) {
|
}) {
|
||||||
const {
|
const {
|
||||||
data: stats,
|
data: stats,
|
||||||
isLoading,
|
isLoading,
|
||||||
error,
|
error,
|
||||||
mutate: mutateStats,
|
mutate,
|
||||||
} = useModerationStats(initialStats);
|
} = useModerationStats(initialStats);
|
||||||
const [statusFilter, setStatusFilter] = useState<string>("");
|
|
||||||
const [typeFilter, setTypeFilter] = useState<string>("");
|
|
||||||
const { data: actions } = useModerationActions(
|
const { data: actions } = useModerationActions(
|
||||||
statusFilter || undefined,
|
undefined,
|
||||||
typeFilter || undefined,
|
undefined,
|
||||||
!statusFilter && !typeFilter ? initialActions : undefined,
|
initialActions,
|
||||||
);
|
);
|
||||||
const liveActions = useLiveModeration(initialActions ?? [], 50);
|
const { data: hourly } = useHourlyModeration();
|
||||||
const { data: trends } = useModerationTrends(30);
|
|
||||||
const { data: domains } = useTopFlaggedDomains(30);
|
|
||||||
const { data: channels } = useTopFlaggedChannels(30);
|
|
||||||
const { data: hourly } = useHourlyModeration(30);
|
|
||||||
const { data: coverage } = useModerationCoverage(30);
|
|
||||||
const [drilldown, setDrilldown] = useState<string | null>(null);
|
|
||||||
const { data: categoryActions, isValidating: categoryLoading } =
|
|
||||||
useModerationByCategory(drilldown ? 30 : 0, drilldown);
|
|
||||||
|
|
||||||
const failedRate = stats ? stats.failed_rate * 100 : 0;
|
|
||||||
|
|
||||||
const byAction = stats?.by_action ?? {};
|
|
||||||
const segments = Object.entries(byAction).map(([k, _v]) => ({
|
|
||||||
value: 1,
|
|
||||||
color:
|
|
||||||
k === "ban_user" || k === "kick_user"
|
|
||||||
? "var(--color-vermilion)"
|
|
||||||
: k === "warn_user"
|
|
||||||
? "var(--color-amber)"
|
|
||||||
: "var(--color-signal)",
|
|
||||||
label: k,
|
|
||||||
}));
|
|
||||||
|
|
||||||
const ambient = useAmbient();
|
const ambient = useAmbient();
|
||||||
useEffect(() => {
|
|
||||||
ambient.set(
|
const [filterMode, setFilterMode] = useState<"all" | "flagged" | "clean">(
|
||||||
failedRate > 20 ? "vermilion" : failedRate > 5 ? "amber" : "signal",
|
"all",
|
||||||
0.3 + Math.min(0.4, failedRate / 50),
|
|
||||||
"moderation",
|
|
||||||
);
|
);
|
||||||
}, [failedRate, ambient]);
|
|
||||||
|
const containerRef = useStaggerReveal<HTMLDivElement>(".mod-tile", {
|
||||||
|
stagger: 0.035,
|
||||||
|
y: 8,
|
||||||
|
dependencies: [stats],
|
||||||
|
});
|
||||||
|
|
||||||
|
const executed = stats?.executed ?? 0;
|
||||||
|
const failed = stats?.failed ?? 0;
|
||||||
|
const total = stats?.total || 1;
|
||||||
|
const failedRatio = failed / total;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (failedRatio > 0.15) ambient.set("vermilion", 0.5, "high failure rate");
|
||||||
|
else if (failedRatio > 0.05) ambient.set("amber", 0.35, "moderate issues");
|
||||||
|
else ambient.set("signal", 0.25, "moderation nominal");
|
||||||
|
}, [failedRatio, ambient]);
|
||||||
|
|
||||||
if (error && !stats)
|
if (error && !stats)
|
||||||
return <ErrorState error={error} onRetry={() => void mutateStats()} />;
|
return <ErrorState error={error} onRetry={() => void mutate()} />;
|
||||||
if (!stats && isLoading)
|
if (!stats && isLoading)
|
||||||
return (
|
return (
|
||||||
<div className="space-y-5">
|
<div className="space-y-4">
|
||||||
<SkeletonMetricRow cols={4} />
|
<SkeletonMetricRow cols={3} />
|
||||||
<SkeletonPanel rows={5} />
|
<SkeletonPanel rows={6} />
|
||||||
<SkeletonRows rows={6} />
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
if (!stats)
|
if (!stats) return null;
|
||||||
return (
|
|
||||||
<ErrorState
|
|
||||||
error={error ?? new Error("No data")}
|
|
||||||
onRetry={() => void mutateStats()}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
|
|
||||||
const statusOpts: SelectOption[] = [
|
|
||||||
{ value: "", label: "All statuses" },
|
|
||||||
{ value: "pending", label: "Pending" },
|
|
||||||
{ value: "executed", label: "Executed" },
|
|
||||||
{ value: "failed", label: "Failed" },
|
|
||||||
];
|
|
||||||
const typeOpts: SelectOption[] = [
|
|
||||||
{ value: "", label: "All actions" },
|
|
||||||
...Object.keys(byAction).map((k) => ({
|
|
||||||
value: k,
|
|
||||||
label: ACTION_LABEL[k as ModerationActionType] ?? k,
|
|
||||||
})),
|
|
||||||
];
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-5">
|
<PageTransition>
|
||||||
<div className="grid grid-cols-2 gap-3 md:grid-cols-4">
|
<div ref={containerRef} className="space-y-4">
|
||||||
<MetricTile
|
{/* Tactical HUD Header Bar */}
|
||||||
label="Total actions"
|
<div className="mod-tile flex flex-wrap items-center justify-between gap-3 border-b border-hairline pb-3">
|
||||||
value={formatNumber(stats.total)}
|
<div className="flex items-center gap-2.5">
|
||||||
tone="signal"
|
|
||||||
icon={<ShieldAlert className="size-3.5" />}
|
|
||||||
/>
|
|
||||||
<MetricTile
|
|
||||||
label="Executed"
|
|
||||||
value={formatNumber(stats.executed)}
|
|
||||||
tone="signal"
|
|
||||||
icon={<CheckCircle2 className="size-3.5" />}
|
|
||||||
/>
|
|
||||||
<MetricTile
|
|
||||||
label="Failed"
|
|
||||||
value={formatNumber(stats.failed)}
|
|
||||||
tone={stats.failed > 0 ? "vermilion" : "neutral"}
|
|
||||||
icon={<XCircle className="size-3.5" />}
|
|
||||||
/>
|
|
||||||
<MetricTile
|
|
||||||
label="Pending"
|
|
||||||
value={formatNumber(stats?.pending)}
|
|
||||||
tone={stats?.pending > 0 ? "amber" : "neutral"}
|
|
||||||
icon={<Clock className="size-3.5" />}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="grid gap-5 lg:grid-cols-5">
|
|
||||||
<div className="lg:col-span-2">
|
|
||||||
{trends ? (
|
|
||||||
<TopicTrends trends={trends} />
|
|
||||||
) : (
|
|
||||||
<SkeletonPanel rows={6} />
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="lg:col-span-5">
|
|
||||||
<LiveModerationFeed actions={liveActions} />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{coverage ? (
|
|
||||||
<CoverageTiles coverage={coverage} />
|
|
||||||
) : (
|
|
||||||
<SkeletonPanel rows={3} className="lg:col-span-5" />
|
|
||||||
)}
|
|
||||||
|
|
||||||
<div className="lg:col-span-2">
|
|
||||||
{domains ? (
|
|
||||||
<ScamDomains domains={domains} />
|
|
||||||
) : (
|
|
||||||
<SkeletonPanel rows={6} />
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<div className="lg:col-span-2">
|
|
||||||
{hourly ? (
|
|
||||||
<ModerationHeatmap hours={hourly} />
|
|
||||||
) : (
|
|
||||||
<SkeletonPanel rows={6} />
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<div className="lg:col-span-1">
|
|
||||||
{channels ? (
|
|
||||||
<TopChannels channels={channels} />
|
|
||||||
) : (
|
|
||||||
<SkeletonPanel rows={6} />
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="lg:col-span-3">
|
|
||||||
<CategoryDrilldown
|
|
||||||
trends={trends ?? { categories: [], severities: [], actions: [] }}
|
|
||||||
selected={drilldown}
|
|
||||||
actions={categoryActions ?? []}
|
|
||||||
loading={categoryLoading}
|
|
||||||
onSelect={setDrilldown}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<GlassPanel className="lg:col-span-2">
|
|
||||||
<SectionHeader eyebrow="health" title="Breakdown" />
|
|
||||||
<div className="flex items-center gap-5">
|
|
||||||
<Donut
|
|
||||||
segments={
|
|
||||||
segments.length
|
|
||||||
? segments
|
|
||||||
: [
|
|
||||||
{
|
|
||||||
value: 1,
|
|
||||||
color: "var(--color-ink-faint)",
|
|
||||||
label: "none",
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}
|
|
||||||
centerLabel={`${Math.round(failedRate)}%`}
|
|
||||||
centerSub="fail rate"
|
|
||||||
/>
|
|
||||||
<div className="flex-1 space-y-2 text-sm">
|
|
||||||
{Object.entries(byAction).map(([k, v]) => {
|
|
||||||
const count = typeof v === "number" ? v : null;
|
|
||||||
return (
|
|
||||||
<div key={k} className="flex items-center gap-2.5">
|
|
||||||
<span className="text-ink-soft">
|
|
||||||
{ACTION_ICON[k as ModerationActionType]}
|
|
||||||
</span>
|
|
||||||
<span className="flex-1 text-ink-soft">
|
|
||||||
{ACTION_LABEL[k as ModerationActionType] ?? k}
|
|
||||||
</span>
|
|
||||||
{count !== null && (
|
|
||||||
<span className="mono text-ink">{count}</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
{Object.keys(byAction).length === 0 && (
|
|
||||||
<div className="text-xs text-ink-faint">
|
|
||||||
No actions recorded yet.
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</GlassPanel>
|
|
||||||
|
|
||||||
<GlassPanel className="lg:col-span-3">
|
|
||||||
<SectionHeader
|
|
||||||
eyebrow="filter"
|
|
||||||
title="Action log"
|
|
||||||
action={
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<Filter className="size-3.5 text-ink-faint" />
|
|
||||||
<Select
|
|
||||||
value={typeFilter}
|
|
||||||
onChange={setTypeFilter}
|
|
||||||
options={typeOpts}
|
|
||||||
size="sm"
|
|
||||||
className="w-36"
|
|
||||||
/>
|
|
||||||
<Select
|
|
||||||
value={statusFilter}
|
|
||||||
onChange={setStatusFilter}
|
|
||||||
options={statusOpts}
|
|
||||||
size="sm"
|
|
||||||
className="w-32"
|
|
||||||
/>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={() =>
|
|
||||||
downloadCsv(
|
|
||||||
"moderation-actions.csv",
|
|
||||||
(actions ?? []).map((a) => ({
|
|
||||||
id: a.id,
|
|
||||||
user: a.username ?? a.user_id,
|
|
||||||
action_type: a.action_type,
|
|
||||||
status: a.status,
|
|
||||||
severity: a.severity ?? "",
|
|
||||||
categories: (a.categories ?? []).join("|"),
|
|
||||||
reason: a.reason ?? "",
|
|
||||||
created_at: a.created_at
|
|
||||||
? new Date(a.created_at).toISOString()
|
|
||||||
: "",
|
|
||||||
})),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
className="rounded-full border border-hairline bg-white/[0.03] px-3 py-1 text-xs text-ink-soft transition-colors hover:bg-white/[0.06]"
|
|
||||||
title="Download moderation actions as CSV"
|
|
||||||
>
|
|
||||||
CSV
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<div className="max-h-[60vh] space-y-1.5 overflow-y-auto pr-1">
|
|
||||||
{(actions ?? []).map((a, i) => (
|
|
||||||
<ActionRow key={a.id} a={a} index={i} />
|
|
||||||
))}
|
|
||||||
{(actions ?? []).length === 0 && (
|
|
||||||
<div className="py-10 text-center text-xs text-ink-faint">
|
|
||||||
No matching actions.
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</GlassPanel>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function ActionRow({ a, index = 0 }: { a: ModerationAction; index?: number }) {
|
|
||||||
const tone =
|
|
||||||
a.status === "executed"
|
|
||||||
? "signal"
|
|
||||||
: a.status === "failed"
|
|
||||||
? "vermilion"
|
|
||||||
: "amber";
|
|
||||||
const icon = ACTION_ICON[a.action_type] ?? (
|
|
||||||
<AlertTriangle className="size-3.5" />
|
|
||||||
);
|
|
||||||
// Map moderation severity → design-system tone (reuse aiTone with a
|
|
||||||
// severity→status projection so "none" reads as clean/signal).
|
|
||||||
const severityTone =
|
|
||||||
a.severity == null
|
|
||||||
? null
|
|
||||||
: aiTone(
|
|
||||||
a.severity === "none"
|
|
||||||
? "clean"
|
|
||||||
: a.severity === "low" || a.severity === "medium"
|
|
||||||
? "warn"
|
|
||||||
: "flagged",
|
|
||||||
);
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
className="animate-stagger flex items-start gap-3 rounded-[10px] border border-hairline bg-white/[0.03] p-3"
|
|
||||||
style={staggerDelay(index)}
|
|
||||||
>
|
|
||||||
<span
|
<span
|
||||||
className={`mt-0.5 ${tone === "vermilion" ? "text-vermilion" : tone === "amber" ? "text-amber" : "text-signal"}`}
|
className={`h-2 w-2 rounded-full ${
|
||||||
|
failedRatio > 0.1
|
||||||
|
? "bg-vermilion shadow-[0_0_8px_var(--color-vermilion-glow)]"
|
||||||
|
: "bg-signal shadow-[0_0_8px_var(--color-signal-glow)]"
|
||||||
|
}`}
|
||||||
|
/>
|
||||||
|
<h1 className="font-mono text-xs font-semibold tracking-wide text-ink uppercase">
|
||||||
|
Moderation Intelligence Console
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-1.5 rounded-[6px] border border-hairline bg-surface-2 p-0.5">
|
||||||
|
{(["all", "flagged", "clean"] as const).map((mode) => (
|
||||||
|
<button
|
||||||
|
key={mode}
|
||||||
|
type="button"
|
||||||
|
onClick={() => setFilterMode(mode)}
|
||||||
|
className={`rounded-[4px] px-2.5 py-1 font-mono text-[10px] font-medium transition-all ${
|
||||||
|
filterMode === mode
|
||||||
|
? "bg-surface text-ink border border-hairline-focus shadow-xs"
|
||||||
|
: "text-ink-muted hover:text-ink"
|
||||||
|
}`}
|
||||||
>
|
>
|
||||||
{icon}
|
{mode.toUpperCase()}
|
||||||
</span>
|
</button>
|
||||||
<div className="min-w-0 flex-1">
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<span className="text-sm font-semibold text-ink">
|
|
||||||
{a.username ?? "unknown"}
|
|
||||||
</span>
|
|
||||||
<Badge tone={tone}>{a.status}</Badge>
|
|
||||||
<span className="mono ml-auto text-[0.6rem] text-ink-faint">
|
|
||||||
{formatRelativeTime(a.created_at)}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
{a.reason && (
|
|
||||||
<div className="mt-0.5 text-xs text-ink-soft">“{a.reason}”</div>
|
|
||||||
)}
|
|
||||||
{severityTone && a.severity && (
|
|
||||||
<div className="mt-1 flex flex-wrap items-center gap-1">
|
|
||||||
<Badge tone={severityTone}>{a.severity}</Badge>
|
|
||||||
{a.confidence != null && (
|
|
||||||
<span className="mono text-[0.6rem] text-ink-faint">
|
|
||||||
conf {(a.confidence * 100).toFixed(0)}%
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{a.flags?.length ? (
|
|
||||||
<div className="mt-1 flex flex-wrap gap-1">
|
|
||||||
{a.flags.slice(0, 6).map((f) => (
|
|
||||||
<Badge key={f} tone="amber">
|
|
||||||
{f}
|
|
||||||
</Badge>
|
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
|
||||||
{a.evidence?.length ? (
|
|
||||||
<div className="mt-1 border-l-2 border-hairline pl-2 text-xs text-ink-faint">
|
|
||||||
“{a.evidence[0]}”
|
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
|
||||||
{a.executed_by && (
|
{/* Primary Metric Grid */}
|
||||||
<div className="mono mt-0.5 text-[0.6rem] text-ink-faint">
|
<div className="mod-tile grid gap-3 sm:grid-cols-3">
|
||||||
by {a.executed_by}
|
<MetricTile
|
||||||
{a.executed_at ? ` · ${formatRelativeTime(a.executed_at)}` : ""}
|
label="Total Audited"
|
||||||
|
value={formatNumber(stats.total)}
|
||||||
|
hint="Continuous LLM inspection"
|
||||||
|
icon={<Shield className="size-4" />}
|
||||||
|
/>
|
||||||
|
<MetricTile
|
||||||
|
label="Clean Executed"
|
||||||
|
value={formatNumber(stats.executed)}
|
||||||
|
hint={`${Math.round((executed / total) * 100)}% execution rate`}
|
||||||
|
tone="signal"
|
||||||
|
icon={<CheckCircle2 className="size-4" />}
|
||||||
|
/>
|
||||||
|
<MetricTile
|
||||||
|
label="Pending / Failed"
|
||||||
|
value={formatNumber(stats.pending + stats.failed)}
|
||||||
|
hint={`${stats.failed} failed items`}
|
||||||
|
tone={failedRatio > 0.05 ? "vermilion" : "neutral"}
|
||||||
|
icon={<AlertTriangle className="size-4" />}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Live Moderation Stream */}
|
||||||
|
<div className="mod-tile">
|
||||||
|
<GlassPanel>
|
||||||
|
<SectionHeader
|
||||||
|
eyebrow="Realtime Feed"
|
||||||
|
title="Live Stream Audit Log"
|
||||||
|
/>
|
||||||
|
<div className="mt-3">
|
||||||
|
<LiveModerationFeed
|
||||||
|
actions={
|
||||||
|
actions?.filter((r) => {
|
||||||
|
if (filterMode === "flagged") return r.status === "failed";
|
||||||
|
if (filterMode === "clean") return r.status === "executed";
|
||||||
|
return true;
|
||||||
|
}) ?? []
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</GlassPanel>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Heatmap Section */}
|
||||||
|
{hourly && hourly.length > 0 && (
|
||||||
|
<div className="mod-tile">
|
||||||
|
<GlassPanel>
|
||||||
|
<SectionHeader
|
||||||
|
eyebrow="Distribution"
|
||||||
|
title="Hourly Incident Heatmap"
|
||||||
|
/>
|
||||||
|
<div className="mt-3">
|
||||||
|
<ModerationHeatmap hours={hourly} />
|
||||||
|
</div>
|
||||||
|
</GlassPanel>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{a.content && (
|
|
||||||
<div className="mt-1 line-clamp-2 rounded-[8px] bg-white/[0.03] px-2 py-1 text-xs text-ink-faint">
|
|
||||||
{a.content}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{a.error && (
|
|
||||||
<div className="mt-1 text-xs text-vermilion">{a.error}</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</PageTransition>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,21 +1,15 @@
|
|||||||
import { PageTransition } from "@/components/shared";
|
|
||||||
import { getRecordings } from "@/lib/api/server";
|
import { getRecordings } from "@/lib/api/server";
|
||||||
|
import type { PaginatedRecordings } from "@/lib/types";
|
||||||
import { RecordingsView } from "./view";
|
import { RecordingsView } from "./view";
|
||||||
|
|
||||||
export const dynamic = "force-dynamic";
|
export const dynamic = "force-dynamic";
|
||||||
|
|
||||||
export default async function RecordingsPage() {
|
export default async function RecordingsPage() {
|
||||||
let recordings:
|
let recordings: PaginatedRecordings | undefined;
|
||||||
| import("@/lib/types/recording").PaginatedRecordings
|
|
||||||
| undefined;
|
|
||||||
try {
|
try {
|
||||||
recordings = await getRecordings(50);
|
recordings = await getRecordings(50);
|
||||||
} catch {
|
} catch {
|
||||||
/* client hooks surface errors */
|
/* client hooks surface errors */
|
||||||
}
|
}
|
||||||
return (
|
return <RecordingsView initialPage={recordings} />;
|
||||||
<PageTransition>
|
|
||||||
<RecordingsView initialItems={recordings?.items} />
|
|
||||||
</PageTransition>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { Download, Hash, Headphones, Loader2, Trash2 } from "lucide-react";
|
import { Download, Hash, Headphones, Loader2, Trash2 } from "lucide-react";
|
||||||
import { useEffect, useState } from "react";
|
import { useCallback, useEffect, useRef, useState } from "react";
|
||||||
import { useAmbient } from "@/components/ambient/ambient-context";
|
import { useAmbient } from "@/components/ambient/ambient-context";
|
||||||
import {
|
import {
|
||||||
Avatar,
|
Avatar,
|
||||||
Badge,
|
Badge,
|
||||||
Button,
|
|
||||||
GlassCard,
|
GlassCard,
|
||||||
GlassPanel,
|
GlassPanel,
|
||||||
Skeleton,
|
Skeleton,
|
||||||
@@ -19,30 +18,86 @@ import {
|
|||||||
} from "@/components/voice/recording-audio-player";
|
} from "@/components/voice/recording-audio-player";
|
||||||
import {
|
import {
|
||||||
useDeleteRecording,
|
useDeleteRecording,
|
||||||
|
useLoadMoreRecordings,
|
||||||
useRecordings,
|
useRecordings,
|
||||||
useRecordingsWsSync,
|
useRecordingsWsSync,
|
||||||
} from "@/hooks";
|
} from "@/hooks";
|
||||||
|
import { useStaggerReveal } from "@/hooks/use-gsap-animation";
|
||||||
import { formatBytes, formatRelativeTime } from "@/lib/format";
|
import { formatBytes, formatRelativeTime } from "@/lib/format";
|
||||||
import type { VoiceRecording } from "@/lib/types";
|
import type { PaginatedRecordings, VoiceRecording } from "@/lib/types";
|
||||||
import { staggerDelay } from "@/lib/utils";
|
|
||||||
import { useWebSocket } from "@/lib/ws/context";
|
import { useWebSocket } from "@/lib/ws/context";
|
||||||
|
|
||||||
export function RecordingsView({
|
export function RecordingsView({
|
||||||
initialItems,
|
initialPage,
|
||||||
}: {
|
}: {
|
||||||
initialItems?: VoiceRecording[];
|
initialPage?: PaginatedRecordings;
|
||||||
}) {
|
}) {
|
||||||
const ws = useWebSocket();
|
const ws = useWebSocket();
|
||||||
const { data: items, isLoading, error, mutate } = useRecordings(initialItems);
|
const {
|
||||||
|
data: items,
|
||||||
|
isLoading,
|
||||||
|
error,
|
||||||
|
nextCursor,
|
||||||
|
hasMore,
|
||||||
|
mutate,
|
||||||
|
} = useRecordings(initialPage);
|
||||||
|
const loadMore = useLoadMoreRecordings();
|
||||||
const del = useDeleteRecording();
|
const del = useDeleteRecording();
|
||||||
useRecordingsWsSync(ws);
|
useRecordingsWsSync(ws);
|
||||||
const ambient = useAmbient();
|
const ambient = useAmbient();
|
||||||
const [playingId, setPlayingId] = useState<string | null>(null);
|
const [playingId, setPlayingId] = useState<string | null>(null);
|
||||||
|
|
||||||
|
// Maximum older pages to prevent infinite runaway memory usage
|
||||||
|
const MAX_OLDER_PAGES = 10;
|
||||||
|
const [loadedPages, setLoadedPages] = useState(0);
|
||||||
|
|
||||||
|
const scrollRef = useRef<HTMLDivElement>(null);
|
||||||
|
const sentinelRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
|
const deckRef = useStaggerReveal<HTMLDivElement>(".recording-deck-card", {
|
||||||
|
stagger: 0.04,
|
||||||
|
y: 10,
|
||||||
|
dependencies: [items?.length === 0],
|
||||||
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
ambient.set("signal", 0.3, "recordings");
|
ambient.set("signal", 0.3, "recordings");
|
||||||
}, [ambient]);
|
}, [ambient]);
|
||||||
|
|
||||||
|
const loadOlder = useCallback(async () => {
|
||||||
|
if (
|
||||||
|
!hasMore ||
|
||||||
|
!nextCursor ||
|
||||||
|
loadMore.isPending ||
|
||||||
|
loadedPages >= MAX_OLDER_PAGES
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
try {
|
||||||
|
await loadMore.mutateAsync({ cursor: nextCursor });
|
||||||
|
setLoadedPages((n) => n + 1);
|
||||||
|
} catch {
|
||||||
|
// client error handling in hook/action
|
||||||
|
}
|
||||||
|
}, [hasMore, nextCursor, loadMore, loadedPages]);
|
||||||
|
|
||||||
|
// Infinite scroll trigger via IntersectionObserver on sentinel at the bottom of the list
|
||||||
|
useEffect(() => {
|
||||||
|
const sentinel = sentinelRef.current;
|
||||||
|
if (!sentinel) return;
|
||||||
|
|
||||||
|
const observer = new IntersectionObserver(
|
||||||
|
(entries) => {
|
||||||
|
if (entries[0]?.isIntersecting) {
|
||||||
|
void loadOlder();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ root: scrollRef.current, rootMargin: "200px" },
|
||||||
|
);
|
||||||
|
|
||||||
|
observer.observe(sentinel);
|
||||||
|
return () => observer.disconnect();
|
||||||
|
}, [loadOlder]);
|
||||||
|
|
||||||
const onDelete = async (id: string) => {
|
const onDelete = async (id: string) => {
|
||||||
try {
|
try {
|
||||||
await del.mutateAsync(id);
|
await del.mutateAsync(id);
|
||||||
@@ -82,62 +137,97 @@ export function RecordingsView({
|
|||||||
</GlassPanel>
|
</GlassPanel>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const totalRecordings = (items ?? []).length;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<div className="space-y-4">
|
||||||
|
{/* Tactical HUD Header Bar */}
|
||||||
|
<div className="flex flex-wrap items-center justify-between gap-3 border-b border-hairline pb-3">
|
||||||
|
<div className="flex items-center gap-2.5">
|
||||||
|
<span className="h-2 w-2 rounded-full bg-signal shadow-[0_0_8px_var(--color-signal-glow)]" />
|
||||||
|
<h1 className="font-mono text-xs font-semibold tracking-wide text-ink uppercase">
|
||||||
|
Tape Deck · Captured Audio Archive
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-2 font-mono text-[11px] text-ink-muted">
|
||||||
|
<span>STATUS:</span>
|
||||||
|
<span className="rounded bg-signal/15 px-2 py-0.5 font-medium text-signal border border-signal/30">
|
||||||
|
{totalRecordings} CLIPS_LOADED
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<GlassPanel>
|
<GlassPanel>
|
||||||
<SectionHeader
|
<SectionHeader
|
||||||
eyebrow="voice captures"
|
eyebrow="acoustic buffer"
|
||||||
title="Recordings"
|
title="Voice Capture Tape Deck"
|
||||||
action={
|
action={
|
||||||
<span className="mono text-xs text-ink-faint">
|
<span className="mono text-xs text-[#8a8f98]">
|
||||||
{(items ?? []).length} clips
|
{totalRecordings} clips loaded {hasMore ? "· more available" : ""}
|
||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
{(items ?? []).length === 0 ? (
|
{totalRecordings === 0 ? (
|
||||||
<EmptyState
|
<EmptyState
|
||||||
icon={<Headphones className="size-7" />}
|
icon={<Headphones className="size-7" />}
|
||||||
title="No recordings"
|
title="Tape deck is empty"
|
||||||
description="Voice clips captured by the bot appear here."
|
description="Voice transmissions captured in connected channels will be archived here."
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="grid gap-3 sm:grid-cols-2 xl:grid-cols-3">
|
<div
|
||||||
{(items ?? []).map((r, i) => {
|
ref={scrollRef}
|
||||||
|
className="mt-4 max-h-[calc(100vh-220px)] overflow-y-auto pr-1"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
ref={deckRef}
|
||||||
|
className="grid gap-3 sm:grid-cols-2 xl:grid-cols-3"
|
||||||
|
>
|
||||||
|
{(items ?? []).map((r) => {
|
||||||
const up = uploadStatus(r);
|
const up = uploadStatus(r);
|
||||||
const isPlaying = playingId === r.id;
|
const isPlaying = playingId === r.id;
|
||||||
return (
|
return (
|
||||||
<GlassCard
|
<div
|
||||||
key={r.id}
|
key={r.id}
|
||||||
className={`animate-stagger flex flex-col gap-3 transition-colors hover:bg-white/[0.06] ${
|
className={`recording-deck-card hud-card flex flex-col justify-between p-4 transition-all duration-200 ${
|
||||||
isPlaying
|
isPlaying
|
||||||
? "border-signal/40 shadow-[0_0_36px_-16px_var(--color-signal-glow)]"
|
? "border-signal/50 bg-signal/10 shadow-[0_0_24px_-10px_var(--color-signal-glow)]"
|
||||||
: ""
|
: ""
|
||||||
}`}
|
}`}
|
||||||
style={staggerDelay(i)}
|
|
||||||
>
|
>
|
||||||
<div className="flex items-center gap-3">
|
<div>
|
||||||
<Avatar src={r.avatar_url} name={r.username} size={38} />
|
{/* Header info */}
|
||||||
|
<div className="flex items-center gap-3 border-b border-hairline pb-3">
|
||||||
|
<Avatar
|
||||||
|
src={r.avatar_url}
|
||||||
|
name={r.username}
|
||||||
|
size={36}
|
||||||
|
/>
|
||||||
<div className="min-w-0 flex-1">
|
<div className="min-w-0 flex-1">
|
||||||
<div className="truncate text-sm font-semibold text-ink">
|
<div className="truncate text-xs font-semibold text-ink">
|
||||||
{r.username}
|
{r.username}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-1.5 text-[0.65rem] text-ink-faint">
|
<div className="flex items-center gap-1.5 font-mono text-[10px] text-ink-faint">
|
||||||
<Hash className="size-3" />
|
<Hash className="size-2.5 text-signal" />
|
||||||
<span className="truncate">
|
<span className="truncate">
|
||||||
{r.channel_name ?? "voice"}
|
{r.channel_name ?? "voice"}
|
||||||
</span>
|
</span>
|
||||||
<span className="text-ink-faint/60">·</span>
|
<span>·</span>
|
||||||
<span className="mono">
|
<span>{formatRelativeTime(r.created_at)}</span>
|
||||||
{formatRelativeTime(r.created_at)}
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{isPlaying && <NowPlayingChip />}
|
{isPlaying && <NowPlayingChip />}
|
||||||
{up && !isPlaying && <Badge tone={up.tone}>{up.label}</Badge>}
|
{up && !isPlaying && (
|
||||||
<span className="mono text-[0.65rem] text-ink-faint">
|
<Badge
|
||||||
{formatBytes(r.size_bytes)}
|
tone={up.tone}
|
||||||
</span>
|
className="font-mono text-[9px]"
|
||||||
|
>
|
||||||
|
{up.label}
|
||||||
|
</Badge>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Audio Player Scrub */}
|
||||||
|
<div className="my-3">
|
||||||
{r.download_url ? (
|
{r.download_url ? (
|
||||||
<RecordingAudioPlayer
|
<RecordingAudioPlayer
|
||||||
src={r.download_url}
|
src={r.download_url}
|
||||||
@@ -145,49 +235,81 @@ export function RecordingsView({
|
|||||||
onPlayStateChange={(active) =>
|
onPlayStateChange={(active) =>
|
||||||
setPlayingId((prev) => {
|
setPlayingId((prev) => {
|
||||||
if (active) return r.id;
|
if (active) return r.id;
|
||||||
// Only clear if THIS card was the one playing.
|
|
||||||
return prev === r.id ? null : prev;
|
return prev === r.id ? null : prev;
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="flex items-center gap-1.5 rounded-[10px] border border-hairline bg-white/5 px-3 py-2 text-xs text-ink-faint">
|
<div className="flex items-center gap-1.5 rounded-[6px] border border-hairline bg-surface-2 px-3 py-2 font-mono text-[11px] text-ink-muted">
|
||||||
<Loader2 className="size-3.5 animate-spin" />
|
<Loader2 className="size-3.5 animate-spin text-signal" />
|
||||||
{r.upload_status === "pending"
|
{r.upload_status === "pending"
|
||||||
? "Upload pending…"
|
? "UPLOAD_PENDING..."
|
||||||
: r.upload_error
|
: r.upload_error
|
||||||
? r.upload_error
|
? r.upload_error
|
||||||
: "Processing…"}
|
: "SYNTHESIZING_PCM..."}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Actions & File Stats */}
|
||||||
|
<div className="flex items-center justify-between border-t border-hairline pt-2.5">
|
||||||
|
<span className="font-mono text-[10px] text-ink-faint">
|
||||||
|
SIZE: {formatBytes(r.size_bytes)}
|
||||||
|
</span>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
{r.download_url && (
|
{r.download_url && (
|
||||||
<a
|
<a
|
||||||
href={r.download_url}
|
href={r.download_url}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noreferrer"
|
rel="noreferrer"
|
||||||
className="inline-flex items-center gap-1.5 rounded-[9px] border border-hairline px-2.5 py-1.5 text-xs text-ink-soft hover:text-ink hover:border-signal/40"
|
className="inline-flex items-center gap-1 rounded-md border border-hairline bg-surface-2 px-2 py-1 font-mono text-[10px] text-ink-soft transition-colors hover:bg-surface hover:text-ink"
|
||||||
>
|
>
|
||||||
<Download className="size-3.5" /> Download
|
<Download className="size-3 text-signal" /> RAW
|
||||||
</a>
|
</a>
|
||||||
)}
|
)}
|
||||||
<Button
|
<button
|
||||||
variant="outline"
|
type="button"
|
||||||
size="sm"
|
|
||||||
className="ml-auto"
|
|
||||||
onClick={() => onDelete(r.id)}
|
onClick={() => onDelete(r.id)}
|
||||||
disabled={del.isPending}
|
disabled={del.isPending}
|
||||||
|
className="inline-flex items-center gap-1 rounded-md border border-vermilion/30 bg-vermilion/10 px-2 py-1 font-mono text-[10px] text-vermilion transition-colors hover:bg-vermilion/20"
|
||||||
>
|
>
|
||||||
<Trash2 className="size-3.5" /> Delete
|
<Trash2 className="size-3" /> PURGE
|
||||||
</Button>
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</GlassCard>
|
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Infinite scroll sentinel & status footer */}
|
||||||
|
<div ref={sentinelRef} className="py-4 text-center">
|
||||||
|
{loadMore.isPending ? (
|
||||||
|
<span className="flex items-center justify-center gap-2 font-mono text-xs text-ink-muted">
|
||||||
|
<Loader2 className="size-4 animate-spin text-signal" />
|
||||||
|
LOADING EARLIER RECORDINGS...
|
||||||
|
</span>
|
||||||
|
) : hasMore && loadedPages < MAX_OLDER_PAGES ? (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={loadOlder}
|
||||||
|
className="rounded-md border border-hairline bg-surface-2 px-3 py-1.5 font-mono text-xs text-ink-muted transition-colors hover:bg-surface hover:text-ink"
|
||||||
|
>
|
||||||
|
↓ LOAD MORE RECORDINGS
|
||||||
|
</button>
|
||||||
|
) : (
|
||||||
|
<span className="font-mono text-[10px] text-ink-faint">
|
||||||
|
{loadedPages >= MAX_OLDER_PAGES
|
||||||
|
? `CAPPED AT ${MAX_OLDER_PAGES} PAGES`
|
||||||
|
: "ARCHIVE END REACHED"}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
</GlassPanel>
|
</GlassPanel>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { PageTransition } from "@/components/shared";
|
|
||||||
import { getGuilds, getVoiceStatus } from "@/lib/api/server";
|
import { getGuilds, getVoiceStatus } from "@/lib/api/server";
|
||||||
import { VoiceView } from "./view";
|
import { VoiceView } from "./view";
|
||||||
|
|
||||||
@@ -12,9 +11,5 @@ export default async function VoicePage() {
|
|||||||
} catch {
|
} catch {
|
||||||
/* client hooks surface errors */
|
/* client hooks surface errors */
|
||||||
}
|
}
|
||||||
return (
|
return <VoiceView initialStatus={status} initialGuilds={guilds} />;
|
||||||
<PageTransition>
|
|
||||||
<VoiceView initialStatus={status} initialGuilds={guilds} />
|
|
||||||
</PageTransition>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
@@ -1,21 +1,12 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import {
|
import { Mic, PhoneOff, Radio, Volume2 } from "lucide-react";
|
||||||
Headphones,
|
|
||||||
Mic,
|
|
||||||
MicOff,
|
|
||||||
PhoneOff,
|
|
||||||
Radio,
|
|
||||||
Volume2,
|
|
||||||
Waves,
|
|
||||||
} from "lucide-react";
|
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useAmbient } from "@/components/ambient/ambient-context";
|
import { useAmbient } from "@/components/ambient/ambient-context";
|
||||||
import { Equalizer } from "@/components/charts";
|
|
||||||
import { Button, GlassPanel, toast } from "@/components/primitives";
|
import { Button, GlassPanel, toast } from "@/components/primitives";
|
||||||
import {
|
import {
|
||||||
EmptyState,
|
|
||||||
ErrorState,
|
ErrorState,
|
||||||
|
PageTransition,
|
||||||
SectionHeader,
|
SectionHeader,
|
||||||
SkeletonPanel,
|
SkeletonPanel,
|
||||||
} from "@/components/shared";
|
} from "@/components/shared";
|
||||||
@@ -29,6 +20,7 @@ import {
|
|||||||
useVoiceListen,
|
useVoiceListen,
|
||||||
useVoiceStatus,
|
useVoiceStatus,
|
||||||
} from "@/hooks";
|
} from "@/hooks";
|
||||||
|
import { useStaggerReveal } from "@/hooks/use-gsap-animation";
|
||||||
import type { Guild, VoiceStatus } from "@/lib/types";
|
import type { Guild, VoiceStatus } from "@/lib/types";
|
||||||
import { useWebSocket } from "@/lib/ws/context";
|
import { useWebSocket } from "@/lib/ws/context";
|
||||||
|
|
||||||
@@ -59,259 +51,215 @@ export function VoiceView({
|
|||||||
const [channelId, setChannelId] = useState<string | null>(
|
const [channelId, setChannelId] = useState<string | null>(
|
||||||
initialStatus?.activeChannelId ?? null,
|
initialStatus?.activeChannelId ?? null,
|
||||||
);
|
);
|
||||||
const [micOn, setMicOn] = useState(false);
|
|
||||||
const [micVol, setMicVol] = useState(100);
|
const [micVol, setMicVol] = useState(100);
|
||||||
const [listenVol, setListenVol] = useState(75);
|
const [listenVol, setListenVol] = useState(75);
|
||||||
|
|
||||||
|
const containerRef = useStaggerReveal<HTMLDivElement>(".voice-tile", {
|
||||||
|
stagger: 0.04,
|
||||||
|
y: 8,
|
||||||
|
dependencies: [status],
|
||||||
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const unsub = subscribe(ws);
|
const unsub = subscribe(ws);
|
||||||
return unsub;
|
return unsub;
|
||||||
}, [subscribe, ws]);
|
}, [subscribe, ws]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (status?.connected) ambient.set("signal", 0.55, "voice live");
|
if (status?.connected) ambient.set("signal", 0.45, "voice active");
|
||||||
else ambient.set("vermilion", 0.35, "voice idle");
|
else ambient.set("vermilion", 0.25, "voice disconnected");
|
||||||
}, [status?.connected, ambient]);
|
}, [status?.connected, ambient]);
|
||||||
|
|
||||||
if (error && !status)
|
if (error && !status)
|
||||||
return <ErrorState error={error} onRetry={() => void mutate()} />;
|
return <ErrorState error={error} onRetry={() => void mutate()} />;
|
||||||
if (!status && isLoading)
|
if (!status && isLoading)
|
||||||
return (
|
return (
|
||||||
<div className="space-y-5">
|
<div className="space-y-4">
|
||||||
<SkeletonPanel rows={2} />
|
<SkeletonPanel rows={3} />
|
||||||
<div className="grid gap-5 lg:grid-cols-3">
|
<SkeletonPanel rows={5} />
|
||||||
<SkeletonPanel className="lg:col-span-2" rows={4} />
|
|
||||||
<SkeletonPanel rows={4} />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
const connected = status?.connected ?? false;
|
const connected = status?.connected ?? false;
|
||||||
const listenBars = Array.from(listen.levels.values()).slice(0, 32);
|
|
||||||
const micBars = mic.micLevel
|
|
||||||
? Array.from({ length: 12 }, (_, i) =>
|
|
||||||
Math.max(
|
|
||||||
0.08,
|
|
||||||
Math.min(1, mic.micLevel * (1 - i * 0.06) + (i % 3) * 0.05),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: [];
|
|
||||||
|
|
||||||
const onConnect = async () => {
|
const onConnect = async () => {
|
||||||
if (!guildId || !channelId) {
|
if (!guildId || !channelId) {
|
||||||
toast({ title: "Pick a guild + channel", tone: "vermilion" });
|
toast({ title: "Select target channel", tone: "vermilion" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await connect.mutateAsync({ guildId, channelId });
|
await connect.mutateAsync({ guildId, channelId });
|
||||||
toast({ title: "Connected to voice", tone: "signal" });
|
toast({ title: "Connected to voice channel", tone: "signal" });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toast({
|
toast({
|
||||||
title: "Connect failed",
|
title: "Connection failed",
|
||||||
description: String(e),
|
description: String(e),
|
||||||
tone: "vermilion",
|
tone: "vermilion",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onMic = async (on: boolean) => {
|
const onDisconnect = async () => {
|
||||||
try {
|
try {
|
||||||
await mic.mutateAsync(on);
|
await disconnect.mutateAsync();
|
||||||
setMicOn(on);
|
toast({ title: "Disconnected from voice", tone: "neutral" });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toast({ title: "Mic error", description: String(e), tone: "vermilion" });
|
toast({
|
||||||
|
title: "Disconnect failed",
|
||||||
|
description: String(e),
|
||||||
|
tone: "vermilion",
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-5">
|
<PageTransition>
|
||||||
<GlassPanel>
|
<div ref={containerRef} className="space-y-4">
|
||||||
|
{/* Precision Sub-Header Bar */}
|
||||||
|
<div className="voice-tile flex flex-wrap items-center justify-between gap-3 border-b border-hairline pb-3">
|
||||||
|
<div className="flex items-center gap-2.5">
|
||||||
|
<span
|
||||||
|
className={`h-2 w-2 rounded-full ${
|
||||||
|
connected
|
||||||
|
? "bg-success shadow-[0_0_8px_var(--color-status-success)]"
|
||||||
|
: "bg-ink-muted"
|
||||||
|
}`}
|
||||||
|
/>
|
||||||
|
<h1 className="font-mono text-xs font-semibold tracking-wide text-ink uppercase">
|
||||||
|
Voice Spectrum & Stage Controls
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-2 font-mono text-[11px]">
|
||||||
|
<span className="text-ink-muted">STAGE:</span>
|
||||||
|
<span
|
||||||
|
className={`rounded px-1.5 py-0.5 font-medium border ${
|
||||||
|
connected
|
||||||
|
? "border-success/30 bg-success/10 text-success"
|
||||||
|
: "border-hairline bg-surface-2 text-ink-muted"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{connected ? "LIVE_BRIDGE" : "OFFLINE"}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Channel Router Stage */}
|
||||||
|
<div className="voice-tile">
|
||||||
|
<GlassPanel className="p-4">
|
||||||
<div className="flex flex-wrap items-center justify-between gap-3">
|
<div className="flex flex-wrap items-center justify-between gap-3">
|
||||||
|
<div className="flex-1 min-w-[240px]">
|
||||||
<GuildChannelPicker
|
<GuildChannelPicker
|
||||||
mode="voice"
|
|
||||||
guildsInitial={initialGuilds}
|
|
||||||
guildId={guildId}
|
guildId={guildId}
|
||||||
channelId={channelId}
|
channelId={channelId}
|
||||||
|
guildsInitial={initialGuilds}
|
||||||
onChange={(g, c) => {
|
onChange={(g, c) => {
|
||||||
setGuildId(g);
|
setGuildId(g);
|
||||||
setChannelId(c);
|
setChannelId(c);
|
||||||
}}
|
}}
|
||||||
|
mode="voice"
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
{connected ? (
|
{connected ? (
|
||||||
<Button
|
<Button
|
||||||
variant="danger"
|
variant="danger"
|
||||||
size="sm"
|
size="md"
|
||||||
onClick={() => disconnect.mutate()}
|
onClick={onDisconnect}
|
||||||
disabled={disconnect.isPending}
|
className="gap-1.5"
|
||||||
>
|
>
|
||||||
<PhoneOff className="size-4" /> Disconnect
|
<PhoneOff className="size-3.5" />
|
||||||
|
Disconnect
|
||||||
</Button>
|
</Button>
|
||||||
) : (
|
) : (
|
||||||
<Button
|
<Button
|
||||||
variant="primary"
|
variant="primary"
|
||||||
size="sm"
|
size="md"
|
||||||
onClick={onConnect}
|
onClick={onConnect}
|
||||||
disabled={connect.isPending}
|
className="gap-1.5"
|
||||||
>
|
>
|
||||||
<Radio className="size-4" /> Connect
|
<Radio className="size-3.5" />
|
||||||
|
Connect Bridge
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</GlassPanel>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="mt-3 flex flex-wrap items-center gap-2">
|
{/* Voice Stage Grid */}
|
||||||
<Button
|
<div className="grid gap-3 lg:grid-cols-3">
|
||||||
variant={micOn ? "primary" : "outline"}
|
<GlassPanel className="voice-tile lg:col-span-2">
|
||||||
size="sm"
|
<SectionHeader
|
||||||
onClick={() => onMic(!micOn)}
|
eyebrow="Participants"
|
||||||
disabled={mic.isPending}
|
title="Active Stage Members"
|
||||||
aria-pressed={micOn}
|
/>
|
||||||
>
|
<div className="mt-4 min-h-[160px]">
|
||||||
{micOn ? <Mic className="size-4" /> : <MicOff className="size-4" />}
|
<VoiceStage speakers={speakers} />
|
||||||
{micOn ? "Mic live" : "Push-to-talk"}
|
|
||||||
</Button>
|
|
||||||
{micOn && (
|
|
||||||
<div
|
|
||||||
className="flex items-center gap-2 rounded-[10px] border border-signal/30 bg-signal/[0.06] px-3 py-1.5"
|
|
||||||
role="status"
|
|
||||||
aria-label="Microphone level meter"
|
|
||||||
>
|
|
||||||
<Mic className="size-4 text-signal" />
|
|
||||||
<Equalizer bars={micBars} className="w-28" />
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
</GlassPanel>
|
||||||
<Button
|
|
||||||
variant={listen.active ? "primary" : "outline"}
|
<GlassPanel className="voice-tile flex flex-col justify-between">
|
||||||
size="sm"
|
<div>
|
||||||
onClick={() => listen.toggle(!listen.active)}
|
<SectionHeader eyebrow="Telemetry" title="Input / Output Mix" />
|
||||||
>
|
<div className="mt-4 space-y-4">
|
||||||
{listen.active ? (
|
<div>
|
||||||
<Headphones className="size-4" />
|
<div className="flex justify-between text-xs font-medium text-ink-soft">
|
||||||
) : (
|
<span className="flex items-center gap-1.5">
|
||||||
<Volume2 className="size-4" />
|
<Mic className="size-3.5 text-signal" />
|
||||||
)}
|
Mic Sensitivity
|
||||||
{listen.active ? "Listening" : "Listen in"}
|
</span>
|
||||||
</Button>
|
<span className="font-mono text-[11px] text-ink-muted">
|
||||||
{listen.active && (
|
{micVol}%
|
||||||
<div className="flex items-center gap-2 rounded-[10px] border border-hairline bg-white/5 px-3 py-1.5">
|
</span>
|
||||||
<Waves className="size-4 text-signal" />
|
|
||||||
<Equalizer bars={listenBars} className="w-40" />
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
|
||||||
<div className="ml-auto flex items-center gap-3">
|
|
||||||
<label className="flex items-center gap-2 text-xs text-ink-faint">
|
|
||||||
<MicOff className="size-3.5" />
|
|
||||||
<input
|
<input
|
||||||
type="range"
|
type="range"
|
||||||
min={0}
|
min={0}
|
||||||
max={100}
|
max={150}
|
||||||
value={micVol}
|
value={micVol}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
const v = Number(e.target.value);
|
const v = Number(e.target.value);
|
||||||
setMicVol(v);
|
setMicVol(v);
|
||||||
mic.setVolume(v);
|
mic.setVolume(v / 100);
|
||||||
}}
|
}}
|
||||||
aria-label="Mic transmit volume"
|
className="mt-2 h-1.5 w-full appearance-none rounded-full bg-surface-2 accent-signal"
|
||||||
className="h-1 w-24 cursor-pointer accent-[var(--color-signal)]"
|
|
||||||
/>
|
/>
|
||||||
<span className="mono w-8 text-right">{micVol}%</span>
|
</div>
|
||||||
</label>
|
|
||||||
<label className="flex items-center gap-2 text-xs text-ink-faint">
|
<div>
|
||||||
<Volume2 className="size-3.5" />
|
<div className="flex justify-between text-xs font-medium text-ink-soft">
|
||||||
|
<span className="flex items-center gap-1.5">
|
||||||
|
<Volume2 className="size-3.5 text-success" />
|
||||||
|
Monitor Output
|
||||||
|
</span>
|
||||||
|
<span className="font-mono text-[11px] text-ink-muted">
|
||||||
|
{listenVol}%
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<input
|
<input
|
||||||
type="range"
|
type="range"
|
||||||
min={0}
|
min={0}
|
||||||
max={100}
|
max={150}
|
||||||
value={listenVol}
|
value={listenVol}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
const v = Number(e.target.value);
|
const v = Number(e.target.value);
|
||||||
setListenVol(v);
|
setListenVol(v);
|
||||||
listen.setVolume(v);
|
listen.setVolume(v / 100);
|
||||||
}}
|
}}
|
||||||
aria-label="Listen volume"
|
className="mt-2 h-1.5 w-full appearance-none rounded-full bg-surface-2 accent-success"
|
||||||
className="h-1 w-24 cursor-pointer accent-[var(--color-signal)]"
|
|
||||||
/>
|
/>
|
||||||
<span className="mono w-8 text-right">{listenVol}%</span>
|
|
||||||
</label>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</GlassPanel>
|
</div>
|
||||||
|
|
||||||
<div className="grid gap-5 lg:grid-cols-3">
|
<div className="mt-6 border-t border-hairline pt-3">
|
||||||
<GlassPanel className="lg:col-span-2">
|
<div className="font-mono text-[10px] text-ink-muted">
|
||||||
<SectionHeader
|
CODEC: OPUS 48KHZ · LOW_LATENCY
|
||||||
eyebrow="stage"
|
|
||||||
title="Live speakers"
|
|
||||||
action={
|
|
||||||
<span className="mono text-xs text-ink-faint">
|
|
||||||
{speakers.length} present
|
|
||||||
</span>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
{speakers.length === 0 ? (
|
|
||||||
<EmptyState
|
|
||||||
icon={<MicOff className="size-7" />}
|
|
||||||
title={connected ? "Silent right now" : "Not connected"}
|
|
||||||
description={
|
|
||||||
connected
|
|
||||||
? "Speakers appear as they talk."
|
|
||||||
: "Connect to a voice channel to see presence."
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<VoiceStage speakers={speakers} />
|
|
||||||
<div className="mt-2 flex flex-wrap justify-center gap-2">
|
|
||||||
{speakers.map((sp) => (
|
|
||||||
<span
|
|
||||||
key={sp.userId}
|
|
||||||
className={`mono flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs ${
|
|
||||||
sp.speaking
|
|
||||||
? "border-signal/40 bg-signal/10 text-signal"
|
|
||||||
: "border-hairline bg-white/5 text-ink-soft"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
className={`size-1.5 rounded-full ${sp.speaking ? "bg-signal animate-breathe" : "bg-ink-faint"}`}
|
|
||||||
/>
|
|
||||||
{sp.username}
|
|
||||||
</span>
|
|
||||||
))}
|
|
||||||
</div>
|
</div>
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</GlassPanel>
|
|
||||||
|
|
||||||
<GlassPanel>
|
|
||||||
<SectionHeader eyebrow="links" title="Connections" />
|
|
||||||
<div className="space-y-2">
|
|
||||||
{(status?.connections ?? []).map((c) => (
|
|
||||||
<div
|
|
||||||
key={`${c.guildId}-${c.channelId}`}
|
|
||||||
className="flex items-center gap-2 rounded-[10px] border border-hairline bg-white/5 px-3 py-2 text-sm"
|
|
||||||
>
|
|
||||||
<span className="size-2 rounded-full bg-signal" />
|
|
||||||
<span className="flex-1 truncate text-ink-soft">
|
|
||||||
{c.channelName}
|
|
||||||
</span>
|
|
||||||
<span className="mono text-[0.6rem] text-ink-faint">
|
|
||||||
{new Date(c.connectedAt).toLocaleTimeString()}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
{(status?.connections ?? []).length === 0 && (
|
|
||||||
<div className="py-6 text-center text-xs text-ink-faint">
|
|
||||||
No active links
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<div className="mt-3 rounded-[10px] border border-hairline bg-white/5 px-3 py-2 text-xs text-ink-soft">
|
|
||||||
<span className="mono text-ink-faint">channel</span>{" "}
|
|
||||||
{status?.activeChannelName ?? "—"}
|
|
||||||
</div>
|
</div>
|
||||||
</GlassPanel>
|
</GlassPanel>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</PageTransition>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -3,456 +3,358 @@
|
|||||||
@custom-variant dark (&:is(.dark *));
|
@custom-variant dark (&:is(.dark *));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GMW — Ambient Ops Console design system.
|
* GMW — Command Center Tactical HUD Design System
|
||||||
*
|
* Engineered for high precision in both DARK and LIGHT modes.
|
||||||
* A signal-driven, immersive ops aesthetic. Hierarchy comes from scale/weight
|
* Uses semantic CSS variables for seamless theme switching, eliminating hardcoded hex clashes.
|
||||||
* and tonal surface blocks, not borders. The whole app sits behind a live
|
|
||||||
* WebGL haze (see components/ambient) tinted by a semantic signal:
|
|
||||||
* lime = OK / live
|
|
||||||
* amber = warn
|
|
||||||
* vermilion = flag / danger
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
:root {
|
||||||
|
/* ── Light Mode Base Palette (Crisp High-Contrast Titanium HUD) ── */
|
||||||
|
--canvas-base: #f0f2f5;
|
||||||
|
--canvas-subtle: #e5e8ed;
|
||||||
|
--panel-bg: rgba(255, 255, 255, 0.85);
|
||||||
|
--panel-bg-subtle: rgba(255, 255, 255, 0.6);
|
||||||
|
--panel-border: rgba(15, 23, 42, 0.08);
|
||||||
|
--panel-border-hover: rgba(94, 106, 210, 0.35);
|
||||||
|
|
||||||
|
--text-primary: #0f172a;
|
||||||
|
--text-secondary: #334155;
|
||||||
|
--text-muted: #64748b;
|
||||||
|
--text-faint: #94a3b8;
|
||||||
|
|
||||||
|
--accent-brand: #4f46e5;
|
||||||
|
--accent-signal: #6366f1;
|
||||||
|
--accent-signal-bg: rgba(99, 102, 241, 0.1);
|
||||||
|
--accent-signal-border: rgba(99, 102, 241, 0.25);
|
||||||
|
--accent-signal-glow: rgba(99, 102, 241, 0.25);
|
||||||
|
|
||||||
|
--color-success: #059669;
|
||||||
|
--color-success-bg: rgba(5, 150, 105, 0.1);
|
||||||
|
--color-warning: #d97706;
|
||||||
|
--color-warning-bg: rgba(217, 119, 6, 0.1);
|
||||||
|
--color-danger: #e11d48;
|
||||||
|
--color-danger-bg: rgba(225, 29, 72, 0.1);
|
||||||
|
|
||||||
|
--grid-pattern: rgba(15, 23, 42, 0.035);
|
||||||
|
--shadow-hud: 0 4px 20px -2px rgba(15, 23, 42, 0.06), 0 0 0 1px rgba(15, 23, 42, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.dark {
|
||||||
|
/* ── Dark Mode Base Palette (Stealth Obsidian Tactical HUD) ── */
|
||||||
|
--canvas-base: #060709;
|
||||||
|
--canvas-subtle: #0c0e12;
|
||||||
|
--panel-bg: rgba(13, 16, 23, 0.75);
|
||||||
|
--panel-bg-subtle: rgba(255, 255, 255, 0.03);
|
||||||
|
--panel-border: rgba(255, 255, 255, 0.07);
|
||||||
|
--panel-border-hover: rgba(113, 112, 255, 0.45);
|
||||||
|
|
||||||
|
--text-primary: #f8fafc;
|
||||||
|
--text-secondary: #cbd5e1;
|
||||||
|
--text-muted: #94a3b8;
|
||||||
|
--text-faint: #475569;
|
||||||
|
|
||||||
|
--accent-brand: #5e6ad2;
|
||||||
|
--accent-signal: #7170ff;
|
||||||
|
--accent-signal-bg: rgba(113, 112, 255, 0.12);
|
||||||
|
--accent-signal-border: rgba(113, 112, 255, 0.3);
|
||||||
|
--accent-signal-glow: rgba(113, 112, 255, 0.35);
|
||||||
|
|
||||||
|
--color-success: #10b981;
|
||||||
|
--color-success-bg: rgba(16, 185, 129, 0.12);
|
||||||
|
--color-warning: #f59e0b;
|
||||||
|
--color-warning-bg: rgba(245, 158, 11, 0.12);
|
||||||
|
--color-danger: #f43f5e;
|
||||||
|
--color-danger-bg: rgba(244, 63, 94, 0.15);
|
||||||
|
|
||||||
|
--grid-pattern: rgba(255, 255, 255, 0.025);
|
||||||
|
--shadow-hud: 0 8px 32px -4px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.06);
|
||||||
|
}
|
||||||
|
|
||||||
@theme {
|
@theme {
|
||||||
/* ── Surfaces (dark-first; light overrides below) ── */
|
--color-canvas: var(--canvas-base);
|
||||||
--color-canvas: oklch(0.12 0.014 70);
|
--color-canvas-2: var(--canvas-subtle);
|
||||||
--color-canvas-2: oklch(0.16 0.02 70);
|
--color-surface: var(--panel-bg);
|
||||||
--color-surface: oklch(0.2 0.022 70 / 0.45);
|
--color-surface-2: var(--panel-bg-subtle);
|
||||||
--color-surface-2: oklch(0.26 0.024 70 / 0.45);
|
--color-hairline: var(--panel-border);
|
||||||
|
--color-hairline-focus: var(--panel-border-hover);
|
||||||
|
|
||||||
/* ── Ink ── */
|
--color-ink: var(--text-primary);
|
||||||
--color-ink: oklch(0.95 0.008 75);
|
--color-ink-soft: var(--text-secondary);
|
||||||
--color-ink-soft: oklch(0.66 0.02 75);
|
--color-ink-muted: var(--text-muted);
|
||||||
--color-ink-faint: oklch(0.5 0.02 75);
|
--color-ink-faint: var(--text-faint);
|
||||||
|
|
||||||
/* ── Structural ── */
|
--color-brand: var(--accent-brand);
|
||||||
--color-hairline: oklch(1 0 0 / 0.1);
|
--color-brand-accent: var(--accent-signal);
|
||||||
--hairline-w: 1px;
|
--color-signal: var(--accent-signal);
|
||||||
|
--color-signal-glow: var(--accent-signal-glow);
|
||||||
|
|
||||||
/* ── Semantic signals (monochrome: tone = luminance steps) ── */
|
--color-status-success: var(--color-success);
|
||||||
--color-signal: oklch(0.97 0 0);
|
--color-amber: var(--color-warning);
|
||||||
--color-signal-ink: oklch(0.1 0 0);
|
--color-vermilion: var(--color-danger);
|
||||||
--color-signal-glow: oklch(1 0 0 / 0.35);
|
|
||||||
--color-amber: oklch(0.72 0 0);
|
|
||||||
--color-vermilion: oklch(0.85 0 0);
|
|
||||||
--color-vermilion-glow: oklch(1 0 0 / 0.45);
|
|
||||||
|
|
||||||
--color-ring: var(--color-signal);
|
--font-sans: var(--font-inter), -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
||||||
|
--font-mono: var(--font-jetbrains-mono), ui-monospace, SFMono-Regular, Menlo, monospace;
|
||||||
|
--font-display: var(--font-display), var(--font-inter), sans-serif;
|
||||||
|
|
||||||
/* ── Fonts ── */
|
--radius-r: 8px;
|
||||||
--font-sans: "Inter", ui-sans-serif, system-ui, sans-serif;
|
--radius-r-panel: 10px;
|
||||||
--font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
|
--radius-r-control: 6px;
|
||||||
--font-display: "Bricolage Grotesque", "Inter", system-ui, sans-serif;
|
|
||||||
|
|
||||||
/* ── Radii ── */
|
|
||||||
--radius-r: 16px;
|
|
||||||
--radius-r-panel: 12px;
|
|
||||||
--radius-r-control: 9px;
|
|
||||||
--radius-r-pill: 9999px;
|
--radius-r-pill: 9999px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Light theme overrides ── */
|
|
||||||
.light {
|
|
||||||
color-scheme: light;
|
|
||||||
--color-canvas: oklch(0.96 0.012 80);
|
|
||||||
--color-canvas-2: oklch(0.92 0.014 80);
|
|
||||||
--color-surface: oklch(1 0 0 / 0.7);
|
|
||||||
--color-surface-2: oklch(1 0 0 / 0.5);
|
|
||||||
|
|
||||||
--color-ink: oklch(0.22 0.02 70);
|
|
||||||
--color-ink-soft: oklch(0.46 0.02 70);
|
|
||||||
--color-ink-faint: oklch(0.6 0.02 70);
|
|
||||||
|
|
||||||
--color-hairline: oklch(0.22 0.02 70 / 0.12);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Light-theme scrollbar + selection tuned for pale canvas */
|
|
||||||
.light ::-webkit-scrollbar-thumb {
|
|
||||||
background: oklch(0.22 0.02 70 / 0.2);
|
|
||||||
}
|
|
||||||
.light ::-webkit-scrollbar-thumb:hover {
|
|
||||||
background: oklch(0.22 0.02 70 / 0.34);
|
|
||||||
}
|
|
||||||
.light ::selection {
|
|
||||||
background: oklch(0.2 0 0 / 0.9);
|
|
||||||
color: oklch(1 0 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@layer base {
|
@layer base {
|
||||||
* {
|
* {
|
||||||
@apply border-transparent;
|
border-color: var(--panel-border);
|
||||||
}
|
}
|
||||||
|
|
||||||
html {
|
html {
|
||||||
@apply font-sans antialiased scroll-smooth;
|
@apply font-sans antialiased scroll-smooth;
|
||||||
|
background-color: var(--canvas-base);
|
||||||
|
color: var(--text-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
@apply bg-canvas text-ink font-sans antialiased;
|
|
||||||
min-height: 100dvh;
|
min-height: 100dvh;
|
||||||
|
background-color: var(--canvas-base);
|
||||||
|
color: var(--text-primary);
|
||||||
|
background-image:
|
||||||
|
linear-gradient(to right, var(--grid-pattern) 1px, transparent 1px),
|
||||||
|
linear-gradient(to bottom, var(--grid-pattern) 1px, transparent 1px);
|
||||||
|
background-size: 32px 32px;
|
||||||
}
|
}
|
||||||
|
|
||||||
::selection {
|
::selection {
|
||||||
background: var(--color-signal-glow);
|
background: var(--accent-signal-bg);
|
||||||
color: inherit;
|
color: var(--accent-signal);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Scrollbar */
|
|
||||||
::-webkit-scrollbar {
|
::-webkit-scrollbar {
|
||||||
width: 8px;
|
width: 6px;
|
||||||
height: 8px;
|
height: 6px;
|
||||||
}
|
}
|
||||||
::-webkit-scrollbar-track {
|
::-webkit-scrollbar-track {
|
||||||
background: transparent;
|
background: transparent;
|
||||||
}
|
}
|
||||||
::-webkit-scrollbar-thumb {
|
::-webkit-scrollbar-thumb {
|
||||||
background: oklch(1 0 0 / 0.14);
|
background: var(--text-faint);
|
||||||
border-radius: 999px;
|
opacity: 0.4;
|
||||||
|
border-radius: 9999px;
|
||||||
}
|
}
|
||||||
::-webkit-scrollbar-thumb:hover {
|
::-webkit-scrollbar-thumb:hover {
|
||||||
background: oklch(1 0 0 / 0.26);
|
background: var(--text-muted);
|
||||||
}
|
}
|
||||||
|
|
||||||
:focus-visible {
|
:focus-visible {
|
||||||
outline: 2px solid var(--color-signal);
|
outline: 2px solid var(--accent-signal);
|
||||||
outline-offset: 2px;
|
outline-offset: 2px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@layer components {
|
@layer components {
|
||||||
/* Glass panel — the workhorse container. Floating, blurred, faint glow. */
|
/* Tactical HUD Glass Panel */
|
||||||
.glass {
|
.glass {
|
||||||
background: var(--color-surface);
|
background: var(--panel-bg);
|
||||||
border: var(--hairline-w) solid var(--color-hairline);
|
border: 1px solid var(--panel-border);
|
||||||
border-radius: var(--radius-r);
|
|
||||||
backdrop-filter: blur(18px) saturate(140%);
|
|
||||||
-webkit-backdrop-filter: blur(18px) saturate(140%);
|
|
||||||
box-shadow:
|
|
||||||
0 1px 0 0 oklch(1 0 0 / 0.06) inset,
|
|
||||||
0 18px 50px -28px oklch(0 0 0 / 0.8);
|
|
||||||
}
|
|
||||||
|
|
||||||
.glass-2 {
|
|
||||||
background: var(--color-surface-2);
|
|
||||||
border: var(--hairline-w) solid var(--color-hairline);
|
|
||||||
border-radius: var(--radius-r-panel);
|
border-radius: var(--radius-r-panel);
|
||||||
backdrop-filter: blur(14px) saturate(130%);
|
backdrop-filter: blur(16px);
|
||||||
-webkit-backdrop-filter: blur(14px) saturate(130%);
|
-webkit-backdrop-filter: blur(16px);
|
||||||
|
box-shadow: var(--shadow-hud);
|
||||||
|
transition: border-color 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.glass:hover {
|
||||||
|
border-color: var(--panel-border-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* HUD Tactical Card */
|
||||||
|
.hud-card {
|
||||||
|
position: relative;
|
||||||
|
background: var(--panel-bg);
|
||||||
|
border: 1px solid var(--panel-border);
|
||||||
|
border-radius: var(--radius-r-panel);
|
||||||
|
backdrop-filter: blur(12px);
|
||||||
|
box-shadow: var(--shadow-hud);
|
||||||
|
transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.hud-card:hover {
|
||||||
|
border-color: var(--panel-border-hover);
|
||||||
|
transform: translateY(-1px);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Section label — small uppercase mono eyebrow */
|
|
||||||
.eyebrow {
|
.eyebrow {
|
||||||
font-family: var(--font-mono);
|
font-family: var(--font-mono);
|
||||||
font-size: 0.68rem;
|
font-size: 0.68rem;
|
||||||
letter-spacing: 0.18em;
|
font-weight: 600;
|
||||||
|
letter-spacing: 0.08em;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
color: var(--color-ink-faint);
|
color: var(--text-muted);
|
||||||
}
|
}
|
||||||
|
|
||||||
.pill {
|
.pill {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.4rem;
|
gap: 0.35rem;
|
||||||
padding: 0.22rem 0.7rem;
|
padding: 0.18rem 0.55rem;
|
||||||
border-radius: var(--radius-r-pill);
|
border-radius: var(--radius-r-pill);
|
||||||
font-size: 0.72rem;
|
font-size: 0.7rem;
|
||||||
font-weight: 600;
|
font-family: var(--font-mono);
|
||||||
letter-spacing: 0.01em;
|
font-weight: 500;
|
||||||
background: oklch(1 0 0 / 0.06);
|
background: var(--panel-bg-subtle);
|
||||||
border: 1px solid var(--color-hairline);
|
border: 1px solid var(--panel-border);
|
||||||
color: var(--color-ink-soft);
|
color: var(--text-secondary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.mono {
|
.mono {
|
||||||
font-family: var(--font-mono);
|
font-family: var(--font-mono);
|
||||||
font-variant-numeric: tabular-nums;
|
font-variant-numeric: tabular-nums;
|
||||||
letter-spacing: -0.01em;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.display {
|
.display {
|
||||||
font-family: var(--font-display);
|
font-family: var(--font-display);
|
||||||
font-weight: 800;
|
font-weight: 700;
|
||||||
letter-spacing: -0.03em;
|
letter-spacing: -0.035em;
|
||||||
line-height: 0.96;
|
line-height: 1.1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@layer utilities {
|
@layer utilities {
|
||||||
.text-signal { color: var(--color-signal); }
|
.text-signal { color: var(--accent-signal); }
|
||||||
.text-amber { color: var(--color-amber); }
|
.text-brand { color: var(--accent-brand); }
|
||||||
.text-vermilion { color: var(--color-vermilion); }
|
.text-amber { color: var(--color-warning); }
|
||||||
.text-ink-soft { color: var(--color-ink-soft); }
|
.text-vermilion { color: var(--color-danger); }
|
||||||
.text-ink-faint { color: var(--color-ink-faint); }
|
.text-success { color: var(--color-success); }
|
||||||
|
.text-ink { color: var(--text-primary); }
|
||||||
|
.text-ink-soft { color: var(--text-secondary); }
|
||||||
|
.text-ink-muted { color: var(--text-muted); }
|
||||||
|
.text-ink-faint { color: var(--text-faint); }
|
||||||
|
|
||||||
/* Fluid hero title — never overflows on small screens. */
|
.bg-canvas { background-color: var(--canvas-base); }
|
||||||
.hero-clamp { font-size: clamp(1.9rem, 1.2rem + 4vw, 2.6rem); }
|
.bg-surface { background-color: var(--panel-bg); }
|
||||||
|
.bg-surface-2 { background-color: var(--panel-bg-subtle); }
|
||||||
|
.border-hairline { border-color: var(--panel-border); }
|
||||||
|
|
||||||
.glow-signal {
|
.glow-signal {
|
||||||
text-shadow: 0 0 22px var(--color-signal-glow);
|
text-shadow: 0 0 16px var(--accent-signal-glow);
|
||||||
}
|
|
||||||
.glow-vermilion {
|
|
||||||
text-shadow: 0 0 22px var(--color-vermilion-glow);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* animated scan line for live headers */
|
|
||||||
.scan-line {
|
|
||||||
position: relative;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
.scan-line::after {
|
|
||||||
content: "";
|
|
||||||
position: absolute;
|
|
||||||
left: 0;
|
|
||||||
top: 0;
|
|
||||||
height: 1px;
|
|
||||||
width: 100%;
|
|
||||||
background: linear-gradient(
|
|
||||||
90deg,
|
|
||||||
transparent,
|
|
||||||
var(--color-signal) 25%,
|
|
||||||
var(--color-signal) 75%,
|
|
||||||
transparent
|
|
||||||
);
|
|
||||||
background-size: 200% 100%;
|
|
||||||
animation: scan 2.8s linear infinite;
|
|
||||||
opacity: 0.7;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ring-focus {
|
|
||||||
transition: box-shadow 0.18s ease, border-color 0.18s ease;
|
|
||||||
}
|
|
||||||
.ring-focus:hover {
|
|
||||||
box-shadow: 0 0 0 1px var(--color-signal-glow);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Keyframes ── */
|
/* ═══ Keyframes & Animations ═══ */
|
||||||
@keyframes scan {
|
@keyframes breathe {
|
||||||
0% { background-position: 200% 0; }
|
0%, 100% { opacity: 0.4; transform: scale(0.95); }
|
||||||
100% { background-position: -200% 0; }
|
50% { opacity: 1; transform: scale(1.05); }
|
||||||
}
|
|
||||||
@keyframes eq {
|
|
||||||
0%, 100% { transform: scaleY(0.25); }
|
|
||||||
30% { transform: scaleY(1); }
|
|
||||||
60% { transform: scaleY(0.5); }
|
|
||||||
}
|
|
||||||
@keyframes fade-up {
|
|
||||||
from { opacity: 0; transform: translateY(10px); }
|
|
||||||
to { opacity: 1; transform: translateY(0); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes spin-disc {
|
@keyframes spin-disc {
|
||||||
from { transform: rotate(0deg); }
|
from { transform: rotate(0deg); }
|
||||||
to { transform: rotate(360deg); }
|
to { transform: rotate(360deg); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes pulse-ring {
|
@keyframes pulse-ring {
|
||||||
0% { transform: scale(0.85); opacity: 1; }
|
0% { transform: scale(0.85); opacity: 0.9; }
|
||||||
100% { transform: scale(2.6); opacity: 0; }
|
100% { transform: scale(2.2); opacity: 0; }
|
||||||
}
|
|
||||||
@keyframes shimmer {
|
|
||||||
0% { background-position: -200% 0; }
|
|
||||||
100% { background-position: 200% 0; }
|
|
||||||
}
|
|
||||||
@keyframes breathe {
|
|
||||||
0%, 100% { opacity: 0.55; }
|
|
||||||
50% { opacity: 1; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.animate-eq {
|
@keyframes shimmer {
|
||||||
animation: eq 0.9s ease-in-out infinite;
|
0% { background-position: 200% 0; }
|
||||||
transform-origin: bottom;
|
100% { background-position: -200% 0; }
|
||||||
}
|
}
|
||||||
.animate-spin-disc { animation: spin-disc 9s linear infinite; }
|
|
||||||
.animate-spin-disc.paused { animation-play-state: paused; }
|
@keyframes eq {
|
||||||
.animate-pulse-ring { animation: pulse-ring 1.6s ease-out infinite; }
|
0%, 100% { transform: scaleY(0.35); }
|
||||||
|
50% { transform: scaleY(1); }
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes fade-up {
|
||||||
|
from { opacity: 0; transform: translateY(6px); }
|
||||||
|
to { opacity: 1; transform: translateY(0); }
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes toast-in {
|
||||||
|
from { opacity: 0; transform: translateY(8px) scale(0.98); }
|
||||||
|
to { opacity: 1; transform: translateY(0) scale(1); }
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes scan {
|
||||||
|
0% { transform: translateY(-100%); }
|
||||||
|
100% { transform: translateY(100%); }
|
||||||
|
}
|
||||||
|
|
||||||
|
.animate-breathe { animation: breathe 2.5s ease-in-out infinite; }
|
||||||
|
.animate-spin-disc { animation: spin-disc 10s linear infinite; }
|
||||||
|
.animate-pulse-ring { animation: pulse-ring 2s cubic-bezier(0.16, 1, 0.3, 1) infinite; }
|
||||||
|
|
||||||
|
/* Skeleton shimmer — theme-aware base + moving highlight sheen. */
|
||||||
.animate-shimmer {
|
.animate-shimmer {
|
||||||
background: linear-gradient(
|
background-color: var(--panel-bg-subtle);
|
||||||
90deg,
|
background-image: linear-gradient(
|
||||||
transparent,
|
105deg,
|
||||||
oklch(0.86 0.19 128 / 0.1),
|
transparent 40%,
|
||||||
transparent
|
color-mix(in oklab, var(--text-primary) 6%, transparent) 50%,
|
||||||
|
transparent 60%
|
||||||
);
|
);
|
||||||
background-size: 200% 100%;
|
background-size: 200% 100%;
|
||||||
animation: shimmer 1.6s infinite;
|
animation: shimmer 1.6s ease-in-out infinite;
|
||||||
}
|
|
||||||
.animate-breathe { animation: breathe 3.5s ease-in-out infinite; }
|
|
||||||
|
|
||||||
/* Page-enter: subtle rise+settle. Respect reduced-motion (handled globally). */
|
|
||||||
.animate-fade-up {
|
|
||||||
animation: fade-up 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
|
|
||||||
}
|
|
||||||
/* List stagger: each child rises in sequence. Pair with inline
|
|
||||||
style={{ animationDelay }} set via staggerDelay(). */
|
|
||||||
.animate-stagger {
|
|
||||||
animation: fade-up 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
|
|
||||||
}
|
|
||||||
/* Toast: slide up + settle from the dock edge. */
|
|
||||||
.animate-toast-in {
|
|
||||||
animation: toast-in 0.22s cubic-bezier(0.22, 1, 0.36, 1) both;
|
|
||||||
}
|
|
||||||
@keyframes toast-in {
|
|
||||||
from {
|
|
||||||
opacity: 0;
|
|
||||||
transform: translateY(14px) scale(0.98);
|
|
||||||
}
|
|
||||||
to {
|
|
||||||
opacity: 1;
|
|
||||||
transform: translateY(0) scale(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ═══ Game-menu nav (monochrome) ═══
|
/* Live equalizer bars (mini-player / recording player). */
|
||||||
Corner brackets + one-shot light sweep + staggered entrance.
|
.animate-eq {
|
||||||
Pure transform/opacity — compositor only. */
|
transform-origin: bottom;
|
||||||
|
animation: eq 0.9s ease-in-out infinite;
|
||||||
.game-nav-item {
|
|
||||||
--i: 0;
|
|
||||||
position: relative;
|
|
||||||
isolation: isolate;
|
|
||||||
animation: nav-in 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
|
|
||||||
animation-delay: calc(var(--i) * 45ms);
|
|
||||||
}
|
}
|
||||||
/* corner brackets on hover/active */
|
|
||||||
.game-nav-item::before,
|
/* Entrance for popovers, toasts, mini-player. */
|
||||||
.game-nav-item::after {
|
.animate-fade-up { animation: fade-up 0.18s cubic-bezier(0.16, 1, 0.3, 1); }
|
||||||
content: "";
|
.animate-toast-in { animation: toast-in 0.2s cubic-bezier(0.16, 1, 0.3, 1); }
|
||||||
|
|
||||||
|
/* Sweeping glow line across a hero/placeholder panel. */
|
||||||
|
.scan-line {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
inset: 0;
|
inset: 0;
|
||||||
opacity: 0;
|
height: 100%;
|
||||||
transition: opacity 0.2s ease;
|
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
background: linear-gradient(
|
||||||
|
180deg,
|
||||||
|
transparent,
|
||||||
|
var(--accent-signal-glow),
|
||||||
|
transparent
|
||||||
|
);
|
||||||
|
opacity: 0.5;
|
||||||
|
animation: scan 2.6s ease-in-out infinite;
|
||||||
}
|
}
|
||||||
.game-nav-item::before {
|
|
||||||
border-left: 2px solid currentColor;
|
/* Mobile nav hover/active sweep fill. */
|
||||||
border-top: 2px solid currentColor;
|
.game-sweep {
|
||||||
border-top-left-radius: 13px;
|
|
||||||
clip-path: polygon(0 0, 62% 0, 62% 30%, 30% 30%, 30% 100%, 0 100%);
|
|
||||||
}
|
|
||||||
.game-nav-item::after {
|
|
||||||
border-right: 2px solid currentColor;
|
|
||||||
border-bottom: 2px solid currentColor;
|
|
||||||
border-bottom-right-radius: 13px;
|
|
||||||
clip-path: polygon(100% 100%, 38% 100%, 38% 70%, 70% 70%, 70% 0, 100% 0);
|
|
||||||
}
|
|
||||||
.game-nav-item:hover::before,
|
|
||||||
.game-nav-item:hover::after,
|
|
||||||
.game-nav-item.is-active::before,
|
|
||||||
.game-nav-item.is-active::after {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
/* one-shot sweep */
|
|
||||||
.game-nav-item .game-sweep {
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
inset: 0;
|
inset: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
border-radius: inherit;
|
border-radius: inherit;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
.game-nav-item .game-sweep > i {
|
|
||||||
position: absolute;
|
|
||||||
top: -20%;
|
|
||||||
bottom: -20%;
|
|
||||||
width: 34%;
|
|
||||||
left: -60%;
|
|
||||||
background: linear-gradient(
|
|
||||||
105deg,
|
|
||||||
transparent,
|
|
||||||
oklch(1 0 0 / 0.16),
|
|
||||||
transparent
|
|
||||||
);
|
|
||||||
transform: skewX(-14deg);
|
|
||||||
}
|
|
||||||
.game-nav-item:hover .game-sweep > i,
|
|
||||||
.game-nav-item.is-active .game-sweep > i {
|
|
||||||
animation: sweep-x 0.55s ease-out both;
|
|
||||||
}
|
|
||||||
/* active triangle marker (game cursor) */
|
|
||||||
.game-marker {
|
|
||||||
position: absolute;
|
|
||||||
top: 50%;
|
|
||||||
width: 0;
|
|
||||||
height: 0;
|
|
||||||
border-block: 7px solid transparent;
|
|
||||||
border-left: 11px solid currentColor;
|
|
||||||
transform: translateY(-50%);
|
|
||||||
filter: drop-shadow(0 0 6px var(--color-signal-glow));
|
|
||||||
animation: marker-nudge 1.6s ease-in-out infinite;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes marker-nudge {
|
.game-sweep i {
|
||||||
0%, 100% { transform: translateY(-50%) translateX(0); }
|
|
||||||
50% { transform: translateY(-50%) translateX(3px); }
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes sweep-x {
|
|
||||||
from { left: -60%; }
|
|
||||||
to { left: 130%; }
|
|
||||||
}
|
|
||||||
@keyframes nav-in {
|
|
||||||
from { opacity: 0; transform: translateX(-10px); }
|
|
||||||
to { opacity: 1; transform: translateX(0); }
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ── Game frame: panel with cut corners + drawn-in edge lines ── */
|
|
||||||
.game-frame {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
.game-frame::before {
|
|
||||||
content: "";
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
inset: 0;
|
inset: 0;
|
||||||
border-radius: inherit;
|
background: var(--accent-signal-bg);
|
||||||
pointer-events: none;
|
transform: translateY(100%);
|
||||||
background:
|
transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
|
||||||
linear-gradient(var(--color-hairline), var(--color-hairline)) top left /
|
|
||||||
26px 1.5px,
|
|
||||||
linear-gradient(var(--color-hairline), var(--color-hairline)) top left / 1.5px
|
|
||||||
26px,
|
|
||||||
linear-gradient(var(--color-hairline), var(--color-hairline)) top right /
|
|
||||||
26px 1.5px,
|
|
||||||
linear-gradient(var(--color-hairline), var(--color-hairline)) top right / 1.5px
|
|
||||||
26px,
|
|
||||||
linear-gradient(var(--color-hairline), var(--color-hairline)) bottom left /
|
|
||||||
26px 1.5px,
|
|
||||||
linear-gradient(var(--color-hairline), var(--color-hairline)) bottom left /
|
|
||||||
1.5px 26px,
|
|
||||||
linear-gradient(var(--color-hairline), var(--color-hairline)) bottom right /
|
|
||||||
26px 1.5px,
|
|
||||||
linear-gradient(var(--color-hairline), var(--color-hairline)) bottom right /
|
|
||||||
1.5px 26px;
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Mobile lightness (<md): cheaper blur, shorter animations ── */
|
.game-nav-item.is-active .game-sweep i,
|
||||||
@media (max-width: 767px) {
|
.game-nav-item:hover .game-sweep i {
|
||||||
.glass {
|
transform: translateY(0);
|
||||||
backdrop-filter: blur(8px);
|
|
||||||
-webkit-backdrop-filter: blur(8px);
|
|
||||||
}
|
|
||||||
.game-nav-item {
|
|
||||||
animation-duration: 0.25s;
|
|
||||||
animation-delay: calc(var(--i) * 18ms);
|
|
||||||
}
|
|
||||||
.scan-line::after,
|
|
||||||
.animate-shimmer {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (prefers-reduced-motion: reduce) {
|
@media (prefers-reduced-motion: reduce) {
|
||||||
.scan-line::after,
|
.animate-breathe,
|
||||||
.scan-line,
|
|
||||||
.animate-eq,
|
|
||||||
.animate-spin-disc,
|
.animate-spin-disc,
|
||||||
.animate-pulse-ring,
|
.animate-pulse-ring,
|
||||||
.animate-shimmer,
|
.animate-shimmer,
|
||||||
.animate-breathe,
|
.animate-eq,
|
||||||
.animate-fade-up,
|
.animate-fade-up,
|
||||||
.animate-stagger,
|
.animate-toast-in,
|
||||||
.animate-toast-in {
|
|
||||||
animation: none !important;
|
|
||||||
}
|
|
||||||
.scan-line {
|
.scan-line {
|
||||||
background: none !important;
|
animation: none !important;
|
||||||
}
|
}
|
||||||
*,
|
*,
|
||||||
*::before,
|
*::before,
|
||||||
@@ -460,7 +362,5 @@
|
|||||||
animation-duration: 0.001ms !important;
|
animation-duration: 0.001ms !important;
|
||||||
animation-iteration-count: 1 !important;
|
animation-iteration-count: 1 !important;
|
||||||
transition-duration: 0.001ms !important;
|
transition-duration: 0.001ms !important;
|
||||||
scroll-behavior: auto !important;
|
|
||||||
}
|
}
|
||||||
html { scroll-behavior: auto; }
|
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@ import type { Metadata, Viewport } from "next";
|
|||||||
import { Bricolage_Grotesque, Inter, JetBrains_Mono } from "next/font/google";
|
import { Bricolage_Grotesque, Inter, JetBrains_Mono } from "next/font/google";
|
||||||
import { ThemeProvider } from "next-themes";
|
import { ThemeProvider } from "next-themes";
|
||||||
import { Toaster } from "@/components/primitives/toast";
|
import { Toaster } from "@/components/primitives/toast";
|
||||||
|
import { SwrProvider } from "@/components/providers";
|
||||||
import "./globals.css";
|
import "./globals.css";
|
||||||
|
|
||||||
const inter = Inter({
|
const inter = Inter({
|
||||||
@@ -47,6 +48,7 @@ export default function RootLayout({
|
|||||||
suppressHydrationWarning
|
suppressHydrationWarning
|
||||||
>
|
>
|
||||||
<body className="min-h-full flex flex-col">
|
<body className="min-h-full flex flex-col">
|
||||||
|
<SwrProvider>
|
||||||
<ThemeProvider
|
<ThemeProvider
|
||||||
attribute="class"
|
attribute="class"
|
||||||
defaultTheme="dark"
|
defaultTheme="dark"
|
||||||
@@ -57,6 +59,7 @@ export default function RootLayout({
|
|||||||
{children}
|
{children}
|
||||||
<Toaster position="bottom-right" />
|
<Toaster position="bottom-right" />
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
|
</SwrProvider>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ export function CategoryDrilldown({
|
|||||||
<span className="w-36 shrink-0 truncate text-ink-soft">
|
<span className="w-36 shrink-0 truncate text-ink-soft">
|
||||||
{c.name}
|
{c.name}
|
||||||
</span>
|
</span>
|
||||||
<div className="h-2 flex-1 overflow-hidden rounded-full bg-white/5">
|
<div className="h-2 flex-1 overflow-hidden rounded-full bg-hairline">
|
||||||
<div
|
<div
|
||||||
className="h-full rounded-full bg-signal"
|
className="h-full rounded-full bg-signal"
|
||||||
style={{ width: `${pct}%` }}
|
style={{ width: `${pct}%` }}
|
||||||
|
|||||||
@@ -1,23 +1,73 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { GlassPanel } from "@/components/primitives";
|
import { Activity, Download, Hash } from "lucide-react";
|
||||||
|
import { useMemo, useState } from "react";
|
||||||
|
import { Badge, GlassPanel } from "@/components/primitives";
|
||||||
import { SectionHeader } from "@/components/shared";
|
import { SectionHeader } from "@/components/shared";
|
||||||
|
import { useStaggerReveal } from "@/hooks/use-gsap-animation";
|
||||||
import { downloadCsv } from "@/lib/csv";
|
import { downloadCsv } from "@/lib/csv";
|
||||||
import { formatRelativeTime } from "@/lib/format";
|
import { formatRelativeTime } from "@/lib/format";
|
||||||
import type { ChannelCultureRow } from "@/lib/types";
|
import type { ChannelCultureRow } from "@/lib/types";
|
||||||
|
|
||||||
|
function deriveSignalStrength(c: ChannelCultureRow): number {
|
||||||
|
let score = 0.3;
|
||||||
|
if (c.culture_summary) {
|
||||||
|
score += Math.min(0.45, c.culture_summary.length / 350);
|
||||||
|
}
|
||||||
|
if (c.last_analyzed_at) {
|
||||||
|
const ageMs = Date.now() - c.last_analyzed_at;
|
||||||
|
const days = ageMs / (1000 * 60 * 60 * 24);
|
||||||
|
score += Math.max(0, 0.25 - days * 0.015);
|
||||||
|
}
|
||||||
|
return Math.max(0.12, Math.min(1, score));
|
||||||
|
}
|
||||||
|
|
||||||
export function ChannelCultureGlossary({
|
export function ChannelCultureGlossary({
|
||||||
cultures,
|
cultures,
|
||||||
}: {
|
}: {
|
||||||
cultures: ChannelCultureRow[];
|
cultures: ChannelCultureRow[];
|
||||||
}) {
|
}) {
|
||||||
|
const [filter, setFilter] = useState("");
|
||||||
|
|
||||||
|
const ranked = useMemo(() => {
|
||||||
|
return cultures
|
||||||
|
.map((c) => ({ c, signal: deriveSignalStrength(c) }))
|
||||||
|
.sort((a, b) => b.signal - a.signal);
|
||||||
|
}, [cultures]);
|
||||||
|
|
||||||
|
const filtered = useMemo(() => {
|
||||||
|
if (!filter.trim()) return ranked;
|
||||||
|
const q = filter.toLowerCase();
|
||||||
|
return ranked.filter(
|
||||||
|
({ c }) =>
|
||||||
|
c.channel_name?.toLowerCase().includes(q) ||
|
||||||
|
c.channel_id.toLowerCase().includes(q) ||
|
||||||
|
c.culture_summary?.toLowerCase().includes(q),
|
||||||
|
);
|
||||||
|
}, [ranked, filter]);
|
||||||
|
|
||||||
|
const containerRef = useStaggerReveal<HTMLDivElement>(".channel-node-card", {
|
||||||
|
stagger: 0.03,
|
||||||
|
y: 10,
|
||||||
|
dependencies: [filtered.length, filter],
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<GlassPanel className="lg:col-span-3">
|
<div className="space-y-4">
|
||||||
<SectionHeader
|
{/* Search and Quick Filters */}
|
||||||
eyebrow="culture"
|
<GlassPanel className="flex flex-wrap items-center justify-between gap-3 p-3">
|
||||||
title="Channel Culture Glossary"
|
<div className="relative flex-1 min-w-[220px]">
|
||||||
action={
|
<Hash className="absolute left-3 top-1/2 size-4 -translate-y-1/2 text-ink-faint" />
|
||||||
cultures.length > 0 ? (
|
<input
|
||||||
|
type="text"
|
||||||
|
placeholder="Filter channels or culture topics..."
|
||||||
|
value={filter}
|
||||||
|
onChange={(e) => setFilter(e.target.value)}
|
||||||
|
className="w-full rounded-[6px] border border-hairline bg-surface-2 py-1.5 pl-9 pr-3 text-xs text-ink placeholder:text-ink-faint focus:border-signal focus:outline-none"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
{cultures.length > 0 && (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
@@ -30,42 +80,103 @@ export function ChannelCultureGlossary({
|
|||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
className="flex items-center gap-1.5 text-xs text-ink-soft hover:text-ink"
|
className="inline-flex items-center gap-1.5 rounded-[6px] border border-hairline bg-surface-2 px-3 py-1.5 font-mono text-[11px] text-ink-soft transition-colors hover:bg-surface hover:text-ink"
|
||||||
>
|
>
|
||||||
CSV
|
<Download className="size-3.5 text-signal" />
|
||||||
|
EXPORT_CSV
|
||||||
</button>
|
</button>
|
||||||
) : null
|
)}
|
||||||
|
</div>
|
||||||
|
</GlassPanel>
|
||||||
|
|
||||||
|
{/* Channel Nodes Grid */}
|
||||||
|
<GlassPanel>
|
||||||
|
<SectionHeader
|
||||||
|
eyebrow="Roster Telemetry"
|
||||||
|
title="Channel Culture & Activity Spectrum"
|
||||||
|
action={
|
||||||
|
<span className="mono text-xs text-ink-faint">
|
||||||
|
{filtered.length} of {cultures.length} channels
|
||||||
|
</span>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
{cultures.length === 0 ? (
|
|
||||||
<p className="py-6 text-center text-xs text-ink-faint">
|
{filtered.length === 0 ? (
|
||||||
No channel cultures captured yet.
|
<div className="py-12 text-center font-mono text-xs text-ink-faint">
|
||||||
|
NO MATCHING CHANNEL TELEMETRY FOUND
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div
|
||||||
|
ref={containerRef}
|
||||||
|
className="mt-4 grid gap-3 sm:grid-cols-2 lg:grid-cols-3"
|
||||||
|
>
|
||||||
|
{filtered.map(({ c, signal }) => {
|
||||||
|
const pct = Math.round(signal * 100);
|
||||||
|
const isHighSignal = signal > 0.65;
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={c.channel_id}
|
||||||
|
className="channel-node-card hud-card group relative flex flex-col justify-between overflow-hidden p-4"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
{/* Channel Card Header */}
|
||||||
|
<div className="flex items-center justify-between gap-2 border-b border-hairline pb-2.5">
|
||||||
|
<div className="flex items-center gap-2 min-w-0">
|
||||||
|
<span className="flex size-6 items-center justify-center rounded bg-surface-2 text-signal">
|
||||||
|
<Hash className="size-3.5" />
|
||||||
|
</span>
|
||||||
|
<span className="truncate font-mono text-xs font-semibold text-ink">
|
||||||
|
{c.channel_name ?? c.channel_id.slice(0, 10)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<Badge
|
||||||
|
tone={isHighSignal ? "signal" : "neutral"}
|
||||||
|
className="font-mono text-[10px]"
|
||||||
|
>
|
||||||
|
{pct}% SIGNAL
|
||||||
|
</Badge>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Culture Summary */}
|
||||||
|
<div className="mt-3">
|
||||||
|
{c.culture_summary ? (
|
||||||
|
<p className="font-sans text-xs text-ink-soft leading-relaxed line-clamp-3">
|
||||||
|
{c.culture_summary}
|
||||||
</p>
|
</p>
|
||||||
) : (
|
) : (
|
||||||
<div className="space-y-3">
|
<p className="font-mono text-[11px] text-ink-faint italic">
|
||||||
{cultures.map((c) => (
|
Awaiting AI culture profile synthesis...
|
||||||
<div key={c.channel_id} className="text-sm">
|
</p>
|
||||||
<div className="flex items-baseline justify-between">
|
|
||||||
<span className="font-medium text-ink">
|
|
||||||
{c.channel_name ?? c.channel_id}
|
|
||||||
</span>
|
|
||||||
{c.last_analyzed_at && (
|
|
||||||
<span className="text-xs text-ink-faint">
|
|
||||||
{formatRelativeTime(c.last_analyzed_at)}
|
|
||||||
</span>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{c.culture_summary ? (
|
|
||||||
<p className="mt-1 text-ink-faint">{c.culture_summary}</p>
|
|
||||||
) : (
|
|
||||||
<span className="text-xs text-ink-faint">
|
|
||||||
(no summary captured)
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
))}
|
|
||||||
|
{/* Signal Strength Bar & Timestamp */}
|
||||||
|
<div className="mt-4 pt-3 border-t border-hairline">
|
||||||
|
<div className="flex items-center justify-between font-mono text-[10px] text-ink-faint mb-1.5">
|
||||||
|
<span className="flex items-center gap-1">
|
||||||
|
<Activity className="size-3 text-signal" />
|
||||||
|
INTEL RATIO
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
{c.last_analyzed_at
|
||||||
|
? formatRelativeTime(c.last_analyzed_at)
|
||||||
|
: "NEVER"}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className="h-1.5 w-full overflow-hidden rounded-full bg-surface-2">
|
||||||
|
<div
|
||||||
|
className="h-full rounded-full bg-signal transition-all duration-500"
|
||||||
|
style={{ width: `${pct}%` }}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</GlassPanel>
|
</GlassPanel>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,17 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { Badge, GlassPanel } from "@/components/primitives";
|
import { useGSAP } from "@gsap/react";
|
||||||
|
import gsap from "gsap";
|
||||||
|
import { CheckCircle2, ShieldAlert, UserX, VolumeX } from "lucide-react";
|
||||||
|
import { useRef } from "react";
|
||||||
|
import { Badge } from "@/components/primitives";
|
||||||
import { formatRelativeTime } from "@/lib/format";
|
import { formatRelativeTime } from "@/lib/format";
|
||||||
import type { ModerationAction } from "@/lib/types";
|
import type { ModerationAction } from "@/lib/types";
|
||||||
|
|
||||||
|
if (typeof window !== "undefined") {
|
||||||
|
gsap.registerPlugin(useGSAP);
|
||||||
|
}
|
||||||
|
|
||||||
const ACTION_LABEL: Record<string, string> = {
|
const ACTION_LABEL: Record<string, string> = {
|
||||||
delete_message: "Deleted",
|
delete_message: "Deleted",
|
||||||
timeout_user: "Timeout",
|
timeout_user: "Timeout",
|
||||||
@@ -15,6 +23,21 @@ const ACTION_LABEL: Record<string, string> = {
|
|||||||
none: "None",
|
none: "None",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function actionIcon(type: string) {
|
||||||
|
switch (type) {
|
||||||
|
case "ban_user":
|
||||||
|
case "kick_user":
|
||||||
|
return <UserX className="size-3.5 text-vermilion" />;
|
||||||
|
case "timeout_user":
|
||||||
|
return <VolumeX className="size-3.5 text-amber" />;
|
||||||
|
case "delete_message":
|
||||||
|
case "warn_user":
|
||||||
|
return <ShieldAlert className="size-3.5 text-signal" />;
|
||||||
|
default:
|
||||||
|
return <CheckCircle2 className="size-3.5 text-success" />;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function severityTone(
|
function severityTone(
|
||||||
sev?: string | null,
|
sev?: string | null,
|
||||||
): "signal" | "amber" | "vermilion" | null {
|
): "signal" | "amber" | "vermilion" | null {
|
||||||
@@ -36,67 +59,110 @@ export function LiveModerationFeed({
|
|||||||
}: {
|
}: {
|
||||||
actions: ModerationAction[];
|
actions: ModerationAction[];
|
||||||
}) {
|
}) {
|
||||||
|
const feedRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
|
useGSAP(
|
||||||
|
() => {
|
||||||
|
if (!feedRef.current) return;
|
||||||
|
const items = feedRef.current.querySelectorAll(".mod-feed-item");
|
||||||
|
if (items.length === 0) return;
|
||||||
|
|
||||||
|
const prefersReduced = window.matchMedia(
|
||||||
|
"(prefers-reduced-motion: reduce)",
|
||||||
|
).matches;
|
||||||
|
if (prefersReduced) return;
|
||||||
|
|
||||||
|
gsap.fromTo(
|
||||||
|
items,
|
||||||
|
{ opacity: 0, x: -8 },
|
||||||
|
{
|
||||||
|
opacity: 1,
|
||||||
|
x: 0,
|
||||||
|
duration: 0.32,
|
||||||
|
stagger: 0.025,
|
||||||
|
ease: "power2.out",
|
||||||
|
clearProps: "transform",
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
{ scope: feedRef, dependencies: [actions.length] },
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<GlassPanel className="flex max-h-[420px] flex-col">
|
<div className="flex max-h-[460px] flex-col">
|
||||||
<div className="flex items-center justify-between border-b border-white/10 px-4 py-3">
|
<div className="flex items-center justify-between border-b border-hairline pb-3">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<span className="relative flex size-2.5">
|
<span className="relative flex size-2">
|
||||||
<span className="absolute inline-flex size-full animate-ping rounded-full bg-emerald-400 opacity-75" />
|
<span className="absolute inline-flex size-full animate-ping rounded-full bg-success opacity-75" />
|
||||||
<span className="relative inline-flex size-2.5 rounded-full bg-emerald-500" />
|
<span className="relative inline-flex size-2 rounded-full bg-success" />
|
||||||
|
</span>
|
||||||
|
<span className="font-mono text-xs font-medium text-ink">
|
||||||
|
Live Stream Audit Log
|
||||||
</span>
|
</span>
|
||||||
<h3 className="text-sm font-medium text-ink">Live Feed</h3>
|
|
||||||
</div>
|
</div>
|
||||||
<span className="text-xs text-ink-faint">{actions.length} recent</span>
|
<span className="font-mono text-[11px] text-ink-faint">
|
||||||
|
{actions.length} RECENT ACTIONS
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex-1 overflow-y-auto">
|
<div ref={feedRef} className="flex-1 space-y-2 overflow-y-auto pt-3 pr-1">
|
||||||
{actions.length === 0 ? (
|
{actions.length === 0 ? (
|
||||||
<p className="px-4 py-6 text-center text-xs text-ink-faint">
|
<div className="py-12 text-center font-mono text-xs text-ink-faint">
|
||||||
Waiting for new moderation actions…
|
AWAITING MODERATION DISPATCH STREAM...
|
||||||
</p>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<ul className="divide-y divide-white/5">
|
actions.map((a) => {
|
||||||
{actions.map((a, i) => {
|
|
||||||
const tone = severityTone(a.severity);
|
const tone = severityTone(a.severity);
|
||||||
return (
|
return (
|
||||||
<li
|
<div
|
||||||
key={a.id}
|
key={a.id}
|
||||||
className={`flex items-start gap-3 px-4 py-3 ${
|
className="mod-feed-item hud-card flex items-start gap-3 p-3 transition-all"
|
||||||
i === 0 ? "animate-[fadeIn_0.4s_ease-out]" : ""
|
|
||||||
}`}
|
|
||||||
>
|
>
|
||||||
<div className="min-w-0 flex-1">
|
<span className="flex size-7 shrink-0 items-center justify-center rounded-[6px] border border-hairline bg-surface-2">
|
||||||
<div className="flex items-center gap-2">
|
{actionIcon(a.action_type)}
|
||||||
<Badge tone={tone ?? "signal"} className="capitalize">
|
|
||||||
{ACTION_LABEL[a.action_type] ?? a.action_type}
|
|
||||||
</Badge>
|
|
||||||
{a.severity && (
|
|
||||||
<span className="text-xs text-ink-faint">
|
|
||||||
{a.severity}
|
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
|
<div className="min-w-0 flex-1">
|
||||||
|
<div className="flex flex-wrap items-center gap-2">
|
||||||
|
<span className="font-mono text-xs font-semibold text-ink">
|
||||||
|
{ACTION_LABEL[a.action_type] ?? a.action_type}
|
||||||
|
</span>
|
||||||
|
{a.severity && (
|
||||||
|
<Badge
|
||||||
|
tone={tone ?? "signal"}
|
||||||
|
className="font-mono text-[9px] uppercase"
|
||||||
|
>
|
||||||
|
{a.severity}
|
||||||
|
</Badge>
|
||||||
)}
|
)}
|
||||||
{a.categories?.length ? (
|
{a.categories?.length ? (
|
||||||
<span className="truncate text-xs text-ink-soft">
|
<span className="truncate font-mono text-[10px] text-ink-faint">
|
||||||
{a.categories.slice(0, 3).join(", ")}
|
[{a.categories.slice(0, 2).join(", ")}]
|
||||||
</span>
|
</span>
|
||||||
) : null}
|
) : null}
|
||||||
|
<span className="ml-auto font-mono text-[10px] text-ink-faint">
|
||||||
|
{formatRelativeTime(a.created_at)}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{a.reason && (
|
{a.reason && (
|
||||||
<p className="mt-1 truncate text-xs text-ink-soft">
|
<p className="mt-1 font-sans text-xs text-ink-soft line-clamp-2">
|
||||||
“{a.reason}”
|
“{a.reason}”
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
<p className="mt-0.5 text-[11px] text-ink-faint">
|
|
||||||
{a.username ?? a.user_id ?? "unknown"} ·{" "}
|
<div className="mt-1.5 flex items-center gap-2 font-mono text-[10px] text-ink-faint">
|
||||||
{formatRelativeTime(a.created_at)}
|
<span>TARGET:</span>
|
||||||
</p>
|
<span className="text-ink-soft">
|
||||||
|
{a.username ?? a.user_id ?? "UNKNOWN_SUBJECT"}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
|
||||||
);
|
);
|
||||||
})}
|
})
|
||||||
</ul>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</GlassPanel>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -8,9 +8,9 @@ import { cn } from "@/lib/utils";
|
|||||||
export function ModerationHeatmap({ hours }: { hours: HourlyModeration[] }) {
|
export function ModerationHeatmap({ hours }: { hours: HourlyModeration[] }) {
|
||||||
const max = hours.reduce((m, h) => Math.max(m, h.total), 0);
|
const max = hours.reduce((m, h) => Math.max(m, h.total), 0);
|
||||||
const intensity = (v: number) => {
|
const intensity = (v: number) => {
|
||||||
if (max <= 0) return "bg-white/5";
|
if (max <= 0) return "bg-hairline";
|
||||||
const t = Math.max(0, Math.min(1, v / max));
|
const t = Math.max(0, Math.min(1, v / max));
|
||||||
if (t < 0.25) return "bg-white/[0.06]";
|
if (t < 0.25) return "bg-surface-2";
|
||||||
if (t < 0.5) return "bg-signal/25";
|
if (t < 0.5) return "bg-signal/25";
|
||||||
if (t < 0.75) return "bg-signal/50";
|
if (t < 0.75) return "bg-signal/50";
|
||||||
return "bg-vermilion/60";
|
return "bg-vermilion/60";
|
||||||
|
|||||||
@@ -48,9 +48,9 @@ export function ScamDomains({ domains }: { domains: FlaggedDomain[] }) {
|
|||||||
<span className="w-44 shrink-0 truncate font-mono text-ink-soft">
|
<span className="w-44 shrink-0 truncate font-mono text-ink-soft">
|
||||||
{d.domain}
|
{d.domain}
|
||||||
</span>
|
</span>
|
||||||
<div className="h-2 flex-1 overflow-hidden rounded-full bg-white/5">
|
<div className="h-2 flex-1 overflow-hidden rounded-full bg-hairline">
|
||||||
<div
|
<div
|
||||||
className="h-full rounded-full bg-[#8b5cf6]"
|
className="h-full rounded-full bg-signal"
|
||||||
style={{ width: `${pct}%` }}
|
style={{ width: `${pct}%` }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,20 +1,119 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { Globe } from "lucide-react";
|
import { ChevronDown, Download, Globe, Search } from "lucide-react";
|
||||||
import { GlassPanel } from "@/components/primitives";
|
import { useMemo, useRef, useState } from "react";
|
||||||
|
import { Badge, GlassPanel } from "@/components/primitives";
|
||||||
import { SectionHeader } from "@/components/shared";
|
import { SectionHeader } from "@/components/shared";
|
||||||
|
import { useStaggerReveal } from "@/hooks/use-gsap-animation";
|
||||||
import { downloadCsv } from "@/lib/csv";
|
import { downloadCsv } from "@/lib/csv";
|
||||||
import { formatRelativeTime } from "@/lib/format";
|
import { formatRelativeTime } from "@/lib/format";
|
||||||
import type { GlossaryRow } from "@/lib/types";
|
import type { GlossaryRow } from "@/lib/types";
|
||||||
|
|
||||||
export function TermGlossary({ terms }: { terms: GlossaryRow[] }) {
|
function GlossaryEntry({ t }: { t: GlossaryRow }) {
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
const bodyRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<GlassPanel className="lg:col-span-3">
|
<div className="glossary-entry hud-card overflow-hidden transition-all">
|
||||||
<SectionHeader
|
<button
|
||||||
eyebrow="knowledge"
|
type="button"
|
||||||
title="Term Knowledge Base"
|
onClick={() => setOpen((v) => !v)}
|
||||||
action={
|
className="flex w-full items-center justify-between gap-3 px-3.5 py-3 text-left transition-colors"
|
||||||
terms.length > 0 ? (
|
aria-expanded={open}
|
||||||
|
>
|
||||||
|
<div className="flex min-w-0 items-baseline gap-2.5">
|
||||||
|
<span className="truncate font-mono text-xs font-semibold text-ink">
|
||||||
|
{t.term}
|
||||||
|
</span>
|
||||||
|
<Badge tone="signal" className="font-mono text-[9px]">
|
||||||
|
{t.hit_count} hits
|
||||||
|
</Badge>
|
||||||
|
</div>
|
||||||
|
<div className="flex shrink-0 items-center gap-2.5 font-mono text-[10px] text-ink-faint">
|
||||||
|
<span>{formatRelativeTime(t.resolved_at)}</span>
|
||||||
|
<ChevronDown
|
||||||
|
className={`size-3.5 text-ink-muted transition-transform duration-200 ${open ? "rotate-180 text-ink" : ""}`}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
<div
|
||||||
|
ref={bodyRef}
|
||||||
|
className="grid transition-[grid-template-rows] duration-300 ease-out"
|
||||||
|
style={{ gridTemplateRows: open ? "1fr" : "0fr" }}
|
||||||
|
>
|
||||||
|
<div className="overflow-hidden">
|
||||||
|
<div className="border-t border-hairline bg-surface-2 px-3.5 py-2.5 text-xs">
|
||||||
|
<p className="font-sans text-ink-soft leading-relaxed">
|
||||||
|
{t.definition}
|
||||||
|
</p>
|
||||||
|
{t.source_url && (
|
||||||
|
<a
|
||||||
|
href={t.source_url}
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
className="mt-2 inline-flex items-center gap-1.5 font-mono text-[10px] text-signal hover:underline"
|
||||||
|
>
|
||||||
|
<Globe className="size-3" />
|
||||||
|
{t.source_url}
|
||||||
|
</a>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function TermGlossary({ terms }: { terms: GlossaryRow[] }) {
|
||||||
|
const [filter, setFilter] = useState("");
|
||||||
|
|
||||||
|
const filtered = useMemo(() => {
|
||||||
|
if (!filter.trim()) return terms;
|
||||||
|
const q = filter.toLowerCase();
|
||||||
|
return terms.filter(
|
||||||
|
(t) =>
|
||||||
|
t.term.toLowerCase().includes(q) ||
|
||||||
|
t.definition?.toLowerCase().includes(q),
|
||||||
|
);
|
||||||
|
}, [terms, filter]);
|
||||||
|
|
||||||
|
const listRef = useStaggerReveal<HTMLDivElement>(".glossary-entry", {
|
||||||
|
stagger: 0.025,
|
||||||
|
y: 8,
|
||||||
|
dependencies: [filtered.length, filter],
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="space-y-4">
|
||||||
|
{/* Tactical HUD Header Bar */}
|
||||||
|
<div className="flex flex-wrap items-center justify-between gap-3 border-b border-hairline pb-3">
|
||||||
|
<div className="flex items-center gap-2.5">
|
||||||
|
<span className="h-2 w-2 rounded-full bg-signal shadow-[0_0_8px_var(--color-signal-glow)]" />
|
||||||
|
<h1 className="font-mono text-xs font-semibold tracking-wide text-ink uppercase">
|
||||||
|
Slang & Term Glossary · Knowledge Base
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-2 font-mono text-[11px] text-ink-muted">
|
||||||
|
<span>INDEXED:</span>
|
||||||
|
<span className="rounded bg-signal/15 px-2 py-0.5 font-medium text-signal border border-signal/30">
|
||||||
|
{terms.length} TERMS_RECORDED
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Filter and Action Bar */}
|
||||||
|
<GlassPanel className="flex flex-wrap items-center justify-between gap-3 p-3">
|
||||||
|
<div className="relative flex-1 min-w-[220px]">
|
||||||
|
<Search className="absolute left-3 top-1/2 size-4 -translate-y-1/2 text-ink-faint" />
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
placeholder="Search slang term or definition keywords..."
|
||||||
|
value={filter}
|
||||||
|
onChange={(e) => setFilter(e.target.value)}
|
||||||
|
className="w-full rounded-[6px] border border-hairline bg-surface-2 py-1.5 pl-9 pr-3 text-xs text-ink placeholder:text-ink-faint focus:border-signal focus:outline-none"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{terms.length > 0 && (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
@@ -29,43 +128,36 @@ export function TermGlossary({ terms }: { terms: GlossaryRow[] }) {
|
|||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
className="flex items-center gap-1.5 text-xs text-ink-soft hover:text-ink"
|
className="inline-flex items-center gap-1.5 rounded-[6px] border border-hairline bg-surface-2 px-3 py-1.5 font-mono text-[11px] text-ink-soft transition-colors hover:bg-surface hover:text-ink"
|
||||||
>
|
>
|
||||||
CSV
|
<Download className="size-3.5 text-signal" />
|
||||||
|
EXPORT_CSV
|
||||||
</button>
|
</button>
|
||||||
) : null
|
)}
|
||||||
|
</GlassPanel>
|
||||||
|
|
||||||
|
<GlassPanel>
|
||||||
|
<SectionHeader
|
||||||
|
eyebrow="knowledge directory"
|
||||||
|
title="Slang & Definition Index"
|
||||||
|
action={
|
||||||
|
<span className="mono text-xs text-ink-muted">
|
||||||
|
{filtered.length} of {terms.length} terms
|
||||||
|
</span>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
{terms.length === 0 ? (
|
{filtered.length === 0 ? (
|
||||||
<p className="py-6 text-center text-xs text-ink-faint">
|
<div className="py-12 text-center font-mono text-xs text-ink-faint">
|
||||||
No term resolutions cached yet.
|
NO TERM DEFINITIONS MATCH YOUR FILTER
|
||||||
</p>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="space-y-3">
|
<div ref={listRef} className="space-y-1.5 mt-3">
|
||||||
{terms.map((t) => (
|
{filtered.map((t) => (
|
||||||
<div key={t.term} className="text-sm">
|
<GlossaryEntry key={t.term} t={t} />
|
||||||
<div className="flex flex-wrap items-baseline justify-between gap-2">
|
|
||||||
<span className="font-medium text-ink">{t.term}</span>
|
|
||||||
<span className="text-xs text-ink-faint">
|
|
||||||
{t.hit_count} uses · {formatRelativeTime(t.resolved_at)}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<p className="mt-1 text-ink-faint">{t.definition}</p>
|
|
||||||
{t.source_url && (
|
|
||||||
<a
|
|
||||||
href={t.source_url}
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
className="mt-0.5 text-xs text-ink-soft hover:text-ink"
|
|
||||||
>
|
|
||||||
<Globe className="mr-1 inline size-3" />
|
|
||||||
{t.source_url}
|
|
||||||
</a>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</GlassPanel>
|
</GlassPanel>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -53,9 +53,9 @@ export function TopChannels({ channels }: { channels: FlaggedChannel[] }) {
|
|||||||
<span className="w-40 shrink-0 truncate text-ink-soft">
|
<span className="w-40 shrink-0 truncate text-ink-soft">
|
||||||
{c.channel_name ?? c.channel_id}
|
{c.channel_name ?? c.channel_id}
|
||||||
</span>
|
</span>
|
||||||
<div className="h-2 flex-1 overflow-hidden rounded-full bg-white/5">
|
<div className="h-2 flex-1 overflow-hidden rounded-full bg-hairline">
|
||||||
<div
|
<div
|
||||||
className="h-full rounded-full bg-[#f59e0b]"
|
className="h-full rounded-full bg-amber"
|
||||||
style={{ width: `${pct}%` }}
|
style={{ width: `${pct}%` }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ function BarRow({
|
|||||||
return (
|
return (
|
||||||
<div className="flex items-center gap-3 text-sm">
|
<div className="flex items-center gap-3 text-sm">
|
||||||
<span className="w-32 shrink-0 truncate text-ink-soft">{label}</span>
|
<span className="w-32 shrink-0 truncate text-ink-soft">{label}</span>
|
||||||
<div className="h-2 flex-1 overflow-hidden rounded-full bg-white/5">
|
<div className="h-2 flex-1 overflow-hidden rounded-full bg-hairline">
|
||||||
<div
|
<div
|
||||||
className="h-full rounded-full"
|
className="h-full rounded-full"
|
||||||
style={{ width: `${pct}%`, background: color }}
|
style={{ width: `${pct}%`, background: color }}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export function Equalizer({
|
|||||||
{Array.from({ length: 28 }).map((_, i) => (
|
{Array.from({ length: 28 }).map((_, i) => (
|
||||||
<span
|
<span
|
||||||
key={`eq-${i}`}
|
key={`eq-${i}`}
|
||||||
className="flex-1 rounded-full bg-white/10"
|
className="flex-1 rounded-full bg-hairline"
|
||||||
style={{ height: "12%" }}
|
style={{ height: "12%" }}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -1,312 +1,263 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import { useGSAP } from "@gsap/react";
|
||||||
|
import gsap from "gsap";
|
||||||
import {
|
import {
|
||||||
Bot,
|
Bot,
|
||||||
Check,
|
Loader2,
|
||||||
Copy,
|
Maximize2,
|
||||||
MessageCircle,
|
Minimize2,
|
||||||
RotateCw,
|
Send,
|
||||||
Trash2,
|
Sparkles,
|
||||||
X,
|
X,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useEffect, useRef, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
import { Avatar, Button, GlassPanel, toast } from "@/components/primitives";
|
import { Button } from "@/components/primitives";
|
||||||
import { MarkdownLite } from "@/components/shared";
|
|
||||||
import { useChatbotUserId } from "@/hooks/use-chatbot-user";
|
import { useChatbotUserId } from "@/hooks/use-chatbot-user";
|
||||||
import { chatbotApi } from "@/lib/api";
|
import { chatbotApi } from "@/lib/api";
|
||||||
import { cn } from "@/lib/utils";
|
import { formatRelativeTime } from "@/lib/format";
|
||||||
|
|
||||||
interface Msg {
|
if (typeof window !== "undefined") {
|
||||||
|
gsap.registerPlugin(useGSAP);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ChatMessage {
|
||||||
id: string;
|
id: string;
|
||||||
role: "user" | "bot";
|
sender: "user" | "bot";
|
||||||
content: string;
|
text: string;
|
||||||
ts: number;
|
timestamp: number;
|
||||||
}
|
|
||||||
|
|
||||||
function formatTime(ts: number): string {
|
|
||||||
try {
|
|
||||||
return new Date(ts).toLocaleTimeString([], {
|
|
||||||
hour: "2-digit",
|
|
||||||
minute: "2-digit",
|
|
||||||
});
|
|
||||||
} catch {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function TypingDots() {
|
|
||||||
return (
|
|
||||||
<div className="flex items-center gap-1 py-1">
|
|
||||||
{[0, 1, 2].map((i) => (
|
|
||||||
<span
|
|
||||||
key={i}
|
|
||||||
className="size-1.5 rounded-full bg-ink-faint animate-bounce"
|
|
||||||
style={{ animationDelay: `${i * 0.15}s`, animationDuration: "0.9s" }}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Chatbot() {
|
export function Chatbot() {
|
||||||
const userId = useChatbotUserId();
|
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const [msgs, setMsgs] = useState<Msg[]>([]);
|
const [expanded, setExpanded] = useState(false);
|
||||||
|
const [messages, setMessages] = useState<ChatMessage[]>([]);
|
||||||
const [input, setInput] = useState("");
|
const [input, setInput] = useState("");
|
||||||
const [loading, setLoading] = useState(false);
|
const [sending, setSending] = useState(false);
|
||||||
const [failed, setFailed] = useState<string | null>(null);
|
const userId = useChatbotUserId();
|
||||||
const [copiedId, setCopiedId] = useState<string | null>(null);
|
|
||||||
const listRef = useRef<HTMLDivElement>(null);
|
|
||||||
const taRef = useRef<HTMLTextAreaElement>(null);
|
|
||||||
const bottomRef = useRef<HTMLDivElement>(null);
|
|
||||||
|
|
||||||
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
|
const scrollRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
|
// Load history on mount
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!open || !userId) return;
|
|
||||||
chatbotApi
|
chatbotApi
|
||||||
.getHistory(userId)
|
.getHistory(userId || undefined)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
setMsgs(
|
if (res.history) {
|
||||||
res.history.slice(-12).flatMap((h) => [
|
const loaded: ChatMessage[] = res.history.flatMap((h) => [
|
||||||
{
|
{
|
||||||
id: `${h.id}-u`,
|
id: `${h.id}-u`,
|
||||||
role: "user" as const,
|
sender: "user",
|
||||||
content: h.user_message,
|
text: h.user_message,
|
||||||
ts: Date.parse(h.created_at) || Date.now(),
|
timestamp: new Date(h.created_at).getTime(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: `${h.id}-b`,
|
id: `${h.id}-b`,
|
||||||
role: "bot" as const,
|
sender: "bot",
|
||||||
content: h.bot_response,
|
text: h.bot_response,
|
||||||
ts: Date.parse(h.created_at) || Date.now(),
|
timestamp: new Date(h.created_at).getTime() + 100,
|
||||||
},
|
},
|
||||||
]),
|
]);
|
||||||
);
|
setMessages(loaded);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
}, [open, userId]);
|
}, [userId]);
|
||||||
|
|
||||||
// Auto-scroll to newest whenever the thread or typing state changes.
|
// Auto-scroll to bottom on new messages
|
||||||
// biome-ignore lint/correctness/useExhaustiveDependencies: scroll must fire on thread/typing changes even though the body only reads the ref
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
bottomRef.current?.scrollIntoView({ behavior: "smooth", block: "end" });
|
if (scrollRef.current) {
|
||||||
}, [msgs, loading, open]);
|
scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
|
||||||
|
|
||||||
// Auto-grow the composer.
|
|
||||||
// biome-ignore lint/correctness/useExhaustiveDependencies: height recompute is keyed to input changes; body only reads the textarea element
|
|
||||||
useEffect(() => {
|
|
||||||
const ta = taRef.current;
|
|
||||||
if (!ta) return;
|
|
||||||
ta.style.height = "auto";
|
|
||||||
ta.style.height = `${Math.min(ta.scrollHeight, 140)}px`;
|
|
||||||
}, [input]);
|
|
||||||
|
|
||||||
const copy = async (id: string, text: string) => {
|
|
||||||
try {
|
|
||||||
await navigator.clipboard.writeText(text);
|
|
||||||
setCopiedId(id);
|
|
||||||
window.setTimeout(() => setCopiedId((c) => (c === id ? null : c)), 1200);
|
|
||||||
} catch {
|
|
||||||
/* clipboard unavailable */
|
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
const clearAll = async () => {
|
// GSAP animation for floating window
|
||||||
if (!userId) return;
|
useGSAP(
|
||||||
setMsgs([]);
|
() => {
|
||||||
try {
|
if (!containerRef.current) return;
|
||||||
await chatbotApi.clearHistory(userId);
|
if (open) {
|
||||||
} catch {
|
gsap.fromTo(
|
||||||
/* best-effort */
|
containerRef.current,
|
||||||
|
{ opacity: 0, scale: 0.95, y: 15 },
|
||||||
|
{ opacity: 1, scale: 1, y: 0, duration: 0.25, ease: "power2.out" },
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
const send = async (text: string) => {
|
|
||||||
if (!text.trim() || loading || !userId) return;
|
|
||||||
setFailed(null);
|
|
||||||
setInput("");
|
|
||||||
setMsgs((m) => [
|
|
||||||
...m,
|
|
||||||
{ id: `u-${Date.now()}`, role: "user", content: text, ts: Date.now() },
|
|
||||||
]);
|
|
||||||
setLoading(true);
|
|
||||||
try {
|
|
||||||
const res = await chatbotApi.send(text, undefined, userId);
|
|
||||||
setMsgs((m) => [
|
|
||||||
...m,
|
|
||||||
{
|
|
||||||
id: `b-${Date.now()}`,
|
|
||||||
role: "bot",
|
|
||||||
content: res.response,
|
|
||||||
ts: Date.parse(res.timestamp) || Date.now(),
|
|
||||||
},
|
},
|
||||||
]);
|
{ dependencies: [open], scope: containerRef },
|
||||||
} catch (e) {
|
);
|
||||||
setFailed(text);
|
|
||||||
toast({ title: "Chat error", description: String(e), tone: "vermilion" });
|
const handleSend = async (e: React.FormEvent) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const query = input.trim();
|
||||||
|
if (!query || sending) return;
|
||||||
|
|
||||||
|
const userMsg: ChatMessage = {
|
||||||
|
id: `u-${Date.now()}`,
|
||||||
|
sender: "user",
|
||||||
|
text: query,
|
||||||
|
timestamp: Date.now(),
|
||||||
|
};
|
||||||
|
|
||||||
|
setMessages((prev) => [...prev, userMsg]);
|
||||||
|
setInput("");
|
||||||
|
setSending(true);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await chatbotApi.send(query, undefined, userId || "operator");
|
||||||
|
const botMsg: ChatMessage = {
|
||||||
|
id: `b-${Date.now()}`,
|
||||||
|
sender: "bot",
|
||||||
|
text: res.response || "No response received.",
|
||||||
|
timestamp: Date.now(),
|
||||||
|
};
|
||||||
|
setMessages((prev) => [...prev, botMsg]);
|
||||||
|
} catch {
|
||||||
|
const errMsg: ChatMessage = {
|
||||||
|
id: `err-${Date.now()}`,
|
||||||
|
sender: "bot",
|
||||||
|
text: "Signal telemetry fault. Failed to communicate with neural core.",
|
||||||
|
timestamp: Date.now(),
|
||||||
|
};
|
||||||
|
setMessages((prev) => [...prev, errMsg]);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setSending(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
{/* Floating Tactical Launcher Button */}
|
||||||
|
{!open && (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
aria-label="Open assistant"
|
aria-label="Open neural HUD assistant"
|
||||||
onClick={() => setOpen((o) => !o)}
|
onClick={() => setOpen(true)}
|
||||||
className="fixed right-4 bottom-24 z-50 flex items-center justify-center rounded-full bg-signal text-signal-ink shadow-[0_10px_30px_-8px_var(--color-signal-glow)] transition-transform hover:scale-105 md:right-5 md:bottom-5"
|
className="fixed right-4 bottom-5 z-50 flex size-11 items-center justify-center rounded-full border border-signal/40 bg-surface text-signal shadow-[0_0_20px_var(--color-signal-glow)] transition-all duration-200 hover:scale-105 hover:border-signal hover:bg-signal hover:text-white"
|
||||||
style={{ width: 52, height: 52 }}
|
|
||||||
>
|
>
|
||||||
{open ? <X className="size-5" /> : <MessageCircle className="size-5" />}
|
<Sparkles className="size-5 animate-breathe" />
|
||||||
</button>
|
</button>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Neural Assistant Dialog */}
|
||||||
{open && (
|
{open && (
|
||||||
<GlassPanel
|
<div
|
||||||
className="fixed right-4 bottom-24 z-50 flex w-[min(94vw,360px)] flex-col p-0 md:right-5 md:bottom-20"
|
ref={containerRef}
|
||||||
style={{
|
className={`glass fixed right-4 bottom-18 z-50 flex flex-col p-0 shadow-2xl transition-all duration-200 ${
|
||||||
animation: "fade-up 0.16s ease",
|
expanded
|
||||||
height: "min(68dvh, 520px)",
|
? "h-[min(85dvh,680px)] w-[min(94vw,540px)]"
|
||||||
}}
|
: "h-[min(65dvh,480px)] w-[min(92vw,360px)]"
|
||||||
|
}`}
|
||||||
>
|
>
|
||||||
<div className="flex items-center gap-2 border-b border-hairline px-4 py-3">
|
{/* Header */}
|
||||||
<span className="flex size-8 items-center justify-center rounded-full bg-signal/15 text-signal">
|
<div className="flex items-center justify-between border-b border-hairline px-3.5 py-2.5">
|
||||||
<Bot className="size-4" />
|
<div className="flex items-center gap-2">
|
||||||
|
<span className="flex size-6 items-center justify-center rounded-[4px] bg-signal/15 text-signal">
|
||||||
|
<Bot className="size-3.5" />
|
||||||
</span>
|
</span>
|
||||||
<div>
|
<div>
|
||||||
<div className="text-sm font-semibold text-ink">
|
<span className="font-mono text-xs font-bold text-ink">
|
||||||
GMW Assistant
|
Neural Core Assistant
|
||||||
|
</span>
|
||||||
|
<span className="ml-2 font-mono text-[10px] text-success">
|
||||||
|
● ACTIVE
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="mono text-[0.6rem] text-ink-faint">
|
|
||||||
context-aware
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
aria-label="Clear conversation"
|
|
||||||
onClick={clearAll}
|
|
||||||
className="ml-auto rounded-[9px] p-1.5 text-ink-faint transition-colors hover:bg-white/5 hover:text-ink-soft"
|
|
||||||
>
|
|
||||||
<Trash2 className="size-4" />
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div className="flex items-center gap-1">
|
||||||
ref={listRef}
|
<button
|
||||||
className="flex-1 space-y-3 overflow-y-auto px-4 py-3"
|
type="button"
|
||||||
|
onClick={() => setExpanded(!expanded)}
|
||||||
|
className="rounded-md p-1 text-ink-muted hover:bg-surface-2 hover:text-ink"
|
||||||
>
|
>
|
||||||
{msgs.length === 0 && !loading && (
|
{expanded ? (
|
||||||
<div className="py-8 text-center text-xs text-ink-faint">
|
<Minimize2 className="size-3.5" />
|
||||||
Ask about moderation, voice, or media.
|
) : (
|
||||||
</div>
|
<Maximize2 className="size-3.5" />
|
||||||
)}
|
)}
|
||||||
{msgs.map((m) => (
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => setOpen(false)}
|
||||||
|
className="rounded-md p-1 text-ink-muted hover:bg-surface-2 hover:text-ink"
|
||||||
|
>
|
||||||
|
<X className="size-3.5" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Messages Body */}
|
||||||
|
<div
|
||||||
|
ref={scrollRef}
|
||||||
|
className="flex-1 space-y-3 overflow-y-auto p-3.5"
|
||||||
|
>
|
||||||
|
{messages.length === 0 ? (
|
||||||
|
<div className="flex h-full flex-col items-center justify-center text-center font-mono text-xs text-ink-muted">
|
||||||
|
<Sparkles className="mb-2 size-6 text-signal opacity-60" />
|
||||||
|
<span>Neural Assistant ready.</span>
|
||||||
|
<span className="text-[10px] text-ink-faint">
|
||||||
|
Ask about telemetry, moderation policies, or channel activity.
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
messages.map((m) => {
|
||||||
|
const isUser = m.sender === "user";
|
||||||
|
return (
|
||||||
<div
|
<div
|
||||||
key={m.id}
|
key={m.id}
|
||||||
className={cn(
|
className={`flex flex-col ${
|
||||||
"group flex gap-2",
|
isUser ? "items-end" : "items-start"
|
||||||
m.role === "user" ? "justify-end" : "justify-start",
|
}`}
|
||||||
)}
|
|
||||||
>
|
>
|
||||||
{m.role === "bot" && (
|
|
||||||
<Avatar
|
|
||||||
name="GMW"
|
|
||||||
size={26}
|
|
||||||
className="mt-0.5 bg-signal/15 text-signal"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<div className="flex max-w-[82%] flex-col">
|
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={`max-w-[85%] rounded-[8px] p-2.5 text-xs leading-relaxed ${
|
||||||
"rounded-2xl px-3 py-2 text-sm",
|
isUser
|
||||||
m.role === "user"
|
? "bg-signal text-white"
|
||||||
? "rounded-br-sm bg-signal/20 text-ink"
|
: "hud-card text-ink-soft"
|
||||||
: "rounded-bl-sm bg-white/5 text-ink-soft",
|
}`}
|
||||||
)}
|
|
||||||
>
|
>
|
||||||
{m.role === "bot" ? (
|
{m.text}
|
||||||
<MarkdownLite content={m.content} />
|
</div>
|
||||||
) : (
|
<span className="mt-1 font-mono text-[9px] text-ink-faint">
|
||||||
<span className="whitespace-pre-wrap break-words">
|
{formatRelativeTime(m.timestamp)}
|
||||||
{m.content}
|
|
||||||
</span>
|
</span>
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
className={cn(
|
|
||||||
"mt-0.5 flex items-center gap-1.5 text-[0.6rem] text-ink-faint",
|
|
||||||
m.role === "user" && "flex-row-reverse",
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<span className="mono">{formatTime(m.ts)}</span>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
aria-label="Copy message"
|
|
||||||
onClick={() => copy(m.id, m.content)}
|
|
||||||
className="rounded p-0.5 opacity-0 transition-opacity hover:text-ink-soft group-hover:opacity-100"
|
|
||||||
>
|
|
||||||
{copiedId === m.id ? (
|
|
||||||
<Check className="size-3 text-signal" />
|
|
||||||
) : (
|
|
||||||
<Copy className="size-3" />
|
|
||||||
)}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
{loading && (
|
|
||||||
<div className="flex gap-2">
|
|
||||||
<Avatar
|
|
||||||
name="GMW"
|
|
||||||
size={26}
|
|
||||||
className="bg-signal/15 text-signal"
|
|
||||||
/>
|
|
||||||
<div className="rounded-2xl rounded-bl-sm bg-white/5 px-3 py-2">
|
|
||||||
<TypingDots />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<div ref={bottomRef} />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{failed && (
|
|
||||||
<div className="mx-3 mb-1 flex items-center gap-2 rounded-[10px] border border-vermilion/30 bg-vermilion/10 px-3 py-1.5 text-xs text-vermilion">
|
|
||||||
<span className="flex-1 truncate">Send failed</span>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={() => send(failed)}
|
|
||||||
className="inline-flex items-center gap-1 font-medium hover:underline"
|
|
||||||
>
|
|
||||||
<RotateCw className="size-3" /> Retry
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
|
);
|
||||||
|
})
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="flex items-end gap-2 border-t border-hairline p-3">
|
{sending && (
|
||||||
<textarea
|
<div className="flex items-center gap-2 font-mono text-xs text-ink-muted">
|
||||||
ref={taRef}
|
<Loader2 className="size-3.5 animate-spin text-signal" />
|
||||||
rows={1}
|
<span>Processing vector inference...</span>
|
||||||
placeholder="Message…"
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Input Footer */}
|
||||||
|
<form
|
||||||
|
onSubmit={handleSend}
|
||||||
|
className="flex items-center gap-1.5 border-t border-hairline p-2"
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
placeholder="Transmit instruction to core..."
|
||||||
value={input}
|
value={input}
|
||||||
onChange={(e) => setInput(e.target.value)}
|
onChange={(e) => setInput(e.target.value)}
|
||||||
onKeyDown={(e) => {
|
className="flex-1 rounded-[6px] border border-hairline bg-surface-2 px-3 py-1.5 font-mono text-xs text-ink placeholder:text-ink-faint focus:border-signal focus:outline-none"
|
||||||
if (e.key === "Enter" && !e.shiftKey) {
|
|
||||||
e.preventDefault();
|
|
||||||
send(input);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
className="max-h-[140px] min-h-[40px] flex-1 resize-none rounded-[11px] bg-white/5 border border-hairline px-3 py-2 text-sm text-ink placeholder:text-ink-faint transition-colors focus:outline-none focus:border-signal/50 focus:bg-white/8"
|
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
variant="primary"
|
variant="primary"
|
||||||
size="icon"
|
size="sm"
|
||||||
onClick={() => send(input)}
|
type="submit"
|
||||||
disabled={loading}
|
disabled={!input.trim() || sending}
|
||||||
|
className="px-2.5"
|
||||||
>
|
>
|
||||||
<MessageCircle className="size-4" />
|
<Send className="size-3.5" />
|
||||||
</Button>
|
</Button>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</GlassPanel>
|
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ export function CommandPalette() {
|
|||||||
placeholder="Type a command or search…"
|
placeholder="Type a command or search…"
|
||||||
className="flex-1 bg-transparent text-sm text-ink outline-none placeholder:text-ink-faint"
|
className="flex-1 bg-transparent text-sm text-ink outline-none placeholder:text-ink-faint"
|
||||||
/>
|
/>
|
||||||
<kbd className="mono rounded bg-white/8 px-1.5 py-0.5 text-[0.6rem] text-ink-faint">
|
<kbd className="mono rounded bg-surface-2 px-1.5 py-0.5 text-[0.6rem] text-ink-faint">
|
||||||
ESC
|
ESC
|
||||||
</kbd>
|
</kbd>
|
||||||
</div>
|
</div>
|
||||||
@@ -156,11 +156,11 @@ export function CommandPalette() {
|
|||||||
key={c.id}
|
key={c.id}
|
||||||
className={`flex w-full items-center gap-3 rounded-[10px] px-3 py-2.5 text-left text-sm transition-colors ${
|
className={`flex w-full items-center gap-3 rounded-[10px] px-3 py-2.5 text-left text-sm transition-colors ${
|
||||||
i === active
|
i === active
|
||||||
? "bg-signal/12 text-ink"
|
? "bg-signal/15 text-ink"
|
||||||
: "text-ink-soft hover:bg-white/5"
|
: "text-ink-soft hover:bg-surface"
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<span className="flex size-7 items-center justify-center rounded-[8px] bg-white/5">
|
<span className="flex size-7 items-center justify-center rounded-[8px] bg-surface-2">
|
||||||
{c.icon}
|
{c.icon}
|
||||||
</span>
|
</span>
|
||||||
<span className="flex-1">{c.label}</span>
|
<span className="flex-1">{c.label}</span>
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ export function MiniPlayer() {
|
|||||||
className="flex min-w-0 flex-1 items-center gap-3"
|
className="flex min-w-0 flex-1 items-center gap-3"
|
||||||
aria-label="Open full media player"
|
aria-label="Open full media player"
|
||||||
>
|
>
|
||||||
<span className="relative flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-full border border-hairline bg-white/5">
|
<span className="relative flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-full border border-hairline bg-surface-2">
|
||||||
{current.thumbnailUrl ? (
|
{current.thumbnailUrl ? (
|
||||||
// biome-ignore lint/performance/noImgElement: external CDN thumbnails, next/image needs remote allowlist
|
// biome-ignore lint/performance/noImgElement: external CDN thumbnails, next/image needs remote allowlist
|
||||||
<img
|
<img
|
||||||
@@ -130,7 +130,7 @@ export function MiniPlayer() {
|
|||||||
onClick={() => skip.mutate()}
|
onClick={() => skip.mutate()}
|
||||||
disabled={skip.isPending}
|
disabled={skip.isPending}
|
||||||
aria-label="Skip to next track"
|
aria-label="Skip to next track"
|
||||||
className="flex size-8 items-center justify-center rounded-full text-ink-soft transition-colors hover:bg-white/10 hover:text-signal active:scale-95"
|
className="flex size-8 items-center justify-center rounded-full text-ink-soft transition-colors hover:bg-surface hover:text-signal active:scale-95"
|
||||||
>
|
>
|
||||||
<SkipForward className="size-4" />
|
<SkipForward className="size-4" />
|
||||||
</button>
|
</button>
|
||||||
@@ -151,7 +151,7 @@ export function MiniPlayer() {
|
|||||||
className={`hidden size-8 items-center justify-center rounded-full text-xs transition-colors sm:flex ${
|
className={`hidden size-8 items-center justify-center rounded-full text-xs transition-colors sm:flex ${
|
||||||
media?.loop
|
media?.loop
|
||||||
? "bg-signal/15 text-signal"
|
? "bg-signal/15 text-signal"
|
||||||
: "text-ink-faint hover:bg-white/10 hover:text-ink"
|
: "text-ink-faint hover:bg-surface hover:text-ink"
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
↻
|
↻
|
||||||
|
|||||||
@@ -1,39 +1,52 @@
|
|||||||
|
import type React from "react";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
type Tone = "signal" | "amber" | "vermilion" | "neutral";
|
export interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement> {
|
||||||
|
tone?: "neutral" | "signal" | "amber" | "vermilion" | "success";
|
||||||
const tones: Record<Tone, string> = {
|
size?: "sm" | "md";
|
||||||
signal: "bg-signal/12 text-signal border-signal/30",
|
dot?: boolean;
|
||||||
amber: "bg-amber/12 text-amber border-amber/30",
|
}
|
||||||
vermilion: "bg-vermilion/12 text-vermilion border-vermilion/30",
|
|
||||||
neutral: "bg-white/6 text-ink-soft border-white/10",
|
|
||||||
};
|
|
||||||
|
|
||||||
export function Badge({
|
export function Badge({
|
||||||
tone = "neutral",
|
tone = "neutral",
|
||||||
dot,
|
size = "md",
|
||||||
|
dot = false,
|
||||||
className,
|
className,
|
||||||
children,
|
children,
|
||||||
}: {
|
...props
|
||||||
tone?: Tone;
|
}: BadgeProps) {
|
||||||
dot?: boolean;
|
const tones = {
|
||||||
className?: string;
|
neutral: "bg-surface-2 text-ink-soft border-hairline",
|
||||||
children: React.ReactNode;
|
signal: "bg-signal/15 text-signal border-signal/30",
|
||||||
}) {
|
success: "bg-success/15 text-success border-success/30",
|
||||||
|
amber: "bg-amber/15 text-amber border-amber/30",
|
||||||
|
vermilion: "bg-vermilion/15 text-vermilion border-vermilion/30",
|
||||||
|
};
|
||||||
|
|
||||||
|
const dots = {
|
||||||
|
neutral: "bg-ink-muted",
|
||||||
|
signal: "bg-signal",
|
||||||
|
success: "bg-success",
|
||||||
|
amber: "bg-amber",
|
||||||
|
vermilion: "bg-vermilion",
|
||||||
|
};
|
||||||
|
|
||||||
|
const sizes = {
|
||||||
|
sm: "px-1.5 py-0.5 text-[10px]",
|
||||||
|
md: "px-2 py-0.5 text-[11px]",
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
className={cn(
|
className={cn(
|
||||||
"inline-flex items-center gap-1.5 rounded-full border px-2.5 py-0.5 text-[0.7rem] font-semibold tracking-wide",
|
"inline-flex items-center gap-1.5 rounded-[6px] border font-mono font-medium tracking-tight",
|
||||||
tones[tone],
|
tones[tone],
|
||||||
|
sizes[size],
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
|
{...props}
|
||||||
>
|
>
|
||||||
{dot && (
|
{dot && <span className={cn("size-1.5 rounded-full", dots[tone])} />}
|
||||||
<span className="relative flex h-1.5 w-1.5">
|
|
||||||
<span className="absolute inline-flex h-full w-full rounded-full bg-current opacity-60 animate-pulse-ring" />
|
|
||||||
<span className="relative inline-flex h-1.5 w-1.5 rounded-full bg-current" />
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
{children}
|
{children}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,51 +1,59 @@
|
|||||||
|
import type React from "react";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { Slot } from "./slot";
|
|
||||||
|
|
||||||
type Variant = "primary" | "ghost" | "outline" | "danger" | "subtle";
|
export const buttonVariants = ({
|
||||||
type Size = "sm" | "md" | "lg" | "icon";
|
variant = "primary",
|
||||||
|
size = "md",
|
||||||
|
className,
|
||||||
|
}: {
|
||||||
|
variant?: "primary" | "ghost" | "danger" | "secondary" | "subtle" | "outline";
|
||||||
|
size?: "sm" | "md" | "lg" | "icon";
|
||||||
|
className?: string;
|
||||||
|
}) => {
|
||||||
|
const base =
|
||||||
|
"inline-flex items-center justify-center font-sans font-medium transition-all duration-150 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-signal disabled:pointer-events-none disabled:opacity-40 cursor-pointer";
|
||||||
|
|
||||||
const variants: Record<Variant, string> = {
|
const variants = {
|
||||||
primary:
|
primary:
|
||||||
"bg-signal text-signal-ink hover:brightness-110 shadow-[0_8px_24px_-10px_var(--color-signal-glow)] font-semibold",
|
"bg-signal text-white hover:opacity-90 shadow-xs active:scale-[0.98]",
|
||||||
ghost: "text-ink-soft hover:text-ink hover:bg-white/5",
|
ghost:
|
||||||
|
"bg-surface-2 text-ink-soft border border-hairline hover:bg-surface hover:text-ink hover:border-hairline-focus active:scale-[0.98]",
|
||||||
outline:
|
outline:
|
||||||
"border border-hairline bg-white/0 text-ink hover:bg-white/5 hover:border-signal/40",
|
"bg-transparent text-ink-soft border border-hairline hover:bg-surface-2 hover:text-ink active:scale-[0.98]",
|
||||||
|
secondary:
|
||||||
|
"bg-surface text-ink hover:bg-surface-2 border border-hairline active:scale-[0.98]",
|
||||||
|
subtle: "bg-transparent text-ink-muted hover:bg-surface-2 hover:text-ink",
|
||||||
danger:
|
danger:
|
||||||
"bg-vermilion text-white hover:brightness-110 shadow-[0_8px_24px_-10px_var(--color-vermilion-glow)] font-semibold",
|
"bg-vermilion/15 text-vermilion border border-vermilion/30 hover:bg-vermilion/25 active:scale-[0.98]",
|
||||||
subtle: "bg-white/5 text-ink hover:bg-white/10",
|
};
|
||||||
};
|
|
||||||
|
|
||||||
const sizes: Record<Size, string> = {
|
const sizes = {
|
||||||
sm: "h-8 px-3 text-xs rounded-[9px] gap-1.5",
|
sm: "h-7 px-2.5 text-xs rounded-[8px] gap-1.5",
|
||||||
md: "h-10 px-4 text-sm rounded-[11px] gap-2",
|
md: "h-8.5 px-3.5 text-xs rounded-[8px] gap-2",
|
||||||
lg: "h-12 px-6 text-base rounded-[13px] gap-2",
|
lg: "h-10 px-4 text-sm rounded-[8px] gap-2.5",
|
||||||
icon: "h-10 w-10 rounded-[11px]",
|
icon: "size-8.5 rounded-[8px] p-0",
|
||||||
|
};
|
||||||
|
|
||||||
|
return cn(base, variants[variant], sizes[size], className);
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface ButtonProps
|
export interface ButtonProps
|
||||||
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
||||||
variant?: Variant;
|
variant?: "primary" | "ghost" | "danger" | "secondary" | "subtle" | "outline";
|
||||||
size?: Size;
|
size?: "sm" | "md" | "lg" | "icon";
|
||||||
asChild?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Button = ({
|
export const Button = ({
|
||||||
className,
|
className,
|
||||||
variant = "subtle",
|
variant = "ghost",
|
||||||
size = "md",
|
size = "md",
|
||||||
asChild,
|
type = "button",
|
||||||
...props
|
...props
|
||||||
}: ButtonProps) => {
|
}: ButtonProps) => {
|
||||||
const Comp = asChild ? Slot : "button";
|
|
||||||
return (
|
return (
|
||||||
<Comp
|
<button
|
||||||
className={cn(
|
type={type}
|
||||||
"inline-flex items-center justify-center whitespace-nowrap transition-all duration-150 select-none active:scale-[0.97]",
|
className={buttonVariants({ variant, size, className })}
|
||||||
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-signal/60 disabled:opacity-40 disabled:pointer-events-none",
|
|
||||||
variants[variant],
|
|
||||||
sizes[size],
|
|
||||||
className,
|
|
||||||
)}
|
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,19 +1,24 @@
|
|||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
/** Floating glass panel — primary container. */
|
export interface GlassPanelProps extends React.HTMLAttributes<HTMLDivElement> {
|
||||||
|
glow?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export function GlassPanel({
|
export function GlassPanel({
|
||||||
className,
|
|
||||||
children,
|
children,
|
||||||
|
className,
|
||||||
|
style,
|
||||||
glow,
|
glow,
|
||||||
...props
|
...props
|
||||||
}: React.HTMLAttributes<HTMLDivElement> & { glow?: boolean }) {
|
}: GlassPanelProps) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
"glass p-5",
|
"relative rounded-[10px] border border-hairline bg-surface p-5 shadow-xl backdrop-blur-md transition-all duration-200",
|
||||||
glow && "shadow-[0_0_40px_-18px_var(--color-signal-glow)]",
|
glow && "shadow-[0_0_24px_var(--color-signal-glow)] border-signal/30",
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
|
style={style}
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
@@ -21,14 +26,21 @@ export function GlassPanel({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Smaller glass sub-panel. */
|
|
||||||
export function GlassCard({
|
export function GlassCard({
|
||||||
className,
|
|
||||||
children,
|
children,
|
||||||
|
className,
|
||||||
|
style,
|
||||||
...props
|
...props
|
||||||
}: React.HTMLAttributes<HTMLDivElement>) {
|
}: React.HTMLAttributes<HTMLDivElement>) {
|
||||||
return (
|
return (
|
||||||
<div className={cn("glass-2 p-4", className)} {...props}>
|
<div
|
||||||
|
className={cn(
|
||||||
|
"relative rounded-[8px] border border-hairline bg-surface-2 p-4 transition-all duration-200 hover:border-hairline-focus hover:bg-surface",
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
style={style}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ export function Input({
|
|||||||
return (
|
return (
|
||||||
<input
|
<input
|
||||||
className={cn(
|
className={cn(
|
||||||
"h-10 w-full rounded-[11px] bg-white/5 border border-hairline px-3.5 text-sm text-ink",
|
"h-10 w-full rounded-[8px] bg-surface-2 border border-hairline px-3.5 text-sm text-ink",
|
||||||
"placeholder:text-ink-faint transition-colors",
|
"placeholder:text-ink-faint transition-colors",
|
||||||
"focus:outline-none focus:border-signal/50 focus:bg-white/8",
|
"focus:outline-none focus:border-signal/50 focus:bg-surface",
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
@@ -24,9 +24,9 @@ export function Textarea({
|
|||||||
return (
|
return (
|
||||||
<textarea
|
<textarea
|
||||||
className={cn(
|
className={cn(
|
||||||
"w-full rounded-[11px] bg-white/5 border border-hairline px-3.5 py-2.5 text-sm text-ink",
|
"w-full rounded-[8px] bg-surface-2 border border-hairline px-3.5 py-2.5 text-sm text-ink",
|
||||||
"placeholder:text-ink-faint transition-colors resize-none",
|
"placeholder:text-ink-faint transition-colors resize-none",
|
||||||
"focus:outline-none focus:border-signal/50 focus:bg-white/8",
|
"focus:outline-none focus:border-signal/50 focus:bg-surface",
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export function Progress({
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
"h-1.5 w-full overflow-hidden rounded-full bg-white/8",
|
"h-1.5 w-full overflow-hidden rounded-full bg-hairline",
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
@@ -39,7 +39,7 @@ export function Spinner({ className }: { className?: string }) {
|
|||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
className={cn(
|
className={cn(
|
||||||
"inline-block size-4 animate-spin rounded-full border-2 border-white/20 border-t-signal",
|
"inline-block size-4 animate-spin rounded-full border-2 border-hairline border-t-signal",
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ export function Select({
|
|||||||
type="button"
|
type="button"
|
||||||
onClick={() => setOpen((o) => !o)}
|
onClick={() => setOpen((o) => !o)}
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex w-full items-center justify-between gap-2 rounded-[11px] border border-hairline bg-white/5 text-left text-ink transition-colors hover:border-signal/40",
|
"flex w-full items-center justify-between gap-2 rounded-[8px] border border-hairline bg-surface-2 text-left text-ink transition-colors hover:border-signal/40",
|
||||||
"focus:outline-none focus:border-signal/60",
|
"focus:outline-none focus:border-signal/60",
|
||||||
size === "sm" ? "h-9 px-3 text-xs" : "h-10 px-3.5 text-sm",
|
size === "sm" ? "h-9 px-3 text-xs" : "h-10 px-3.5 text-sm",
|
||||||
)}
|
)}
|
||||||
@@ -79,10 +79,10 @@ export function Select({
|
|||||||
setOpen(false);
|
setOpen(false);
|
||||||
}}
|
}}
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex w-full items-center justify-between gap-2 rounded-[9px] px-3 py-2 text-left text-sm transition-colors",
|
"flex w-full items-center justify-between gap-2 rounded-[8px] px-3 py-2 text-left text-sm transition-colors",
|
||||||
o.value === value
|
o.value === value
|
||||||
? "bg-signal/15 text-signal"
|
? "bg-signal/15 text-signal"
|
||||||
: "text-ink hover:bg-white/6",
|
: "text-ink hover:bg-surface",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<span className="truncate">{o.label}</span>
|
<span className="truncate">{o.label}</span>
|
||||||
|
|||||||
Loaded 50 of 71 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user