Commit Graph
92 Commits
Author SHA1 Message Date
weishu 7da8144ff6 fix(web): restore dark mode styling broken by conditional Telegram SDK loading
The conditional Telegram SDK loading (commit 4606ba2) caused dark mode to
break in non-Telegram browsers. Added dark mode CSS variable overrides with
proper fallbacks, and restored the module-level applyTheme() call that applies
theme before React renders, preventing a flash of incorrect styling.

- web/src/index.css: Added dark mode overrides for primary colors (--app-bg,
  --app-fg, --app-hint, --app-link, --app-button, --app-button-text,
  --app-secondary-bg) with system-appropriate dark fallbacks when Telegram
  theme variables are unavailable
- web/src/hooks/useTheme.ts: Restored module-level applyTheme(currentScheme)
  call to ensure theme is applied before React renders
2025-12-19 00:15:48 +08:00
weishu ac67718ec0 feat: implement AskUserQuestion tool with interactive UI and question flow
Add comprehensive support for the AskUserQuestion tool including:
- New footer component for handling user responses with multi-step question flow
- Type definitions and parsing utilities for question and answer formats
- View component for displaying questions and options
- Integration with permission system to capture user answers
- Support for single and multi-select questions with optional text input
- Haptic feedback and error handling for better UX
2025-12-18 23:24:41 +08:00
weishu 7042596c90 Revert "feat: optimize PWA service worker update strategy for better caching"
This reverts commit 5856db6781.
2025-12-18 23:24:39 +08:00
weishu 55b1a753ba refactor(web): enhance DiffView with modal preview and inline variant 2025-12-18 22:56:00 +08:00
weishu 4606ba23d9 feat(web): implement conditional Telegram SDK loading
Add lazy loading of Telegram SDK only when running inside Telegram Mini App
environment instead of unconditionally loading in all browsers. Includes:

- New environment detection functions: isTelegramEnvironment(), isTelegramApp()
- Dynamic SDK loading with 3s timeout via loadTelegramSdk()
- Removed static script tag from index.html
- Made haptic feedback lazy (SDK check on each call)
- Made theme listeners lazy (attached in initializeTheme())
- Updated all components to use unified detection functions

This prevents SDK load time overhead in regular browser environments while
ensuring the app works correctly both in Telegram and browser contexts.
2025-12-18 22:54:40 +08:00
weishu 2a097d0cdf fix(web): prevent Android Chrome keyboard overlap 2025-12-18 19:05:01 +08:00
weishu 5856db6781 feat: optimize PWA service worker update strategy for better caching
Improve service worker update handling to fix caching issues during development:
- Add skipWaiting and clientsClaim in Workbox config for immediate SW activation
- Remove user confirmation prompt and switch to silent automatic updates
- Replace hourly polling with visibility-based update checks via visibilitychange event

This resolves the issue where web updates would not take effect without manual cache clearing.
2025-12-18 18:18:35 +08:00
weishu 80b8d2e34f fix: remove unreliable Telegram environment detection to fix loading delay
Remove unreliable conditions from Telegram environment detection in useAuthSource:
- window.Telegram !== undefined: Always true due to unconditional SDK loading
- window.self !== window.top: Causes false positives in iframe scenarios

Only keep URL parameter detection (tgWebApp in search/hash) which is reliable.
This prevents 5-second polling delay before login page displays on PC browser.
2025-12-18 16:28:24 +08:00
weishu f95350d245 fix: integrate History API for browser back button navigation
Syncs React routing state with browser History API. Clicking the browser
back button now navigates within the app instead of exiting. Telegram
BackButton behavior is preserved by checking for initData.
2025-12-18 16:06:10 +08:00
weishu 3cf66983fc feat: optimize web bundle with custom minimal Shiki highlighter
Replaces react-shiki with a custom minimal Shiki highlighter to significantly reduce bundle size. Only loads 29 common languages and 2 themes (github-light/dark), using the JavaScript RegExp engine instead of WASM.

- Reduced web bundle from 5.8MB to 2.5MB (57% reduction)
- Saves 622KB by avoiding WASM runtime
- Graceful fallback for unsupported languages
- Removed react-shiki dependency
- Added @shikijs/langs, @shikijs/themes, shiki, hast-util-to-jsx-runtime
- Added light mode CSS rules for syntax highlighting
2025-12-18 15:09:49 +08:00
weishu be00343289 feat: add iOS Safari install guide and improve PWA UX with neutral theme
- Add iOS Safari install prompt with step-by-step modal guide
- Fix Telegram environment detection (check initData, not just SDK presence)
- Fix install prompt re-entrancy issue (clear deferredPrompt immediately)
- Extract icon components to separate file (web/src/components/icons.tsx)
- Rename "Happy App" to "Hapi" throughout the UI and manifests
- Change button/icon colors from blue (--app-button) to neutral theme (--app-fg/--app-bg)
- Add install dismiss state to prevent repeated prompts
- Improve iOS Safari detection with robust user agent parsing
2025-12-18 14:05:50 +08:00
weishu ea9f0f3b1a feat: implement progressive web app support with offline capabilities
Add complete PWA implementation including service worker registration,
offline support, and installation prompts:

- Add vite-plugin-pwa and workbox-window dependencies for PWA tooling
- Configure VitePWA plugin with web app manifest and app metadata
- Set up Workbox caching strategies for API endpoints and CDN assets
- Implement service worker auto-update with user-triggered refresh
- Create usePWAInstall hook to handle beforeinstallprompt events
- Create useOnlineStatus hook for monitoring network connectivity
- Add InstallPrompt component with haptic feedback integration
- Add OfflineBanner component to notify users of offline status
- Configure PWA icons and assets (64x64, 192x192, 512x512 variants)
- Add TypeScript type declarations for virtual PWA register module
- Integrate PWA components and service worker into App.tsx and main.tsx
- Add PWA meta tags and viewport configuration to index.html
2025-12-18 13:40:36 +08:00
weishu 9be0a96af4 feat: add web vibration api fallback for haptic feedback
Replace no-op browser haptic feedback with Web Vibration API support,
allowing haptic feedback when running outside Telegram Mini App. Also
remove stale react-syntax-highlighter type reference from tsconfig.
2025-12-18 12:53:11 +08:00
weishu cf2b96b566 feat: add browser environment support with access token authentication
Enable the web client to run in plain browser environments alongside Telegram Mini App support:

- Server: Add CLI_API_TOKEN authentication path as alternative to Telegram initData
- Client: Add useAuthSource hook to detect and manage Telegram vs browser auth sources
- Client: Add usePlatform hook for platform abstraction with graceful haptic feedback degradation
- Client: Add LoginPrompt component for browser access token login
- Client: Extend useTheme to fall back to system prefers-color-scheme in browser
- Client: Migrate all direct HapticFeedback calls to use usePlatform hook
2025-12-18 12:45:49 +08:00
weishu 5fe1256e11 refactor: replace react-syntax-highlighter with react-shiki
Consolidate markdown rendering logic into dedicated assistant-ui components and update syntax highlighting to use Shiki with GitHub themes. Removes dependency on react-markdown and react-syntax-highlighter in favor of @assistant-ui/react-markdown with Shiki-based highlighting.
2025-12-18 12:45:26 +08:00
weishu fd55750a12 refactor: replace react-syntax-highlighter with react-shiki
Consolidate markdown rendering logic into dedicated assistant-ui components and update syntax highlighting to use Shiki with GitHub themes. Removes dependency on react-markdown and react-syntax-highlighter in favor of @assistant-ui/react-markdown with Shiki-based highlighting.
2025-12-18 12:08:59 +08:00
weishu 35d959dba4 feat: improve event presentation with separate icons and add aria labels to buttons 2025-12-18 08:56:52 +08:00
weishu 279c0c2dd8 fix: change retry button text from Chinese to English 2025-12-18 08:51:44 +08:00
weishu f75a7d46bb feat: add model-aware context budget calculation for status bar warnings 2025-12-18 08:50:07 +08:00
weishu 7f07bdc796 refactor: extract presentation utilities and status indicator component 2025-12-18 08:47:13 +08:00
weishu 120de5515d feat: improve settings overlay and tool message display
- Refactor HappyComposer settings overlay to conditionally render permission and model settings based on their availability
- Add showPermissionSettings and showModelSettings flags for cleaner conditional rendering
- Enhance ToolMessage fallback UI with styled card layout and code blocks for arguments and results
- Improve type validation in isToolCallBlock with comprehensive property checks
- Add safeStringify utility for robust JSON serialization with fallback handling
2025-12-18 08:39:49 +08:00
weishu 282471428f fix: wrap system message content in text object structure for @assistant-ui/react compatibility 2025-12-18 08:38:16 +08:00
weishu e2428f11b5 refactor: remove deprecated chat components in favor of @assistant-ui/react 2025-12-18 08:20:14 +08:00
weishu 532ceb5595 feat: integrate @assistant-ui/react library with new chat components 2025-12-18 01:15:37 +08:00
weishu 3c7387f684 feat: add viewport height tracking and improve scroll behavior on mobile 2025-12-17 21:44:12 +08:00
weishu a6d088b51d feat: add iOS platform detection and improve dark theme contrast 2025-12-17 18:48:44 +08:00
weishu dc81620594 fix: increase ChatInput padding to match happy-app spacing 2025-12-17 18:31:54 +08:00
weishu b0b0a2e228 fix: add iOS safe area bottom padding to ChatInput to prevent Home Indicator overlap 2025-12-17 18:27:06 +08:00
weishu cf8ab441ca feat: add support for multiple special words in rainbow text effect 2025-12-17 18:09:25 +08:00
weishu e2ea9fbc45 feat: add rainbow sparkle text effect for ultrathink in user messages 2025-12-17 18:09:25 +08:00
weishu 3faa68f988 refactor: remove dead code components from web/src/components
Remove 5 unused component files that were not imported anywhere:
- SessionDetail.tsx (replaced by SessionChat)
- PermissionPanel.tsx (only used by dead SessionDetail)
- MessageList.tsx
- PermissionBanner.tsx
- PermissionDialog.tsx

Confirmed via grep searches and successful build.
2025-12-17 16:04:15 +08:00
weishu 502b63c236 refactor: simplify session component headers and add Telegram Web App support
- Unify session title logic across components to check metadata.name first
- Add Telegram Web App detection with re-check after mount
- Hide header and buttons when running in Telegram environment
- Replace host display with path information in session details
- Remove unused Badge components for session status
- Simplify SessionList and SessionHeader layouts
2025-12-17 14:56:20 +08:00
weishu 0e828a0c13 refactor: use GenericResultView for mcp tools instead of MarkdownResultView 2025-12-17 13:38:26 +08:00
weishu 2d42f41113 refactor: extract tool result views into dedicated registry pattern 2025-12-17 13:35:41 +08:00
weishu 9cc13b51be feat: add todo tracking and custom tool views
Adds todo tracking infrastructure with TodoWrite tool integration to extract
and persist todos in sessions. Refactors ToolCard component to support
custom tool view rendering and displays todo progress in SessionList.
2025-12-17 11:45:17 +08:00
weishu 031116bfce feat: Add online status display and context usage tracking to ChatInput
- Display connection status indicators (online, offline, thinking, permission required) in ChatInput with dynamic vibing messages
- Add context size percentage display showing remaining context availability
- Track latest usage data in reducer with inputTokens, outputTokens, cache metrics, and contextSize
- Calculate contextSize from message usage data and expose via latestUsage in reduceChatBlocks
- Pass thinking, agentState, and contextSize props to ChatInput component
- Remove redundant status indicators from SessionHeader (moved to ChatInput for unified display)
2025-12-17 09:35:45 +08:00
weishu ec3a849cbd feat: refactor ChatInput with autocomplete, suggestion management, and settings integration
Extract word detection and suggestion logic into reusable utilities and hooks.
Add FloatingOverlay and Autocomplete components for intelligent input assistance.
Integrate settings panel and abort button directly into ChatInput component.
Simplify SessionHeader by removing settings dialog (now in ChatInput).
2025-12-17 09:13:15 +08:00
weishu a307fd4893 refactor: remove border styling and improve component styling 2025-12-17 08:39:29 +08:00
weishu 959ee72e68 refactor: simplify permission footer display and remove unused accent border styling 2025-12-17 08:16:18 +08:00
weishu 0fa05dc205 feat: add permission decision options, tool allowlisting, and refactored chat UI components 2025-12-17 07:57:37 +08:00
weishu 0485065b87 refactor: improve message synchronization with sequence-based pagination and merging 2025-12-16 21:07:20 +08:00
weishu b4654acb92 init 2025-12-16 15:03:50 +08:00