Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ jobs:
- run: pnpm run test
- run: pnpm run build
- run: pnpm run test:smoke
- name: Install Chromium
run: pnpm --filter @yuxianglin/dsh-bridge-browser exec playwright-core install --with-deps chromium
- run: pnpm run test:browser
2 changes: 2 additions & 0 deletions extensions/dsh-browser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ For extension development, load `extensions/dsh-browser/dist/` from `chrome://ex

See the root README for [installation, updates, startup, and uninstall](../../README.md#detailed-installation-and-usage).

The side panel follows your system's light or dark appearance and updates when it changes.

## Composer controls: permission, model, commands, and skills

The composer carries the same controls the Web GUI exposes, backed by Host
Expand Down
2 changes: 2 additions & 0 deletions extensions/dsh-browser/README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ pnpm --filter dsh-browser-extension run test

安装、更新、启动和卸载方式见根目录 README 的[详细安装与使用](../../README.zh.md#详细安装与使用)。

侧栏会跟随系统的浅色或深色外观,并在系统外观变化时自动更新。

## 输入区控制:权限模式、模型、命令与 Skill

输入区提供与 Web GUI 对齐的控件,全部由桥插件自有的 Host 方法支撑:
Expand Down
188 changes: 188 additions & 0 deletions extensions/dsh-browser/src/panel/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -3503,3 +3503,191 @@ textarea:focus-visible {
color: var(--ink);
cursor: pointer;
}

@media (prefers-color-scheme: dark) {
:root {
color-scheme: dark;
--canvas: #111722;
--canvas-deep: #1b2433;
--surface: #1d2736;
--ink: #dde4ef;
--ink-strong: #f2f5fa;
--muted: #adb9cc;
--faint: #98a6bd;
--line: #344156;
--line-strong: #465570;
--blue-ink: #b0bfff;
--blue-soft: #263458;
--blue-wash: #202c44;
--danger: #ffaba3;
--danger-soft: #3c252b;
--danger-border: #75434a;
--security: #efc56f;
--security-soft: #352e20;
--security-border: #6e5930;
--shadow: 0 10px 28px rgba(0, 0, 0, 0.28), 0 2px 6px rgba(0, 0, 0, 0.18);
}

* {
scrollbar-color: var(--line-strong) transparent;
}

::-webkit-scrollbar-thumb {
background-color: var(--line-strong);
}

.topbar {
border-color: var(--line);
background: var(--surface);
}

.tab-affinity {
border-color: var(--security-border);
background: var(--security-soft);
}

.tab-affinity.background {
border-color: var(--line-strong);
background: var(--blue-wash);
}

.tab-affinity.lost {
border-color: var(--danger-border);
background: var(--danger-soft);
}

.tab-affinity-node::before,
.update-beacon,
.draft-image > button {
border-color: var(--surface);
}

.tab-affinity-actions .return:hover {
background: var(--blue-wash);
}

.tab-affinity-actions .keep:hover {
border-color: var(--line-strong);
background: var(--canvas-deep);
}

.tab-affinity-actions .keep-always:hover,
.question-actions .secondary:hover:not(:disabled),
.update-check:hover:not(:disabled),
.bridge-detection-actions button:hover,
.settings input:hover,
.settings select:hover,
.settings-actions .secondary:hover {
border-color: var(--line-strong);
}

.scroll-to-bottom:hover,
.empty button:hover:not(:disabled),
.question-option:hover,
.question-option.checked,
.composer-box:focus-within {
border-color: var(--blue);
}

.empty-logo,
.empty button,
.row.user .body,
.assistant-avatar,
.tool-activity,
.tool-activity.running,
.question-card,
.question-mark,
.page-selection-chip,
.install-pill.install-managed,
.version-pill,
.update-card {
border-color: var(--line-strong);
}

.row.user .body {
color: var(--ink);
}

.row.tool::before,
.question-index,
.page-selection-chip > button:hover {
background: var(--line);
}

.tool-activity,
.install-pill,
.version-pill,
.update-reload-glyph {
background: var(--surface);
}

.tool-activity.running {
background: var(--blue-wash);
}

.tool-summary,
.approval-origins code {
color: var(--ink);
}

.approval-origins code.unknown {
color: var(--danger);
}

.spinner {
border-color: var(--line-strong);
border-top-color: var(--blue);
}

.row .body.md code {
border-color: var(--line);
background: var(--canvas-deep);
}

.row .body.md a {
text-decoration-color: var(--blue);
}

.row .body.md blockquote,
.page-selection-quote,
.row .body.md blockquote.page-selection-quote {
border-left-color: var(--line-strong);
}

.composer-actions button:disabled {
border-color: var(--line);
background: var(--canvas-deep);
color: var(--faint);
}

.update-card {
background: linear-gradient(145deg, var(--surface) 0%, var(--blue-wash) 100%);
}

.install-pill.install-checkout {
border-color: #426c58;
color: #9bd8b6;
}

.install-pill.install-unknown,
.update-reload-reminder,
.update-reload-glyph {
border-color: var(--security-border);
}

.update-reload-reminder,
.approval-actions .session-trust:hover,
.approval-actions .read-always:hover {
background: var(--security-soft);
}

.setting-toggle-control {
border-color: var(--line-strong);
background: var(--line);
}

.setting-toggle-input:checked + .setting-toggle-control {
border-color: var(--blue);
background: var(--blue);
}
}
63 changes: 60 additions & 3 deletions scripts/smoke-browser.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import assert from 'node:assert/strict'
import { spawn } from 'node:child_process'
import { randomUUID } from 'node:crypto'
import { once } from 'node:events'
import { mkdir, mkdtemp, writeFile } from 'node:fs/promises'
import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises'
import { createServer } from 'node:http'
import { createConnection, createServer as createTcpServer } from 'node:net'
import { createRequire } from 'node:module'
import { tmpdir } from 'node:os'
import { dirname, join } from 'node:path'
import { setTimeout as delay } from 'node:timers/promises'
import { fileURLToPath, pathToFileURL } from 'node:url'
Expand All @@ -20,8 +21,7 @@ const cli = join(dirname(require.resolve('@deepseek-ai/dsh/package.json')), 'lib
const artifacts = join(root, '.artifacts/browser-smoke')
await mkdir(artifacts, { recursive: true })
const directory = await mkdtemp(join(artifacts, 'run-'))
const runtimeTmp = join(directory, 'tmp')
await mkdir(runtimeTmp)
const runtimeTmp = await mkdtemp(join(tmpdir(), 'dsh-browser-'))
const token = randomUUID()
const env = { ...process.env, DSH_HOME: join(directory, 'home'), TMPDIR: runtimeTmp, DSH_TELEMETRY_DISABLED: '1' }
delete env.DSH_EXT_TOKEN
Expand Down Expand Up @@ -56,6 +56,43 @@ async function command(args) {
assert.equal(code, 0, output)
}

async function verifyPanelTheme(page, scheme, selectors) {
await page.emulateMedia({ colorScheme: scheme, reducedMotion: 'reduce' })
await waitFor(() => page.evaluate(expected => getComputedStyle(document.documentElement).colorScheme === expected, scheme),
`${scheme} panel color scheme`)
await page.evaluate(() => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve))))
const swatches = await page.evaluate(selectors => {
const channels = color => color.match(/[\d.]+/g).map(Number)
const background = element => {
const [r, g, b, alpha = 1] = channels(getComputedStyle(element).backgroundColor)
if (alpha === 1) return [r, g, b]
const behind = element.parentElement ? background(element.parentElement) : [255, 255, 255]
return [r, g, b].map((channel, index) => channel * alpha + behind[index] * (1 - alpha))
}
return selectors.map(selector => {
const element = document.querySelector(selector)
if (!element) throw new Error(`Missing theme test element: ${selector}`)
return { selector, disabled: element.matches(':disabled'), foreground: channels(getComputedStyle(element).color), background: background(element) }
})
}, selectors)
for (const swatch of swatches) {
const foreground = relativeLuminance(swatch.foreground)
const background = relativeLuminance(swatch.background)
const contrast = (Math.max(foreground, background) + 0.05) / (Math.min(foreground, background) + 0.05)
if (!swatch.disabled) assert.ok(contrast >= 4.5, `${scheme} ${swatch.selector}: text contrast ${contrast.toFixed(2)}`)
assert.ok(scheme === 'dark' ? background < 0.15 : background > 0.75,
`${scheme} ${swatch.selector}: background luminance ${background.toFixed(2)}`)
}
}

function relativeLuminance(channels) {
const linear = channels.slice(0, 3).map(channel => {
const srgb = channel / 255
return srgb <= 0.04045 ? srgb / 12.92 : ((srgb + 0.055) / 1.055) ** 2.4
})
return linear[0] * 0.2126 + linear[1] * 0.7152 + linear[2] * 0.0722
}

const inner = `<!doctype html><body style="margin:0;min-height:1000px"><button id="inner" style="position:absolute;left:20px;top:20px;width:100px;height:50px">Inner target</button>
<input id="upload" type="file" style="position:absolute;left:10px;top:100px;width:130px">
<input id="input" value="abcd" style="position:absolute;left:150px;top:20px;width:100px">
Expand Down Expand Up @@ -401,6 +438,25 @@ try {
assert.equal(await chat.locator('.row.user').count(), 1)
await composer.fill('Keep this draft.')

const chatViewport = chat.viewportSize()
await chat.setViewportSize({ width: 420, height: 900 })
for (const scheme of ['light', 'dark', 'light']) {
await verifyPanelTheme(chat, scheme, ['body', '.session-menu-trigger', '.new-session-trigger', '.row.user .body', '.composer textarea'])
await chat.screenshot({ path: join(directory, `theme-${scheme}-chat.png`), animations: 'disabled' })
await chat.getByRole('button', { name: 'Permission preset', exact: true }).click()
await chat.getByRole('option', { name: 'Full access', exact: true }).click()
await verifyPanelTheme(chat, scheme, ['.approval-heading h2', '.approval-detail strong', '.approval-actions .deny'])
await chat.screenshot({ path: join(directory, `theme-${scheme}-permission.png`), animations: 'disabled' })
await chat.getByRole('button', { name: 'Cancel', exact: true }).click()
await chat.getByRole('button', { name: 'Open settings', exact: true }).click()
await verifyPanelTheme(chat, scheme, ['.settings h1', '.settings input', '.settings select', '.update-status strong'])
await chat.screenshot({ path: join(directory, `theme-${scheme}-settings.png`), animations: 'disabled' })
await chat.getByRole('button', { name: 'Back to chat', exact: true }).click()
assert.equal(await composer.inputValue(), 'Keep this draft.')
}
await chat.setViewportSize(chatViewport)
results.push('panel follows live light/dark changes with readable chat, permission dialog and settings text and preserves the draft')

const bridgeRpc = async (method, payload) => {
const id = await panel.evaluate(({ method, payload }) => {
const id = crypto.randomUUID()
Expand Down Expand Up @@ -515,4 +571,5 @@ try {
await new Promise(resolve => server.close(resolve))
await new Promise(resolve => childServer.close(resolve))
await writeFile(join(directory, 'host.log'), hostLog)
await rm(runtimeTmp, { recursive: true, force: true })
}