waveterm/pkg
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
..
aiusechat Add Google AI file summarization package (#2455) 2025-10-17 17:24:06 -07:00
authkey Happy new year! (#1684) 2025-01-04 20:56:57 -08:00
blockcontroller working on more terminal context (#2444) 2025-10-17 12:19:40 -07:00
blocklogger conn updates 3 (#1711) 2025-01-10 14:09:32 -08:00
docsite Add license identifiers to missing files (#1806) 2025-01-22 20:06:36 -08:00
eventbus Happy new year! (#1684) 2025-01-04 20:56:57 -08:00
faviconcache web bookmarks (#1930) 2025-02-07 16:11:40 -08:00
filestore Fix windows path for wsh url (#1798) 2025-01-22 17:28:59 -08:00
genconn WSL Updates for New Architecture (#1756) 2025-01-16 15:54:58 -08:00
gogen Embedded Structs in Code Generation (#1909) 2025-02-07 13:13:47 -08:00
ijson Happy new year! (#1684) 2025-01-04 20:56:57 -08:00
panichandler new tevents analytics framework (#1894) 2025-02-03 15:32:44 -08:00
remote Not found paths in prefix fs always treated as dir (#2002) 2025-02-21 16:32:14 -08:00
schema settings schema.json (#1874) 2025-02-03 14:20:50 -08:00
service add tsunami view in wave (#2350) 2025-09-15 12:58:59 -07:00
shellexec implement cmd:jwt and fix remote execution of commands (#2292) 2025-08-26 16:23:48 -07:00
suggestion remove wsh s3 dependency (#1994) 2025-02-18 18:52:32 -08:00
telemetry Add AI Response Feedback + Copy Buttons (#2457) 2025-10-17 14:18:30 -07:00
trimquotes Add license identifiers to missing files (#1806) 2025-01-22 20:06:36 -08:00
tsgen New AIPanel (#2370) 2025-10-07 13:32:10 -07:00
userinput Known Hosts User Input Fix (#1778) 2025-01-20 14:38:40 -08:00
util Add OSC 7 support for Fish and PowerShell shells (#2456) 2025-10-17 17:23:08 -07:00
utilds add tsunami view in wave (#2350) 2025-09-15 12:58:59 -07:00
vdom Happy new year! (#1684) 2025-01-04 20:56:57 -08:00
waveai New AIPanel (#2370) 2025-10-07 13:32:10 -07:00
waveapp fail any rpc call which blocks the runServer loop for more than 1s (#1861) 2025-01-27 22:38:19 -08:00
wavebase working on more terminal context (#2444) 2025-10-17 12:19:40 -07:00
waveobj Add mobile user agent emulation for web widgets (#2454) 2025-10-17 17:45:32 -07:00
wcloud working on more terminal context (#2444) 2025-10-17 12:19:40 -07:00
wconfig exclude autoupdate channel in custom settings (#2438) 2025-10-15 21:20:58 -07:00
wcore Updates to prepare for v0.12 launch (#2434) 2025-10-15 16:10:37 -07:00
web Reimplement wsh ai, fix text file attaching format (#2435) 2025-10-15 17:28:56 -07:00
wps New AIPanel (#2370) 2025-10-07 13:32:10 -07:00
wshrpc handle reasoning deltas and display them in the UI (#2443) 2025-10-16 11:17:24 -07:00
wshutil s3 suggestions + widget cache (#1987) 2025-02-18 15:15:12 -08:00
wsl WSL Updates for New Architecture (#1756) 2025-01-16 15:54:58 -08:00
wslconn new tevents analytics framework (#1894) 2025-02-03 15:32:44 -08:00
wstore working on more terminal context (#2444) 2025-10-17 12:19:40 -07:00