fix(browser): refine connection and preview UI with extension version
parent
a89a5a2c43
commit
b8f081f03a
|
|
@ -78,6 +78,9 @@ export default {
|
|||
"pause": "Pause browser",
|
||||
"start": "Start task",
|
||||
"stop": "End browser task",
|
||||
"resumeShort": "Resume",
|
||||
"pauseShort": "Pause",
|
||||
"stopShort": "End",
|
||||
"pairHint": "Open Connection settings → Remote connection in the extension, paste the pairing link, and confirm the server. The link is valid for 5 minutes and can be used once.",
|
||||
"copyPairing": "Copy pairing link",
|
||||
"copied": "Copied",
|
||||
|
|
@ -96,10 +99,14 @@ export default {
|
|||
"reconnectHint": "Authorization is saved. Keep Chrome and BrowserSkill open to reconnect automatically.",
|
||||
"replaceDevice": "Change browser",
|
||||
"installExtension": "Install BrowserSkill",
|
||||
"installHint": "Use the matching package for this server; the official store version may receive updates later.",
|
||||
"storeInstall": "Open Chrome Web Store",
|
||||
"manualInstall": "Install manually (alternative)",
|
||||
"storeInstallHint": "Install BrowserSkill from the Chrome Web Store, then return here to pair.",
|
||||
"installHint": "If the store is unavailable or its version is incompatible, download the matching package and install it manually.",
|
||||
"downloadExtension": "Download matching package",
|
||||
"officialExtension": "Official extension (Chrome Web Store)",
|
||||
"installGuide": "How do I install the downloaded package?",
|
||||
"pairGuide": "How do I use the pairing link?",
|
||||
"pairBrowser": "Connect this browser",
|
||||
"packageUnavailable": "Ask your administrator for the matching extension package; a download is not configured yet.",
|
||||
"manualCopy": "Select and copy the link below. It expires in 5 minutes and can be used once.",
|
||||
|
|
|
|||
|
|
@ -78,6 +78,9 @@ export default {
|
|||
"pause": "操作を一時停止",
|
||||
"start": "タスクを開始",
|
||||
"stop": "ブラウザータスクを終了",
|
||||
"resumeShort": "再開",
|
||||
"pauseShort": "一時停止",
|
||||
"stopShort": "終了",
|
||||
"pairHint": "拡張機能の「接続設定 → リモート接続」にリンクを貼り付け、サーバーを確認します。リンクは 5 分間有効で、1 回限り使用できます。",
|
||||
"copyPairing": "ペアリングリンクをコピー",
|
||||
"copied": "コピーしました",
|
||||
|
|
@ -96,10 +99,14 @@ export default {
|
|||
"reconnectHint": "認証は保存されています。Chrome と拡張機能を開くと自動的に再接続します。",
|
||||
"replaceDevice": "ブラウザーを変更",
|
||||
"installExtension": "BrowserSkill をインストール",
|
||||
"installHint": "このサーバーに対応するパッケージを推奨します。公式ストアへの更新反映は遅れる場合があります。",
|
||||
"storeInstall": "Chrome ウェブストアへ",
|
||||
"manualInstall": "手動インストール(代替手段)",
|
||||
"storeInstallHint": "Chrome ウェブストアから BrowserSkill をインストールし、ここに戻ってペアリングしてください。",
|
||||
"installHint": "ストアにアクセスできない場合やバージョンに互換性がない場合は、対応パッケージをダウンロードして手動でインストールできます。",
|
||||
"downloadExtension": "対応パッケージをダウンロード",
|
||||
"officialExtension": "公式拡張機能(Chrome ウェブストア)",
|
||||
"installGuide": "ダウンロードしたパッケージのインストール方法",
|
||||
"pairGuide": "ペアリングリンクの使い方",
|
||||
"pairBrowser": "ブラウザーを接続",
|
||||
"packageUnavailable": "対応する拡張機能パッケージを管理者から入手してください。",
|
||||
"manualCopy": "下のリンクをコピーしてください。有効期限は 5 分、使用は 1 回限りです。",
|
||||
|
|
|
|||
|
|
@ -78,6 +78,9 @@ export default {
|
|||
"pause": "조작 일시 중지",
|
||||
"start": "작업 시작",
|
||||
"stop": "브라우저 작업 종료",
|
||||
"resumeShort": "재개",
|
||||
"pauseShort": "일시 중지",
|
||||
"stopShort": "종료",
|
||||
"pairHint": "확장 프로그램의 연결 설정 → 원격 연결에 페어링 링크를 붙여넣고 서버를 확인하세요. 링크는 5분 동안 한 번만 사용할 수 있습니다.",
|
||||
"copyPairing": "페어링 링크 복사",
|
||||
"copied": "복사됨",
|
||||
|
|
@ -96,10 +99,14 @@ export default {
|
|||
"reconnectHint": "인증이 저장되어 있습니다. Chrome과 확장 프로그램을 열면 자동으로 다시 연결됩니다.",
|
||||
"replaceDevice": "브라우저 변경",
|
||||
"installExtension": "BrowserSkill 설치",
|
||||
"installHint": "현재 서버와 호환되는 패키지를 권장합니다. 공식 스토어에는 업데이트가 늦게 반영될 수 있습니다.",
|
||||
"storeInstall": "Chrome 웹 스토어 열기",
|
||||
"manualInstall": "수동 설치 (대안)",
|
||||
"storeInstallHint": "Chrome 웹 스토어에서 BrowserSkill을 설치한 후 여기로 돌아와 페어링하세요.",
|
||||
"installHint": "스토어에 접근할 수 없거나 버전이 호환되지 않으면 호환 패키지를 다운로드하여 수동으로 설치할 수 있습니다.",
|
||||
"downloadExtension": "호환 패키지 다운로드",
|
||||
"officialExtension": "공식 확장 프로그램 (Chrome 웹 스토어)",
|
||||
"installGuide": "다운로드한 패키지는 어떻게 설치하나요?",
|
||||
"pairGuide": "페어링 링크는 어떻게 사용하나요?",
|
||||
"pairBrowser": "브라우저 연결",
|
||||
"packageUnavailable": "관리자에게 호환되는 확장 프로그램 패키지를 요청하세요.",
|
||||
"manualCopy": "아래 링크를 복사하세요. 5분 동안 한 번만 사용할 수 있습니다.",
|
||||
|
|
|
|||
|
|
@ -78,6 +78,9 @@ export default {
|
|||
"pause": "Приостановить браузер",
|
||||
"start": "Начать задачу",
|
||||
"stop": "Завершить задачу браузера",
|
||||
"resumeShort": "Продолжить",
|
||||
"pauseShort": "Пауза",
|
||||
"stopShort": "Завершить",
|
||||
"pairHint": "Откройте в расширении «Настройки подключения → Удалённое подключение», вставьте ссылку и подтвердите сервер. Ссылка действует 5 минут и используется один раз.",
|
||||
"copyPairing": "Скопировать ссылку",
|
||||
"copied": "Скопировано",
|
||||
|
|
@ -96,10 +99,14 @@ export default {
|
|||
"reconnectHint": "Авторизация сохранена. Откройте Chrome и BrowserSkill для автоматического подключения.",
|
||||
"replaceDevice": "Сменить браузер",
|
||||
"installExtension": "Установите BrowserSkill",
|
||||
"installHint": "Рекомендуем пакет для этого сервера: обновления в официальном магазине могут появляться позже.",
|
||||
"storeInstall": "Открыть магазин Chrome",
|
||||
"manualInstall": "Установить вручную (альтернатива)",
|
||||
"storeInstallHint": "Установите BrowserSkill из Интернет-магазина Chrome, затем вернитесь сюда для сопряжения.",
|
||||
"installHint": "Если магазин недоступен или версия несовместима, скачайте подходящий пакет и установите его вручную.",
|
||||
"downloadExtension": "Скачать совместимый пакет",
|
||||
"officialExtension": "Официальное расширение (Интернет-магазин Chrome)",
|
||||
"installGuide": "Как установить скачанный пакет?",
|
||||
"pairGuide": "Как использовать ссылку сопряжения?",
|
||||
"pairBrowser": "Подключите браузер",
|
||||
"packageUnavailable": "Запросите совместимое расширение у администратора.",
|
||||
"manualCopy": "Скопируйте ссылку ниже. Она действует 5 минут и используется один раз.",
|
||||
|
|
|
|||
|
|
@ -78,6 +78,9 @@ export default {
|
|||
"pause": "暂停操作",
|
||||
"start": "开始任务",
|
||||
"stop": "结束浏览器任务",
|
||||
"resumeShort": "继续",
|
||||
"pauseShort": "暂停",
|
||||
"stopShort": "结束",
|
||||
"pairHint": "打开扩展的「连接设置 → 远程连接」,粘贴配对链接并确认服务器。链接 5 分钟内有效,仅可使用一次。",
|
||||
"copyPairing": "复制配对链接",
|
||||
"copied": "已复制",
|
||||
|
|
@ -96,10 +99,14 @@ export default {
|
|||
"reconnectHint": "保留授权,等待扩展自动重连。请确认 Chrome 和 BrowserSkill 扩展已开启。",
|
||||
"replaceDevice": "更换浏览器",
|
||||
"installExtension": "安装 BrowserSkill 扩展",
|
||||
"installHint": "建议使用与当前服务匹配的配套扩展;官方商店版本可能稍晚更新。",
|
||||
"storeInstall": "前往 Chrome 商店",
|
||||
"manualInstall": "手动安装(备用)",
|
||||
"storeInstallHint": "在 Chrome 应用商店安装 BrowserSkill,再回到这里配对。",
|
||||
"installHint": "无法访问商店或商店版本不兼容时,可下载配套扩展并手动安装。",
|
||||
"downloadExtension": "下载配套扩展",
|
||||
"officialExtension": "官方扩展(Chrome 应用商店)",
|
||||
"installGuide": "如何安装下载的扩展包?",
|
||||
"pairGuide": "如何使用配对链接?",
|
||||
"pairBrowser": "连接这台浏览器",
|
||||
"packageUnavailable": "管理员尚未配置扩展下载包,请向管理员获取配套版本。",
|
||||
"manualCopy": "点击下方输入框复制链接,5 分钟内有效,仅可配对一次。",
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ test('human handoff expands, stays reachable on narrow screens, focuses the brow
|
|||
export async function get() { return {data:{...window.fixtureStatus}} }
|
||||
export async function post(_, {action}) {
|
||||
window.fixtureActions.push(action);
|
||||
return {data: action === 'preview' ? {image_base64:'',format:'jpeg'} : {...window.fixtureStatus}};
|
||||
return {data: action === 'preview' ? {image_base64:window.fixtureFrame || '',format:'png'} : {...window.fixtureStatus}};
|
||||
}`
|
||||
if (id === '\0/fixture-entry.js') return `
|
||||
import {createApp} from 'vue'; import {createPinia} from 'pinia';
|
||||
|
|
@ -55,7 +55,23 @@ test('human handoff expands, stays reachable on narrow screens, focuses the brow
|
|||
await page.goto(`http://127.0.0.1:${server.httpServer.address().port}/fixture`)
|
||||
const card = page.locator('.browser-task-preview')
|
||||
await card.waitFor()
|
||||
assert.equal(Math.round((await card.boundingBox()).width),240)
|
||||
assert.equal(Math.round((await card.boundingBox()).width),320)
|
||||
// A new frame can change aspect ratio when the source browser is resized.
|
||||
for (const [width, height] of [[1200, 600], [600, 900]]) {
|
||||
await page.evaluate(([width, height]) => {
|
||||
const canvas = document.createElement('canvas')
|
||||
canvas.width = width; canvas.height = height
|
||||
window.fixtureFrame = canvas.toDataURL('image/png').split(',')[1]
|
||||
}, [width, height])
|
||||
await page.waitForFunction(([width, height]) => {
|
||||
const image = document.querySelector('.preview-image img')
|
||||
return image?.naturalWidth === width && image?.naturalHeight === height
|
||||
}, [width, height])
|
||||
const image = await page.locator('.preview-image img').boundingBox()
|
||||
const frame = await page.locator('.preview-image').boundingBox()
|
||||
assert.ok(Math.abs(image.width / image.height - width / height) < 0.01, 'preserve source aspect ratio')
|
||||
assert.ok(Math.abs(frame.height - image.height) <= 2, 'frame follows image without a fixed-height gap')
|
||||
}
|
||||
await page.evaluate(() => {
|
||||
window.fixtureStatus.needs_help=true
|
||||
window.fixtureStatus.help_prompt='请在浏览器中扫码登录,完成后确认。'.repeat(18)
|
||||
|
|
@ -80,6 +96,6 @@ test('human handoff expands, stays reachable on narrow screens, focuses the brow
|
|||
await page.evaluate(() => { window.fixtureStatus.needs_help=false; window.fixtureStatus.help_prompt='' })
|
||||
await page.waitForFunction(() => !document.querySelector('.needs-help'))
|
||||
assert.equal(await page.locator('.preview-handoff').count(),0)
|
||||
assert.equal(Math.round((await card.boundingBox()).width),200)
|
||||
assert.equal(Math.round((await card.boundingBox()).width),280)
|
||||
} finally { await browser?.close(); await server.close() }
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,33 +1,55 @@
|
|||
<template>
|
||||
<Teleport :to="pipTarget || 'body'" :disabled="!pipTarget">
|
||||
<aside v-if="status.selected" ref="previewElement" class="browser-task-preview" :class="{ 'is-dragging': dragging, 'is-pip': !!pipTarget, 'needs-help': status.needs_help }" :style="pipTarget ? {} : positionStyle" :aria-label="t('localBrowser.preview')">
|
||||
<div class="preview-heading" @pointerdown="!pipTarget && startDrag($event)" @pointermove="moveDrag" @pointerup="stopDrag" @pointercancel="stopDrag" @lostpointercapture="stopDrag"><BrowserIcon class="preview-browser-icon" width="20" height="20" /><strong>{{ t('localBrowser.local') }}</strong><span>{{ t(!status.connected ? 'localBrowser.offline' : status.stopping ? 'localBrowser.stopping' : status.paused ? 'localBrowser.paused' : status.needs_help ? 'localBrowser.needHelp' : status.task_id ? 'localBrowser.connected' : 'localBrowser.waiting') }}</span>
|
||||
<button v-if="pipSupported" class="preview-popout" :disabled="pipOpening" :title="t(pipTarget ? 'localBrowser.pipReturn' : 'localBrowser.pipOpen')" :aria-label="t(pipTarget ? 'localBrowser.pipReturn' : 'localBrowser.pipOpen')" @pointerdown.stop @click="togglePictureInPicture"><t-icon :name="pipTarget ? 'fullscreen-exit' : 'fullscreen'" size="16px" /></button>
|
||||
</div>
|
||||
<section v-if="status.needs_help" class="preview-handoff" role="status" aria-live="polite">
|
||||
<strong>{{ t('localBrowser.needHelp') }}</strong>
|
||||
<p v-if="status.help_prompt" class="handoff-prompt">{{ status.help_prompt }}</p>
|
||||
<p>{{ t(status.action === 'tab_borrow' ? 'localBrowser.borrowHint' : 'localBrowser.helpHint') }}</p>
|
||||
<t-button v-if="status.action !== 'tab_borrow'" class="handoff-locate" theme="default" variant="outline" size="small" :disabled="!status.connected || !status.task_id || busy || status.stopping" @click="act('focus')"><t-icon name="jump" />{{ t('localBrowser.locateWindow') }}</t-button>
|
||||
</section>
|
||||
<button v-if="!(status.needs_help && status.action === 'tab_borrow')" class="preview-image" :disabled="!status.connected || !status.task_id || busy || status.stopping" :aria-label="t('localBrowser.locateWindow')" @click="act('focus')">
|
||||
<img v-if="preview" :src="preview" :alt="t('localBrowser.preview')" />
|
||||
<span v-else>{{ t(status.connected ? 'localBrowser.waiting' : 'localBrowser.reconnectShort') }}</span>
|
||||
<span v-if="status.connected && status.task_id" class="locate"><t-icon name="jump" size="13px" />{{ t('localBrowser.locateWindow') }}</span>
|
||||
</button>
|
||||
<p v-if="status.action" class="preview-progress">{{ browserActionLabel(t, status.action) }} · {{ t('localBrowser.elapsedSeconds', { seconds: Math.floor((status.action_elapsed_ms || 0) / 1000) }) }}</p>
|
||||
<p v-if="browserPageAddress(status.page_url)" class="preview-address">{{ browserPageAddress(status.page_url) }}</p>
|
||||
<p v-if="status.last_error" class="preview-error">{{ status.last_error }}</p>
|
||||
<p class="preview-sync" role="status">{{ t(!status.connected ? 'localBrowser.reconnectShort' : status.idle ? 'localBrowser.previewIdle' : previewStale ? 'localBrowser.previewStale' : preview ? 'localBrowser.previewLive' : 'localBrowser.previewLoading') }}</p>
|
||||
<p v-if="pipFailed" class="preview-error" role="alert">{{ t('localBrowser.pipFailed') }}</p>
|
||||
<p v-if="error" class="preview-error" role="alert">{{ error }}</p>
|
||||
<p class="preview-scope">{{ t('localBrowser.controlScope') }}</p>
|
||||
<div class="preview-actions">
|
||||
<t-button v-if="status.connected" :title="t(status.paused ? 'localBrowser.resume' : 'localBrowser.pauseHint')" size="small" theme="default" variant="text" :disabled="busy || status.stopping" @click="act(status.paused ? 'resume' : 'pause')">{{ t(status.paused ? 'localBrowser.resume' : 'localBrowser.pause') }}</t-button>
|
||||
<t-button v-else size="small" theme="default" variant="text" @click="openBrowserSettings">{{ t('localBrowser.settingsTitle') }}</t-button>
|
||||
<t-button :title="t('localBrowser.stopHint')" size="small" theme="default" variant="text" :disabled="busy || status.stopping" @click="act('stop')">{{ t('localBrowser.stop') }}</t-button>
|
||||
</div>
|
||||
</aside>
|
||||
<aside v-if="status.selected" ref="previewElement" class="browser-task-preview"
|
||||
:class="{ 'is-dragging': dragging, 'is-pip': !!pipTarget, 'needs-help': status.needs_help }"
|
||||
:style="pipTarget ? {} : positionStyle" :aria-label="t('localBrowser.preview')">
|
||||
<div class="preview-heading" @pointerdown="!pipTarget && startDrag($event)" @pointermove="moveDrag"
|
||||
@pointerup="stopDrag" @pointercancel="stopDrag" @lostpointercapture="stopDrag">
|
||||
<BrowserIcon class="preview-browser-icon" width="16" height="16" />
|
||||
<strong :title="pageAddress || t('localBrowser.controlScope')">{{ pageHost || t('localBrowser.local') }}</strong>
|
||||
<button v-if="!(status.needs_help && status.action === 'tab_borrow')" class="preview-popout"
|
||||
:disabled="!status.connected || !status.task_id || busy || status.stopping"
|
||||
:title="t('localBrowser.locateWindow')" :aria-label="t('localBrowser.locateWindow')"
|
||||
@pointerdown.stop @click="act('focus')"><t-icon name="jump" size="15px" /></button>
|
||||
<button v-if="pipSupported" class="preview-popout" :disabled="pipOpening"
|
||||
:title="t(pipTarget ? 'localBrowser.pipReturn' : 'localBrowser.pipOpen')"
|
||||
:aria-label="t(pipTarget ? 'localBrowser.pipReturn' : 'localBrowser.pipOpen')"
|
||||
@pointerdown.stop @click="togglePictureInPicture"><t-icon :name="pipTarget ? 'fullscreen-exit' : 'fullscreen'" size="15px" /></button>
|
||||
</div>
|
||||
<section v-if="status.needs_help" class="preview-handoff" role="status" aria-live="polite">
|
||||
<strong>{{ t('localBrowser.needHelp') }}</strong>
|
||||
<p v-if="status.help_prompt" class="handoff-prompt">{{ status.help_prompt }}</p>
|
||||
<p>{{ t(status.action === 'tab_borrow' ? 'localBrowser.borrowHint' : 'localBrowser.helpHint') }}</p>
|
||||
<t-button v-if="status.action !== 'tab_borrow'" class="handoff-locate" theme="default" variant="outline" size="small"
|
||||
:disabled="!status.connected || !status.task_id || busy || status.stopping" @click="act('focus')">
|
||||
<t-icon name="jump" />{{ t('localBrowser.locateWindow') }}
|
||||
</t-button>
|
||||
</section>
|
||||
<button v-if="!(status.needs_help && status.action === 'tab_borrow')" class="preview-image" :class="{ 'is-empty': !preview }"
|
||||
:disabled="!status.connected || !status.task_id || busy || status.stopping"
|
||||
:aria-label="t('localBrowser.locateWindow')" :title="t('localBrowser.locateWindow')" @click="act('focus')">
|
||||
<img v-if="preview" :src="preview" :alt="t('localBrowser.preview')" />
|
||||
<span v-else class="preview-empty"><BrowserIcon width="28" height="28" />{{ t(status.connected ? 'localBrowser.waiting' : 'localBrowser.reconnectShort') }}</span>
|
||||
</button>
|
||||
<p v-if="status.last_error" class="preview-error" role="alert">{{ status.last_error }}</p>
|
||||
<p v-if="pipFailed" class="preview-error" role="alert">{{ t('localBrowser.pipFailed') }}</p>
|
||||
<p v-if="error" class="preview-error" role="alert">{{ error }}</p>
|
||||
<div class="preview-toolbar" :aria-label="t('localBrowser.controlScope')">
|
||||
<span class="preview-status" :class="{ live: status.connected && !status.paused && !status.stopping && !status.needs_help && !status.idle && !previewStale, attention: status.needs_help || status.paused }"
|
||||
:title="statusDetail" role="status"><i /><span>{{ statusLabel }}</span></span>
|
||||
<div class="preview-actions">
|
||||
<button v-if="status.connected" class="preview-control"
|
||||
:aria-label="t(status.paused ? 'localBrowser.resume' : 'localBrowser.pause')"
|
||||
:title="t(status.paused ? 'localBrowser.resume' : 'localBrowser.pauseHint')"
|
||||
:disabled="busy || status.stopping" @click="act(status.paused ? 'resume' : 'pause')">
|
||||
<t-icon :name="status.paused ? 'play' : 'pause'" size="14px" />{{ t(status.paused ? 'localBrowser.resumeShort' : 'localBrowser.pauseShort') }}
|
||||
</button>
|
||||
<button v-else class="preview-control" @click="openBrowserSettings">{{ t('localBrowser.settingsTitle') }}</button>
|
||||
<button class="preview-control" :title="t('localBrowser.stopHint')" :aria-label="t('localBrowser.stop')"
|
||||
:disabled="busy || status.stopping" @click="act('stop')"><t-icon name="stop" size="14px" />{{ t('localBrowser.stopShort') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
</Teleport>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
|
|
@ -43,6 +65,26 @@ const props = defineProps<{ sessionId: string }>()
|
|||
const { t } = useI18n(), uiStore = useUIStore()
|
||||
const status = ref({ enabled: false, selected: false, connected: false, paused: false, idle: false, needs_help: false, help_prompt: '', task_id: '', action: '', action_elapsed_ms: 0, page_url: '', last_error: '', stopping: false })
|
||||
const busy = ref(false), error = ref(''), preview = ref(''), previewStale = ref(false)
|
||||
const pageAddress = computed(() => browserPageAddress(status.value.page_url))
|
||||
const pageHost = computed(() => pageAddress.value ? new URL(pageAddress.value).hostname : '')
|
||||
const statusLabel = computed(() => {
|
||||
const s = status.value
|
||||
if (!s.connected) return t('localBrowser.offline')
|
||||
if (s.stopping) return t('localBrowser.stopping')
|
||||
if (s.needs_help) return t('localBrowser.needHelp')
|
||||
if (s.paused) return t('localBrowser.paused')
|
||||
if (s.idle) return t('localBrowser.previewIdle')
|
||||
if (previewStale.value) return t('localBrowser.previewStale')
|
||||
if (!s.task_id) return t('localBrowser.waiting')
|
||||
if (s.action) return browserActionLabel(t, s.action)
|
||||
return t(preview.value ? 'localBrowser.running' : 'localBrowser.previewLoading')
|
||||
})
|
||||
const statusDetail = computed(() => [
|
||||
statusLabel.value,
|
||||
status.value.action ? t('localBrowser.elapsedSeconds', { seconds: Math.floor((status.value.action_elapsed_ms || 0) / 1000) }) : '',
|
||||
preview.value && !previewStale.value ? t('localBrowser.previewLive') : '',
|
||||
].filter(Boolean).join(' · '))
|
||||
|
||||
const { supported: pipSupported, target: pipTarget, opening: pipOpening, open: openPiP, close: closePiP } = useDocumentPictureInPicture(computed(() => status.value.selected), () => t('localBrowser.preview'))
|
||||
const previewElement = ref<HTMLElement | null>(null)
|
||||
const { positionStyle, dragging, startDrag, moveDrag, stopDrag } = useFloatingPreviewDrag(computed(() => pipTarget.value ? null : previewElement.value))
|
||||
|
|
@ -106,30 +148,71 @@ onMounted(() => { document.addEventListener('visibilitychange', onVisible); void
|
|||
onBeforeUnmount(() => { alive = false; document.removeEventListener('visibilitychange', onVisible); revision++; cancelTimer?.(); controller.abort(); preview.value = '' })
|
||||
</script>
|
||||
<style scoped>
|
||||
.browser-task-preview { position: absolute; right: 20px; bottom: 16px; width: 240px; max-width: calc(100% - 40px); max-height: calc(100% - 24px); box-sizing: border-box; z-index: 5; overflow: auto; background: var(--td-bg-color-container); border: 1px solid var(--td-component-border); border-radius: var(--app-radius-xl); box-shadow: 0 4px 20px #0000000d; }
|
||||
.browser-task-preview {
|
||||
position: absolute; right: 20px; bottom: 16px; width: 320px; max-width: calc(100% - 40px);
|
||||
max-height: calc(100% - 24px); box-sizing: border-box; z-index: 5; overflow: auto;
|
||||
background: var(--td-bg-color-container); border: 1px solid var(--td-component-stroke);
|
||||
border-radius: 12px; box-shadow: 0 8px 28px #18252014, 0 2px 6px #18252008;
|
||||
}
|
||||
.preview-heading {
|
||||
display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 9px 0 12px;
|
||||
cursor: grab; touch-action: none; user-select: none; position: sticky; top: 0; z-index: 1;
|
||||
background: var(--td-bg-color-container);
|
||||
}
|
||||
.is-dragging .preview-heading { cursor: grabbing; }
|
||||
.preview-browser-icon { flex-shrink: 0; color: var(--td-text-color-secondary); }
|
||||
.preview-heading { display: flex; align-items: center; gap: 7px; padding: 10px 12px; cursor: grab; touch-action: none; user-select: none; position: sticky; top: 0; z-index: 1; background: var(--td-bg-color-container); }.is-dragging .preview-heading { cursor: grabbing; }.preview-heading strong { font-size: var(--app-text-sm); font-weight: 500; flex: 1; }.preview-heading span { color: var(--td-text-color-secondary); font-size: var(--app-text-xs); }
|
||||
.preview-image { width: 100%; height: 126px; border: 0; border-block: 1px solid var(--td-component-border); background: var(--td-bg-color-secondarycontainer); color: var(--td-text-color-secondary); display: grid; place-items: center; position: relative; cursor: pointer; padding: 0; font-size: var(--app-text-sm); }.preview-image:disabled { cursor: default; }.preview-image img { width: 100%; height: 100%; object-fit: contain; object-position: top; }.preview-image:focus-visible { outline: 2px solid var(--td-brand-color); outline-offset: -2px; }.locate { position: absolute; display: inline-flex; align-items: center; gap: 5px; bottom: 8px; padding: 4px 8px; border-radius: 5px; background: var(--td-bg-color-container); color: var(--td-text-color-primary); box-shadow: 0 1px 5px #00000014; }.preview-image:hover .locate { color: var(--td-brand-color); }
|
||||
.preview-progress, .preview-address, .preview-sync, .preview-help, .preview-scope { font-size: var(--app-text-xs); line-height: 1.5; margin: 6px 12px; color: var(--td-text-color-secondary); }
|
||||
.preview-address { overflow-wrap: anywhere; }
|
||||
.preview-help { color: var(--td-brand-color); }
|
||||
.preview-actions { display: flex; flex-wrap: wrap; gap: 4px; justify-content: space-between; padding: 5px 8px; }.preview-error { margin: 8px 12px; color: var(--td-error-color); font-size: var(--app-text-sm); line-height: 1.5; }
|
||||
@media(max-width:720px){.browser-task-preview { right: 12px; bottom: 12px; width: 200px; }.preview-image { height: 100px; }}
|
||||
.preview-popout { display: grid; place-items: center; flex-shrink: 0; padding: 3px; border: 0; border-radius: var(--app-radius-xs); background: transparent; color: var(--td-text-color-secondary); cursor: pointer; }
|
||||
.preview-popout:hover { background: var(--td-bg-color-secondarycontainer); color: var(--td-brand-color); }
|
||||
.preview-popout:focus-visible { outline: 2px solid var(--td-brand-color); }
|
||||
.preview-popout:disabled { opacity: .5; cursor: wait; }
|
||||
.browser-task-preview.is-pip { position: static; width: 100%; max-width: none; min-height: 100%; max-height: none; border: 0; border-radius: 0; box-shadow: none; }
|
||||
.is-pip .preview-heading { cursor: default; }
|
||||
.is-pip .preview-image { height: clamp(126px, 45vh, 480px); }
|
||||
.preview-heading strong {
|
||||
flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
||||
font-size: var(--app-text-sm); font-weight: 500; color: var(--td-text-color-secondary);
|
||||
}
|
||||
.preview-image {
|
||||
width: 100%; height: auto; border: 0; border-block: 1px solid var(--td-component-stroke);
|
||||
background: var(--td-bg-color-secondarycontainer); color: var(--td-text-color-secondary);
|
||||
display: grid; place-items: center; cursor: pointer; padding: 0; font-size: var(--app-text-xs);
|
||||
}
|
||||
.preview-image:disabled { cursor: default; }
|
||||
.preview-image.is-empty { aspect-ratio: 16 / 9; }
|
||||
.preview-image img { display: block; width: 100%; height: auto; min-height: 0; }
|
||||
.preview-image:focus-visible { outline: 2px solid var(--td-brand-color); outline-offset: -2px; }
|
||||
.preview-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px; line-height: 1.5; }
|
||||
.preview-empty svg { opacity: .45; }
|
||||
.preview-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 8px 10px 8px 12px; position: sticky; bottom: 0; background: var(--td-bg-color-container); }
|
||||
.preview-status {
|
||||
display: flex; align-items: center; gap: 6px; flex: 1 1 64px; min-width: 0; overflow: hidden;
|
||||
white-space: nowrap; font-size: var(--app-text-xs); line-height: 1.5; color: var(--td-text-color-secondary);
|
||||
}
|
||||
.preview-status i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
|
||||
.preview-status > span { overflow: hidden; text-overflow: ellipsis; }
|
||||
.preview-status.live i { background: var(--td-success-color); }
|
||||
.preview-status.attention i { background: var(--td-warning-color); }
|
||||
.preview-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; margin-left: auto; }
|
||||
.preview-control, .preview-popout {
|
||||
display: inline-flex; align-items: center; justify-content: center; gap: 4px;
|
||||
min-width: 28px; min-height: 28px; padding: 4px; border: 0; border-radius: 6px;
|
||||
font: inherit; font-size: var(--app-text-xs); background: transparent;
|
||||
color: var(--td-text-color-secondary); cursor: pointer; flex-shrink: 0;
|
||||
transition: background-color .16s, color .16s;
|
||||
}
|
||||
.preview-control { box-sizing: border-box; padding: 4px 8px; border: 1px solid var(--td-component-stroke); font-size: var(--app-text-sm); line-height: 18px; color: var(--td-text-color-primary); }
|
||||
.preview-control :deep(.t-icon) { flex-shrink: 0; color: var(--td-text-color-secondary); }
|
||||
.preview-control:not(:disabled):hover, .preview-popout:not(:disabled):hover { background: var(--td-bg-color-container-hover); color: var(--td-text-color-primary); }
|
||||
.preview-control:focus-visible, .preview-popout:focus-visible { outline: 2px solid var(--td-brand-color); outline-offset: 1px; }
|
||||
.preview-control:disabled, .preview-popout:disabled { opacity: .4; cursor: default; }
|
||||
.preview-error { margin: 8px 12px; color: var(--td-error-color); font-size: var(--app-text-sm); line-height: 1.5; overflow-wrap: anywhere; }
|
||||
.browser-task-preview.is-pip { position: static; width: 100%; max-width: none; height: 100dvh; max-height: none; border: 0; border-radius: 0; box-shadow: none; display: flex; flex-direction: column; }
|
||||
.is-pip .preview-heading { cursor: default; flex-shrink: 0; }
|
||||
.is-pip .preview-image { flex: 1; min-height: 0; overflow: hidden; aspect-ratio: auto; grid-template-rows: minmax(0, 1fr); }
|
||||
.is-pip .preview-image img { height: 100%; object-fit: contain; }
|
||||
.is-pip .preview-toolbar { margin-top: auto; flex-shrink: 0; }
|
||||
.browser-task-preview.needs-help { width: 420px; }
|
||||
.preview-handoff { display: flex; flex-direction: column; align-items: stretch; gap: 8px; padding: 12px; border-top: 1px solid var(--td-component-border); background: var(--td-bg-color-secondarycontainer); overflow-wrap: anywhere; }
|
||||
.preview-handoff { display: flex; flex-direction: column; align-items: stretch; gap: 8px; padding: 16px; border-top: 1px solid var(--td-component-stroke); background: var(--td-bg-color-secondarycontainer); overflow-wrap: anywhere; }
|
||||
.preview-handoff strong { font-size: var(--app-text-md); font-weight: 600; color: var(--td-text-color-primary); }
|
||||
.preview-handoff p { font-size: var(--app-text-sm); line-height: 1.6; margin: 0; color: var(--td-text-color-secondary); white-space: pre-wrap; }
|
||||
.preview-handoff .handoff-prompt { max-height: 22vh; overflow-y: auto; color: var(--td-text-color-primary); }
|
||||
.preview-handoff .handoff-locate { align-self: flex-end; flex-shrink: 0; max-width: 100%; margin-top: 2px; }
|
||||
.needs-help .preview-image { height: clamp(140px, 30vh, 260px); }
|
||||
.needs-help .preview-heading { flex-wrap: wrap; }
|
||||
.is-pip .preview-handoff { flex-shrink: 0; }
|
||||
.browser-task-preview.is-pip.needs-help { width: 100%; }
|
||||
@media(max-width:720px) { .browser-task-preview { right: 12px; bottom: 12px; width: 280px; max-width: calc(100% - 24px); } .preview-toolbar { padding-left: 8px; } }
|
||||
@media(max-width:480px) { .browser-task-preview.needs-help { width: calc(100% - 24px); max-width: calc(100% - 24px); } .browser-task-preview.is-pip.needs-help { width: 100%; max-width: none; } }
|
||||
@media(prefers-reduced-motion: reduce) { .preview-control, .preview-popout { transition: none; } }
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
<div class="product-heading">
|
||||
<div class="product-name">
|
||||
<strong>BrowserSkill</strong>
|
||||
<span v-if="status.connected && status.extension_version" class="product-version">v{{ status.extension_version }}</span>
|
||||
<a class="product-link" href="https://github.com/Tencent/BrowserSkill" target="_blank"
|
||||
rel="noopener noreferrer" aria-label="BrowserSkill">
|
||||
<t-icon name="jump" size="14px" />
|
||||
|
|
@ -27,72 +28,70 @@
|
|||
<i />{{ t(status.connected ? 'localBrowser.connected' : status.device ? 'localBrowser.offline' : 'localBrowser.notPaired') }}
|
||||
</span>
|
||||
</div>
|
||||
<p class="product-desc">{{ t('localBrowser.productDescription') }}</p>
|
||||
<p v-if="status.device" class="product-desc">{{ status.device.label }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template v-if="status.device">
|
||||
<div class="device-block">
|
||||
<div class="device-meta">
|
||||
<strong>{{ status.device.label }}</strong>
|
||||
<span>{{ t('localBrowser.lastSeen') }} {{ formatDate(status.device.last_seen_at) }}</span>
|
||||
</div>
|
||||
<p v-if="!status.connected" class="device-hint">{{ t('localBrowser.reconnectHint') }}</p>
|
||||
<div class="device-actions">
|
||||
<t-button theme="default" variant="text" size="small" :disabled="busy" @click="pair">
|
||||
{{ t('localBrowser.replaceDevice') }}
|
||||
</t-button>
|
||||
<t-popconfirm theme="warning" :content="t('localBrowser.revokeConfirm')"
|
||||
:confirm-btn="{ content: t('localBrowser.revoke'), theme: 'danger' }"
|
||||
:cancel-btn="{ content: t('common.cancel') }" placement="bottom" @confirm="disconnect">
|
||||
<t-button theme="default" variant="outline" size="small" :disabled="busy">
|
||||
<template #icon><t-icon name="rollback" /></template>
|
||||
<t-button class="revoke-action" theme="default" variant="text" size="small" :disabled="busy">
|
||||
{{ t('localBrowser.revoke') }}
|
||||
</t-button>
|
||||
</t-popconfirm>
|
||||
<t-button theme="default" variant="outline" size="small" :disabled="busy" @click="pair">
|
||||
<template #icon><t-icon name="refresh" /></template>
|
||||
{{ t('localBrowser.replaceDevice') }}
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
<p v-if="!status.connected" class="device-hint">{{ t('localBrowser.reconnectHint') }}</p>
|
||||
</template>
|
||||
|
||||
<ol v-else class="setup-steps">
|
||||
<li>
|
||||
<span class="step-index">1</span>
|
||||
<div class="step-copy">
|
||||
<strong>{{ t('localBrowser.installExtension') }}</strong>
|
||||
<p>{{ t('localBrowser.installHint') }}</p>
|
||||
<a class="official-extension-link"
|
||||
href="https://chromewebstore.google.com/detail/hhcmgoofomhgciiibhipgmgkgnoenaoi"
|
||||
target="_blank" rel="noopener noreferrer">
|
||||
{{ t('localBrowser.officialExtension') }}
|
||||
<t-icon name="jump" size="14px" />
|
||||
</a>
|
||||
<strong>{{ t('localBrowser.usageStep1Title') }}</strong>
|
||||
<details class="install-guide">
|
||||
<summary>{{ t('localBrowser.installGuide') }}</summary>
|
||||
<p>{{ t('localBrowser.usageStep1Text') }}</p>
|
||||
<summary>{{ t('localBrowser.manualInstall') }}<t-icon name="chevron-down" size="12px" /></summary>
|
||||
<div class="setup-help">
|
||||
<p>{{ t('localBrowser.installHint') }}</p>
|
||||
<p>{{ t('localBrowser.usageStep1Text') }}</p>
|
||||
<t-button class="setup-action fallback-download" theme="default" variant="outline" size="small"
|
||||
:disabled="!status.extension_available || downloading" @click="download">
|
||||
<template #icon><t-icon name="download" size="13px" /></template>
|
||||
{{ t('localBrowser.downloadExtension') }}
|
||||
</t-button>
|
||||
<p v-if="!status.extension_available" class="package-hint">{{ t('localBrowser.packageUnavailable') }}</p>
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
<t-button theme="default" variant="outline" size="small"
|
||||
:disabled="!status.extension_available || downloading" @click="download">
|
||||
<template #icon><t-icon name="download" /></template>
|
||||
{{ t('localBrowser.downloadExtension') }}
|
||||
</t-button>
|
||||
<a class="setup-action setup-main-action store-action" href="https://chromewebstore.google.com/detail/hhcmgoofomhgciiibhipgmgkgnoenaoi"
|
||||
target="_blank" rel="noopener noreferrer">
|
||||
{{ t('localBrowser.storeInstall') }}<t-icon name="jump" size="13px" />
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<span class="step-index">2</span>
|
||||
<div class="step-copy">
|
||||
<strong>{{ t('localBrowser.pairBrowser') }}</strong>
|
||||
<p>{{ t('localBrowser.pairHint') }}</p>
|
||||
<details class="install-guide">
|
||||
<summary>{{ t('localBrowser.pairGuide') }}<t-icon name="chevron-down" size="12px" /></summary>
|
||||
<div class="setup-help"><p>{{ t('localBrowser.pairHint') }}</p></div>
|
||||
</details>
|
||||
</div>
|
||||
<t-button theme="primary" size="small" :disabled="busy" @click="pair">
|
||||
<template #icon><t-icon name="file-copy" /></template>
|
||||
<button type="button" class="setup-action setup-main-action" :disabled="busy" @click="pair">
|
||||
{{ t(copied ? 'localBrowser.copyAgain' : 'localBrowser.copyPairing') }}
|
||||
</t-button>
|
||||
<t-icon name="file-copy" size="13px" />
|
||||
</button>
|
||||
</li>
|
||||
</ol>
|
||||
<p v-if="!status.device && !status.extension_available" class="package-hint">
|
||||
{{ t('localBrowser.packageUnavailable') }}
|
||||
</p>
|
||||
|
||||
<div v-if="pairing" class="pairing-feedback" role="status">
|
||||
<t-icon name="check-circle-filled" size="16px" />
|
||||
|
|
@ -104,14 +103,14 @@
|
|||
|
||||
<BrowserSearchPreferences />
|
||||
|
||||
<section class="usage" :aria-label="t('localBrowser.usageTitle')">
|
||||
<h3>{{ t('localBrowser.usageTitle') }}</h3>
|
||||
<details class="usage">
|
||||
<summary>{{ t('localBrowser.usageTitle') }}<t-icon name="chevron-down" size="16px" /></summary>
|
||||
<ol>
|
||||
<li>
|
||||
<span class="usage-index">1</span>
|
||||
<div class="usage-copy">
|
||||
<strong>{{ t('localBrowser.usageStep1Title') }}</strong>
|
||||
<p>{{ t('localBrowser.usageStep1Text') }}</p>
|
||||
<p>{{ t('localBrowser.storeInstallHint') }}</p>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
|
|
@ -136,7 +135,7 @@
|
|||
</div>
|
||||
</li>
|
||||
</ol>
|
||||
</section>
|
||||
</details>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -148,7 +147,7 @@ import { useBrowserConnectionStore } from '@/stores/browserConnection'
|
|||
import browserLogo from '@/assets/browserskill/logo.png'
|
||||
import BrowserSearchPreferences from './BrowserSearchPreferences.vue'
|
||||
interface Device { id: string; label: string; last_seen_at: string }
|
||||
interface Connection { enabled: boolean; connected: boolean; device?: Device; extension_available: boolean }
|
||||
interface Connection { enabled: boolean; connected: boolean; device?: Device; extension_available: boolean; extension_version?: string }
|
||||
const { t, locale } = useI18n()
|
||||
const browserConnection = useBrowserConnectionStore()
|
||||
const status = ref<Connection>({ enabled: false, connected: false, extension_available: false })
|
||||
|
|
@ -200,7 +199,8 @@ async function disconnect() {
|
|||
async function download() {
|
||||
downloading.value = true; error.value = ''
|
||||
try {
|
||||
const blob = await getDown(`${endpoint}/extension`)
|
||||
// Bypass archives cached before the server started sending no-store.
|
||||
const blob = await getDown(`${endpoint}/extension?t=${Date.now()}`)
|
||||
if (!alive) return
|
||||
const url = URL.createObjectURL(blob), link = document.createElement('a')
|
||||
link.href = url; link.download = 'browser-skill-weknora.zip'; link.click()
|
||||
|
|
@ -223,28 +223,23 @@ onBeforeUnmount(() => { alive = false; controller.abort(); clearTimeout(timer);
|
|||
}
|
||||
|
||||
.connection-card {
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
border-radius: var(--app-radius-xl);
|
||||
padding: 20px;
|
||||
background: var(--td-bg-color-container);
|
||||
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
|
||||
border-radius: 16px;
|
||||
padding: 24px;
|
||||
background: color-mix(in srgb, var(--td-bg-color-secondarycontainer) 65%, var(--td-bg-color-container));
|
||||
}
|
||||
|
||||
.product-row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.product-logo {
|
||||
flex-shrink: 0;
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
border-radius: var(--app-radius-xl);
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 11px;
|
||||
object-fit: cover;
|
||||
box-shadow:
|
||||
0 1px 2px rgba(15, 23, 42, 0.08),
|
||||
0 6px 16px rgba(234, 88, 12, 0.16);
|
||||
}
|
||||
|
||||
.product-copy {
|
||||
|
|
@ -266,7 +261,7 @@ onBeforeUnmount(() => { alive = false; controller.abort(); clearTimeout(timer);
|
|||
min-width: 0;
|
||||
|
||||
strong {
|
||||
font-size: var(--app-text-xl);
|
||||
font-size: var(--app-text-lg);
|
||||
font-weight: 600;
|
||||
line-height: 24px;
|
||||
color: var(--td-text-color-primary);
|
||||
|
|
@ -286,6 +281,17 @@ onBeforeUnmount(() => { alive = false; controller.abort(); clearTimeout(timer);
|
|||
}
|
||||
}
|
||||
|
||||
.product-version {
|
||||
color: var(--td-text-color-secondary);
|
||||
font-size: var(--app-text-sm);
|
||||
font-weight: 400;
|
||||
font-variant-numeric: tabular-nums;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
max-width: 12ch;
|
||||
}
|
||||
|
||||
.product-desc {
|
||||
margin: 4px 0 0;
|
||||
font-size: var(--app-text-md);
|
||||
|
|
@ -298,9 +304,7 @@ onBeforeUnmount(() => { alive = false; controller.abort(); clearTimeout(timer);
|
|||
align-items: center;
|
||||
gap: 6px;
|
||||
margin-left: auto;
|
||||
padding: 3px 9px;
|
||||
border-radius: var(--app-radius-pill);
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
padding: 3px 0;
|
||||
color: var(--td-text-color-secondary);
|
||||
font-size: var(--app-text-sm);
|
||||
font-weight: 500;
|
||||
|
|
@ -317,12 +321,10 @@ onBeforeUnmount(() => { alive = false; controller.abort(); clearTimeout(timer);
|
|||
|
||||
&.idle {
|
||||
color: var(--td-warning-color);
|
||||
background: color-mix(in srgb, var(--td-warning-color) 12%, transparent);
|
||||
}
|
||||
|
||||
&.online {
|
||||
color: var(--td-success-color);
|
||||
background: color-mix(in srgb, var(--td-success-color) 12%, transparent);
|
||||
|
||||
i {
|
||||
opacity: 1;
|
||||
|
|
@ -351,7 +353,8 @@ onBeforeUnmount(() => { alive = false; controller.abort(); clearTimeout(timer);
|
|||
|
||||
span {
|
||||
font-size: var(--app-text-sm);
|
||||
color: var(--td-text-color-placeholder);
|
||||
color: var(--td-text-color-secondary);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -365,8 +368,22 @@ onBeforeUnmount(() => { alive = false; controller.abort(); clearTimeout(timer);
|
|||
.device-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
margin-top: 14px;
|
||||
gap: 4px;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.device-block {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-top: 20px;
|
||||
padding-top: 14px;
|
||||
}
|
||||
|
||||
.revoke-action {
|
||||
color: var(--td-text-color-secondary);
|
||||
&:hover { color: var(--td-error-color); }
|
||||
}
|
||||
|
||||
.connection-card :deep(.t-button--variant-outline.t-button--theme-default) {
|
||||
|
|
@ -381,19 +398,64 @@ onBeforeUnmount(() => { alive = false; controller.abort(); clearTimeout(timer);
|
|||
|
||||
.setup-steps {
|
||||
list-style: none;
|
||||
margin: 18px 0 0;
|
||||
padding: 16px 0 0;
|
||||
margin: 20px 0 0;
|
||||
padding: 20px 0 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
gap: 24px;
|
||||
}
|
||||
|
||||
.setup-steps li {
|
||||
display: flex;
|
||||
display: grid;
|
||||
grid-template-columns: 22px minmax(0, 1fr) auto;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.connection-card .setup-action {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 4px;
|
||||
box-sizing: border-box;
|
||||
height: 30px;
|
||||
padding: 3px 10px;
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
border-radius: 6px;
|
||||
background: var(--td-bg-color-container);
|
||||
color: var(--setup-action-color, var(--td-text-color-primary));
|
||||
font-family: inherit;
|
||||
font-size: var(--app-text-sm);
|
||||
font-weight: 500;
|
||||
line-height: 22px;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
transition: background-color .16s, border-color .16s;
|
||||
&:disabled { opacity: .5; cursor: not-allowed; }
|
||||
&:focus-visible { outline: 2px solid var(--td-brand-color); outline-offset: 2px; }
|
||||
:deep(.t-icon) { color: currentColor; margin: 0; flex-shrink: 0; }
|
||||
// TDesign adds 8px here; use the same flex gap as the other actions.
|
||||
:deep(.t-icon + .t-button__text:not(:empty)) { margin-left: 0; }
|
||||
}
|
||||
|
||||
.connection-card .setup-main-action {
|
||||
min-width: 144px;
|
||||
}
|
||||
|
||||
.connection-card .store-action {
|
||||
--setup-action-color: color-mix(in srgb, var(--td-brand-color) 75%, var(--td-text-color-primary));
|
||||
color: var(--setup-action-color);
|
||||
}
|
||||
|
||||
.connection-card .setup-action:not(:disabled) {
|
||||
&:hover,
|
||||
&:active {
|
||||
color: var(--setup-action-color, var(--td-text-color-primary));
|
||||
background: var(--td-bg-color-container-hover);
|
||||
border-color: var(--td-component-border);
|
||||
}
|
||||
}
|
||||
|
||||
.step-index {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
|
|
@ -401,8 +463,8 @@ onBeforeUnmount(() => { alive = false; controller.abort(); clearTimeout(timer);
|
|||
display: grid;
|
||||
place-items: center;
|
||||
flex-shrink: 0;
|
||||
border-radius: 50%;
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
border-radius: 6px;
|
||||
background: var(--td-bg-color-container);
|
||||
color: var(--td-text-color-secondary);
|
||||
font-size: var(--app-text-sm);
|
||||
font-weight: 600;
|
||||
|
|
@ -435,20 +497,8 @@ onBeforeUnmount(() => { alive = false; controller.abort(); clearTimeout(timer);
|
|||
color: var(--td-text-color-secondary);
|
||||
}
|
||||
|
||||
.official-extension-link {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
margin-top: 4px;
|
||||
color: var(--td-brand-color);
|
||||
font-size: var(--app-text-sm);
|
||||
line-height: 1.6;
|
||||
text-decoration: none;
|
||||
|
||||
&:hover,
|
||||
&:focus-visible {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.fallback-download {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.install-guide {
|
||||
|
|
@ -460,7 +510,23 @@ onBeforeUnmount(() => { alive = false; controller.abort(); clearTimeout(timer);
|
|||
summary {
|
||||
cursor: pointer;
|
||||
width: fit-content;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
list-style: none;
|
||||
&::-webkit-details-marker { display: none; }
|
||||
&:hover { color: var(--td-text-color-primary); }
|
||||
&:focus-visible { outline: 2px solid var(--td-brand-color); outline-offset: 3px; }
|
||||
}
|
||||
|
||||
&[open] summary :deep(.t-icon) { transform: rotate(180deg); }
|
||||
}
|
||||
|
||||
.setup-help {
|
||||
margin-top: 10px;
|
||||
padding-left: 12px;
|
||||
border-left: 2px solid var(--td-component-stroke);
|
||||
p + p { margin-top: 8px; }
|
||||
}
|
||||
|
||||
.pairing-feedback {
|
||||
|
|
@ -490,15 +556,27 @@ onBeforeUnmount(() => { alive = false; controller.abort(); clearTimeout(timer);
|
|||
}
|
||||
|
||||
.usage {
|
||||
margin-top: 28px;
|
||||
margin-top: 24px;
|
||||
padding-top: 20px;
|
||||
border-top: 1px solid var(--td-component-stroke);
|
||||
|
||||
h3 {
|
||||
margin: 0 0 16px;
|
||||
font-size: var(--app-text-lg);
|
||||
font-weight: 600;
|
||||
color: var(--td-text-color-primary);
|
||||
summary {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
list-style: none;
|
||||
cursor: pointer;
|
||||
font-size: var(--app-text-md);
|
||||
font-weight: 500;
|
||||
color: var(--td-text-color-secondary);
|
||||
&::-webkit-details-marker { display: none; }
|
||||
&:hover { color: var(--td-text-color-primary); }
|
||||
&:focus-visible { outline: 2px solid var(--td-brand-color); outline-offset: 4px; }
|
||||
}
|
||||
|
||||
&[open] summary { margin-bottom: 20px; }
|
||||
&[open] summary :deep(.t-icon) { transform: rotate(180deg); }
|
||||
|
||||
ol {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
|
|
@ -570,12 +648,15 @@ onBeforeUnmount(() => { alive = false; controller.abort(); clearTimeout(timer);
|
|||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.connection-card { padding: 18px; }
|
||||
.device-actions { margin-left: 0; }
|
||||
.setup-steps li {
|
||||
flex-wrap: wrap;
|
||||
grid-template-columns: 22px minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.setup-steps li :deep(.t-button) {
|
||||
margin-left: 34px;
|
||||
.setup-steps li > .setup-action {
|
||||
grid-column: 2;
|
||||
justify-self: start;
|
||||
}
|
||||
|
||||
.status-pill {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<p class="description">{{ t('localBrowser.searchInstructionsDescription') }}</p>
|
||||
<t-skeleton v-if="loading" animation="gradient" :row-col="[{ width: '100%', height: '64px' }]" />
|
||||
<template v-else-if="loaded">
|
||||
<t-textarea v-model="draft" :autosize="{ minRows: 2, maxRows: 8 }" :maxlength="4000"
|
||||
<t-textarea v-model="draft" :autosize="{ minRows: 3, maxRows: 8 }" :maxlength="4000"
|
||||
:tips="t('localBrowser.searchInstructionsHint')"
|
||||
:disabled="saving" :aria-label="t('localBrowser.searchInstructionsTitle')" />
|
||||
<div class="actions">
|
||||
|
|
@ -75,13 +75,16 @@ onBeforeUnmount(() => { alive = false })
|
|||
|
||||
<style scoped lang="less">
|
||||
.browser-search-preferences {
|
||||
margin-top: 20px;
|
||||
h3 { margin: 0 0 6px; font-size: var(--app-text-xl); color: var(--td-text-color-primary); }
|
||||
.description { margin: 0 0 8px; color: var(--td-text-color-secondary); font-size: var(--app-text-md); line-height: 1.5; }
|
||||
.actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 8px; }
|
||||
margin-top: 32px;
|
||||
h3 { margin: 0 0 6px; font-size: var(--app-text-lg); font-weight: 600; color: var(--td-text-color-primary); }
|
||||
.description { margin: 0 0 16px; color: var(--td-text-color-secondary); font-size: var(--app-text-md); line-height: 1.5; }
|
||||
.actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 16px; }
|
||||
.actions span { color: var(--td-success-color); font-size: var(--app-text-sm); }
|
||||
:deep(.t-textarea__inner) { font-size: var(--app-text-md); line-height: 20px; }
|
||||
:deep(.t-textarea__info_wrapper) { font-size: var(--app-text-sm); }
|
||||
:deep(.t-textarea__inner) { padding: 14px 16px; border-radius: 10px; border-color: var(--td-component-stroke); font-size: var(--app-text-md); line-height: 1.7; transition: border-color .18s, box-shadow .18s; }
|
||||
:deep(.t-textarea__inner:hover) { border-color: var(--td-component-border); }
|
||||
:deep(.t-textarea__inner:focus) { border-color: var(--td-brand-color); }
|
||||
:deep(.t-textarea__info_wrapper) { margin-top: 8px; font-size: var(--app-text-xs); line-height: 1.5; }
|
||||
:deep(.t-textarea__limit) { font-variant-numeric: tabular-nums; }
|
||||
.error { color: var(--td-error-color); font-size: var(--app-text-md); }
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -178,6 +178,7 @@ func (m *Manager) Account(ctx context.Context, s Scope) (AccountStatus, error) {
|
|||
return result, e
|
||||
}
|
||||
result.Connected = status.Connected
|
||||
result.ExtensionVersion = status.ExtensionVersion
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
|
@ -201,6 +202,7 @@ func (m *Manager) GetStatus(ctx context.Context, s Scope, session string) (Statu
|
|||
time.Now().After(record.LeaseUntil) ||
|
||||
record.Owner != m.nodeID {
|
||||
status.Connected = false
|
||||
status.ExtensionVersion = ""
|
||||
status.SessionID = ""
|
||||
status.Paused = status.Selected
|
||||
}
|
||||
|
|
@ -242,5 +244,6 @@ func (m *Manager) DownloadExtension(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
w.Header().Set("Content-Type", "application/zip")
|
||||
w.Header().Set("Content-Disposition", `attachment; filename="browser-skill-weknora.zip"`)
|
||||
w.Header().Set("Cache-Control", "no-store")
|
||||
http.ServeFile(w, r, p)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,6 +84,10 @@ func TestRequestsRouteToBrowserOwnerAcrossReplicas(t *testing.T) {
|
|||
status, err := follower.GetStatus(ctx, scope, "chat")
|
||||
require.NoError(t, err)
|
||||
require.True(t, status.Connected)
|
||||
require.Equal(t, "0.3.0", status.ExtensionVersion)
|
||||
account, err := follower.Account(ctx, scope)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "0.3.0", account.ExtensionVersion, "account version follows the remote connection owner")
|
||||
_, err = follower.Call(ctx, scope, "chat", "navigate", map[string]any{"url": "https://example.com"})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, status.SessionID, (<-fixture.calls)["session_id"])
|
||||
|
|
|
|||
|
|
@ -45,19 +45,20 @@ func (s Scope) valid() bool { return s.Tenant != 0 && s.User != "" }
|
|||
|
||||
// Status describes the connection and current conversation task.
|
||||
type Status struct {
|
||||
Action string `json:"action,omitempty"`
|
||||
ActionElapsedMS int64 `json:"action_elapsed_ms"`
|
||||
PageURL string `json:"page_url,omitempty"`
|
||||
LastError string `json:"last_error,omitempty"`
|
||||
Stopping bool `json:"stopping"`
|
||||
HelpPrompt string `json:"help_prompt,omitempty"`
|
||||
Idle bool `json:"idle"` // Between turns; does not imply debugger release.
|
||||
NeedsHelp bool `json:"needs_help"`
|
||||
Enabled bool `json:"enabled"`
|
||||
Selected bool `json:"selected"`
|
||||
Connected bool `json:"connected"`
|
||||
Paused bool `json:"paused"`
|
||||
SessionID string `json:"task_id,omitempty"`
|
||||
Action string `json:"action,omitempty"`
|
||||
ActionElapsedMS int64 `json:"action_elapsed_ms"`
|
||||
PageURL string `json:"page_url,omitempty"`
|
||||
LastError string `json:"last_error,omitempty"`
|
||||
Stopping bool `json:"stopping"`
|
||||
HelpPrompt string `json:"help_prompt,omitempty"`
|
||||
Idle bool `json:"idle"` // Between turns; does not imply debugger release.
|
||||
NeedsHelp bool `json:"needs_help"`
|
||||
Enabled bool `json:"enabled"`
|
||||
Selected bool `json:"selected"`
|
||||
Connected bool `json:"connected"`
|
||||
ExtensionVersion string `json:"extension_version,omitempty"`
|
||||
Paused bool `json:"paused"`
|
||||
SessionID string `json:"task_id,omitempty"`
|
||||
}
|
||||
type task struct {
|
||||
action string
|
||||
|
|
@ -81,18 +82,19 @@ type task struct {
|
|||
nextCall uint64
|
||||
}
|
||||
type device struct {
|
||||
writeMu sync.Mutex
|
||||
uiCalls map[string]chan uiReply
|
||||
mu sync.Mutex
|
||||
runtime *daemon
|
||||
browserID string
|
||||
upstream *websocket.Conn
|
||||
conn *websocket.Conn
|
||||
ready bool
|
||||
generation uint64
|
||||
tasks map[string]*task
|
||||
expires time.Time
|
||||
recordID string
|
||||
writeMu sync.Mutex
|
||||
uiCalls map[string]chan uiReply
|
||||
mu sync.Mutex
|
||||
runtime *daemon
|
||||
browserID string
|
||||
extensionVersion string
|
||||
upstream *websocket.Conn
|
||||
conn *websocket.Conn
|
||||
ready bool
|
||||
generation uint64
|
||||
tasks map[string]*task
|
||||
expires time.Time
|
||||
recordID string
|
||||
// connecting counts extension handshakes holding this device against
|
||||
// eviction; attaching excludes a second handshake while dialing unlocked.
|
||||
connecting int
|
||||
|
|
@ -163,6 +165,9 @@ func (m *Manager) Status(s Scope, session string) Status {
|
|||
d.mu.Lock()
|
||||
defer d.mu.Unlock()
|
||||
result.Connected = d.conn != nil && d.ready && time.Now().Before(d.expires)
|
||||
if result.Connected {
|
||||
result.ExtensionVersion = d.extensionVersion
|
||||
}
|
||||
if t := d.tasks[session]; t != nil {
|
||||
result.Selected = t.selected
|
||||
result.Paused = t.paused
|
||||
|
|
@ -317,6 +322,7 @@ func disconnectDeviceLocked(d *device) {
|
|||
d.conn, d.upstream = nil, nil
|
||||
d.ready = false
|
||||
d.browserID = ""
|
||||
d.extensionVersion = ""
|
||||
d.generation++
|
||||
for _, t := range d.tasks {
|
||||
t.id = ""
|
||||
|
|
@ -443,6 +449,7 @@ func (m *Manager) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
d.upstream = up
|
||||
d.ready = false
|
||||
// The lease identity is assigned by the authenticated gateway, never the extension.
|
||||
d.extensionVersion = ""
|
||||
d.browserID = leaseKey
|
||||
browserID := d.browserID
|
||||
d.generation++
|
||||
|
|
@ -464,7 +471,7 @@ func (m *Manager) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
up.SetReadLimit(maxFrame)
|
||||
// Complete and verify the first handshake before publishing readiness.
|
||||
// This keeps identity assignment out of the generic frame forwarding path.
|
||||
reply, err := relayHandshake(conn, up, browserID)
|
||||
reply, extensionVersion, err := relayHandshake(conn, up, browserID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
@ -474,6 +481,7 @@ func (m *Manager) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
d.ready = true
|
||||
d.extensionVersion = extensionVersion
|
||||
d.mu.Unlock()
|
||||
_ = conn.SetWriteDeadline(time.Now().Add(10 * time.Second))
|
||||
if conn.WriteMessage(websocket.TextMessage, reply) != nil {
|
||||
|
|
@ -549,7 +557,7 @@ func (m *Manager) attach(
|
|||
return up, conn, nil
|
||||
}
|
||||
|
||||
func relayHandshake(conn, up *websocket.Conn, browserID string) ([]byte, error) {
|
||||
func relayHandshake(conn, up *websocket.Conn, browserID string) ([]byte, string, error) {
|
||||
deadline := time.Now().Add(5 * time.Second)
|
||||
_ = conn.SetReadDeadline(deadline)
|
||||
_ = up.SetReadDeadline(deadline)
|
||||
|
|
@ -560,27 +568,27 @@ func relayHandshake(conn, up *websocket.Conn, browserID string) ([]byte, error)
|
|||
}()
|
||||
typ, data, err := conn.ReadMessage()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, "", err
|
||||
}
|
||||
var frame map[string]json.RawMessage
|
||||
if typ != websocket.TextMessage || json.Unmarshal(data, &frame) != nil {
|
||||
return nil, errors.New("invalid browser handshake")
|
||||
return nil, "", errors.New("invalid browser handshake")
|
||||
}
|
||||
var method, id string
|
||||
var params map[string]json.RawMessage
|
||||
if json.Unmarshal(frame["method"], &method) != nil || method != "system.handshake" ||
|
||||
json.Unmarshal(frame["id"], &id) != nil || id == "" ||
|
||||
json.Unmarshal(frame["params"], ¶ms) != nil || params == nil {
|
||||
return nil, errors.New("expected browser handshake")
|
||||
return nil, "", errors.New("expected browser handshake")
|
||||
}
|
||||
params["instance_id"], _ = json.Marshal(browserID)
|
||||
frame["params"], _ = json.Marshal(params)
|
||||
if err := up.WriteJSON(frame); err != nil {
|
||||
return nil, err
|
||||
return nil, "", err
|
||||
}
|
||||
typ, reply, err := up.ReadMessage()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, "", err
|
||||
}
|
||||
var response struct {
|
||||
ID string `json:"id"`
|
||||
|
|
@ -592,9 +600,14 @@ func relayHandshake(conn, up *websocket.Conn, browserID string) ([]byte, error)
|
|||
if typ != websocket.TextMessage || json.Unmarshal(reply, &response) != nil ||
|
||||
response.ID != id || response.Result.Protocol == "" ||
|
||||
(len(response.Error) != 0 && string(response.Error) != "null") {
|
||||
return nil, errors.New("BrowserSkill handshake failed")
|
||||
return nil, "", errors.New("BrowserSkill handshake failed")
|
||||
}
|
||||
return reply, nil
|
||||
// This is the extension's version, not browser.version or protocol_version.
|
||||
var version string
|
||||
if json.Unmarshal(params["version"], &version) != nil || len(version) > 64 {
|
||||
version = ""
|
||||
}
|
||||
return reply, strings.TrimSpace(version), nil
|
||||
}
|
||||
|
||||
func validExtensionOrigin(origin string) bool {
|
||||
|
|
|
|||
|
|
@ -165,6 +165,9 @@ func TestNativeDaemonRelay(t *testing.T) {
|
|||
if handshake["error"] != nil {
|
||||
t.Fatalf("handshake: %v", handshake)
|
||||
}
|
||||
if version := m.Status(scope, "").ExtensionVersion; version != "0.2.1" {
|
||||
t.Fatalf("extension version = %q, want 0.2.1", version)
|
||||
}
|
||||
calls := make(chan map[string]any, 20)
|
||||
var starts atomic.Int32
|
||||
go func() {
|
||||
|
|
|
|||
|
|
@ -40,6 +40,23 @@ type sharedFixture struct {
|
|||
calls chan map[string]any
|
||||
}
|
||||
|
||||
func TestAccountReportsConnectedExtensionVersion(t *testing.T) {
|
||||
m, ctx := sharedTestManager(t)
|
||||
scope := Scope{1, "extension-version"}
|
||||
fixture := connectSharedFixture(ctx, t, m, scope, "", "chrome")
|
||||
account, err := m.Account(ctx, scope)
|
||||
require.NoError(t, err)
|
||||
require.True(t, account.Connected)
|
||||
require.Equal(t, "0.3.0", account.ExtensionVersion)
|
||||
|
||||
require.NoError(t, fixture.ws.Close())
|
||||
require.Eventually(t, func() bool { return !m.Status(scope, "").Connected }, time.Second, 10*time.Millisecond)
|
||||
account, err = m.Account(ctx, scope)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, account.Device, "authorization survives a transient disconnection")
|
||||
require.Empty(t, account.ExtensionVersion, "do not display a stale version as the connected extension")
|
||||
}
|
||||
|
||||
func TestConcurrentCommandsShareAutomaticSessionCreation(t *testing.T) {
|
||||
m, ctx := sharedTestManager(t)
|
||||
s := Scope{1, "auto-start-queue"}
|
||||
|
|
|
|||
Loading…
Reference in New Issue