Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Oct 17, 2025

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
Original prompt

for our web widgets... frontend/app/view/webview/webview.tsx ... i'd like to add a meta key -- wtypemeta.go called web:useragenttype ... it can have 3 values (or null), "default" | "mobile:iphone", "mobile:android" ... the default when null is "default". when set to one of the mobile values, it should override the "useragent" on the webview to an iphone/android useragent string (so we can emulate a mobile browser for debugging).

after editing wtypemeta.go you'll have to run task generate to run code generation (will update the FE types, gotypes.d.ts)

then we should update getSettingsMenuItems() in the model to add a new menu item User Agent Type that will have a sub-menu for selecting between them -- which will set the meta key (and thus change the user agent).

last, when we have a mobile user agent, we should add a new endIconButtons ... like some fontawesome mobile-looking icon... with a title tooltip that's appropriate. no click handler (it just shows status).


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@Copilot Copilot AI assigned Copilot and sawka Oct 17, 2025
@CLAassistant
Copy link

CLAassistant commented Oct 17, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ sawka
❌ Copilot
You have signed the CLA already but the status is still pending? Let us recheck it.

Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Add meta key for user agent type in webview Add mobile user agent emulation for web widgets Oct 17, 2025
Copilot finished work on behalf of sawka October 17, 2025 18:47
@Copilot Copilot AI requested a review from sawka October 17, 2025 18:47
Copy link
Contributor

coderabbitai bot commented Oct 18, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

@sawka sawka merged commit 665facb into main Oct 18, 2025
4 of 7 checks passed
@sawka sawka deleted the copilot/add-user-agent-type-meta branch October 18, 2025 00:45
a5af pushed a commit to a5af/waveterm that referenced this pull request Oct 18, 2025
Merges 59 commits from wavetermdev/waveterm v0.12.0 release into a5af fork.
Resolves 49 merge conflicts across frontend, backend, and configuration files.

## Major Upstream Features Integrated

### AI Enhancements (v0.12.0)
- AI Response Feedback + Copy Buttons (wavetermdev#2457)
- Reasoning Deltas Display (wavetermdev#2443)
- Google AI File Summarization (wavetermdev#2455)
- `wsh ai` Command Reimplementation (wavetermdev#2435)
- Terminal Context Improvements (wavetermdev#2444)
- Batch Tool Approval System
- Enhanced AI Panel with welcome message
- Context menu support for AI messages

### Infrastructure Updates
- Mobile User Agent Emulation for web widgets (wavetermdev#2454)
- OSC 7 Support for Fish & PowerShell shells (wavetermdev#2456)
- Log Rotation System (wavetermdev#2432)
- Onboarding improvements
- React 19 compatibility updates
- Tailwind v4 migration progress
- Dependency updates (50+ commits)

## Fork Features Preserved

✅ **Horizontal Widget Bar** (tabbar.tsx)
   - Widgets remain in horizontal tab bar (not reverted to sidebar)
   - Fork-specific layout maintained

✅ **Optional Pane Title Labels** (blockframe.tsx)
   - Auto-generated pane titles preserved
   - Custom block rendering logic intact

✅ **Layout Model Modifications** (layoutModel.ts)
   - Fork's widget positioning logic maintained
   - Horizontal layout integration preserved

## Conflict Resolution Summary

**Configuration (8 files):**
- Accepted upstream: .golangci.yml, Taskfile.yml, package.json, go.mod, etc.
- All dependencies updated to v0.12.0 levels

**Backend AI (13 files):**
- Accepted upstream: All pkg/aiusechat/ files
- New AI tools: read_dir, screenshot, terminal context
- Enhanced OpenAI backend with reasoning support

**Frontend AI Panel (12 files):**
- Accepted upstream: All frontend/app/aipanel/ files
- New features: reasoning display, feedback buttons, welcome message
- Enhanced message handling and UX

**Backend Infrastructure (7 files):**
- Accepted upstream: emain, pkg/telemetry, pkg/wcore, pkg/wshrpc
- Updated RPC types and telemetry data structures

**Frontend Fork Features (8 files):**
- Preserved fork: blockframe.tsx, tabbar.tsx, layoutModel.ts
- Accepted upstream: keymodel.ts, wshclientapi.ts, termwrap.ts, etc.

**Deleted Files (1 file):**
- Removed: frontend/app/modals/tos.tsx (deleted upstream)

## Files Changed

- Configuration: 8 files
- Backend: 20+ files
- Frontend: 25+ files
- Total staged: 135 files

## Testing Required

1. Verify AI panel functionality (reasoning, feedback, tools)
2. Test horizontal widget bar (fork feature)
3. Test pane title labels (fork feature)
4. Build verification: `npm install && npm run build:dev`
5. Backend build: `go build ./...`
6. Full test suite: `npm test`

## Known Issues

⚠️ Widget bar integration may need review - upstream removed widget sidebar
⚠️ Layout changes may conflict with horizontal widget positioning
⚠️ React 19 compatibility should be tested thoroughly

## Rollback

If issues arise, rollback available at:
- Tag: fork-v0.11.6-pre-v0.12-merge
- Branch: backup-pre-v0.12-merge

## Next Steps

1. Test all functionality thoroughly
2. Fix any runtime errors from merge
3. Review fork feature integration points
4. Update documentation if needed
5. Create PR to main after validation

---

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

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants