Commit Graph
351 Commits
Author SHA1 Message Date
asepharyana c9bc5f5b50 feat(leptos): Phase 4 Task 1 - voice/media control hooks 2026-07-03 20:55:19 +07:00
asepharyana 3de7f8d823 fix(leptos): resolve Phase 3 compilation errors
- Add PartialEq to MessageRecord and all nested types in shared-types
- Fix String references in view! macro by cloning owned values
- Fix match arm types with .into_any() in app.rs
- Clone on_load_more before FnMut closure in message_feed.rs
- Pre-compute class strings before passing to view! in message_card.rs
- Fix lifetime issues with imgs/vids/cats by using owned Vec<AttachmentRef>
- Use separate closures for different event types in mod.rs
- Fix disabled property to use signal pattern
- Fix filter chip closure signatures
2026-07-03 20:45:35 +07:00
asepharyana 63ddc1e112 fix(leptos): compile errors in Phase 3 message components - WIP
Fixed:
- Icon imports: Replaced lucide-leptos icons with SVG/emoji alternatives
- AnyView lifetime: Fixed render_emojis to use owned strings
- Missing html import in message_feed.rs
- use_messages: Removed #[component] to make it a regular function
- MessageRecord fields: Removed is_reply, is_forward, is_crosspost checks
- String wrapping in view! macros: Wrapped strings in <span> elements
- Closure handling: Changed .into_forget() to .forget() for web_sys Closure
- URL borrowing in image_grid: Clone URLs before using in view!

Remaining issues (in progress):
- String references in class attributes need owned values
- Type inference for None.into_any()
- Closure capture issues with on_load_more
- Match arm type incompatibilities

19 errors remaining out of 31 initial errors - ~61% fixed
2026-07-03 20:32:15 +07:00
asepharyana 9322434daa feat(leptos): messages module skeleton + use_messages hook 2026-07-03 20:14:59 +07:00
asepharyana 1b970a4c51 fix(leptos): wire format corrections from whole-branch review 2026-07-03 18:43:25 +07:00
asepharyana bf36bf55fe feat(leptos): integrate auth with API + WS auth gating 2026-07-03 18:30:41 +07:00
asepharyana 2520faad47 feat(leptos): app shell with auth gate and tab routing 2026-07-03 18:22:28 +07:00
asepharyana 5389c82f31 feat(leptos): layout components -- Header, Sidebar, TabStrip, MobileTabBar 2026-07-03 18:16:08 +07:00
asepharyana aa20d1a633 feat(leptos): API client with all endpoint functions 2026-07-03 18:09:30 +07:00
asepharyana 20ef844682 feat(leptos): WebSocket singleton with event dispatch 2026-07-03 18:07:01 +07:00
asepharyana 5832ca7cd4 feat(leptos): UI primitives — Skeleton, StatusBadge, EmptyState, Modal 2026-07-03 17:59:38 +07:00
asepharyana b9e3a255bb feat(leptos): UI primitives — Input, Select, Tabs, ScrollArea, Toast 2026-07-03 17:47:21 +07:00
asepharyana 2b514142e6 feat(leptos): UI primitives — Button, Badge, Card 2026-07-03 17:41:07 +07:00
asepharyana 65804acaca feat(leptos): css design system with component classes and animations 2026-07-03 17:36:28 +07:00
asepharyana c4c43ce912 feat(leptos): frontend crate scaffold with empty app
- frontend/ crate compiles to WASM via trunk
- empty Leptos app mounted to body via wasm_bindgen(start)
- dependencies: leptos 0.7 CSR, leptos-use, lucide-leptos, gloo-net, web-sys
- workspace cargo check passes (first time the workspace compiles end-to-end)
- trunk build produces 65KB WASM + 25KB JS glue

Deviations from brief:
- lucide-leptos: 0.5 (brief) -> 3 (only version published)
- web-sys: removed invalid features ArrayBuffer/DataView (in js-sys/wasm-bindgen)
- src/main.rs -> src/lib.rs with #[wasm_bindgen(start)] to avoid bin/lib duplicate artifact
2026-07-03 17:09:44 +07:00
asepharyana f67bc5125b fix(leptos): correct shared-types timestamps to match JSON wire format 2026-07-03 07:24:28 +07:00
asepharyana 0926f235cb fix(auth): only reset activeTab on mount, don't block tab switching
Previous code continuously forced activeTab to 'messages' when not
authenticated, making dashboard and voice tabs unclickable.
Now uses useEffect once on mount to reset localStorage carryover,
then lets tab switching work normally.
2026-07-02 07:45:02 +07:00
asepharyana 948e41cec6 fix(ui): chat bubble max-w-xs broken by tailwind spacing override (4px not 320px)
tailwind.config.js overrides spacing.xs to 4px, which also overrides
max-w-xs to max-width: 4px instead of the default 20rem (320px).
Changed to explicit max-w-[280px] to bypass the corrupted token.
2026-07-02 07:08:58 +07:00
asepharyana 77812f9452 fix(auth): force activeTab to messages if not authenticated — prevent localStorage carryover
When a user visited the Live tab in a previous session, localStorage
stored activeTab: 'live'. On page reload, even with the new auth guard,
the app would try to render the Live tab and show the auth overlay.
Now if not authenticated, activeTab is always forced to 'messages'.
2026-07-02 07:06:33 +07:00
asepharyana 58de0df24b fix(ui): chat bubble text wrapping — replace break-words with overflow-wrap:anywhere
Fixes MascotChatbot messages wrapping 1 character per line.
overflow-wrap:anywhere handles long unbroken strings better
than break-words which only breaks at word boundaries.
2026-07-02 06:53:27 +07:00
asepharyana ffea9bb0ba fix(backend): only require auth for voice/media routes, rest public
Messages, analysis, mascot-chat, recordings, ui-state, and guilds
endpoints are now accessible without authentication.
Only voice (connect/disconnect/transmit) and media (queue/skip/stop/volume)
remain behind the admin password guard.
2026-07-02 06:51:57 +07:00
asepharyana 0ae1ef1987 fix(auth): only guard Live tab, messages & dashboard are public
Auth overlay only shows when accessing Voice & Media without
authentication. Messages panel and Dashboard panel remain fully
accessible without login.
2026-07-02 06:40:39 +07:00
asepharyana 112b865a5b fix(infra): bypass Cloudflare Rocket Loader — breaks ES module scripts
Cloudflare Rocket Loader transforms <script type="module"> into
type="<hash>-module", which the browser cannot parse as ES module.
The React app never mounts — blank page on every route.

Fix: Vite plugin adds data-cfasync="false" attribute to the module
script tag, telling Rocket Loader to skip transformation.

Also: remove dist/ from the commit (build artifacts excluded).
2026-07-02 06:30:26 +07:00
asepharyana d53ec74d64 fix(build): resolve Tailwind 4 @apply breaking changes
- Replace @apply im-btn in im-btn-primary/secondary/ghost
  with inline Tailwind utilities + CSS properties
- Replace @apply im-status-dot in status dot variants
  with inline properties
- Tailwind 4 cannot @apply component-level classes from within
  @layer components — only standard utility classes are valid
2026-07-02 06:17:58 +07:00
asepharyanaandworkflow agents ade5d6a7c3 fix: backend and discord-gateway improvements
- Update shared database schema
- Add shared utils
- Refactor backend middleware, auth routes, and dashboard repository
- Improve media analysis client with better error handling
- Fix searxng search URL construction
- Update URL fetcher for robustness

Co-authored-by: workflow agents
2026-07-02 06:02:07 +07:00
asepharyana 81a004d250 feat(frontend): IMPHNEN design deep integration — full 5-layer redesign
Layer 0 — Foundation:
- Dark mode palette (30+ CSS var pairs in [data-theme='dark'])
- CSS-first theme engine in styles.css (@theme + CSS vars)
- UseTheme hook with light/dark/system support + localStorage persistence
- Fixed animation keyframes (shimmer 1.5s canonical, glowPulse moved to CSS)
- Smooth theme switch transitions via .theme-transitioning class

Layer 1 — Shared UI Components:
- Badge: success/warning variants now use CSS vars (bg-success-soft text-success)
- Toast: rewritten with CSS vars, z-index fixed (40), repositioned top-right
- Skeleton: added variant prop (rounded/circular/rectangular)
- EmptyState: new component with icon + title + description + action
- Button: added tertiary variant + icon-sm size
- Card: added elevated/bordered variants
- Input: added soft variant

Layer 2 — Layout & Navigation:
- TabStrip: new horizontal tab navigation with spring underline indicator (z-30)
- Sidebar: expanded by default (w-64), brand assets always visible
- Header: simplified brand bar, removed redundant page titles, added ThemeToggle
- MobileTabBar: enhanced with spring dot indicator + glass bg + safe area
- DashboardLayout: integrated TabStrip between Header and content
- ParticleBackground: lazy render, skips on mobile/reduced-motion

Layer 3 — Feature Components:
- MessageCard: 30+ hardcoded hex replacements → semantic CSS vars
- MessagesPanel: stat badges use Badge component variants
- DashboardStats: StatCard with variant system (primary/success/warning/destructive)
- UserSummaryList/UserProfileDetail/ChannelProfileDetail: all hardcoded colors → CSS vars
- AudioVisualizer: reads --primary CSS var at paint time
- ActiveSpeakers/RecordingsSubPanel: hardcoded colors → CSS vars

Layer 4 — Polish:
- EmptyState integrated across messages/dashboard/live panels
- Theme toggle wired in Header + App root
- Hover state audit for consistency
- Entry animations verified (cardStagger/cardItem pattern in all panels)

Resolves DESIGN_TOKENS.md §13.x issues: hardcoded colors, shimmer mismatch,
glow-pulse fragmentation, z-index collisions, toast positioning.
2026-07-02 05:58:36 +07:00
asepharyana bf9d018f7a fix: skip AI analysis for channel 1508059937031589949 2026-07-02 04:28:33 +07:00
asepharyana fa82593a38 fix: switch to node:22-slim, install deps from npm, remove vendor 2026-07-02 04:07:18 +07:00
asepharyana 7efaf00c93 Revert "feat: migrate frontend to Astro + expand AI moderation + backend admin/runtime config"
This reverts commit d59b59a7a7.
2026-07-02 03:54:44 +07:00
asepharyana bf86fcda8e Revert "feat: migrate frontend to Astro SSG with design system"
This reverts commit 8ad888da28.
2026-07-02 03:54:44 +07:00
asepharyana 24c738dd19 Revert "fix: split LiveShell into Astro layout + individual islands"
This reverts commit 6e1757410a.
2026-07-02 03:54:44 +07:00
asepharyana 5a10bec67a Revert "fix: replace Astro.redirect with direct live content at /"
This reverts commit 34ac4be6c2.
2026-07-02 03:54:44 +07:00
asepharyana 34ac4be6c2 fix: replace Astro.redirect with direct live content at / 2026-07-02 03:47:23 +07:00
asepharyana 6e1757410a fix: split LiveShell into Astro layout + individual islands
- Rewrite live.astro to use Astro Sidebar/Header/Card components
- VoiceControls becomes self-contained (fetches guilds/channels internally)
- Remove LiveShell.tsx (no longer needed)
- Each React island uses appropriate client:load/idle directive
2026-07-02 03:13:54 +07:00
asepharyana 8ad888da28 feat: migrate frontend to Astro SSG with design system
- Replace monolithic React SPA (App.tsx) with 7 Astro pages (+ routing)
- Implement full design system from design/ (OKLCH tokens, Tailwind 4 @theme)
- Add 12 Astro components (Button, Badge, Card, Sidebar, Header, states)
- Add 11 React islands (AuthGuard, MessageFeed, VoiceControls, AudioVisualizer, etc.)
- Add 3 Zustand stores (UI, voice, message state)
- Add CSS architecture: dark/light themes, glassmorphism, fluid typography, animations
- Add 404, login, settings, recordings pages
- Remove 40+ legacy React SPA files
- Add Particles background and MascotChat deferred islands
- Wire WebSocket bridge for real-time messages and voice events

Build: 7 pages in ~900ms
Typecheck: clean (0 errors)
Lint: clean (0 errors)
2026-07-02 01:18:45 +07:00
asepharyana d59b59a7a7 feat: migrate frontend to Astro + expand AI moderation + backend admin/runtime config
Frontend:
- migrate from Vite to Astro (astro.config.mjs, pages/, layouts/)
- add admin panel, settings page, command palette, error boundary
- refactor App.tsx, MascotChatbot, Sidebar, Header, DashboardLayout
- update API client, WebSocket, auth, dashboard features

Backend:
- add admin module and config routes
- refactor middlewares, Redis connection, WebSocket server/bridge
- add runtime config loader

Discord Gateway:
- refactor AI moderation: circuit breaker, concurrency limiter, fallback processor
- add media analysis client, Seaxng search, user profile learner
- add new drizzle migration

Shared:
- extend database schema, add new config fields
2026-07-02 00:02:41 +07:00
MythEclipse d5c22a3959 fix(discord-gateway): handle forwarded message content via messageSnapshots
Two-layer fix for forwarded messages showing as empty/clean:

Layer 1 (messageMetadata.ts): getReferencedMessageContent() now falls
back to message.messageSnapshots Collection when channel.messages.cache
lookup fails. Discord stores forward content in message_snapshots API
field, not in message.content.

Layer 2 (moderationBuilders.ts): buildReferenceXml() now parses msg.
metadata JSON to extract reference.content when DB getMessageById()
fails (cross-server forwards not in local DB).

Previously: forward messages captured with empty parentContent →
LLM saw no reference text → '99% confidence, pesan kosong'.
Now: forward content flows through capture → metadata → analysis.
2026-06-23 23:27:23 +07:00
MythEclipse ed4a506ca7 refactor: split llmModerationClient.ts + add tests + metrics
## Split llmModerationClient.ts (2103 → 3 files)
- **moderationBuilders.ts** (67 lines) — shared: escapeXml, getAnalysisContent, buildReferenceXml
- **mediaAnalysisClient.ts** (656 lines) — vision analysis with multi-layer LRU/DB/phash caching, image/video download, ffmpeg frame extraction, prepareMediaMessage
- **moderationOrchestrator.ts** (998 lines) — callModerationLLM, runTextOnlyBatch, runMediaBatch, runModerationAnalysis, runSimpleTextFallback
- **llmModerationClient.ts** (30 lines) — re-export bridge (backward compat)

No import changes needed — aiAnalysisWorker.ts still imports from llmModerationClient.js.

## Unit tests (backend)
- vitest.config.ts + e2e.test.ts with 9 tests against production:
  - health, metrics, dashboard/stats, recordings, config, auth, guilds, negative (404/400)

## Monitoring metrics
- moderationMetrics.ts in backend health module:
  - LLM call count/duration/tokens
  - Cache hit/miss per layer
  - Media analysis count/download duration
  - Batch size distribution, errors, SearXNG, auto-delete
2026-06-22 20:38:34 +07:00
MythEclipse a3c99a08c3 fix: recordings endpoint 500 — column 'transcription' doesn't exist
- SELECT transcription FROM voice_recordings fails because table has no such column
- Removed non-existent transcription from SELECT and interface
- Previous sql.raw() parameter binding also broken — fixed with proper drizzle sql``
2026-06-22 18:22:46 +07:00
MythEclipse 3a282d8467 fix: recordings endpoint 500 — broken SQL parameter binding
- Hand-rolled ,  params with sql.raw() didn't actually bind values
- Drizzle's sql.raw() just inserts literal text — no parameter binding
- Replaced with proper sql`` tagged templates + sql.join() for conditions
- Each filter now correctly binds via drizzle's parameterized query
2026-06-22 17:54:09 +07:00
MythEclipse ad84d0a1bb fix: messages with text+media also go into text batch immediately
- Previously: text+media message went ONLY to media array → text waited for vision
- Now: text part goes to text batch (immediate LLM analysis), media parallel
- DB update is idempotent — second write to same message_id overwrites
- User sees text moderation results instantly, media follows when ready
2026-06-22 17:45:32 +07:00
MythEclipse e8286247d6 fix: parallelize text + media LLM analysis instead of sequential
- text-only and media analysis now run concurrently via Promise.all
- text no longer blocks on media download + vision analysis
- each path independently saves to DB when its own results are ready
- same batch still uses single context fetch + attachment lookup
2026-06-22 17:42:46 +07:00
MythEclipse dfabdc85cd feat: search ALL messages via SearXNG + Redis cache dedup
- Remove shouldSearchContent() trigger gate — search runs on all messages
- extractSearchQueries() now extracts from ANY message, not just trigger-matched
- Redis cache (24h TTL) prevents redundant searches for same query
- initSearxngCache() lazy-connects via config.REDIS_URL
- Cache miss→API, hit→skip — fire-and-forget writes
- Both text batch + media path simplified
2026-06-22 12:41:48 +07:00
MythEclipse 84f87104e7 refactor: remove hardcoded lists from prompt, use SearXNG as single source of truth
- Remove hardcoded hentai title lists (Boku no Pico, Euphoria, etc.) from prompt
- Remove hardcoded SARA examples from prompt (Kitabonia, etc.)
- Prompt now tells LLM to use <web_searches> as evidence instead of hardcoded knowledge
- Evidence priority: searxng > web_content > media_analysis > internal model
- Code-side triggers in searxngSearch.ts still filter which messages to search
- LLM makes final decision based on search results, not static lists
2026-06-22 12:01:55 +07:00
MythEclipse 18ee8a35d2 feat: SearXNG search enrichment for moderation
- extractSearchQueries(): extract specific terms from trigger patterns
  instead of searching entire message (e.g. 'bokuno pico' from 'nonton bokuno pico anime')
- Add hentai studio/publisher triggers (Pink Pineapple, Maryjane, etc.)
- Fix media path SearXNG: use extractSearchQueries instead of quoted-only
- Prompt: add <web_searches> usage instructions so LLM actually uses search data
- Priority: searxng evidence > web_content > internal model knowledge
2026-06-22 10:58:52 +07:00
MythEclipse 641fb47d10 fix: hentai reference detection + severity high auto-delete
- Add explicit hentai title detection rule (Boku no Pico, Euphoria, Bible Black,
  Kuroinu, loli/shota) -> sexual_deviation severity high, recommended_action delete
- LLM flagged correctly but severity 'medium' caused auto-delete skip in fallback path
2026-06-22 10:28:16 +07:00
MythEclipse f502918b27 feat: multimodal video detection + reply/forward/crosspost + batch optimization
- Video frame extraction via ffmpeg (4 key frames per video → vision LLM)
- Video display in FE MessageCard with HTML5 <video> player
- Reply/forward/crosspost indicator in FE + pipeline in DG/BE
- Fix: missing sanitizeAiContent + escapeXml in media path (prompt injection)
- Optimize: text-only batch results saved to DB immediately, no longer wait for media analysis
- BE mapper/schema/repo: add reference fields (is_reply, is_forward, etc.)
2026-06-22 09:46:06 +07:00
MythEclipse dc62b283c0 refactor(ai-moderation): fix all 8 issues per review
- #2: Duplikasi contoh → single-source ALL_EXAMPLES array + formatExamples()
- #3: Hierarki evasion → Level 1 (Wajib Flag) vs Level 2 (Pilih Clean)
- #4: Dead code → remove duplicate PromptMode, cleanup
- #5: Sanitasi AI content → sanitizeAiContent() + CDATA wrapping for
      channel culture & user profile (prevents prompt injection)
- #6: Contoh personality → match actual XML format (<message>,
      <user_profile>, <content> tags instead of plain text)
- #7: Contoh invite link → example #29 added
- #8: 'Deskripsi selesai.' removed from stickerPrompt.ts
- Image analysis balance: teks = gambar (equal weight), no more bias
- Removed LGBT exclusion from SYSTEM_RULES
- Removed all template fallback language, enforce specific descriptions
2026-06-21 22:14:59 +07:00
MythEclipse 04f2862abc feat(ai-moderation): profile learner ai_status filter + channel-aware + simple fallback memory
- userProfileLearner.ts: filter query to only clean messages (eq ai_status='clean')
  to prevent profile contamination from flagged content. Also select channel_id
  to group messages by channel in prompt, enabling channel-aware personality
  summarization (user may behave differently across channels).
- llmModerationClient.ts (runSimpleTextFallback): inject user profile into
  both the classify prompt and the reason prompt, so even the last-resort
  fallback path has personality/memory context instead of being blind.
2026-06-21 20:07:51 +07:00
MythEclipse e5fa2b3f30 feat(ai-moderation): personality-rich user/channel profiling & memory-aware analysis
- moderationPrompt.ts: Add PERSONALITY & MEMORY section instructing LLM to
  use user_profile and channel_culture in analysis, with 3 new few-shot
  examples (normal profile use, deviation detection, don't overfit)
- userProfileLearner.ts: Richer personality summary prompt — asks for
  communication style, passion topics, unique habits/signature traits,
  social dynamics, and writes in warm observer prose
- cultureLearner.ts: Richer channel culture summary — asks for 'vibe',
  inside jokes, social norms, dynamics. Writes in anthropologist style
2026-06-21 19:11:11 +07:00