Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
12 commits
Select commit Hold shift + click to select a range
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
44 changes: 44 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,26 @@ jobs:
timeout-minutes: 5
run: node scripts/workbench/e2e-session-workspaces.mjs

- name: Verify native task inspection and a confirmed pause in Chrome
id: task_ui
if: ${{ !cancelled() && steps.host_tests.outcome == 'success' }}
timeout-minutes: 5
env:
DEVA_QA_LAYOUT_CAPTURE: '1'
run: node scripts/workbench/e2e-task-inspection.mjs

- name: Publish verified task layouts from synthetic data only
if: ${{ !cancelled() && steps.task_ui.outcome == 'success' }}
uses: actions/upload-artifact@v4
with:
name: task-workbench-layouts
path: |
test-results/task-inspection/tasks-wide.png
test-results/task-inspection/tasks-compact.png
test-results/task-inspection/layout.json
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 @@ -110,6 +130,30 @@ jobs:
timeout-minutes: 3
run: node scripts/workbench/container-focus-ci.mjs

packaged-tasks:
name: Packaged native task management on amd64 Docker
if: ${{ github.event_name == 'pull_request' && github.head_ref == 'feat/web-workbench-task-inspection' }}
runs-on: ubuntu-latest
timeout-minutes: 12
steps:
- uses: actions/checkout@v5
- name: Build the production workbench image
timeout-minutes: 8
run: |
set -eu
test "$(uname -m)" = x86_64
docker build --platform linux/amd64 --target runtime -t deva-workbench:tasks-verify .
docker image inspect -f '{{.Os}}/{{.Architecture}} {{.Id}} {{.Size}} bytes' deva-workbench:tasks-verify
- name: Inspect, preview and pause real task records through the packaged HTTP server
timeout-minutes: 3
run: |
set -eu
test -f "$PWD/apps/headless/test/task-inspection-http.test.mjs"
docker run --rm --init --network none --read-only --user 1000:1000 --cap-drop ALL --security-opt no-new-privileges:true \
--pids-limit 128 --cpus 2 --memory 512m --tmpfs /tmp:rw,nosuid,nodev,noexec,mode=1777,size=96m \
--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

sandbox:
name: Private human browser worker
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ node_modules/
dist/
out/
.vite/
/test-results/
*.tsbuildinfo

# Logs
Expand Down
2 changes: 1 addition & 1 deletion README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ 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 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. An [optional human-operated browser](apps/browser-worker/README.md) uses a separate sandboxed worker and an explicit list of sites. 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) 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.

## Build from Source

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

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

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

## 从源码构建

Expand Down
38 changes: 38 additions & 0 deletions apps/desktop/src/main/services/schedule-preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { describeSchedule, isValidTimeZone, nextRun, parseCron, parseWallIso } from './schedule'
import type { TaskSchedule } from './tasks-types'

/** 预览结果:成功带人读摘要与下次触发(epoch ms,null=无更多触发);失败带与 createTask 一致的错误码。 */
export type PreviewScheduleResult =
| { ok: true; description: string; nextRunAt: number | null }
| { ok: false; error: 'invalid-input' | 'invalid-tz' | 'invalid-cron' | 'invalid-once' }

/**
* 校验日程并返回人读摘要 + 下次触发。预览不读写任务、不创建任务。
* `allowPast` 默认 false:名片编辑态把过期的 once 视为错误。已创建任务的只读展示传 true,
* 合法但过期的 once 仍返回人读摘要(nextRunAt=null)。`now` 为本次预览的评估时刻(epoch ms)。
*/
export function previewSchedule(
schedule: TaskSchedule,
locale: 'zh-CN' | 'en' = 'zh-CN',
allowPast = false,
now = Date.now()
): PreviewScheduleResult {
if (!schedule || typeof schedule !== 'object') return { ok: false, error: 'invalid-input' }
if (!isValidTimeZone(schedule.tz)) return { ok: false, error: 'invalid-tz' }
if (schedule.kind === 'recurring') {
if (!parseCron(schedule.cron ?? '')) return { ok: false, error: 'invalid-cron' }
const next = nextRun(schedule, now)
if (next == null) return { ok: false, error: 'invalid-cron' } // 病态但语法合法(如 2/30)
return { ok: true, description: describeSchedule(schedule, locale), nextRunAt: next }
}
if (schedule.kind === 'once') {
const next = nextRun(schedule, now)
if (next == null) {
if (allowPast && parseWallIso(schedule.at ?? ''))
return { ok: true, description: describeSchedule(schedule, locale), nextRunAt: null }
return { ok: false, error: 'invalid-once' } // 非法或(编辑态下)已过期
}
return { ok: true, description: describeSchedule(schedule, locale), nextRunAt: next }
}
return { ok: false, error: 'invalid-input' }
}
44 changes: 3 additions & 41 deletions apps/desktop/src/main/services/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { randomUUID } from 'crypto'
import { getDevaHome } from './config'
import { publishSessionsChanged } from './chat-bus'
import { listSessions, rebindSessionPersona, syncSessionBinding } from './chat-store'
import { nextRun, parseCron, isValidTimeZone, describeSchedule, parseWallIso } from './schedule'
import { nextRun, parseCron, isValidTimeZone } from './schedule'
import { previewSchedule, type PreviewScheduleResult } from './schedule-preview'
import {
ERROR_PAUSE_THRESHOLD,
MAX_RUNS_PER_TASK,
Expand Down Expand Up @@ -431,46 +432,7 @@ export function applyRunResult(
return { task: t, autoPausedError }
}

// ── 日程预览(确认名片实时校验 + 人读摘要 + 下次触发)──────────────────────

/** 预览结果:成功带人读摘要与下次触发(epoch ms,null=无更多触发);失败带与 createTask 一致的错误码。 */
export type PreviewScheduleResult =
| { ok: true; description: string; nextRunAt: number | null }
| { ok: false; error: 'invalid-input' | 'invalid-tz' | 'invalid-cron' | 'invalid-once' }

/**
* 校验一份日程并返回人读摘要 + 下次触发,供确认名片实时预览(与 createTask 校验同源,所见即所得)。
* 纯读、不落盘、不建任务——名片编辑期的只读推演。
*
* `allowPast`(默认 false):名片编辑态用默认——一次性时间已过视为错误(invalid-once),供用户改后重建。
* 任务列表/详情为**已创建任务的只读展示**(如已完成的一次性任务其墙钟必然已过),传 true——
* 一次性时间虽已过但日程本身合法时回落人读摘要(nextRunAt=null),避免把「已执行完毕」误标为「日程无效」。
*/
export function previewSchedule(
schedule: TaskSchedule,
locale: 'zh-CN' | 'en' = 'zh-CN',
allowPast = false
): PreviewScheduleResult {
if (!schedule || typeof schedule !== 'object') return { ok: false, error: 'invalid-input' }
if (!isValidTimeZone(schedule.tz)) return { ok: false, error: 'invalid-tz' }
if (schedule.kind === 'recurring') {
if (!parseCron(schedule.cron ?? '')) return { ok: false, error: 'invalid-cron' }
const next = nextRun(schedule, Date.now())
if (next == null) return { ok: false, error: 'invalid-cron' } // 病态但语法合法(如 2/30)
return { ok: true, description: describeSchedule(schedule, locale), nextRunAt: next }
}
if (schedule.kind === 'once') {
const next = nextRun(schedule, Date.now())
if (next == null) {
// 时间已过:仅当墙钟本身可解析(即合法但过期,非畸形)且允许过去时,回落人读摘要。
if (allowPast && parseWallIso(schedule.at ?? ''))
return { ok: true, description: describeSchedule(schedule, locale), nextRunAt: null }
return { ok: false, error: 'invalid-once' } // 非法或(编辑态下)已过期
}
return { ok: true, description: describeSchedule(schedule, locale), nextRunAt: next }
}
return { ok: false, error: 'invalid-input' }
}
export { previewSchedule, type PreviewScheduleResult }

// ── 可注入运行器(scheduler 装载后接管 run-now / 触发)──────────────────────

Expand Down
127 changes: 127 additions & 0 deletions apps/desktop/src/renderer/src/redesign/IconRail.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import { useState, type Ref } from 'react'
import { AlarmClock, Cog, MessageCircle, Smartphone, Users } from 'lucide-react'
import { useI18n } from '../i18n/i18n'
import { ProfilePanel } from './ProfilePanel'
import { Avatar } from './shell-common'

/** 图标栏的 tab:对话 / 角色 / 定时任务 / 机器人。 */
export type RailTab = 'chats' | 'roster' | 'tasks' | 'bots'

/* ============================ 最左:图标导航栏(微信式) ============================ */
/**
* 窄图标栏:顶部当前用户头像,中部「对话 / 角色」切换(点击切左栏列表列),底部设置入口。
* 把原先挤在列表列顶部的文字 tab 与底部的用户/设置脚移到这里,列表列因而只承载列表本身。
*/
export function IconRail({
tab,
onTab,
listCollapsed,
onChatsHover,
onChatsLeave,
onOpenSettings,
chatAlert,
unavailable,
library,
taskInspection
}: {
tab: RailTab
/** 点亮着的「对话」图标也回调(由调用方切换会话列表的收起 / 展开)。 */
onTab: (t: RailTab) => void
/** 对话页的会话列表已收起:「对话」图标的提示改为「展开会话列表」,红点也显示在它上面。 */
listCollapsed: boolean
/** 悬停 / 离开「对话」图标(收起时据此浮出列表)。 */
onChatsHover?: () => void
onChatsLeave?: () => void
onOpenSettings: () => void
/** 其他对话有新消息或待你处理 → 按钮上显示红点。 */
chatAlert: boolean
/** Explanation for features that this host does not expose. Omitted on desktop. */
unavailable?: string
library?: { openProfile: () => void; openRoster: () => void }
/** Web host may expose saved tasks even while the other native tabs remain unavailable. */
taskInspection?: { panelId: string; disabled: boolean; buttonRef: Ref<HTMLButtonElement> }
}): React.JSX.Element {
const { t } = useI18n()
const [profileOpen, setProfileOpen] = useState(false)
// 亮着的「对话」图标点了是收起 / 展开,提示写明,免得点了以为列表丢了。
const chatsLabel =
tab !== 'chats' ? t('cf.tabChats') : listCollapsed ? t('cf.expandList') : t('cf.collapseList')
return (
<nav className="cf-iconrail">
<button
type="button"
className="cf-iconrail__me"
title={library ? t('cf.profile.open') : unavailable ?? t('cf.profile.open')}
disabled={!!unavailable && !library}
data-testid={library ? 'workbench-profile' : undefined}
aria-label={t('cf.profile.open')}
onClick={library?.openProfile ?? (() => setProfileOpen(true))}
>
<Avatar user size={34} />
</button>
{profileOpen && !unavailable && <ProfilePanel onClose={() => setProfileOpen(false)} />}
<button
className={`cf-navbtn${tab === 'chats' ? ' is-active' : ''}`}
title={chatsLabel}
aria-label={chatsLabel}
aria-current={tab === 'chats'}
aria-expanded={tab === 'chats' ? !listCollapsed : undefined}
onClick={() => onTab('chats')}
onMouseEnter={onChatsHover}
onMouseLeave={onChatsLeave}
>
<MessageCircle size={20} />
{/* 看不到会话列表时(不在对话页,或列表已收起),在导航按钮上提示其他对话的动静。 */}
{(tab !== 'chats' || listCollapsed) && chatAlert && (
<span className="cf-navbtn__dot" aria-hidden="true" />
)}
</button>
<button
className={`cf-navbtn${tab === 'roster' ? ' is-active' : ''}`}
title={library ? t('cf.tabRoster') : unavailable ?? t('cf.tabRoster')}
disabled={!!unavailable && !library}
data-testid={library ? 'workbench-roster' : undefined}
aria-label={t('cf.tabRoster')}
aria-current={tab === 'roster'}
onClick={library?.openRoster ?? (() => onTab('roster'))}
>
<Users size={20} />
</button>
<button
type="button"
ref={taskInspection?.buttonRef}
className={`cf-navbtn${tab === 'tasks' ? ' is-active' : ''}`}
title={taskInspection ? t('cf.tabTasks') : unavailable ?? t('cf.tabTasks')}
disabled={taskInspection ? taskInspection.disabled : !!unavailable}
data-testid={taskInspection ? 'workbench-tasks-toggle' : undefined}
aria-label={t('cf.tabTasks')}
aria-current={tab === 'tasks'}
aria-expanded={taskInspection ? tab === 'tasks' : undefined}
aria-controls={tab === 'tasks' ? taskInspection?.panelId : undefined}
onClick={() => onTab('tasks')}
>
<AlarmClock size={20} />
</button>
<div className="cf-spacer" />
<button
className={`cf-navbtn${tab === 'bots' ? ' is-active' : ''}`}
title={unavailable ?? t('bots.title')}
disabled={!!unavailable}
aria-label={t('bots.title')}
aria-current={tab === 'bots'}
onClick={() => onTab('bots')}
>
<Smartphone size={20} />
</button>
<button
className="cf-navbtn"
title={t('cf.settings')}
aria-label={t('cf.settings')}
data-testid={unavailable ? "workbench-settings" : undefined}
onClick={onOpenSettings}
>
<Cog size={20} />
</button>
</nav>
)
}
Loading
Loading