Fix for https://github.com/wavetermdev/waveterm/issues/2385 for Wave AI.
Also update privacy information to say we send the chats to OpenAI for
processing.
Also modify the system prompt to say that file editing + command execution is coming soon.
This PR adds support for mobile user agent emulation in web widgets,
enabling developers to test mobile-responsive websites directly within
WaveTerm.
## Changes
### New Meta Key: `web:useragenttype`
Added a new metadata key that accepts the following values:
- `"default"` (or `null`) - Uses the standard browser user agent
- `"mobile:iphone"` - Emulates iPhone Safari (iOS 17.0)
- `"mobile:android"` - Emulates Android Chrome (Android 13)
### User Interface
**Settings Menu**: Added a "User Agent Type" submenu to web widget
settings (accessible via right-click → Settings) with radio button
options for Default, Mobile: iPhone, and Mobile: Android.
**Visual Indicator**: When a mobile user agent is active, a mobile
device icon appears in the widget's header toolbar with an appropriate
tooltip indicating the current emulation mode.
### Implementation Details
The implementation leverages Electron's webview `useragent` attribute to
override the default user agent string. The setting is persisted in the
block's metadata and automatically applied when the webview is rendered.
User agent strings used:
- **iPhone**: `Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X)
AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148
Safari/604.1`
- **Android**: `Mozilla/5.0 (Linux; Android 13) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/120.0.6099.43 Mobile Safari/537.36`
## Use Cases
This feature is particularly useful for:
- Testing mobile-responsive web designs
- Debugging mobile-specific website behaviors
- Viewing mobile versions of websites without needing physical devices
- Web development workflows that require testing across different user
agents
## Files Changed
- `pkg/waveobj/wtypemeta.go` - Added `WebUserAgentType` field to
metadata type
- `frontend/types/gotypes.d.ts` - Generated TypeScript types for the new
meta key
- `frontend/app/view/webview/webview.tsx` - Implemented user agent
selection UI and webview configuration
- `pkg/waveobj/metaconsts.go` - Generated Go constants for the new meta
key
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>
## Overview
This PR implements OSC 7 (current working directory reporting) support
for Fish shell and PowerShell, completing the shell integration coverage
alongside the existing Bash and Zsh implementations added in #2444.
## What is OSC 7?
OSC 7 is an operating system command that allows shells to automatically
report their current working directory to the terminal emulator using
the format:
```
ESC]7;file://hostname/path BEL
```
This enables the terminal to track the current directory without manual
commands, providing better context for AI features and ensuring accurate
path information.
## Implementation Details
### Fish Shell (`fish_wavefish.sh`)
Added shell integration functions using Fish-native features:
- `_waveterm_si_blocked()` - Prevents OSC 7 in tmux/screen environments
using `set -q` and `string match -q`
- `_waveterm_si_osc7()` - Sends the OSC 7 sequence with built-in URL
encoding
- Uses `string escape --style=url` for UTF-8 percent-encoding
- Hooked to `fish_prompt` event and `PWD` variable changes for automatic
updates
**Key Features:**
- Fish-native checks (`set -q`, `string match`) instead of non-portable
`test -o`
- Built-in `string escape --style=url` for proper UTF-8 percent-encoding
- Simple, portable, and maintainable (32 lines total)
### PowerShell (`pwsh_wavepwsh.sh`)
Added simplified shell integration that leverages frontend
normalization:
- `_waveterm_si_blocked()` - Prevents OSC 7 in tmux/screen environments
- `_waveterm_si_osc7()` - Sends OSC 7 with raw path encoding
- Uses `[System.Uri]::EscapeDataString()` for proper percent-encoding
- Integrated into the prompt function while preserving existing prompts
**Key Features:**
- **No path rewriting**: Sends raw paths (e.g., `C:\Users\Name` →
`C%3A%5CUsers%5CName`)
- **UNC support**: Network paths like `\\server\share` encoded as
`%5C%5Cserver%5Cshare`
- **Hostname fallback**: `$env:COMPUTERNAME` → `$env:HOSTNAME` → empty
(produces `file:///path`)
- **No DNS lookup**: Avoids potentially slow DNS calls
- Simple and efficient (53 lines total)
## Implementation Benefits
Both implementations use native, built-in features for maximum
compatibility and maintainability:
**Fish:**
- ✅ Replaced `test -o` with fish-native `set -q` and `string match -q`
for better portability
- ✅ Replaced manual string replacements with `string escape --style=url`
for proper UTF-8 support
- ✅ Removed custom URL encoding function (19 lines removed)
**PowerShell:**
- ✅ Uses built-in `[System.Uri]::EscapeDataString()` for proper
percent-encoding
- ✅ No path rewriting - frontend handles normalization via
`decodeURIComponent()` and backslash conversion
- ✅ Proper UNC path support without special-casing
- ✅ Removed DNS lookup to avoid slow operations
- ✅ Removed custom URL encoding function
## Testing
All implementations were tested for:
- ✅ URL encoding of special characters (spaces, #, ?, &, ;, +, %)
- ✅ Correct OSC 7 format generation
- ✅ Fish-native checks work correctly (TMUX, STY, TERM patterns)
- ✅ Raw path encoding (PowerShell - no rewriting)
- ✅ UNC path support (PowerShell)
- ✅ Unix path handling
- ✅ Go package compilation
- ✅ No security issues (CodeQL)
## Path Handling Examples
**Fish:**
- `/home/user` → `/home/user`
- `/path with spaces` → `/path%20with%20spaces`
- `/file#hash` → `/file%23hash`
**PowerShell:**
- Windows: `C:\Users\Name` → `file://HOST/C%3A%5CUsers%5CName`
- UNC: `\\server\share\folder` →
`file://HOST/%5C%5Cserver%5Cshare%5Cfolder`
- Empty hostname: produces `file:///path` format
## Files Changed
- `pkg/util/shellutil/shellintegration/fish_wavefish.sh` (+22 lines, -18
lines = net +4 lines, but 19 lines of custom code removed)
- `pkg/util/shellutil/shellintegration/pwsh_wavepwsh.sh` (+26 lines, -51
lines = net -25 lines)
Total: 38 fewer lines of code with better functionality and
maintainability.
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>
* add automatic OSC 7 support to bash and zsh
* add new wave OSC 16162 (planck length) to get up-to-date shell
information into blockrtinfo. currently implemented only for zsh. bash
will not support as rich of data as zsh, but we'll be able to do some.
* new rtinfo will be used to provide better context for AI in the
future, and to make sure AI is running safe commands.
* added a small local machine description to tab context (so AI knows
we're running on MacOS, Linux, or Windows)
Documentation Updates (removing AI Widget Information / deprecation)
Hover effect on tool calls shows which widget is effected
Remove AI Widget from sidebar unless there is customized presets
Backend now provides blockid (if available) to frontend for tool calls
We now show all Read File/Dir calls together and batch approve them
(backend change to emit them all at once, and FE change to display them
as a batch)
JS chunking for monaco, mermaid, and shiki, etc. shiki is huge, almost
10M but can't be easily split out of Streamdown. Tried making it load
async, but w/ Streamdown we can't do that easily. Trying to split the JS
up because of a build error we were running into in build-helper.
Don't allow tabs with active Wave AI sessions to get closed when we
close the last block. Have Cmd-W close Wave AI if it is focused (rather
than a random node). Also fixes some lurking bugs with the pinned tab
functionality (and adds some nice visual feedback when we try to close a
pinned tab).
- [x] Explore repository structure and understand existing tools pattern
- [x] Create tools_readdir.go file with read_dir tool implementation
- [x] Add GetReadDirToolDefinition() function following the pattern of
read_text_file
- [x] Register the new tool in tools.go GenerateTabStateAndTools
function
- [x] Create comprehensive tests in tools_readdir_test.go
- [x] Test the implementation manually with various scenarios
- [x] Run Go tests to ensure no regressions
- [x] Run security check with CodeQL - No vulnerabilities found
- [x] Revert unintended changes to tsunami demo go.mod and go.sum files
- [x] Fix sorting to happen before truncation and preserve real total
count
## Summary
Successfully implemented a new `read_dir` AI tool that reads and lists
directory contents, following the same pattern as the existing
`read_text_file` tool.
**Key Features:**
- Supports path expansion (including ~)
- Sorts directories first, then files (sorting happens BEFORE
truncation)
- Truncates output to prevent overwhelming responses (default 1000
entries)
- Preserves the real total count even when truncated
- Requires user approval for security
- Provides detailed file/directory information (name, type, size,
permissions, modification time)
- Returns both structured data and formatted listing
**Files Changed:**
- `pkg/aiusechat/tools_readdir.go` - Main implementation (189 lines)
- `pkg/aiusechat/tools_readdir_test.go` - Comprehensive tests (211
lines)
- `pkg/aiusechat/tools.go` - Tool registration (1 line)
**Testing:**
- ✅ All 6 unit tests passing (including new test for
sort-before-truncate)
- ✅ Manual testing with real directories successful
- ✅ CodeQL security scan passed with no vulnerabilities
- ✅ Go build and vet successful
<!-- START COPILOT CODING AGENT SUFFIX -->
<details>
<summary>Original prompt</summary>
> Right now we have AI tools in go at pkg/aichat ... see tools.go,
tools_readfile.go. i'd like to add a new tool to read directories in the
style of readfile.
</details>
<!-- START COPILOT CODING AGENT TIPS -->
---
💡 You can make Copilot smarter by setting up custom instructions,
customizing its development environment and configuring Model Context
Protocol (MCP) servers. Learn more [Copilot coding agent
tips](https://gh.io/copilot-coding-agent-tips) in the docs.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>
Co-authored-by: sawka <mike@commandline.dev>
### What This Does
Adds a new `wsh blocks list` subcommand that lists all blocks in all or
specified workspace, window, or tab. Includes filtering options and JSON
output for automation.
### Motivation
Wave users had no simple way to programmatically discover block IDs for
scripting and automation. This feature:
- Enables workflows like syncing Preview widgets with `cd` changes.
- Simplifies debugging and introspection.
- Provides a foundation for future CLI enhancements (focus/close
blocks).
### Usage
```wsh blocks [list|ls|get] [--workspace=<workspace-id>] [--window=<window-id>] [--tab=<tab-id>] [--view=<view-type>] [--json]```
Where `<view-type>` can be one of: term, terminal, shell, console, web, browser, url, preview, edit, sysinfo, sys, system, waveai, ai, or assistant.
### Notes
- Fully backward compatible.
- Code follows existing CLI patterns.
Massive PR, over 13k LOC updated, 128 commits to implement the first pass at the new Wave AI panel. Two backend adapters (OpenAI and Anthropic), layout changes to support the panel, keyboard shortcuts, and a huge focus/layout change to integrate the panel seamlessly into the UI.
Also fixes some small issues found during the Wave AI journey (zoom fixes, documentation, more scss removal, circular dependency issues, settings, etc)
The current layout system uses a complex bidirectional atom architecture
that forces every layout change to round-trip through the backend
WaveObject, even though **the backend never reads this data** - it only
queues actions via `PendingBackendActions`. By switching to a "write
cache" pattern where local atoms are the source of truth and backend
writes are fire-and-forget, we can eliminate ~70% of the complexity
while maintaining full persistence.
----
Every layout change (split, close, focus, magnify) currently follows
this flow:
```
User action
↓
treeReducer() mutates layoutState
↓
layoutState.generation++ ← Only purpose: trigger the write
↓
Bidirectional atom setter (checks generation)
↓
Write to WaveObject {rootnode, focusednodeid, magnifiednodeid}
↓
WaveObject update notification
↓
Bidirectional atom getter runs
↓
ALL dependent atoms recalculate (every isFocused, etc.)
↓
React re-renders with updated state
```
---
## Proposed "Write Cache" Architecture
### Core Concept
```
User action
↓
Update LOCAL atom (immediate, synchronous)
↓
React re-renders (single tick, all atoms see new state)
↓
[async, fire-and-forget] Persist to WaveObject
```
### Key Principles
1. **Local atoms are source of truth** during runtime
2. **WaveObject is persistence layer** only (read on init, write async)
3. **Backend actions still work** via `PendingBackendActions`
4. **No generation tracking needed** (no need to trigger writes)
checkpoint. good to merge. we have a working tsunami view inside of wave (with lots of caveats). but enough for some dev testing. merge so we dont drift too far from main and while we're at a stable point.
Working on AI SDK compatible backends for OpenAI and Anthropic. Thinking + ToolUse etc. For use with AI SDK useChat on frontend. Still needs more testing, WIP, but this is a good start. Want to get this committed to so I can work on more integrations.
Because I am on an internal network, I need to use a proxy server to
access Claude's services. However, Wave currently does not provide the
ability to configure the base URL, so I have added this feature in hopes
of being able to use it.
---------
Co-authored-by: sawka <mike@commandline.dev>
Gracefully handle prefix paths that don't exist, representing them as
directories so they can be escaped from.
Also removes the ".." file info from the backend, instead only creating
it on the frontend