How gaigai315/yuzuki-phone works
Purpose and host integration
This is a browser-side SillyTavern extension that renders an immersive virtual phone and app ecosystem for roleplay. The extension entry is index.js; metadata and installation identity are in manifest.json. It is loaded under SillyTavern’s third-party extension runtime, not as a standalone web service.
Phone shell and navigation
The phone UI is a persistent shell with home-screen launching, floating entry access, and layered in-phone navigation. phone/phone-shell.js, phone/home-screen.js, and phone/floating-entry.js form the primary UI control boundary; phone.css supplies shell-wide styling. The architecture favors retained view layers and gesture-driven back navigation rather than page reloads.
Shared state, time, and persistence
Cross-app state and host-facing persistence are centralized in configuration managers. config/storage.js persists phone/app data; config/time-manager.js derives phone time from story context; config/global-social-store.js coordinates shared social entities/activity. config/context-settings.js and config/worldbook-manager.js bridge phone behavior with SillyTavern character/chat context and lore data.
AI and generation boundary
AI calls are mediated rather than embedded directly in individual apps. config/api-manager.js supports independent model/API communication, while config/prompt-manager.js owns prompt construction and config/tag-filter.js constrains generated content. This separates “online” phone-only AI interactions from story-context injection and keeps provider-specific logic outside application views.
App composition pattern
Most apps follow an explicit three-part structure: app orchestration, state/data operations, and DOM rendering, e.g. apps/wechat/wechat-app.js, apps/wechat/wechat-data.js, and apps/wechat/chat-view.js; similarly apps/diary/diary-app.js and apps/diary/diary-view.js. config/apps.js is the app registry/launch integration point. This makes each app a feature module mounted into the common phone shell.
Social and communication subsystems
WeChat is the deepest social subsystem: chat, contacts, Moments, themes, snapshots, voice-to-text, and style presets are split across apps/wechat/wechat-app.js, apps/wechat/chat-view.js, and apps/wechat/moments-view.js. Phone calling/SMS is isolated in apps/phone/phone-app.js, apps/phone/sms-popup.js, and apps/phone/phone-data.js. Weibo, Honey, Diary, Music, Album, Calendar, and Wangxiang reuse the same app/data/view boundary for generated or user-managed social content.
Media, TTS, and image infrastructure
Image ingestion is handled through crop/upload components in apps/settings/image-cropper.js and apps/settings/image-upload.js; the intended storage model is server-hosted paths rather than Base64 blobs. config/image-generation-manager.js and config/tts-manager.js abstract media generation/playback. Optional relay and queue infrastructure lives in workers/doubao-clone-worker.js, workers/mimo-tts-relay-worker.js, and workers/nai-queue-worker.js, enabling external image/TTS providers where configured.
Games and specialized experiences
apps/games/games-app.js is a games hub with independently scoped game modules such as apps/games/poker/poker-app.js, apps/games/sudoku/sudoku-data.js, and apps/games/werewolf/werewolf-view.js. Shared AI/game context is centralized in apps/games/common/games-ai-context.js, preserving a boundary between common roleplay-aware generation and each game’s rules/UI.
Main entry points: apps.js App Registry · wechat-app.js WeChat · storage.js Phone Storage · api-manager.js AI Generation Boundary
Components 20
Host Integration
- Extension Entry · Loads in SillyTavern's third-party extension runtime.
index.js - Story & Lore Bridge
config/context-settings.js
Phone Platform
- Phone Shell · Retains phone layers and gesture-driven navigation.
phone/phone-shell.js - Home & Floating Entry
phone/home-screen.js - App Registry
config/apps.js - Phone Storage · Persists phone and app data.
config/storage.js - Story Time · Derives phone time from story context.
config/time-manager.js - Global Social Store
config/global-social-store.js - AI Generation Boundary · Mediates provider calls, prompts, and generated-content constraints.
config/api-manager.js
App Ecosystem
- WeChat · Deep social subsystem for chat, contacts, Moments, and related features.
apps/wechat/wechat-app.js - WeChat Chat & Moments
apps/wechat/chat-view.js - Calls & SMS
apps/phone/phone-app.js - Diary
apps/diary/diary-app.js - Other Social Apps · Weibo, Honey, Music, Album, Calendar, and Wangxiang follow the shared app pattern.
Media Services
- Image Ingestion · Stores server-hosted image paths rather than Base64 blobs.
apps/settings/image-upload.js - Image & TTS Managers
config/image-generation-manager.js - Optional Provider Workers · Relays external image and TTS providers when configured.
workers/doubao-clone-worker.js
Games
- Games Hub
apps/games/games-app.js - Games AI Context · Separates roleplay-aware generation from game rules and UI.
apps/games/common/games-ai-context.js - Scoped Game Modules · Poker, Sudoku, and Werewolf remain independently scoped.
apps/games/poker/poker-app.js
Connections 24
- Extension Entry → Phone Shell: boots
- Extension Entry → Story & Lore Bridge: uses host context
- Phone Shell → Home & Floating Entry: hosts
- Home & Floating Entry → App Registry: launches apps
- App Registry → WeChat: mounts
- App Registry → Calls & SMS: mounts
- App Registry → Diary: mounts
- App Registry → Other Social Apps: mounts
- App Registry → Games Hub: mounts
- Story & Lore Bridge → Story Time: supplies story context
- Story & Lore Bridge → AI Generation Boundary: enriches prompts
- WeChat → WeChat Chat & Moments: orchestrates
- WeChat → Global Social Store: shares activity
- WeChat → Phone Storage: persists data
- Calls & SMS → Phone Storage: persists calls and SMS
- Diary → Phone Storage: persists entries
- Other Social Apps → Phone Storage: persist content
- WeChat → AI Generation Boundary: requests generation
- Other Social Apps → AI Generation Boundary: requests generation
- Image Ingestion → Phone Storage: stores image paths
- Image & TTS Managers → Optional Provider Workers: optionally relays
- Games Hub → Scoped Game Modules: launches
- Scoped Game Modules → Games AI Context: uses shared context
- Games AI Context → AI Generation Boundary: requests roleplay-aware generation