Skip to content

Commit 4c37f0c

Browse files
committed
chore: update claude
1 parent 62d9db2 commit 4c37f0c

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

CLAUDE.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,43 @@ Note: `SessionInfo` from `zellij-tile` has many required fields. See `manager.rs
9898
## CI
9999

100100
GitHub Actions workflow (`.github/workflows/ci.yml`) runs on PRs and pushes to main:
101-
- `test` - Runs unit tests on native target
101+
- `test` - Runs unit tests on native target (must explicitly specify `--target x86_64-unknown-linux-gnu` because `.cargo/config.toml` defaults to wasm32-wasip1)
102102
- `build-wasm` - Verifies WASM compilation
103103
- `clippy` - Lints with `-D warnings`
104104
- `fmt` - Checks formatting
105+
106+
## WASM Sandbox Limitations
107+
108+
Zellij plugins run in a WASI sandbox with restricted filesystem access:
109+
110+
- **Cannot directly write to real filesystem** - `std::fs::write()` writes to a sandboxed virtual filesystem
111+
- **Mapped paths** (per [Zellij docs](https://zellij.dev/documentation/plugin-api-file-system.html)):
112+
- `/host` - Working directory of last focused terminal
113+
- `/data` - Plugin-specific folder (but NOT shared across sessions despite docs)
114+
- `/tmp` - Sandboxed temp directory (NOT the real /tmp)
115+
116+
**To persist data across sessions**, use `run_command` to shell out:
117+
```rust
118+
run_command(&["sh", "-c", "echo 'data' > /tmp/myfile"], context);
119+
```
120+
121+
## Plugin Instance Behavior
122+
123+
**Each Zellij session has its own plugin instance** with separate state:
124+
- Switching from session A to B means interacting with B's plugin instance
125+
- State does not transfer between sessions automatically
126+
- To share state, must use external storage (files via `run_command`)
127+
128+
**Plugin reloading**:
129+
- `zellij action start-or-reload-plugin "file:/path/to/plugin.wasm"` - Reloads in current session only
130+
- Must reload separately in each session, or close/reopen the plugin pane
131+
- Closing the pane (not just hiding) and reopening loads the new binary
132+
133+
## Quick-Switch Feature
134+
135+
The plugin supports quick-switching to the previous session:
136+
- When switching sessions, writes current session name to `/tmp/zsm-previous-session` via `run_command`
137+
- When plugin opens, reads that file and pre-selects the previous session
138+
- Press Enter to instantly toggle back
139+
140+
Implementation in `state.rs`: `write_previous_session()` and `request_previous_session_read()` use async `run_command` because direct filesystem access is sandboxed.

0 commit comments

Comments
 (0)