Commit graph

542 commits

Author SHA1 Message Date
Mike Sawka
edacd6580f
allow wsh ai to attach directory listings to the chat (#2469) 2025-10-22 09:47:58 -07:00
Mike Sawka
271c3550ab
should lowercase ext when looking up in staticmimetypemap (#2468) 2025-10-21 10:06:08 -07:00
Mike Sawka
6781ae4e2d
Fix IME inputs for Wave AI, and update privacy wording to be more clear about OpenAI (#2466)
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.
2025-10-20 23:27:16 -07:00
Mike Sawka
2e0b3d2569
implement more OSC 16162 for fish, pwsh, and bash (#2462) 2025-10-20 17:29:38 -07:00
Copilot
665facbc7c
Add mobile user agent emulation for web widgets (#2454)
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>
2025-10-17 17:45:32 -07:00
Copilot
0d04b99b46
Add Google AI file summarization package (#2455)
- [x] Create new directory pkg/aiusechat/google
- [x] Implement SummarizeFile function with:
  - Context parameter for timeout
  - File validation (images, PDFs, text files only)
  - Use gemini-2.5-flash-lite model
  - Configurable API URL and prompt as constants
  - Return (string, usage, error)
- [x] Define Google-specific usage struct
- [x] Test the implementation (all tests pass)
- [x] Verify with existing linting and build
- [x] Run CodeQL security check (no issues found)
- [x] Revert unintended tsunami demo dependency changes

## Summary

Successfully implemented a new Google AI package at
`pkg/aiusechat/google` with:

1. **SummarizeFile function** - A simple request-response API (not
streaming, not SSE)
   - Takes context for timeout
   - Validates file types (images, PDFs, text only) 
   - Enforces file size limits matching wshcmd-ai.go
   - Uses gemini-2.5-flash-lite model
   - Returns (summary string, usage stats, error)

2. **GoogleUsage struct** - Tracks token consumption:
   - PromptTokenCount
   - CachedContentTokenCount  
   - CandidatesTokenCount
   - TotalTokenCount

3. **Configurable constants**:
   - GoogleAPIURL (for reference)
   - SummarizePrompt (customizable prompt)
   - SummarizeModel (gemini-2.5-flash-lite)

4. **Comprehensive tests** - 41.7% coverage with all tests passing
5. **Security verified** - No CodeQL alerts
6. **Package documentation** - doc.go with usage examples

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>
2025-10-17 17:24:06 -07:00
Copilot
2619c85d03
Add OSC 7 support for Fish and PowerShell shells (#2456)
## 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>
2025-10-17 17:23:08 -07:00
Mike Sawka
38ede673aa
Add AI Response Feedback + Copy Buttons (#2457) 2025-10-17 14:18:30 -07:00
Mike Sawka
6a173a6227
working on more terminal context (#2444)
* 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)
2025-10-17 12:19:40 -07:00
Mike Sawka
af3279b411
handle reasoning deltas and display them in the UI (#2443) 2025-10-16 11:17:24 -07:00
Mike Sawka
4077c26b97
reduce some logging for prod release (#2440) 2025-10-15 22:10:00 -07:00
Mike Sawka
38163e7633
exclude autoupdate channel in custom settings (#2438) 2025-10-15 21:20:58 -07:00
Mike Sawka
0fd0daf134
Reimplement wsh ai, fix text file attaching format (#2435) 2025-10-15 17:28:56 -07:00
Mike Sawka
0e8eb83f62
Updates to prepare for v0.12 launch (#2434)
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
2025-10-15 16:10:37 -07:00
Mike Sawka
50cf6b589b
add an onboarding upgrade modal (#2433) 2025-10-14 20:21:10 -07:00
Mike Sawka
2480ebe2dd
Batch Approval for AI Tool Calls, fix "AI is thinking" message, chunk JS (#2430)
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.
2025-10-13 23:37:45 -07:00
Mike Sawka
822f05e379
Big Onboarding Updates (#2428) 2025-10-13 16:39:37 -07:00
Mike Sawka
2463e54479
Make Block Close / Cmd-W more consistent (#2417)
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).
2025-10-09 23:57:02 -07:00
Copilot
fa19d7c287
Add read_dir AI tool for reading directory contents (#2414)
- [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>
2025-10-09 21:41:50 -07:00
Mike Sawka
7451294f11
onboarding and polish for v0.12 (#2411) 2025-10-09 16:29:09 -07:00
Mike Sawka
ef6366f6c6
openai native web search tool enabled (#2410) 2025-10-09 15:06:40 -07:00
Mike Sawka
fd0e75a984
New data-tooluse AI SDK packet and Tool Approvals Implemented (#2407)
provides richer information for FE to use to display tools. also implements a full approve/deny flow for tools that require approval (readfile)
2025-10-09 10:21:01 -07:00
Oleksandr Hreshchuk
7681214fa1
feat(cli): add blocks list with filtering and JSON output (#2337)
### 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.
2025-10-08 13:41:24 -07:00
Mike Sawka
2312752003
custom streamdown components for wave ai (#2404)
much nicer markdown display for assistant messages.  lots of fixes for code components.
2025-10-08 13:22:00 -07:00
Mike Sawka
28385ce08a
update react, fix tool def (#2402) 2025-10-07 16:57:23 -07:00
Mike Sawka
d272a4ec03
New AIPanel (#2370)
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)
2025-10-07 13:32:10 -07:00
Mike Sawka
5a95e827bf
layout simplification (#2387)
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)
2025-10-03 10:10:07 -07:00
Mike Sawka
50cc08a769
add tsunami view in wave (#2350)
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.
2025-09-15 12:58:59 -07:00
Mike Sawka
6e3554407b
AI SDK Backend (#2336)
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.
2025-09-12 12:56:24 -07:00
Mike Sawka
5bd630d906
track if AI requests are local to see feature usage (#2313) 2025-08-29 14:19:42 -07:00
Mike Sawka
5c28874f34
switch to using gpt-5-mini for free proxy (#2297) 2025-08-28 14:28:49 -07:00
Mike Sawka
a38413193a
detect firstlaunch, also remove old history migration code (#2298) 2025-08-28 14:15:31 -07:00
Mike Sawka
07bd6c5766
implement $ENV:[env-var]:[fallback] config replacements (#2293) 2025-08-26 16:56:05 -07:00
Mike Sawka
56f03896cb
implement cmd:jwt and fix remote execution of commands (#2292) 2025-08-26 16:23:48 -07:00
Mike Sawka
b81b824b7d
fix some telemetry events (#2289) 2025-08-26 16:08:39 -07:00
Mike Sawka
d47b9f2ba8
add config setting to disable overlay blocknums from showing when holding ctrl:shift (#2288) 2025-08-25 21:47:35 -07:00
Mike Sawka
a85b658cd7
migrate to react 19 (#2272)
migrate to react 19 + fix lingering typescript errors and weirdness.
2025-08-25 21:17:15 -07:00
Mike Sawka
66164ac15e
term shiftenternewline config for claude code Shift+Enter support (#2285) 2025-08-22 14:08:48 -07:00
Mike Sawka
6845cd5a72
standalone fixes, linting errors, speedups, QOL changes ported from wave-12 branch (#2271) 2025-08-20 18:07:11 -07:00
Mike Sawka
462a1b68eb
fix gpt-5, and newer openai models that require maxcompletiontokens. (#2264) 2025-08-19 13:30:11 -07:00
Lilith-Sangreal
981a0882c1
feat: Claude AI configuration supports custom base URL (#2249)
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>
2025-08-19 11:30:58 -07:00
Mike Sawka
c66e79bc26
implement ai:proxyurl for proxy url access to different models (#2263) 2025-08-19 10:19:27 -07:00
Mike Sawka
58eb56408f
remove panic, and revert connserver from using non-blocking drainchannel safe (#2049) 2025-03-08 12:07:16 -08:00
Evan Simkowitz
d51ff87c26
Not found paths in prefix fs always treated as dir (#2002)
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
2025-02-21 16:32:14 -08:00
Evan Simkowitz
9ef213fc42
Fix XDG_RUNTIME_DIR setting in shellexec (#2019)
XDG_RUNTIME_DIR needs to be set. If it is not set by a user-defined
config, it should default to `/run/user/$UID`
2025-02-21 16:32:04 -08:00
Evan Simkowitz
aa7713e015
Remove env vars in shellexec if the value is empty in the overriding map (#2007) 2025-02-21 10:38:25 -08:00
Evan Simkowitz
7d1c80568d
Skip empty XDG values in shellexec (#2006) 2025-02-20 16:54:03 -08:00
Evan Simkowitz
b0e3b6d777
Fix move & copy for prefix filesystems (#1998)
Also makes recursive the default for copy, adds better error for move
without recursive
2025-02-20 10:17:32 -08:00
Mike Sawka
8d9e4b8dfd
remove wsh s3 dependency (#1994) 2025-02-18 18:52:32 -08:00
Evan Simkowitz
772ea41990
Clean up atom usage in preview (#1986) 2025-02-18 16:40:36 -08:00