mirror of
https://github.com/wavetermdev/waveterm
synced 2026-05-21 15:58:30 +00:00
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>
141 lines
6.4 KiB
Go
141 lines
6.4 KiB
Go
// Copyright 2025, Command Line Inc.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
// Generated Code. DO NOT EDIT.
|
|
|
|
package waveobj
|
|
|
|
const (
|
|
MetaKey_View = "view"
|
|
|
|
MetaKey_Controller = "controller"
|
|
|
|
MetaKey_File = "file"
|
|
|
|
MetaKey_Url = "url"
|
|
|
|
MetaKey_PinnedUrl = "pinnedurl"
|
|
|
|
MetaKey_Connection = "connection"
|
|
|
|
MetaKey_Edit = "edit"
|
|
|
|
MetaKey_History = "history"
|
|
MetaKey_HistoryForward = "history:forward"
|
|
|
|
MetaKey_DisplayName = "display:name"
|
|
MetaKey_DisplayOrder = "display:order"
|
|
|
|
MetaKey_Icon = "icon"
|
|
MetaKey_IconColor = "icon:color"
|
|
|
|
MetaKey_FrameClear = "frame:*"
|
|
MetaKey_Frame = "frame"
|
|
MetaKey_FrameBorderColor = "frame:bordercolor"
|
|
MetaKey_FrameActiveBorderColor = "frame:activebordercolor"
|
|
MetaKey_FrameTitle = "frame:title"
|
|
MetaKey_FrameIcon = "frame:icon"
|
|
MetaKey_FrameText = "frame:text"
|
|
|
|
MetaKey_CmdClear = "cmd:*"
|
|
MetaKey_Cmd = "cmd"
|
|
MetaKey_CmdInteractive = "cmd:interactive"
|
|
MetaKey_CmdLogin = "cmd:login"
|
|
MetaKey_CmdRunOnStart = "cmd:runonstart"
|
|
MetaKey_CmdClearOnStart = "cmd:clearonstart"
|
|
MetaKey_CmdRunOnce = "cmd:runonce"
|
|
MetaKey_CmdCloseOnExit = "cmd:closeonexit"
|
|
MetaKey_CmdCloseOnExitForce = "cmd:closeonexitforce"
|
|
MetaKey_CmdCloseOnExitDelay = "cmd:closeonexitdelay"
|
|
MetaKey_CmdNoWsh = "cmd:nowsh"
|
|
MetaKey_CmdArgs = "cmd:args"
|
|
MetaKey_CmdShell = "cmd:shell"
|
|
MetaKey_CmdAllowConnChange = "cmd:allowconnchange"
|
|
MetaKey_CmdJwt = "cmd:jwt"
|
|
MetaKey_CmdEnv = "cmd:env"
|
|
MetaKey_CmdCwd = "cmd:cwd"
|
|
MetaKey_CmdInitScript = "cmd:initscript"
|
|
MetaKey_CmdInitScriptSh = "cmd:initscript.sh"
|
|
MetaKey_CmdInitScriptBash = "cmd:initscript.bash"
|
|
MetaKey_CmdInitScriptZsh = "cmd:initscript.zsh"
|
|
MetaKey_CmdInitScriptPwsh = "cmd:initscript.pwsh"
|
|
MetaKey_CmdInitScriptFish = "cmd:initscript.fish"
|
|
|
|
MetaKey_AiClear = "ai:*"
|
|
MetaKey_AiPresetKey = "ai:preset"
|
|
MetaKey_AiApiType = "ai:apitype"
|
|
MetaKey_AiBaseURL = "ai:baseurl"
|
|
MetaKey_AiApiToken = "ai:apitoken"
|
|
MetaKey_AiName = "ai:name"
|
|
MetaKey_AiModel = "ai:model"
|
|
MetaKey_AiOrgID = "ai:orgid"
|
|
MetaKey_AIApiVersion = "ai:apiversion"
|
|
MetaKey_AiMaxTokens = "ai:maxtokens"
|
|
MetaKey_AiTimeoutMs = "ai:timeoutms"
|
|
|
|
MetaKey_EditorClear = "editor:*"
|
|
MetaKey_EditorMinimapEnabled = "editor:minimapenabled"
|
|
MetaKey_EditorStickyScrollEnabled = "editor:stickyscrollenabled"
|
|
MetaKey_EditorWordWrap = "editor:wordwrap"
|
|
MetaKey_EditorFontSize = "editor:fontsize"
|
|
|
|
MetaKey_GraphClear = "graph:*"
|
|
MetaKey_GraphNumPoints = "graph:numpoints"
|
|
MetaKey_GraphMetrics = "graph:metrics"
|
|
|
|
MetaKey_SysinfoType = "sysinfo:type"
|
|
|
|
MetaKey_BgClear = "bg:*"
|
|
MetaKey_Bg = "bg"
|
|
MetaKey_BgOpacity = "bg:opacity"
|
|
MetaKey_BgBlendMode = "bg:blendmode"
|
|
MetaKey_BgBorderColor = "bg:bordercolor"
|
|
MetaKey_BgActiveBorderColor = "bg:activebordercolor"
|
|
|
|
MetaKey_WaveAiPanelOpen = "waveai:panelopen"
|
|
MetaKey_WaveAiPanelWidth = "waveai:panelwidth"
|
|
MetaKey_WaveAiModel = "waveai:model"
|
|
MetaKey_WaveAiChatId = "waveai:chatid"
|
|
MetaKey_WaveAiWidgetContext = "waveai:widgetcontext"
|
|
|
|
MetaKey_TermClear = "term:*"
|
|
MetaKey_TermFontSize = "term:fontsize"
|
|
MetaKey_TermFontFamily = "term:fontfamily"
|
|
MetaKey_TermMode = "term:mode"
|
|
MetaKey_TermTheme = "term:theme"
|
|
MetaKey_TermLocalShellPath = "term:localshellpath"
|
|
MetaKey_TermLocalShellOpts = "term:localshellopts"
|
|
MetaKey_TermScrollback = "term:scrollback"
|
|
MetaKey_TermVDomSubBlockId = "term:vdomblockid"
|
|
MetaKey_TermVDomToolbarBlockId = "term:vdomtoolbarblockid"
|
|
MetaKey_TermTransparency = "term:transparency"
|
|
MetaKey_TermAllowBracketedPaste = "term:allowbracketedpaste"
|
|
MetaKey_TermShiftEnterNewline = "term:shiftenternewline"
|
|
MetaKey_TermConnDebug = "term:conndebug"
|
|
|
|
MetaKey_WebZoom = "web:zoom"
|
|
MetaKey_WebHideNav = "web:hidenav"
|
|
MetaKey_WebPartition = "web:partition"
|
|
MetaKey_WebUserAgentType = "web:useragenttype"
|
|
|
|
MetaKey_MarkdownFontSize = "markdown:fontsize"
|
|
MetaKey_MarkdownFixedFontSize = "markdown:fixedfontsize"
|
|
|
|
MetaKey_TsunamiClear = "tsunami:*"
|
|
MetaKey_TsunamiSdkReplacePath = "tsunami:sdkreplacepath"
|
|
MetaKey_TsunamiAppPath = "tsunami:apppath"
|
|
MetaKey_TsunamiScaffoldPath = "tsunami:scaffoldpath"
|
|
MetaKey_TsunamiEnv = "tsunami:env"
|
|
|
|
MetaKey_VDomClear = "vdom:*"
|
|
MetaKey_VDomInitialized = "vdom:initialized"
|
|
MetaKey_VDomCorrelationId = "vdom:correlationid"
|
|
MetaKey_VDomRoute = "vdom:route"
|
|
MetaKey_VDomPersist = "vdom:persist"
|
|
|
|
MetaKey_OnboardingGithubStar = "onboarding:githubstar"
|
|
MetaKey_OnboardingLastVersion = "onboarding:lastversion"
|
|
|
|
MetaKey_Count = "count"
|
|
)
|
|
|