Skip to content
Draft
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
42 changes: 42 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,25 @@ jobs:
if-no-files-found: error
retention-days: 14

- name: Verify clipboard, quotes, local shortcuts and page fullscreen in real Chrome
id: client_ui
if: ${{ !cancelled() && steps.host_tests.outcome == 'success' }}
timeout-minutes: 5
env:
DEVA_QA_CLIENT_CAPTURE: '1'
run: node scripts/workbench/e2e-client-interactions.mjs

- name: Publish the verified selection menu and quote draft from synthetic data
if: ${{ !cancelled() && steps.client_ui.outcome == 'success' }}
uses: actions/upload-artifact@v4
with:
name: client-clipboard-and-quote
path: |
test-results/client-interactions/selection-menu.png
test-results/client-interactions/quoted-draft.png
if-no-files-found: error
retention-days: 14

- name: Select the same installed Chrome for UI and worker
run: bash scripts/workbench/ci-select-chromium.sh

Expand Down Expand Up @@ -154,6 +173,29 @@ jobs:
--mount "type=bind,src=$PWD/apps/headless/test/task-inspection-http.test.mjs,dst=/opt/deva/apps/headless/ci/task-inspection.test.mjs,readonly" \
--entrypoint node deva-workbench:tasks-verify --test /opt/deva/apps/headless/ci/task-inspection.test.mjs

packaged-client:
name: Sandboxed Chrome using the actual amd64 workbench image
if: ${{ github.event_name == 'pull_request' && github.head_ref == 'feat/web-workbench-client-interactions' }}
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: 22
package-manager-cache: false
- name: Build the actual Linux amd64 runtime
timeout-minutes: 8
run: |
set -eu
test "$(uname -m)" = x86_64
docker build --platform linux/amd64 --target runtime -t deva-workbench:client-verify .
- name: Select the installed Chrome client
run: bash scripts/workbench/ci-select-chromium.sh
- name: Use the production CLI through a single loopback publication
timeout-minutes: 5
run: node scripts/workbench/container-client-interactions.mjs

sandbox:
name: Private human browser worker
runs-on: ubuntu-latest
Expand Down
9 changes: 8 additions & 1 deletion README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,14 @@ When memory is full, the next write by the model first consolidates the existing

## Headless server workbench (fork development)

The [amd64 Docker Compose workbench](apps/headless/README.md) supports browser enrollment, the original desktop model settings, and general text conversations with shared desktop UI, streaming, cancellation and reconnect. It also includes profile and role editing, avatar management, and notes scoped to the owner, a role, or a registered project. A conversation may keep an explicitly attached project or inherit its role’s registered project at creation. Browsing another folder is separate from changing this binding; neither operation sends files or notes to a model. Separately approved projects also have a manually activated Git view for tracked changes, branches, first-parent history and staged versus working-tree comparisons. The native task view shows saved schedules and run history, previews times in an explicit zone, and can pause one existing active record after confirmation. It does not run a scheduler. The workbench accepts supported UTF-8 text, static images and PDFs for compatible adapters. Confirmed replies can be exported as Markdown or plain text. Desktop delivery cards are reused for scoped downloads and project file reveal. The [optional human-operated browser](apps/browser-worker/README.md) remains experimental: it requires an independent sandboxed worker and its full handoff has not passed acceptance. The base app requires neither that worker nor a running desktop. This is separate from the mobile relay; see the [parity inventory](docs/development/web-workbench/README.md) for the remaining desktop workflows.
The [amd64 Docker Compose workbench](apps/headless/README.md) runs independently of Electron, a remote desktop or the mobile relay, using the same React components as the desktop application.

- **Conversations:** claim the instance, configure models, stream, stop and reconnect. Use the desktop message menu to copy a selection or quote it in an unsent draft. Clipboard, sidebar shortcuts and page fullscreen belong to the client browser.
- **Library and projects:** manage profiles, roles, avatars and scoped notes. A conversation can inherit or explicitly attach an approved project; manually opening its files or notes does not send them to a model.
- **Attachments and deliveries:** explicitly send supported text, static images or PDFs on compatible adapters. Export confirmed replies or use the desktop delivery card to download and reveal an authorized project file.
- **Inspection:** view branches, first-parent history and staged or working-tree differences in separately approved repositories. Inspect recorded desktop tasks, preview a schedule in an explicit time zone, and pause an active record after confirmation. The server does not run a task scheduler.

The [optional server-side human-operated browser](apps/browser-worker/README.md) remains experimental: full handoff has not passed acceptance. The base workbench does not depend on it. See the [desktop parity inventory](docs/development/web-workbench/README.md) for pending work.

## Build from Source

Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,14 @@ IM 机器人支持 `/new [角色名]`、`/list`、`/stop`、`/status`、`/help`

## 无 GUI 服务器工作台(本分支开发中)

[amd64 Docker Compose 与 Web 工作台说明](apps/headless/README.md):当前可在浏览器认领服务器、配置模型,并使用桌面同源的会话列表、编辑器及消息区进行通用文本对话;支持停止与刷新续接。网页还可以编辑个人资料、普通角色及其头像,并分别管理全局、角色和已授权项目的记忆。可手动浏览获准项目的文件,也可显式把所选文本、静态图片或兼容协议的 PDF 作为会话附件发送;浏览项目不会自动上传。定时任务视图可以查阅桌面任务和历史、按时区预览日程、明确暂停一条活动记录;容器不会因此自动执行任务。每段对话可独立关联或解除项目;从已关联标签打开文件和项目记忆,角色的新对话可继承已登记的默认项目。管理员另外批准的仓库可手动查看已跟踪文件的改动、分支、首父提交历史,以及暂存和工作树的差异。已确认的回复可导出为 Markdown 或纯文本;桌面交付卡复用于 Web,支持按授权项目下载文件和定位。[独立人工浏览器面板](apps/browser-worker/README.md)仍属实验功能:已验证普通浏览器客户端,服务端工作器的完整接管与交还尚未通过;默认工作台不依赖它。它和手机版中转是两个不同部署目标;完整业务进度见[对等清单](docs/development/web-workbench/README.md)。
[amd64 Docker Compose 部署与使用](apps/headless/README.md)。这是独立的服务器工作台,复用桌面 React 界面;运行时无需 Electron、远程桌面或手机版中转。

- **对话**:在浏览器认领实例、配置模型,使用原会话列表和编辑器聊天、停止、刷新续接。选中文字可复制或加入当前草稿的引用条;剪贴板、侧栏快捷键和页面全屏都属于操作电脑。
- **资料与项目**:管理个人资料、角色、头像和分域记忆。会话可继承或显式关联管理员登记的项目;手动打开文件或笔记不会将内容发送给模型。
- **附件与交付**:显式发送文本、静态图片或兼容协议的 PDF;导出已完成的回复,或在桌面同源交付卡下载、定位授权文件。
- **检查**:获准仓库可看分支、首父历史,以及暂存区和工作树的差异;任务页可查阅桌面记录、预览时区日程和确认暂停。它不会启动任务调度器。

[可选的服务器端人工浏览器](apps/browser-worker/README.md)仍属实验功能,完整接管与交还尚未通过。普通工作台不依赖它。逐项实现状态与回归门禁见[桌面对等清单](docs/development/web-workbench/README.md)。

## 从源码构建

Expand Down
11 changes: 11 additions & 0 deletions apps/desktop/src/renderer/src/features/chat/CodeClipboard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { createContext, useContext, useMemo, type ReactNode } from 'react'

/** The web presentation can provide its local clipboard operation without introducing a
* dependency on the browser host in the shared Markdown renderer or in Electron. */
export type CodeClipboard = { writeText(text: string): Promise<void>; locked: boolean }
const Context = createContext<CodeClipboard | null>(null)
export function CodeClipboardProvider({ writeText, locked, children }: CodeClipboard & { children: ReactNode }): React.JSX.Element {
const value = useMemo(() => ({ writeText, locked }), [writeText, locked])
return <Context.Provider value={value}>{children}</Context.Provider>
}
export function useCodeClipboard(): CodeClipboard | null { return useContext(Context) }
32 changes: 31 additions & 1 deletion apps/desktop/src/renderer/src/features/chat/Markdown.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { memo, useRef, useState, type ReactNode } from 'react'
import { memo, useLayoutEffect, useRef, useState, type ReactNode } from 'react'
import ReactMarkdown, { type Components, type Options } from 'react-markdown'
import remarkGfm from 'remark-gfm'
import rehypeHighlight from 'rehype-highlight'
import { Copy, Check } from 'lucide-react'
import { useI18n } from '../../i18n/i18n'
import { useCodeClipboard, type CodeClipboard } from './CodeClipboard'

/**
* 助手消息的 Markdown 渲染(GFM + 代码高亮),对齐 DeepSeek/Codex 观感。
Expand All @@ -27,6 +28,35 @@ function isBlockCode(className: string, children: ReactNode): boolean {

/** 代码块表头的「复制」按钮:复制成功后 1.5 秒内显示「已复制」。时间轴上展开的命令框同用。 */
export function CopyButton({ getText }: { getText: () => string }): React.JSX.Element {
const client = useCodeClipboard()
return client ? <WorkbenchCodeCopy getText={getText} client={client} /> : <DesktopCodeCopy getText={getText} />
}

function WorkbenchCodeCopy({ getText, client }: {getText: () => string; client: CodeClipboard}): React.JSX.Element {
const { t, locale } = useI18n()
const [status, setStatus] = useState<'idle'|'copied'|'failed'>('idle')
const generation = useRef(0), timer = useRef<ReturnType<typeof setTimeout>>()
useLayoutEffect(() => {
generation.current++; setStatus('idle')
return () => { generation.current++; clearTimeout(timer.current) }
}, [client])
const copy = (event: React.MouseEvent): void => {
if (client.locked || !event.nativeEvent.isTrusted) return
const text = getText()
if (!text) return
const current = ++generation.current
clearTimeout(timer.current)
void client.writeText(text).then(() => {
if (generation.current !== current) return
setStatus('copied'); timer.current = setTimeout(() => { if (generation.current === current) setStatus('idle') }, 1500)
}, () => { if (generation.current === current) setStatus('failed') })
}
const label = status === 'failed' ? (locale === 'zh-CN' ? '复制失败' : 'Copy failed') : t(status === 'copied' ? 'chat.md.copied' : 'chat.md.copy')
return <button type="button" className="md-code__copy" data-testid="workbench-code-copy" data-status={status}
aria-live="polite" disabled={client.locked} onClick={copy}>{status === 'copied' ? <Check size={12} /> : <Copy size={12} />}{label}</button>
}

function DesktopCodeCopy({ getText }: { getText: () => string }): React.JSX.Element {
const { t } = useI18n()
const [copied, setCopied] = useState(false)

Expand Down
22 changes: 5 additions & 17 deletions apps/desktop/src/renderer/src/redesign/Composer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import {
import { samePath, DEFAULT_PERSONA_ID, fill, AvatarStack, Avatar } from './shell-common'
import { GitWidget, WorkspaceMenu } from './GitWidget'
import { leadingQuote, withQuote, quotePlain } from './ConvMessage'
import { ComposerQuoteBar } from './ComposerQuoteBar'
import { ModelPanel } from './ModelPanel'
import { ComposerAttachmentButton, ComposerDraftInput, ComposerJump, ComposerSendButton, ComposerWorkspaceButton } from './ComposerControls'

Expand Down Expand Up @@ -882,23 +883,10 @@ export const Composer = memo(function Composer({
{/* 引用条(右键「引用」,同 TG 的回复):在附件之后、文字之前;左竖线 + 灰字一行,悬停看全文;
✕ 取消引用,焦点回到输入框。 */}
{quote && (
<div className="cf-quotebar">
<span className="cf-quotebar__text" title={quotePlain(quote, true)}>
{quotePlain(quote)}
</span>
<button
type="button"
className="cf-quotebar__x"
title={t('cf.quoteRemove')}
aria-label={t('cf.quoteRemove')}
onClick={() => {
setQuote('')
composer.focusEnd()
}}
>
<X size={13} />
</button>
</div>
<ComposerQuoteBar quote={quote} onRemove={() => {
setQuote('')
composer.focusEnd()
}} />
)}
{/* 输入区:Lexical 接管的 contentEditable(子节点归编辑器管,React 不渲染内容);占位提示叠在其上。 */}
<ComposerDraftInput editor={composer} height={boxH} placeholder={placeholder}
Expand Down
30 changes: 30 additions & 0 deletions apps/desktop/src/renderer/src/redesign/ComposerQuoteBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { X } from 'lucide-react'
import { useI18n } from '../i18n/i18n'
import { quotePlain } from './ConvMessage'

/** 引用条:在附件之后、正文之前;悬停看全文。 */
export function ComposerQuoteBar({ quote, onRemove, testId, removeTestId }: {
quote: string
onRemove: () => void
testId?: string
removeTestId?: string
}): React.JSX.Element {
const { t } = useI18n()
return (
<div className="cf-quotebar" data-testid={testId}>
<span className="cf-quotebar__text" title={quotePlain(quote, true)}>
{quotePlain(quote)}
</span>
<button
type="button"
className="cf-quotebar__x"
data-testid={removeTestId}
title={t('cf.quoteRemove')}
aria-label={t('cf.quoteRemove')}
onClick={onRemove}
>
<X size={13} />
</button>
</div>
)
}
34 changes: 31 additions & 3 deletions apps/desktop/src/renderer/src/redesign/ContextMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* 右键菜单(对话列表、Git、工作区、对话流共用)。
*/
import { useEffect, useLayoutEffect, useRef, useState } from 'react'
import { useEffect, useLayoutEffect, useRef, useState, type KeyboardEvent as ReactKeyboardEvent } from 'react'

/** 菜单条目:普通项点击即执行并关闭菜单;separator=分隔线;section=不可点的分组标题;filter=过滤框(按 label 过滤普通项)。 */
interface CtxItem {
Expand All @@ -11,6 +11,7 @@ interface CtxItem {
/** 禁用项:灰显 + 悬停说明(title),不可点(如系统默认角色的删除项)。 */
disabled?: boolean
title?: string
testId?: string
onClick: () => void
}

Expand All @@ -31,14 +32,19 @@ export function ContextMenu({
y,
items,
onClose,
openUp = false
openUp = false,
keyboard = false,
testId
}: {
x: number
y: number
items: CtxEntry[]
onClose: () => void
/** 向上浮出:y 视作菜单底边锚点,菜单朝上生长(默认向下)。 */
openUp?: boolean
/** Optional keyboard navigation for menus opened from a focusable surface. */
keyboard?: boolean
testId?: string
}): React.JSX.Element {
const ref = useRef<HTMLDivElement>(null)
const [pos, setPos] = useState({ left: x, top: y })
Expand All @@ -64,6 +70,25 @@ export function ContextMenu({
window.addEventListener('keydown', onKey)
return () => window.removeEventListener('keydown', onKey)
}, [onClose])
useLayoutEffect(() => {
if (keyboard) ref.current?.querySelector<HTMLElement>('[role="menuitem"]:not(:disabled)')?.focus({ preventScroll: true })
}, [keyboard, x, y, items.length])
const navigate = (event: ReactKeyboardEvent<HTMLDivElement>): void => {
if (event.key === 'Escape' || event.key === 'Tab') {
event.preventDefault()
event.stopPropagation()
onClose()
return
}
if (!['ArrowDown', 'ArrowUp', 'Home', 'End'].includes(event.key)) return
const options = Array.from(event.currentTarget.querySelectorAll<HTMLElement>('[role="menuitem"]:not(:disabled)'))
if (!options.length) return
event.preventDefault()
const index = options.indexOf(event.target as HTMLElement)
const next = event.key === 'Home' ? 0 : event.key === 'End' ? options.length - 1
: event.key === 'ArrowDown' ? (index + 1) % options.length : (Math.max(index, 0) + options.length - 1) % options.length
options[next].focus({ preventScroll: true })
}
return (
<>
<div
Expand All @@ -74,7 +99,8 @@ export function ContextMenu({
onClose()
}}
/>
<div ref={ref} className="cf-ctx" style={{ left: pos.left, top: pos.top }} role="menu">
<div ref={ref} className="cf-ctx" style={{ left: pos.left, top: pos.top }} role="menu"
data-testid={testId} onKeyDown={keyboard ? navigate : undefined}>
{items.map((it, i) => {
if ('kind' in it) {
if (it.kind === 'separator') return q ? null : <div key={i} className="cf-ctx__sep" role="separator" />
Expand All @@ -96,6 +122,8 @@ export function ContextMenu({
key={i}
type="button"
role="menuitem"
tabIndex={keyboard ? -1 : undefined}
data-testid={it.testId}
className={`cf-ctx__item${it.danger ? ' is-danger' : ''}`}
disabled={it.disabled}
title={it.title}
Expand Down
Loading
Loading