27 Commits

Author SHA1 Message Date
Jason Lee
1614d3e144 web: Update to support web with WASM. (#2102)
Ref https://github.com/zed-industries/zed/pull/50228

## Summary
- Refactored to share Gallery component between native and web versions
- Fixed WASM compatibility issues with async/threading
- Added web version of the story gallery

## Show case

https://huacnlee.github.io/gpui-component-story-web/

## Key Changes

### 1. Shared Gallery Component
- Extracted Gallery to `crates/story/src/gallery.rs`
- Removed duplicate code (~570 lines) from `main.rs` and
`story-web/lib.rs`
- Both native and web versions now use the same Gallery implementation

### 2. WASM Async Architecture Improvements
**Problem:** WASM main thread cannot use blocking synchronization
primitives (`Mutex`, `RwLock`) that rely on `Atomics.wait`.

**Solution:** Redesigned the async architecture to avoid cross-thread
locks:
- Changed from `Arc<Mutex<ParsedContent>>` to direct storage in
`TextViewState`
- Backend tasks now use pure message-passing instead of shared locks
- All state updates happen on the main thread

**New workflow:**
1. User updates text → Send `UpdateOptions` to background task
2. Background task → Receives copy of current `ParsedContent`, parses
text, returns new `ParsedContent`
3. Main thread → Receives result, directly replaces `parsed_content`
4. Rendering → Reads `parsed_content`, no locks needed

### 3. Cross-platform Time APIs
- Replaced `std::time` with `instant` crate for cross-platform
compatibility
- Updated 11 files to use `instant::{Duration, Instant}`
- Fixed tracing-subscriber initialization for WASM (`.without_time()`)

## Technical Details

### Files Modified
- `crates/story/src/gallery.rs` - **New** shared Gallery module
- `crates/story/src/main.rs` - Simplified to use shared Gallery
- `crates/story-web/src/lib.rs` - Simplified to use shared Gallery (326
lines → 26 lines)
- `crates/ui/src/text/state.rs` - WASM async architecture improvements
- `crates/ui/src/async_util.rs` - Cross-platform async utilities
- `crates/ui/Cargo.toml` - Added `instant` and `parking_lot`
dependencies

### Key Architecture Changes
```rust
// Before: Shared mutable state with locks (blocked on WASM)
pub struct TextViewState {
    parsed_content: Arc<Mutex<ParsedContent>>,
}

// After: Direct storage with message-passing (WASM-compatible)
pub struct TextViewState {
    parsed_content: ParsedContent,
}
```

## Test Plan
-  Native version compiles and runs
-  WASM version builds successfully
-  All components render correctly in both versions
-  No "Atomics.wait cannot be called in this context" errors

## Benefits
- **Reduced code duplication**: Removed ~570 lines of duplicate code
- **Single source of truth**: Gallery updates only need to happen in one
place
- **WASM compatibility**: Proper async architecture that works on
single-threaded WASM
- **Cross-platform**: Native and Web use identical code paths

## TODO

- [ ] `gpui_web` not have implement the `set_menus`, app menu missing.
- [ ] `tree-sitter` can't compiled for wasm, disabled to without
highlight.
- [ ] Input can't handle any type events.
- [ ] Embed font for CJK.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-02 13:12:24 +00:00
Leo
90b707a7f1 docs: Keep the doc version in sync with the package official version (#1946)
Closes #1947

## Description

The `Release Docs` action is currently triggered by a tag, but this can
cause it to become unsynchronized with the official package version if
the package fails to publish.

To address this, change the `Release Docs` action to be triggered by the
`Release Crate` workflow. Once that workflow completes successfully, it
will trigger the documentation release, ensuring that the doc version
stays in sync with the official package version.
2026-01-16 10:25:15 +08:00
Jason Lee
7f956e0f55 ci: Update release crate CI. 2025-11-27 10:10:35 +08:00
Jason Lee
91de551ab0 ci: Update only release docs on tag push. (#1650) 2025-11-20 17:39:50 +08:00
Jason Lee
83dddfa987 assets: Fix #1605 embed assets for crate. (#1607) 2025-11-14 10:34:59 +00:00
Jason Lee
2a98628b5e docs: Improve docs to use variable version from toml. (#1603) 2025-11-14 16:10:48 +08:00
Jason Lee
1375c8cd70 ci: Update CI to only run docs test when only docs changed. (#1596) 2025-11-14 11:55:28 +08:00
Jason Lee
956fbe08d4 docs: Fix GitHub pages upload artifact. 2025-10-21 15:22:17 +08:00
Jason Lee
cc21374f76 docs: Switch to use VitePress. (#1405)
https://vitepress.dev/
2025-10-21 15:18:41 +08:00
YougLin-dev
5a61c82778 docs: Add documentation website with comprehensive component guides (#1398)
Initialize a Next.js-based documentation site using Fumadocs framework
to provide comprehensive guides for all GPUI components. The site
includes getting started guides, API references, and documentation for
40+ components including Button, Input, Table, Tree, Chart, and more.

---------

Co-authored-by: Jason Lee <huacnlee@gmail.com>
2025-10-20 17:02:53 +08:00
Jason Lee
0c0c36cb87 menu: Fix trigger action with context. (#1372)
Fix previous #1338 broken trigger action with context.
2025-10-14 19:58:11 +08:00
Jason Lee
6ca9ac46fa chore: Bump crate version. (#1340) 2025-10-09 15:20:34 +08:00
Copilot
ed05c3ebec chore: Remove Wef code as it has been extracted to separate repository (#1302)
All WEF (Web Embedding Framework) related code has been successfully
removed from the repository as it has been extracted to
https://github.com/longbridge/wef

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: huacnlee <5518+huacnlee@users.noreply.github.com>
2025-09-29 15:31:58 +08:00
Jason Lee
4983300ddf input: Update RopeExt to use LF style for get correct line when have \r. (#1296) 2025-09-28 01:04:14 +08:00
Jason Lee
ef1d727c3d chore: Improve RopeExt API and add more docs. (#1289) 2025-09-25 18:17:46 +08:00
Jason Lee
f93e9a9475 editor: Change to pass cursor as offset for completions method. (#1271)
And to support `filter_text` as completion item highlight match.
2025-09-22 16:29:51 +08:00
Jason Lee
41663ca030 chore: Update GPUI and fix FocusableWrapper removed error. (#1026)
Close #1024 

Ref https://github.com/zed-industries/zed/pull/32436
2025-07-02 11:06:04 +08:00
Sunli
b70b229370 wef: Added a new WebView component named "Wef" based on CEF. (#877)
Wef is a Rust library for embedding WebView functionality using Chromium
Embedded Framework (CEF3) with offscreen rendering support.
2025-06-17 18:57:44 +08:00
Jason Lee
71b79cf1b4 chore: Add Windows CI (#789) 2025-04-14 20:46:32 +08:00
Floyd Wang
9d3b673c96 CI: Reopen machete (#755)
https://github.com/longbridge/gpui-component/pull/663
2025-03-31 18:24:53 +08:00
Floyd Wang
e5371c3209 ci: Temporarily skip machete (#663)
https://github.com/actions/runner-images/pull/11661

`cargo-machete` needs edition 2024, reopen after this PR is merged.
2025-02-25 15:13:54 +08:00
Jason Lee
06f9178ec4 text: Add TextView with Markdown and Simple HTML support. (#639) 2025-02-20 20:08:59 +08:00
Jason Lee
2aaf424df9 title_bar: Fix move window support for Linux. (#368) 2024-10-21 15:23:36 +08:00
Jason Lee
a798bd81c6 chore: Fix typos. (#364) 2024-10-18 14:30:24 +08:00
Jason Lee
19bb5eee3a Fix clippy warnings and fix CI to fail when have warnings. (#301) 2024-10-03 10:46:02 +08:00
Jason Lee
4edf1e3427 Update ScrollView to let content is FnOnce. (#65) 2024-07-24 11:38:30 +08:00
Jason Lee
e0103d1d58 Add CI (#62) 2024-07-24 10:39:19 +08:00