Skip to content

Add real-time translation and fix Settings language dropdown#63

Merged
ZhangHanDong merged 7 commits intomainfrom
feature/realtime-translation-v2
Apr 7, 2026
Merged

Add real-time translation and fix Settings language dropdown#63
ZhangHanDong merged 7 commits intomainfrom
feature/realtime-translation-v2

Conversation

@ZhangHanDong
Copy link
Copy Markdown

Summary

  • Add real-time translation feature for the room input bar with LLM-powered translation
  • Fix Settings → Preferences language dropdown rendering (was invisible due to uniform/plain type mismatch)

Real-time Translation

  • Translation service module (src/room/translation.rs) with OpenAI-compatible LLM API
  • Settings → Labs: configure API URL, key, model with Test Connection button
  • Translate button in input bar opens language selector popup (17 languages)
  • Debounce-based real-time translation (500ms) as user types
  • Translation preview with Apply button to replace input text
  • Global config via Mutex<Option<TranslationConfig>> for cross-widget access

Settings Language Dropdown Fix

  • Root cause: Makepad DropDown shader uses two types of color declarations:
    • draw_text.color = plain value (base color for get_color shader mix chain)
    • draw_text.color_hover/focus/down = uniform() (GPU uniforms mixed in)
    • All draw_bg.* colors = uniform()
  • Previous attempts (custom set_type_default() types, plain value overrides) failed because they mismatched the declaration types
  • Fix: override with matching types — plain for color, uniform() for everything else

Test plan

  • cargo build passes
  • Settings → Labs → Translation: configure API, Test Connection works
  • Room input bar: click translate icon → select language → type text → translation appears
  • Click Apply → translated text replaces input
  • Settings → Preferences → Language dropdown renders and functions correctly
  • Changing model in Settings takes effect immediately

🤖 Generated with Claude Code

ZhangHanDong and others added 4 commits April 8, 2026 04:12
Real-time translation:
- New translation service module with OpenAI-compatible LLM API
- Translation settings UI in Settings → Labs (API URL, key, model)
- Translate button in room input bar with language selector popup
- Debounce-based real-time translation as user types
- Translation preview with Apply button to replace input text
- Global config via Mutex for cross-widget access
- Config auto-refreshes from global state on every event

Settings language dropdown fix:
- Remove broken set_type_default() custom DropDown types
- Use inline DropDown instance with correct uniform/plain typing
- Key insight: draw_text.color must be plain value, all other
  color variants must use uniform() to match shader declarations

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- specs/task-realtime-translation.spec.md: complete feature spec
- issues/002: Settings DropDown arrow visual artifact with root cause
  analysis of Makepad uniform/plain shader type system

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Replace Makepad DropDown widget (unsolvable shader styling issues)
  with custom RoundedView + Label + ExpandArrow + popup list
- ExpandArrow provides animated triangle: right (>) collapsed,
  down (v) expanded — SDF-drawn, no SVG dependency
- Add chevron_right.svg and chevron_down.svg (unused now, kept for
  potential future use)
- Fix issue #2: DropDown arrow visual artifact no longer applies

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…sistentState

CI runs with RUSTFLAGS="-D warnings", so clippy warnings are errors.
Box the AppState payload to reduce enum size from 512+ bytes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ZhangHanDong and others added 3 commits April 8, 2026 05:57
- Replace reqwest::Error in UrlPreviewError with String to avoid
  direct reqwest crate dependency (not available on Android target)
- Replace reqwest::StatusCode imports with matrix_sdk::reqwest::StatusCode
  (matrix-sdk re-exports reqwest)
- Fix clippy unnecessary closure warnings in ok_or_else

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use English for the LLM system prompt and message format tag
([Target language:xxx]) for better compatibility across models.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The variable was only used inside #[cfg(unix)] but declared outside,
causing unused variable warning on Windows (treated as error by CI).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ZhangHanDong ZhangHanDong merged commit 87a991e into main Apr 7, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant