Merge remote-tracking branch 'origin/master' into docs/desktop-publish-config-templates
This commit is contained in:
commit
090b64341b
256 files changed
+7258
-1150
No files matched your search
@@ -15,8 +15,8 @@
|
||||
en: db0a2deb9193a00d
|
||||
zh: dab5a65b88957464
|
||||
/agent-note-experimental-auto-review-before-each-tool-call/decision/one-complete-reviewer-request:
|
||||
en: 7bd9fef90e8639b9
|
||||
zh: e2a096885c9c1e83
|
||||
en: 45ac7b4e759b29ad
|
||||
zh: 5374cc89e587f076
|
||||
/agent-note-experimental-auto-review-before-each-tool-call/decision/result-and-cancellation:
|
||||
en: 647fe68c52b907e0
|
||||
zh: 267a739bad44ad65
|
||||
|
||||
@@ -41,6 +41,8 @@ The integration uses only the latest `request/header.config` provider/model and
|
||||
|
||||
Each item is its own message and keeps the same text in later reviews: the pending call becomes a historical call, and the integration remembers, for each live Session, the schema each reviewed call showed so that it reappears at the same position. A review's messages therefore begin with all messages of the previous review. Providers that cache only at message ends, such as OpenAI implicit breakpoints on GPT-5.6 and later, or at a final marker with lookback, such as Anthropic `cache_control`, reuse the previous review; one growing user message let them reuse only the policy. The schema memory is process-local, so the first review after a restart omits earlier schemas and misses the cache once.
|
||||
|
||||
The request also carries the reviewed Session's `sessionId` and `purpose: 'auto-review'`. Routes that require a per-conversation identity or key prompt caching on one, such as the `x-opencode-session` header OpenCode requires and OpenAI `prompt_cache_key`, derive it from that id; without it OpenCode rejects every review, and Auto fails every call. The [DeepSeek Session-log upload](../../../../packages/session/session-log-deepseek/README.md#request-field) applies the same eligibility and registered exclusions to reviews as to other requests. The uploaded data is the canonical Session log; review prompts and decisions remain outside that log.
|
||||
|
||||
The reviewer builds the history and the pending call from the Session's complete action history: an authorization is the earlier call the `REVIEW_POLICY` source rules make eligible, and a duplicate or conflicting identity has to be visible anywhere in the log rather than inside a recent window, so neither the Session projections nor a bounded read serves the decision. The read is the deprecated synchronous `snapshotEvents()` under a line-scoped `typescript/no-deprecated` waiver.
|
||||
|
||||
The main agent's V3 `system/message` nodes, assistant text/reasoning, and tool results are excluded. The current call must belong to the open step recorded by `step/start`; missing step ownership fails closed. It appears only as the final message; an unstarted sibling has no historical call fact. Native schema comes from the latest request header. PTC captures a frozen schema at binding construction and passes it through the scheduler into `ToolExecution`; descriptions and parameter schemas never enter start/settle events or the Session/SDK wire. Missing, inconsistent, or ambiguous action facts reject the call without consulting the live registry. An oversized request fails closed without summarization, truncation, another compaction pass, or a small output-token budget.
|
||||
|
||||
@@ -41,6 +41,8 @@ Integration 只使用最新 `request/header.config` 的 provider/model 与 shi
|
||||
|
||||
每个条目各占一条消息,并在后续评审中保持相同文本:待审调用会变成历史调用,integration 为每个存活 Session 记住每次已审调用展示的 schema,使其在同一位置再次出现。因此一次评审的消息以上一次评审的全部消息开头。只在消息结尾缓存的 provider(如 GPT-5.6 及以后的 OpenAI 隐式断点),或在末尾标记处向前回溯的 provider(如 Anthropic `cache_control`),都能复用上一次评审;单条不断增长的 user 消息只能让它们复用策略。Schema 记忆只在进程内,因此重启后的第一次评审会缺少先前的 schema,并有一次缓存未命中。
|
||||
|
||||
请求还携带被评审 Session 的 `sessionId` 与 `purpose: 'auto-review'`。需要按对话标识路由或以其为 prompt 缓存键的路由(例如 OpenCode 要求的 `x-opencode-session` header 与 OpenAI 的 `prompt_cache_key`)由该 id 派生;缺少它时 OpenCode 会拒绝每次评审,Auto 会让每个调用失败。[DeepSeek session-log 上传](../../../../packages/session/session-log-deepseek/README.zh.md#request-field)对评审和其他请求应用相同的上传资格与注册排除条件。上传的是权威 Session 日志;评审提示词和决策仍不进入该日志。
|
||||
|
||||
reviewer 从 Session 的完整动作历史构建历史与待审调用:授权是符合 `REVIEW_POLICY` 来源规则的那个更早调用,而重复或冲突的身份必须在整份日志的任何位置都可见,而不是只在近期窗口内可见,因此 Session 投影与有界读取都无法支撑该判定。这次读取使用已废弃的同步 `snapshotEvents()`,并带有行级 `typescript/no-deprecated` 豁免。
|
||||
|
||||
主 agent 的 V3 `system/message` 节点、assistant 正文/reasoning 与 tool results 全部排除。当前调用必须属于 `step/start` 记录的开放 step;缺少 step 归属时拒绝执行。该调用只作为最后一条消息出现;尚未开始的 sibling 没有历史调用事实。原生 schema 来自最新 request header。PTC 在 binding 构造时捕获冻结 schema,经由调度器传入 `ToolExecution`;描述与参数 schema 不进入开始/结算事件或 Session/SDK wire。动作事实缺失、不一致或有歧义时拒绝调用,不查询 live registry。超窗请求直接拒绝,不做摘要、截断、额外 compaction 或设置小型输出 token 预算。
|
||||
|
||||
@@ -9,14 +9,14 @@
|
||||
en: 344bcc7e9825bbc8
|
||||
zh: c1d0f4b54f5b3786
|
||||
/agent-note-change-request-panel-and-worktree-sessions/decision:
|
||||
en: b18b287b701aef93
|
||||
zh: 462c0f561f1a0c18
|
||||
en: 0b159e4e33409515
|
||||
zh: 2bf1eafd644f2d26
|
||||
/agent-note-change-request-panel-and-worktree-sessions/deferred:
|
||||
en: 32ef8af85f4d2f66
|
||||
zh: b82b67f94346399e
|
||||
/agent-note-change-request-panel-and-worktree-sessions/alternatives-considered:
|
||||
en: 91b3338f958ad0e9
|
||||
zh: b64f30d333280084
|
||||
en: e471e16b6b6450ca
|
||||
zh: 5fbc9242edc8d112
|
||||
/agent-note-change-request-panel-and-worktree-sessions/consequences:
|
||||
en: 97976f073b9f65e0
|
||||
zh: 95be3f7f375b0876
|
||||
@@ -26,6 +26,8 @@ The panel does not move a Session between existing worktrees. Removing a change
|
||||
|
||||
The panel also shows the changes behind a Session's work in a changes view, a resource tab type of this package. The Remote parses every diff on the Host into files and hunks, so the browser draws them without a patch parser, and bounds each read with `maxDiffBytes` and `maxUntrackedFiles`. Local changes come from confined `git diff` in the Session's execution world, in a scope the user picks: the branch against its fork point by default, or the uncommitted, unstaged, or staged changes; untracked files are read through the Session's filesystem and shown as new files. A change request's changes come from its code host at the head of the binding's latest status, through two provider reads the forge seam gained, `diff` and `fileText`. The Host keeps the patch it read last for each change request, keyed by the head commit and base branch and bounded by `maxCachedDiffBytes`, so reopening, refreshing, and navigating at the same head download nothing again; a host or provider that refuses an answer over its size limit reports the forge failure `too-large`, and the view then offers the change request's web page instead of a retry. Unchanged lines between hunks expand from the file's new side, which is the working tree, the index, or the head commit, and only while that text still matches the hunks. Each inspection also sizes the branch's changes for a local changes card, shown while no open change request carries the checked-out branch; its Create change request sends the Session a user message, so the Agent creates the change request with its own tools and the binding follows from `gh pr create` as for any other.
|
||||
|
||||
Review comments capture the file, side, range, complete hunk, and reviewed head when the user selects code. Agent references enter the existing composer quote mechanism, so the user controls batching and the sent message records exactly what the model receives. GitHub writes belong to the optional forge provider operation: preflight checks the current head, the write addresses that commit, and an ambiguous outcome blocks another write until the user reconciles it. Review drafts and inline records belong to a browser tab occurrence, not to the Session log or a GitHub pending review. Switching Sessions retains that occurrence; closing it discards the local state and rejects late write completions. Published GitHub comments remain external records.
|
||||
|
||||
## Deferred
|
||||
|
||||
A left-navigation review page next to Plugins and Scheduled tasks, listing the user's pull requests or merge requests on the selected provider, is deferred. It attaches without changing this package's Session surfaces:
|
||||
@@ -79,6 +81,12 @@ The changes view offers no scope for one commit or for the last turn yet; both w
|
||||
|
||||
**Creating the change request from the card.** The panel would need to push the branch and compose the title and description; a message lets the Agent do both with its tools and the user's instructions, and keeps one way to bind change requests.
|
||||
|
||||
**Sending each line comment immediately to the Agent.** It starts a turn before the user can collect related comments or add a shared instruction; composer references preserve that choice.
|
||||
|
||||
**Keeping review drafts after their tab closes.** Reopening the same PR would restore abandoned review state. A tab occurrence gives closing a clear discard meaning while preserving Session switching.
|
||||
|
||||
**Automatically retrying a review write.** A lost response does not mean that GitHub rejected the request. Retaining the outgoing request and requiring reconciliation prevents a transport failure from silently duplicating comments.
|
||||
|
||||
## Consequences
|
||||
|
||||
The panel shows current status only while it is open; checks that finish while nothing is mounted produce no notification. Changes made outside the Session appear after Refresh or the next tool result. Every inspection spawns up to eleven short Git processes in the Session's execution world with one remote, and two more for each further remote it tries for a fork point. A worktree exists only for a Session that requested it before its first step, and a failed or cancelled attempt can leave its branch or checkout behind. A message that enters while the Agent runs a turn or other maintenance gets no hold, so its worktree is created within the first turn and a removed worktree is not checked. While a message waits, the Agent stays idle in maintenance: the composer offers no stop, and callers waiting for the Agent to become idle wait as well. Restoring loses changes that were never committed. A base branch that requires a merge queue cannot merge from the panel. With Git Worktrees also enabled, two independent worktree services exist; the model's tool never sees the panel's service. A local or change request diff over `maxDiffBytes`, or one the host refuses, shows no files. Expanding unchanged lines of a change request reads each file from the code host once.
|
||||
@@ -26,6 +26,8 @@ Session 所在的 worktree 可能在 Session 之外被删除。每次检查都
|
||||
|
||||
面板还通过变更视图展示 Session 工作背后的变更;变更视图是本包的一个资源标签页类型。Remote 在宿主上把每个 diff 解析成文件与 hunk,因此浏览器无需补丁解析器即可绘制,每次读取都受 `maxDiffBytes` 与 `maxUntrackedFiles` 约束。本地变更来自 Session 执行环境中受限的 `git diff`,范围由用户选择:默认是分支相对于分叉点的变更,也可以是未提交、未暂存或已暂存的变更;未跟踪文件经 Session 的文件系统读取,显示为新文件。变更请求的变更来自代码托管平台,取自绑定最新状态中的 head,经 forge seam 新增的两个提供方读取操作 `diff` 与 `fileText` 获得。Host 为每个变更请求保留最近读到的补丁,按 head 提交与目标分支区分,总量受 `maxCachedDiffBytes` 约束,因此在同一 head 下重新打开、刷新与导航都不会再次下载;托管平台或提供方因结果超过其大小上限而拒绝时报告 forge 失败 `too-large`,视图随之提供变更请求的网页而不是重试。hunk 之间未变更的行从文件的新版本展开,即工作树、暂存区或 head 提交,并且只在该文本仍与 hunk 吻合时展开。每次检查还会为变更卡片统计分支的变更规模;没有打开中的变更请求以当前检出分支为源分支时才显示该卡片。卡片上的“创建变更请求”向 Session 发送一条用户消息,由 Agent 用自己的工具创建变更请求,绑定像其他变更请求一样来自 `gh pr create`。
|
||||
|
||||
评审评论在用户选择代码时固定文件、侧、行范围、完整 hunk 与所评审的 head。Agent 引用进入既有输入框引用机制,由用户决定批量发送,发送后的消息记录模型实际收到的内容。GitHub 写入属于 forge 提供方的可选操作:预检核对当前 head,写入明确指向该提交;结果不明时阻止再次写入,直到用户核对。评审草稿与行内记录归浏览器页签实例所有,不进入 Session 日志,也不创建 GitHub 待提交评审。切换 Session 保留该实例;关闭时丢弃本地状态并拒绝迟到的写入结果。已发布的 GitHub 评论仍保留在外部平台。
|
||||
|
||||
## Deferred
|
||||
|
||||
在左侧导航“插件”“自动化任务”旁边新增代码审查页、列出用户在所选提供方上的 pull request 或 merge request,这项工作推迟。它的接入不需要改动本包面向 Session 的界面:
|
||||
@@ -79,6 +81,12 @@ Session 所在的 worktree 可能在 Session 之外被删除。每次检查都
|
||||
|
||||
**直接在卡片上创建变更请求。** 面板需要推送分支并撰写标题与描述;发送消息让 Agent 用自己的工具和用户的指示完成这两件事,绑定变更请求的方式也只保留一种。
|
||||
|
||||
**把每条行内评论立即发送给 Agent。** 用户还没来得及收集相关评论或补充共同指令,就会开始一轮;输入框引用保留用户的选择。
|
||||
|
||||
**关闭页签后仍保留评审草稿。** 重新打开同一个 PR 会恢复已放弃的评审状态。页签实例让关闭明确表示丢弃,同时保留切换 Session 的状态。
|
||||
|
||||
**自动重试评审写入。** 丢失响应不代表 GitHub 拒绝了请求。保留发出的请求并要求核对,可以避免传输失败悄悄产生重复评论。
|
||||
|
||||
## Consequences
|
||||
|
||||
面板只在打开时显示当前状态;没有任何界面挂载时检查结束不会有通知。Session 之外的改动要等到刷新或下一个工具结果才会出现。只有一个远端时,每次检查最多在 Session 的执行环境中启动十一个短暂的 Git 进程;为寻找分叉点每多尝试一个远端,就多启动两个。只有在第一步之前提出请求的 Session 才会有 worktree,失败或被取消的尝试可能留下它的分支或检出。Agent 正在运行一轮或其他维护任务时进入的消息不会被暂留,因此它的 worktree 在第一轮之内创建,已删除的 worktree 也不会被检查。消息等待期间,Agent 以空闲状态处于维护任务中:输入框不提供停止,等待 Agent 空闲的调用方也会一并等待。恢复会丢失从未提交的修改。要求合并队列的基准分支无法从面板合并。同时启用 Git Worktrees 时会存在两个互不影响的 worktree 服务;模型的工具看不到面板的服务。本地或变更请求的 diff 超过 `maxDiffBytes`,或被托管平台拒绝时,不显示任何文件。展开变更请求中未变更的行时,每个文件只从托管平台读取一次。
|
||||
@@ -18,11 +18,11 @@
|
||||
en: 1310a89c351e5bfe
|
||||
zh: e6386ae10b893c2d
|
||||
/agent-note-performance-baselines-for-large-session-corpora/decision/measured-endpoints:
|
||||
en: 11937dfa4a349a19
|
||||
zh: b91a136890fe92e8
|
||||
en: add81088ce51033f
|
||||
zh: c7065dc3052648fa
|
||||
/agent-note-performance-baselines-for-large-session-corpora/calibration-evidence:
|
||||
en: f934c95748dcbfe0
|
||||
zh: df6a68286c21510f
|
||||
en: adb815c213373d8e
|
||||
zh: 44d4c6752a4df51f
|
||||
/agent-note-performance-baselines-for-large-session-corpora/alternatives-considered:
|
||||
en: 4eaa4666262a1aee
|
||||
zh: 7e2eb44b94bad05d
|
||||
|
||||
@@ -47,6 +47,8 @@ The shared corpus and projection-list controller fixture awaits controller activ
|
||||
|
||||
The file must finish within five minutes on standard hosted CI, including seeding, and its last case asserts that limit. Search over 1,000 Sessions and one fork of the longest Session take about 170 s of it, so each has one sample. The list corpus is the largest that fits the remainder. Budgets enforce medians of list boot, first, and repeat, and of the fork median over strata and rank 990; search and the longest fork enforce their single samples. Search and fork use separate 1,000-Session roots, so fork children never reach the search index. Rank 988 is the highest top-level rank at the measured p99 (7,229 events); forking a subagent child adds a lineage lookup, and rank 990 already falls in the 99.3% anchor. Peak RSS of the list, search, and fork processes has a budget with the shared 1.25 headroom and no time scale. Each child's deadline equals the file limit, and each test's deadline outlasts its sequential children, so a failed case reaps every child before the scratch root is removed.
|
||||
|
||||
Fork workers use a 512 MiB V8 old-space limit so every runner measures the same heap constraint. The corpus, timed endpoints, and whole-process peak RSS budget stay unchanged; native buffers still count toward RSS. The longest fork retains about 193 MiB after collection, so the limit leaves room for live objects while forcing collection before a larger host-selected heap delays it. This measures a bounded-heap workload, not the default-heap peak of every deployment.
|
||||
|
||||
## Calibration evidence
|
||||
|
||||
Budgets use standard two-CPU hosted CI expectations (Linux x64, Node 24.21, PR #5403), rounded above the higher recorded median across the AMD EPYC 7763 and EPYC 9V74 runners and multiplied by the shared 1.25 headroom. Samples varied by up to 15% within one run; the runner models differed by up to 25% per endpoint. The hosted-to-reference ratio is 2.4 to 3.4, above the shared reference scale of 2, so reference-machine scaling would reject ordinary hosted runs.
|
||||
@@ -67,6 +69,8 @@ With seeding in one process, the complete file took 294.5 s on the EPYC 7763 run
|
||||
|
||||
On Apple M5 Pro with Node 26.5, isolated runs measured list 1,000 at 311–358 ms first, list 5,000 at 1,364–1,603 ms first, search at 57 s first, and fork of the longest Session at 6.0–6.4 s. A 10,000-Session list took 3.2–5.4 s for the first call with 1.9 GB peak RSS.
|
||||
|
||||
Node 24.22 hosted runs of the unchanged longest-fork workload recorded 696 MiB peak RSS on EPYC 9V74 and 1,077.7 MiB on EPYC 7763, against the same 938 MiB budget. On Apple M5 Pro with Node 24.19, two default-heap runs retained 192.8–193.4 MiB and peaked at 770.7–812.6 MiB in 2.416–2.447 s; two 512 MiB old-space runs retained the same range and peaked at 764.2–764.7 MiB in 2.487–2.528 s. The fixed limit controls the heap policy without raising the RSS or timing budgets.
|
||||
|
||||
## Alternatives considered
|
||||
|
||||
- **Sanitized copies of real Sessions.** Rejected: benchmarks never use recorded user material.
|
||||
|
||||
@@ -47,6 +47,8 @@ worker 是编译后的纯 Node 进程,每次都针对已播种根目录全新
|
||||
|
||||
此文件(包括播种)必须在标准托管 CI 上五分钟内完成,其最后一个用例断言该上限。1,000 个 Session 的搜索和最长 Session 的一次 fork 约占其中 170 s,因此两者各取一个样本。列表语料是剩余时间内能容纳的最大规模。预算约束列表启动、首次和重复的中位数,以及 fork 分层中位数和排名 990 的中位数;搜索和最长 fork 约束各自的单个样本。搜索和 fork 使用各自独立的 1,000 个 Session 根目录,因此 fork 子会话不会进入搜索索引。排名 988 是实测 p99(7,229 个事件)上最高的顶层排名;fork subagent 子会话会增加一次谱系查找,而排名 990 已落入 99.3% 锚点。列表、搜索和 fork 进程的峰值 RSS 设有预算,使用共享的 1.25 余量,不做时间缩放。每个子进程的截止时间等于文件上限,每个测试的截止时间长于其顺序子进程之和,因此失败的用例会在删除临时根目录之前回收所有子进程。
|
||||
|
||||
Fork worker 使用 512 MiB 的 V8 old-space 上限,让各运行器在相同的堆约束下测量。语料、计时终点和整个进程的峰值 RSS 预算保持不变,原生缓冲区仍计入 RSS。最长 fork 回收后保留约 193 MiB,因此该上限为存活对象保留空间,同时避免较大的宿主默认堆延迟回收。该用例测量受限堆下的工作负载,不代表每种部署默认堆下的峰值。
|
||||
|
||||
## 校准证据
|
||||
|
||||
预算使用标准双 CPU 托管 CI 的期望值(Linux x64、Node 24.21、PR #5403),取高于 AMD EPYC 7763 与 EPYC 9V74 运行器中较高记录中位数的整数,再乘以共享的 1.25 余量。同一次运行内的样本差异最多 15%;两种运行器型号在单个端点上最多相差 25%。托管与参考机器的比值为 2.4 到 3.4,高于共享的参考缩放系数 2,因此按参考机器缩放会拒绝正常的托管运行。
|
||||
@@ -67,6 +69,8 @@ worker 是编译后的纯 Node 进程,每次都针对已播种根目录全新
|
||||
|
||||
在 Apple M5 Pro 和 Node 26.5 上的隔离运行中,1,000 个 Session 的首次列表为 311–358 ms,5,000 个 Session 的首次列表为 1,364–1,603 ms,首次搜索为 57 s,fork 最长 Session 为 6.0–6.4 s。10,000 个 Session 的首次列表耗时 3.2–5.4 s,峰值 RSS 为 1.9 GB。
|
||||
|
||||
未改动的最长 fork 工作负载在 Node 24.22 托管运行中,EPYC 9V74 的峰值 RSS 为 696 MiB,EPYC 7763 为 1,077.7 MiB,使用的预算均为 938 MiB。在 Apple M5 Pro、Node 24.19 上,两次默认堆运行回收后保留 192.8–193.4 MiB,峰值为 770.7–812.6 MiB,耗时 2.416–2.447 s;两次 512 MiB old-space 运行保留量相同,峰值为 764.2–764.7 MiB,耗时 2.487–2.528 s。固定上限用于控制堆策略,没有提高 RSS 或耗时预算。
|
||||
|
||||
## 考虑过的替代方案
|
||||
|
||||
- **脱敏复制真实 Session。** 已否决:基准从不使用录制的用户材料。
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: record-browser-gif
|
||||
description: Record browser or Web UI interaction demos as optimized GIFs using the available browser-control workflow, optional Playwright Videos for higher capture frame rates, and deterministic encoding, then attach the GIF to a pull request with `gh --attach`, falling back to a dedicated assets branch where attach cannot apply. Use when asked to make, record, or generate a GIF that demonstrates a browser workflow, and for every pull request that changes product-user-visible GUI behavior, which MUST include a GIF recorded from the pull request's real server and model flow.
|
||||
description: Record browser or Web UI interaction demos as optimized GIFs using the available browser-control workflow, optional Playwright Videos for higher capture frame rates, and deterministic encoding, then attach the GIF to a pull request with `gh --attach`; publication requires gh v2.99.0 or later, and a GIF over 5 MiB is split into parts. Use when asked to make, record, or generate a GIF that demonstrates a browser workflow, and for every pull request that changes product-user-visible GUI behavior, which MUST include a GIF recorded from the pull request's real server and model flow.
|
||||
---
|
||||
|
||||
# Record Browser GIF
|
||||
@@ -17,8 +17,8 @@ The recording itself is part of the evidence: use a real server booted from that
|
||||
|
||||
## Keep recording separate from publication
|
||||
|
||||
- Recording produces local video or screenshots and one `.gif` artifact only; it never mutates remote state.
|
||||
- Publication — attaching the GIF to a pull request body with `gh --attach`, or pushing it to an assets branch and embedding its URL where attach cannot apply — is the separate final step, performed only when the task includes attaching the GIF to a pull request. It never touches the pull request's own branch.
|
||||
- Recording produces local video or screenshots; encoding produces one `.gif` artifact, or its [numbered parts](#attach-with-gh) when it exceeds the 5 MiB limit. Neither mutates remote state.
|
||||
- Publication — attaching the GIF to a pull request body with `gh --attach` — is the separate final step, performed only when the task includes attaching the GIF to a pull request. It never commits to any branch.
|
||||
- Preserve the requested recording conditions. A real-server or real-API demo must not use fixture queries, mock transports, synthetic event injection, or test-only hooks. If credentials or the server are unavailable, report that limitation instead of substituting a fixture.
|
||||
- Never read or expose credential values. Use the application's normal configuration path and a benign demonstration prompt.
|
||||
|
||||
@@ -117,13 +117,15 @@ Encoder maintenance: run `python3 -m unittest discover -s "$GIF_SKILL_DIR/script
|
||||
|
||||
Perform this step only when the task includes attaching the GIF to a pull request.
|
||||
|
||||
Never commit a GIF to the pull request's own branch or any branch that merges into a long-lived branch: binary media committed there bloats the repository history for every future clone. Prefer `gh --attach`, which uploads the GIF to GitHub and rewrites the body reference in one command, so no branch carries the media.
|
||||
Never commit a GIF to the pull request's own branch or any other branch: every default clone and full-history fetch of the repository downloads media committed to any branch. Publish only with `gh --attach`, which uploads the GIF to GitHub and rewrites the body reference in one command, so no branch carries the media.
|
||||
|
||||
### Attach with gh
|
||||
|
||||
`gh --attach` requires `gh` v2.99.0 or later (`gh --version`), a repository on github.com — GitHub Enterprise Server is not supported — write access to the repository, and a GIF at or below 10 MB. Confirm the verified artifact fits that limit; when it does not, shrink it with `--max-width`, then `--colors` or `--fps`, before attaching.
|
||||
Before attaching, check `gh --version`. `gh --attach` requires `gh` v2.99.0 or later, a repository on github.com — GitHub Enterprise Server is not supported — and write access to the repository. When `gh` is older than v2.99.0, stop and tell the developer to upgrade `gh` to v2.99.0 or later; keep the verified GIF for the retry, and do not install or upgrade `gh` without authorization. When any other requirement is unmet or the attach fails — authentication, write access, a repository outside github.com, or an upload error — stop and report it to the developer. Never publish the GIF any other way.
|
||||
|
||||
Write the GIF into the body file as an ordinary local-path reference, using the same path passed to `--attach`; `gh` rewrites the reference in place to the uploaded URL, keeping its position and alt text:
|
||||
Publish GIFs at or below 5 MiB, the encoder's default `--max-bytes`. When the encoder rejects the output for size, shrink it with `--max-width`, then `--colors` or `--fps`. When the GIF still exceeds 5 MiB at readable text quality, split it instead: encode consecutive, non-overlapping intervals of the same evidence run into numbered parts that each pass the encoder's size check — `--start` and `--end` over the one video, or consecutive screenshot subsets selected with `--pattern` — and verify every part as an artifact. Beside each embed, state its position (such as `2/3`) and its source interval or frames.
|
||||
|
||||
Write each GIF into the body file as an ordinary local-path reference, using the same path passed to `--attach`; `gh` rewrites each reference in place to its uploaded URL, keeping its position and alt text, so the order of references in the body sets the display order of split parts:
|
||||
|
||||
```markdown
|
||||

|
||||
@@ -138,35 +140,8 @@ gh pr create --body-file <body.md> --attach <path/to/demo.gif> # new pull re
|
||||
gh pr edit <pr> --body-file <body.md> --attach <path/to/demo.gif> # existing pull request
|
||||
```
|
||||
|
||||
`--attach` is repeatable but refuses the same file twice. A GIF the body does not reference is appended at the end, where alt text set on the flag (`--attach '<path>#<alt text>'`) applies; a rewritten reference keeps the body's alt text. After attaching, re-read the demonstrated live head and require it to remain at that recorded commit. Re-read the live body and confirm the reference now points at the uploaded URL, render the body through GitHub's Markdown API and confirm the expected `<img>`, and fetch the uploaded URL once to confirm `200` and `image/gif`.
|
||||
`--attach` is repeatable but refuses the same file twice. Publish split parts in one `gh pr create` or `gh pr edit` with one `--attach` per part, so a single pair of live-head checks covers every part. A GIF the body does not reference is appended at the end, where alt text set on the flag (`--attach '<path>#<alt text>'`) applies; a rewritten reference keeps the body's alt text. After attaching, re-read the demonstrated live head and require it to remain at that recorded commit. Re-read the live body and confirm the reference now points at the uploaded URL, render the body through GitHub's Markdown API and confirm the expected `<img>`, and fetch the uploaded URL once to confirm `200` and `image/gif`.
|
||||
|
||||
### Fall back to an assets branch
|
||||
### Existing assets branches
|
||||
|
||||
Use the assets-branch workflow only when `gh --attach` cannot apply: the GIF still exceeds 10 MB, `gh` is older than v2.99.0, or the repository is not on github.com. GIFs then live on a dedicated orphan assets branch — a branch with no parent commit and nothing but media — and one assets branch serves a whole pull request series (named `<series>-assets`; list existing ones with `git ls-remote --heads origin '*assets*'`).
|
||||
|
||||
Before either workflow below pushes, verify that the assets branch contains media only and that the staged GIF's checksum matches the verified local artifact.
|
||||
|
||||
For an existing assets branch, work in a shallow single-branch scratch clone so the publication cannot touch your working tree:
|
||||
|
||||
```sh
|
||||
git clone --branch <assets-branch> --single-branch --depth 1 <repo-url> /tmp/assets-checkout
|
||||
cp /absolute/path/to/demo.gif /tmp/assets-checkout/<name>.gif
|
||||
cd /tmp/assets-checkout
|
||||
git add <name>.gif
|
||||
git commit -m "assets: <what it shows> gif (#<pr>)"
|
||||
git push origin <assets-branch>
|
||||
```
|
||||
|
||||
For a new series, make a fresh shallow scratch clone (`git clone --depth 1 <repo-url> /tmp/assets-checkout`), create the orphan branch with `git switch --orphan <assets-branch>`, then add the GIF, commit, and push the same way.
|
||||
|
||||
After pushing, use authenticated GitHub API or raw requests to confirm the remote path, byte size, checksum, `200` response, and `image/gif` content type. An anonymous `404` does not disprove a private-repository asset; authenticate the verification instead. This proves the repository-member review path, not public availability.
|
||||
|
||||
Immediately before editing the pull-request body, re-read the demonstrated pull request's live head and compare it with the commit recorded next to the GIF. Stop and re-record when it moved. After the edit, re-read the demonstrated live head and require it to remain at that recorded commit. Separately, render the body through GitHub's Markdown API and confirm that the expected `<img>` is present.
|
||||
|
||||
Embed the GIF in the pull request body with the raw blob URL; the `?raw=true` suffix is required, because the plain blob URL renders GitHub's file page instead of the image:
|
||||
|
||||
```markdown
|
||||

|
||||
```
|
||||
|
||||
Never delete or rewrite an assets branch, and never force-push it: merged pull request bodies reference its URLs forever. Append new commits only.
|
||||
Earlier pull request bodies embed GIFs from orphan `*-assets` branches in this repository. Never add to, delete, rewrite, or force-push them: merged pull request bodies reference their URLs.
|
||||
@@ -14,6 +14,7 @@ on:
|
||||
- larger-runner-benchmark
|
||||
- consolidated-runner-benchmark
|
||||
- ssh-helper
|
||||
- wine
|
||||
|
||||
# New master pushes and manual runs replace obsolete checks in this workflow/ref.
|
||||
# Standby drills share cancellation; use completed runs as readiness evidence.
|
||||
@@ -49,9 +50,9 @@ jobs:
|
||||
secrets:
|
||||
DEEPSEEK_API_KEY_EXTERNAL: ${{ secrets.DEEPSEEK_API_KEY_EXTERNAL }}
|
||||
|
||||
# Wine runs once here, independently of the native serial standby aggregates.
|
||||
# Wine runs on master pushes or an explicit suite=wine dispatch, independently of native standbys.
|
||||
windows:
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
||||
if: (github.event_name == 'push' && github.ref == 'refs/heads/master') || (github.event_name == 'workflow_dispatch' && inputs.suite == 'wine')
|
||||
runs-on: ubuntu-latest
|
||||
name: windows node 24 / wine
|
||||
timeout-minutes: 15
|
||||
|
||||
@@ -24,18 +24,7 @@ env:
|
||||
jobs:
|
||||
pack:
|
||||
name: Pack npm tarballs
|
||||
runs-on: >-
|
||||
${{ vars.DSH_CI_FAILOVER_LINUX == 'selfhosted'
|
||||
&& github.repository == 'deepseek-harness/deepseek-harness'
|
||||
&& github.actor != 'dependabot[bot]'
|
||||
&& (github.event_name == 'workflow_dispatch'
|
||||
|| (github.event_name == 'push' && github.ref == 'refs/heads/master')
|
||||
|| (github.event_name == 'pull_request'
|
||||
&& github.event.pull_request.head.repo.full_name == github.repository
|
||||
&& github.event.pull_request.head.repo.fork == false
|
||||
&& github.event.pull_request.user.login != 'dependabot[bot]'))
|
||||
&& fromJSON('["self-hosted", "linux", "x64", "vm-backup"]')
|
||||
|| 'ubuntu-24.04' }}
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
# Complete history: the release scripts read tags.
|
||||
- uses: actions/[email protected]
|
||||
|
||||
@@ -53,11 +53,6 @@ on:
|
||||
type: string
|
||||
default: ''
|
||||
required: false
|
||||
build_root:
|
||||
description: '独立构建根目录:填写绝对路径,每次任务创建独立源码副本;留空使用 runner 工作区'
|
||||
type: string
|
||||
default: ''
|
||||
required: false
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -82,7 +77,6 @@ jobs:
|
||||
PACKAGE_TEST_RELEASE_ID: ${{ inputs.test_release_id }}
|
||||
PACKAGE_SIGNING: ${{ inputs.signing }}
|
||||
PACKAGE_CACHE_NAMESPACE: ${{ inputs.cache_namespace }}
|
||||
PACKAGE_BUILD_ROOT: ${{ inputs.build_root }}
|
||||
PACKAGE_WINDOWS_COMPRESSION_LEVEL: ${{ inputs.compression_level }}
|
||||
steps:
|
||||
- name: Reset packaging checkout
|
||||
@@ -106,7 +100,7 @@ jobs:
|
||||
run: |
|
||||
$helpers = Join-Path $env:RUNNER_TEMP "packaging-helpers-$env:GITHUB_RUN_ID-$env:GITHUB_RUN_ATTEMPT"
|
||||
New-Item -ItemType Directory -Path $helpers -ErrorAction Stop | Out-Null
|
||||
foreach ($name in @('windows-packaging-priority.ps1', 'windows-build-workspace.mjs')) {
|
||||
foreach ($name in @('windows-packaging-priority.ps1')) {
|
||||
Copy-Item -LiteralPath (Join-Path 'apps/desktop/scripts' $name) -Destination $helpers -ErrorAction Stop
|
||||
}
|
||||
"PACKAGE_CI_HELPERS=$helpers" >> $env:GITHUB_ENV
|
||||
@@ -140,17 +134,6 @@ jobs:
|
||||
- uses: actions/[email protected]
|
||||
with:
|
||||
node-version: '24'
|
||||
- name: Select packaging workspace
|
||||
id: build_workspace
|
||||
env:
|
||||
PACKAGE_SOURCE_SHA: ${{ steps.checkout.outputs.commit }}
|
||||
run: |
|
||||
if (!$env:PACKAGE_BUILD_ROOT) {
|
||||
"directory=$env:GITHUB_WORKSPACE" >> $env:GITHUB_OUTPUT
|
||||
} else {
|
||||
node "$env:PACKAGE_CI_HELPERS/windows-build-workspace.mjs"
|
||||
exit $LASTEXITCODE
|
||||
}
|
||||
- name: Configure persistent pnpm store
|
||||
# PNPM_HOME belongs to this run; keep downloaded packages outside its temporary directory.
|
||||
env:
|
||||
@@ -167,7 +150,6 @@ jobs:
|
||||
"DSH_DESKTOP_PACKAGE_CACHE_DIR=$env:DSH_DESKTOP_PACKAGE_CACHE_DIR" >> $env:GITHUB_ENV
|
||||
"PNPM_CONFIG_STORE_DIR=$storeRoot" >> $env:GITHUB_ENV
|
||||
- name: Install locked dependencies
|
||||
working-directory: ${{ steps.build_workspace.outputs.directory }}
|
||||
run: |
|
||||
& "$env:PACKAGE_CI_HELPERS/windows-packaging-priority.ps1" -BestEffort
|
||||
node -e "const os=require('node:os'); console.log(JSON.stringify({node:process.version,availableParallelism:os.availableParallelism(),logicalCpus:os.cpus().length,totalMemoryBytes:os.totalmem(),freeMemoryBytes:os.freemem()}))"
|
||||
@@ -178,12 +160,10 @@ jobs:
|
||||
exit $LASTEXITCODE
|
||||
- name: Validate preset and resolve build version
|
||||
id: settings
|
||||
working-directory: ${{ steps.build_workspace.outputs.directory }}
|
||||
env:
|
||||
PACKAGE_BUILD_VERSION: ${{ inputs.build_version }}
|
||||
run: node apps/desktop/scripts/prepare-windows-ci.mjs
|
||||
- name: Check packaging configuration and toolchain
|
||||
working-directory: ${{ steps.build_workspace.outputs.directory }}
|
||||
env:
|
||||
PACKAGE_VERSION: ${{ steps.settings.outputs.version }}
|
||||
run: |
|
||||
@@ -192,23 +172,16 @@ jobs:
|
||||
pnpm @packageArgs
|
||||
exit $LASTEXITCODE
|
||||
- name: Build installer and verify packaged runtime
|
||||
working-directory: ${{ steps.build_workspace.outputs.directory }}
|
||||
env:
|
||||
PACKAGE_VERSION: ${{ steps.settings.outputs.version }}
|
||||
PACKAGE_BUILD_TEMP: ${{ steps.build_workspace.outputs.temporaryDirectory }}
|
||||
run: |
|
||||
& "$env:PACKAGE_CI_HELPERS/windows-packaging-priority.ps1" -BestEffort
|
||||
if ($env:PACKAGE_BUILD_TEMP) {
|
||||
$env:TEMP = $env:PACKAGE_BUILD_TEMP
|
||||
$env:TMP = $env:PACKAGE_BUILD_TEMP
|
||||
}
|
||||
$packageArgs = @('run', 'package:desktop:win:x64', '--build-version', $env:PACKAGE_VERSION)
|
||||
if ($env:PACKAGE_SIGNING -eq 'unsigned') { $packageArgs += '--unsigned' }
|
||||
pnpm @packageArgs
|
||||
exit $LASTEXITCODE
|
||||
- name: Retain complete package outside the checkout
|
||||
id: retained
|
||||
working-directory: ${{ steps.build_workspace.outputs.directory }}
|
||||
env:
|
||||
PACKAGE_SOURCE_SHA: ${{ steps.checkout.outputs.commit }}
|
||||
PACKAGE_VERSION: ${{ steps.settings.outputs.version }}
|
||||
@@ -219,7 +192,7 @@ jobs:
|
||||
with:
|
||||
name: windows-package-logs-${{ github.run_id }}-${{ github.run_attempt }}
|
||||
include-hidden-files: true
|
||||
path: ${{ steps.build_workspace.outputs.directory || github.workspace }}/apps/desktop/.desktop-build/packaging-runs/
|
||||
path: ${{ github.workspace }}/apps/desktop/.desktop-build/packaging-runs/
|
||||
if-no-files-found: warn
|
||||
retention-days: 14
|
||||
- name: Retain verified unsigned installer
|
||||
@@ -242,8 +215,3 @@ jobs:
|
||||
path: ${{ steps.retained.outputs.directory }}/*
|
||||
if-no-files-found: error
|
||||
retention-days: 14
|
||||
- name: Remove isolated packaging workspace
|
||||
if: success() && inputs.build_root != ''
|
||||
env:
|
||||
PACKAGE_SOURCE_SHA: ${{ steps.checkout.outputs.commit }}
|
||||
run: node "$env:PACKAGE_CI_HELPERS/windows-build-workspace.mjs" --remove
|
||||
@@ -24,11 +24,11 @@
|
||||
en: 5b4f0f80a117f202
|
||||
zh: ff05be196c181087
|
||||
/desktop-packaging/windows-actions-packaging:
|
||||
en: 9dd2227f2878519e
|
||||
zh: cd95dd6efd48298f
|
||||
en: 253e17998951931c
|
||||
zh: b582b377391d2ec2
|
||||
/desktop-packaging/macos-self-hosted-packaging:
|
||||
en: ee628e830d849ae9
|
||||
zh: 44313f5fb842f042
|
||||
en: f4cc5209bdaeefba
|
||||
zh: 1db959d1ed345fcc
|
||||
/desktop-packaging/unsigned-windows-test-installer:
|
||||
en: f429bc0c280e2dfa
|
||||
zh: 4adbcc9e906bdf80
|
||||
|
||||
@@ -115,11 +115,9 @@ Select the workflow in Actions, choose the source branch, preset, signing mode a
|
||||
|
||||
Open the completed run in Actions and download its Artifacts. `windows-x64-signed-<version>-<run_id>-<run_attempt>` and `windows-x64-unsigned-<version>-<run_id>-<run_attempt>` contain the corresponding EXE; `windows-package-logs-<run_id>-<run_attempt>` contains packaging diagnostics. The upload steps are `Retain verified signed installer`, `Retain verified unsigned installer`, and `Retain packaging diagnostics`; their step durations and timestamped logs show upload time. These artifacts are not a Release or download-site publication.
|
||||
|
||||
For path-sensitive Windows build measurements, `build_root` optionally selects an absolute directory outside existing Git checkouts. Each run clones the validated source commit into a new `windows-package-<run-id>-<attempt>/source` directory; ignored files and previous build outputs are not copied. Only the packaging process uses a sibling run-owned `temp` directory through `TEMP` and `TMP`; Actions steps and post-job hooks retain their original temporary directories. Dependency and signing caches retain their existing locations. Successful runs remove only their owned checkout after artifact uploads, retrying transient filesystem failures up to three times with 100 ms increasing delays; persistent cleanup errors fail the Job and may leave a partially removed directory. Failed builds retain their checkout for inspection. Leave the input empty to build in the original Actions checkout. Include checkout creation and cleanup in the complete Job timing.
|
||||
|
||||
For cache measurements, `cache_namespace` selects a retained subdirectory for both dependency stores and upstream downloads; leave it empty for normal shared caches. Use a new name for a cold sample and repeat that name for warm samples. Names contain 1–64 lowercase letters, digits or hyphens, start with a letter or digit, and cannot be Windows device names. This does not reset the separate signature cache or OS file cache; report those states and Job start-to-completion time alongside phase timings and artifact size. Before dependency installation, the workflow records the Node version, available CPU parallelism, logical CPU count, and total/free memory.
|
||||
|
||||
The dependency-install and packaging steps normalize their own shell to normal CPU, I/O and memory priority before launching children. Priority and isolated-workspace helpers are copied from the exact workflow commit into a run-specific temporary directory, independently of the selected product source. Missing helpers stop CI setup; unavailable priority adjustment emits a warning and marks scheduling unsuitable for performance comparison, but does not stop packaging. This does not modify the runner task or other processes. Version, preset and retained-artifact adapters remain tied to product source and its formats.
|
||||
The dependency-install and packaging steps normalize their own shell to normal CPU, I/O and memory priority before launching children. The priority helper is copied from the exact workflow commit into a run-specific temporary directory, independently of the selected product source. A missing helper stops CI setup; unavailable priority adjustment emits a warning and marks scheduling unsuitable for performance comparison, but does not stop packaging. This does not modify the runner task or other processes. Version, preset and retained-artifact adapters remain tied to product source and its formats.
|
||||
|
||||
Installer uploads store the already-compressed release files without ZIP recompression; this preserves installer bytes and signatures. Diagnostic uploads retain their ordinary compression.
|
||||
|
||||
@@ -129,13 +127,12 @@ Installer uploads store the already-compressed release files without ZIP recompr
|
||||
|
||||
The [Apple Silicon workflow](../../../.github/workflows/macos-package.yml) and [Intel workflow](../../../.github/workflows/macos-intel-package.yml) produce separate arm64 and x64 packages on the Apple Silicon runner labeled `dsh-mac-package-trial`. Both share one concurrency group. The Intel workflow checks Rosetta execution before dependency installation; its selected source must include the target-aware macOS CI adapter. Both select `test` or `production` and use the existing signing, notarization and packaged-runtime checks. Successful DMG/ZIP files and diagnostic logs are retained for 14 days without publishing a release. Installer uploads disable redundant ZIP compression. The operator must verify a complete Actions run and installation on the target architecture before release qualification. The `compression_level` dropdown defaults to `3` and also offers `7`; it overrides the machine preset for this run and affects only ZIP and automatic-update downloads, not DMG.
|
||||
|
||||
All three platform forms put source, environment, update channel, version mode, manual version, test release ID and compression level first, with matching defaults. macOS notarization and Windows signing, cache measurement and isolated-workspace options follow these common fields.
|
||||
All three platform forms put source, environment, update channel, version mode, manual version, test release ID and compression level first, with matching defaults. macOS notarization and Windows signing and cache measurement options follow these common fields.
|
||||
|
||||
Run `node apps/desktop/scripts/setup-macos-packaging.mjs "$HOME/dsh-ci"` to prepare private `runner/`, `packaging/{presets,secrets,certificates}` and `cache/macos-signatures` directories without overwriting existing files; append `--check` to inspect them. Fill the [preset](../config/macos-packaging/test.env.example) and [signing](../config/macos-packaging/macos-signing.env.example) templates outside the checkout. Set secret and certificate files to mode `0600`. `DSH_PACKAGING_CONFIG_DIR` selects the absolute `packaging` directory and `DSH_PACKAGING_PRESET` selects its preset; missing files fail without falling back to `.env.macos`. Signed and preparation-only Mac builds read `secrets/macos-signing.env`; relative credential paths resolve beside that file. Public presets reject signing credentials, and signing files cannot override public settings. Local unsigned Mac builds retain their configuration-free behavior.
|
||||
|
||||
Run `bash apps/desktop/scripts/start-macos-packaging-runner.sh "$HOME/dsh-ci/runner" "$HOME/dsh-ci/packaging" <absolute-node-24-bin-directory> --check` to check the host tools and configuration files. The script selects the active Xcode and its macOS SDK together and compiles a small linker probe. After registration, omit `--check` to run in the foreground with a cleared inherited environment and prevent idle sleep while the runner is alive. Stop it with Ctrl-C before installing the service below. The runner owns its `_work` checkout, separate from daily development. The account can read its signing files, so run only trusted code. The existing notarization proxy restoration rules apply; after forced termination, inspect retained recovery records before another build. New setup templates set `DSH_DESKTOP_MACOS_SIGNATURE_CACHE_DIR` to the absolute `cache/macos-signatures` directory outside checkout. For existing installations, rerun setup and add that field to each preset; existing files are preserved. This retains signatures across clean checkouts; cache verification and limits are described under [macOS signing](#macos-release-signing).
|
||||
|
||||
|
||||
ZIP compression uses the same configured level with or without notarization; the App is assembled once, then DMG and ZIP are built separately so the ZIP setting does not change DMG compression. The `skip_notarization` workflow option defaults to `false`; the equivalent CLI flag is `--skip-notarization`. It retains Developer ID signing, DMG signature verification and packaged-runtime verification, but omits Apple notarization and stapling and does not require Apple notarization credentials. DMG/ZIP filenames carry `-unnotarized`, are stored under `.desktop-build/targets/<target>/unnotarized-artifacts/`, and are uploaded with an `unnotarized-debug` label. These artifacts are for internal debugging only: Gatekeeper may block downloaded copies, and they are not qualified for distribution or update publishing. No release completion record is written. The flag rejects unsigned, Windows and preparation-only builds.
|
||||
|
||||
Install the user service from the checkout as the same account that registered the runner, without `sudo`:
|
||||
|
||||
@@ -115,11 +115,9 @@ runner 的受监督启动和恢复见 [Windows runner 机器准备](../windows-s
|
||||
|
||||
在 Actions 打开完成的运行并下载 Artifacts。`windows-x64-signed-<version>-<run_id>-<run_attempt>` 与 `windows-x64-unsigned-<version>-<run_id>-<run_attempt>` 包含对应 EXE;`windows-package-logs-<run_id>-<run_attempt>` 包含打包诊断。上传步骤名为 `Retain verified signed installer`、`Retain verified unsigned installer` 和 `Retain packaging diagnostics`;步骤耗时与带时间戳的日志显示上传用时。这些产物不等于发布 Release 或下载站内容。
|
||||
|
||||
测量 Windows 构建路径对性能的影响时,可用 `build_root` 指定现有 Git checkout 之外的绝对目录。每轮任务将已验证的源码提交克隆到新的 `windows-package-<run-id>-<attempt>/source` 目录;不会复制忽略文件或此前的构建输出。仅打包进程通过 `TEMP` 和 `TMP` 使用同轮所属的同级 `temp` 目录;Actions 步骤及 Job 后置钩子保留原临时目录。依赖缓存和签名缓存沿用原有位置。成功任务在产物上传后仅删除本轮所属的 checkout,临时文件系统错误最多重试三次,等待时间按 100 ms 递增;持续清理失败会使 Job 失败,并可能留下部分删除的目录。构建失败时保留 checkout 供检查。输入留空时使用原 Actions checkout。完整 Job 耗时须包含 checkout 创建和清理。
|
||||
|
||||
测量缓存时,`cache_namespace` 为两个依赖 store 和上游下载选择保留的子目录;留空使用正常共享缓存。新名称用于冷缓存采样,再次使用同名用于热缓存采样。名称由 1–64 个小写字母、数字或连字符组成,以字母或数字开头,且不能为 Windows 设备名。这不会重置独立的签名缓存或操作系统文件缓存;应将其状态、Job 开始至完成的总耗时与阶段耗时和产物体积一并报告。workflow 在依赖安装前记录 Node 版本、可用 CPU 并行数、逻辑 CPU 数及总内存和空闲内存。
|
||||
|
||||
依赖安装和打包步骤在启动子进程前,将自身 shell 的 CPU、I/O 和内存优先级调整为普通值。优先级及独立构建目录辅助脚本从 workflow 的精确提交复制到本轮临时目录,与选中的产品源码分离。缺失辅助脚本会终止 CI 准备;无法调整优先级时明确告警并标记调度条件不适合性能对比,但继续打包。这不会修改 runner 任务或其他进程。版本、preset 和产物留存适配器仍跟随产品源码及其格式。
|
||||
依赖安装和打包步骤在启动子进程前,将自身 shell 的 CPU、I/O 和内存优先级调整为普通值。优先级辅助脚本从 workflow 的精确提交复制到本轮临时目录,与选中的产品源码分离。缺失辅助脚本会终止 CI 准备;无法调整优先级时明确告警并标记调度条件不适合性能对比,但继续打包。这不会修改 runner 任务或其他进程。版本、preset 和产物留存适配器仍跟随产品源码及其格式。
|
||||
|
||||
安装器上传直接存储已经压缩的发布文件,不再进行 ZIP 二次压缩;安装器字节和签名保持不变。诊断日志上传保留通常的压缩方式。
|
||||
|
||||
@@ -129,13 +127,12 @@ runner 的受监督启动和恢复见 [Windows runner 机器准备](../windows-s
|
||||
|
||||
[Apple Silicon 工作流](../../../.github/workflows/macos-package.yml)与 [Intel 工作流](../../../.github/workflows/macos-intel-package.yml)在带有 `dsh-mac-package-trial` 标签的 Apple Silicon runner 上分别生成 arm64 和 x64 安装包,两者共用一个并发组。Intel 工作流在安装依赖前检查 Rosetta 能否执行;所选源码必须包含按目标架构校验的 macOS CI 适配脚本。两者均选择 `test` 或 `production`,并复用现有签名、公证和打包运行时检查。成功的 DMG/ZIP 与诊断日志保留 14 天,不发布 release;安装包上传关闭重复 ZIP 压缩。操作人员须验收完整 Actions 运行及目标架构上的安装,才能确认可交付。`compression_level` 下拉选项默认为 `3`,也可选择 `7`;本次运行以该选项覆盖机器预设,只影响 ZIP 和自动升级下载,不影响 DMG。
|
||||
|
||||
三个平台的表单均依次展示源码、环境、升级通道、版本模式、手动版本号、测试 release ID 和压缩等级,默认值一致。macOS 公证选项和 Windows 签名、缓存测量、独立构建目录选项位于公共字段之后。
|
||||
三个平台的表单均依次展示源码、环境、升级通道、版本模式、手动版本号、测试 release ID 和压缩等级,默认值一致。macOS 公证选项和 Windows 签名、缓存测量选项位于公共字段之后。
|
||||
|
||||
运行 `node apps/desktop/scripts/setup-macos-packaging.mjs "$HOME/dsh-ci"` 创建私有 `runner/`、`packaging/{presets,secrets,certificates}` 和 `cache/macos-signatures` 目录,不覆盖已有文件;追加 `--check` 仅检查。在 checkout 外填写 [preset](../config/macos-packaging/test.env.example) 和[签名](../config/macos-packaging/macos-signing.env.example)模板,将秘密和证书文件权限设为 `0600`。`DSH_PACKAGING_CONFIG_DIR` 指定 `packaging` 的绝对目录,`DSH_PACKAGING_PRESET` 选择其中的 preset;缺少文件立即失败,不回退到 `.env.macos`。Mac 签名和仅准备构建读取 `secrets/macos-signing.env`,相对凭据路径以该文件所在目录为基准。公开 preset 拒绝签名凭据,签名文件不能覆盖公开配置。本地未签名 Mac 构建保留无需配置的行为。
|
||||
|
||||
运行 `bash apps/desktop/scripts/start-macos-packaging-runner.sh "$HOME/dsh-ci/runner" "$HOME/dsh-ci/packaging" <absolute-node-24-bin-directory> --check` 检查宿主工具和配置文件。脚本同时选择当前 Xcode 及其 macOS SDK,并编译小型链接探针。注册后省略 `--check`,清理继承环境并在前台启动 runner,存活期间阻止空闲睡眠。安装下方服务前,先用 Ctrl-C 停止。runner 拥有 `_work` 下的源码目录,与日常开发分开。该账户可读取签名文件,因此只执行可信代码。沿用现有公证代理恢复规则;强制终止后,先检查保留的恢复记录再构建。新建模板将 `DSH_DESKTOP_MACOS_SIGNATURE_CACHE_DIR` 设为 checkout 外 `cache/macos-signatures` 的绝对路径。已有部署重新运行 setup 后,在各 preset 中补上该字段;已有文件保持不变。这样可跨干净检出保留签名;缓存验证和容量限制见 [macOS 签名](#macos-release-signing)。
|
||||
|
||||
|
||||
无论是否公证,ZIP 都使用同一压缩配置;App 只组装一次,再分别生成 DMG 和 ZIP,确保 ZIP 设置不改变 DMG 压缩。工作流选项 `skip_notarization` 默认为 `false`;对应 CLI 参数是 `--skip-notarization`。该模式保留 Developer ID 签名、DMG 签名验证和打包运行时验证,跳过 Apple 公证和 stapling,不要求 Apple 公证凭据。DMG/ZIP 文件名带 `-unnotarized`,存放于 `.desktop-build/targets/<target>/unnotarized-artifacts/`,上传产物标为 `unnotarized-debug`。这些产物仅供内部调试:Gatekeeper 可能阻止下载副本运行,不能视为可分发包或用于更新发布。该模式不写入发布完成记录,不能与未签名、Windows 或仅准备构建组合。
|
||||
|
||||
在 checkout 中,以注册 runner 的同一账户安装用户服务,不使用 `sudo`:
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
/** Identity of a Windows packaging run and its independent build root. */
|
||||
export interface WindowsBuildWorkspaceOptions {
|
||||
sourceDirectory: string
|
||||
buildRoot: string
|
||||
runId: string
|
||||
runAttempt: string
|
||||
sourceSha: string
|
||||
}
|
||||
/**
|
||||
* Clone the clean selected commit into a new run-owned directory.
|
||||
* @param options - Original checkout and Actions run identity.
|
||||
* @returns Checkout and temporary directory owned by this run.
|
||||
*/
|
||||
export function prepareWindowsBuildWorkspace(options: WindowsBuildWorkspaceOptions): { directory: string; temporaryDirectory: string }
|
||||
/**
|
||||
* Remove the directory only when its ownership record matches the run.
|
||||
* @param options - Original checkout and Actions run identity.
|
||||
*/
|
||||
export function removeWindowsBuildWorkspace(options: WindowsBuildWorkspaceOptions): void
|
||||
@@ -1,96 +0,0 @@
|
||||
/** Create and remove a run-owned checkout for Windows packaging. */
|
||||
import { execFileSync } from 'node:child_process'
|
||||
import { appendFileSync, existsSync, lstatSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
||||
import { dirname, isAbsolute, join, parse, resolve } from 'node:path'
|
||||
import { pathToFileURL } from 'node:url'
|
||||
|
||||
function assertUnlinkedAncestors(directory) {
|
||||
for (let current = directory; ; current = dirname(current)) {
|
||||
if (existsSync(current) && lstatSync(current).isSymbolicLink()) {
|
||||
throw new Error('Packaging workspace ancestors must not be links')
|
||||
}
|
||||
if (dirname(current) === current) break
|
||||
}
|
||||
}
|
||||
|
||||
function locations(options) {
|
||||
const { buildRoot, runId, runAttempt, sourceSha } = options
|
||||
if (!buildRoot || !isAbsolute(buildRoot) || /[\r\n\0]/.test(buildRoot)) {
|
||||
throw new Error('Packaging build root must be a nonempty absolute directory')
|
||||
}
|
||||
const root = resolve(buildRoot)
|
||||
if (root === parse(root).root) throw new Error('Packaging build root must not be a volume root')
|
||||
if (!/^[1-9]\d*$/.test(runId) || !/^[1-9]\d*$/.test(runAttempt) || !/^[a-f0-9]{40}$/.test(sourceSha)) {
|
||||
throw new Error('Packaging workspace requires a run identity and exact commit')
|
||||
}
|
||||
assertUnlinkedAncestors(root)
|
||||
for (let current = root; ; current = dirname(current)) {
|
||||
if (existsSync(join(current, '.git'))) throw new Error('Packaging build root must be outside existing Git checkouts')
|
||||
if (dirname(current) === current) break
|
||||
}
|
||||
const owner = join(root, `windows-package-${runId}-${runAttempt}`)
|
||||
assertUnlinkedAncestors(owner)
|
||||
return { root, owner, directory: join(owner, 'source'), temporaryDirectory: join(owner, 'temp') }
|
||||
}
|
||||
|
||||
function git(directory, args) {
|
||||
return execFileSync('git', args, { cwd: directory, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }).trim()
|
||||
}
|
||||
|
||||
function ownership(options, paths) {
|
||||
return JSON.stringify({ version: 1, root: paths.root, source: resolve(options.sourceDirectory), runId: options.runId, runAttempt: options.runAttempt, sourceSha: options.sourceSha })
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone the validated commit into a new run-owned checkout; failures retain diagnostics.
|
||||
* @param {{sourceDirectory: string, buildRoot: string, runId: string, runAttempt: string, sourceSha: string}} options - Source and run identity.
|
||||
* @returns {{directory: string, temporaryDirectory: string}} Checkout and temporary directory owned by this run.
|
||||
*/
|
||||
export function prepareWindowsBuildWorkspace(options) {
|
||||
const paths = locations(options)
|
||||
if (git(options.sourceDirectory, ['rev-parse', 'HEAD']) !== options.sourceSha || git(options.sourceDirectory, ['status', '--porcelain'])) {
|
||||
throw new Error('Packaging source must be clean and match the selected commit')
|
||||
}
|
||||
mkdirSync(paths.root, { recursive: true })
|
||||
mkdirSync(paths.owner)
|
||||
writeFileSync(join(paths.owner, 'owner.json'), ownership(options, paths), { flag: 'wx' })
|
||||
mkdirSync(paths.temporaryDirectory)
|
||||
git(paths.owner, ['clone', '--no-hardlinks', '--no-checkout', resolve(options.sourceDirectory), paths.directory])
|
||||
git(paths.directory, ['checkout', '--detach', options.sourceSha])
|
||||
if (git(paths.directory, ['rev-parse', 'HEAD']) !== options.sourceSha || git(paths.directory, ['status', '--porcelain'])) {
|
||||
throw new Error('Isolated packaging checkout does not match the selected commit')
|
||||
}
|
||||
return { directory: paths.directory, temporaryDirectory: paths.temporaryDirectory }
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove only the matching run-owned directory after successful artifact upload.
|
||||
* Transient filesystem failures retry up to three times; persistent failures propagate.
|
||||
* @param {{sourceDirectory: string, buildRoot: string, runId: string, runAttempt: string, sourceSha: string}} options - Original source and run identity.
|
||||
* @returns {void}
|
||||
*/
|
||||
export function removeWindowsBuildWorkspace(options) {
|
||||
const paths = locations(options)
|
||||
const marker = join(paths.owner, 'owner.json')
|
||||
const stat = lstatSync(marker)
|
||||
if (!stat.isFile() || stat.isSymbolicLink() || stat.size > 8192 || readFileSync(marker, 'utf8') !== ownership(options, paths)) {
|
||||
throw new Error('Packaging workspace ownership does not match this run')
|
||||
}
|
||||
rmSync(paths.owner, { recursive: true, maxRetries: 3, retryDelay: 100 })
|
||||
}
|
||||
|
||||
if (process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {
|
||||
const options = {
|
||||
sourceDirectory: process.env.GITHUB_WORKSPACE ?? '',
|
||||
buildRoot: process.env.PACKAGE_BUILD_ROOT ?? '',
|
||||
runId: process.env.GITHUB_RUN_ID ?? '',
|
||||
runAttempt: process.env.GITHUB_RUN_ATTEMPT ?? '',
|
||||
sourceSha: process.env.PACKAGE_SOURCE_SHA ?? '',
|
||||
}
|
||||
if (process.argv[2] === '--remove') removeWindowsBuildWorkspace(options)
|
||||
else {
|
||||
if (process.argv.length !== 2 || !process.env.GITHUB_OUTPUT) throw new Error('Expected Actions output file and no arguments')
|
||||
const result = prepareWindowsBuildWorkspace(options)
|
||||
appendFileSync(process.env.GITHUB_OUTPUT, `directory=${result.directory}\ntemporaryDirectory=${result.temporaryDirectory}\n`)
|
||||
}
|
||||
}
|
||||
@@ -21,8 +21,9 @@ it('keeps settings and expanded plugin dialogs clear of the Windows caption acro
|
||||
document.documentElement.setAttribute('data-windows-titlebar', '')
|
||||
document.documentElement.style.setProperty('--dsh-windows-titlebar-height', '40px')
|
||||
})
|
||||
const reopenSidebar = page.getByRole('button', { name: '打开侧边栏', exact: true })
|
||||
if (await reopenSidebar.isVisible()) await reopenSidebar.click()
|
||||
await page.setViewportSize({ width: 521, height: 600 })
|
||||
await page.locator('[data-sidebar-drawer]').waitFor({ state: 'detached' })
|
||||
const reopenSidebar = page.locator('[data-shell-leading]').getByRole('button', { name: '打开侧边栏', exact: true })
|
||||
await openSettings(page, 'zh')
|
||||
const settings = page.getByRole('dialog', { name: '设置', exact: true })
|
||||
const settingsMask = settings.locator('..').locator(':scope > [aria-hidden="true"]')
|
||||
@@ -51,7 +52,7 @@ it('keeps settings and expanded plugin dialogs clear of the Windows caption acro
|
||||
await menu.waitFor({ state: 'hidden' })
|
||||
expect(await settings.isVisible()).toBe(true)
|
||||
await settings.getByRole('button', { name: '关闭', exact: true }).click()
|
||||
if (await reopenSidebar.isVisible()) await reopenSidebar.click()
|
||||
if (await page.locator('[data-sidebar-drawer][data-sidebar-collapsed]').count() > 0) await reopenSidebar.click()
|
||||
await page.getByRole('navigation', { name: '全局面板' }).getByRole('button', { name: '插件', exact: true }).click()
|
||||
await page.locator('[data-plugin-panel]').getByRole('button', { name: '添加插件', exact: true }).click()
|
||||
const plugin = page.getByRole('dialog', { name: '添加插件', exact: true })
|
||||
@@ -88,7 +89,9 @@ it('keeps settings and expanded plugin dialogs clear of the Windows caption acro
|
||||
if (value === 'darwin') document.documentElement.setAttribute('data-platform', value)
|
||||
else document.documentElement.removeAttribute('data-platform')
|
||||
}, platform)
|
||||
if (await reopenSidebar.isVisible()) await reopenSidebar.click()
|
||||
// Publish the synthetic platform change through the frame's size observer.
|
||||
await page.setViewportSize({ width: platform === 'darwin' ? 520 : 521, height: 600 })
|
||||
await page.locator('[data-sidebar-drawer]').waitFor()
|
||||
await openSettings(page, 'zh')
|
||||
await expect.poll(async () => (await settings.boundingBox())?.y).toBe(platform === 'darwin' ? 68 : 0)
|
||||
expect((await settingsMask.boundingBox())?.y).toBe(0)
|
||||
|
||||
@@ -309,6 +309,9 @@ async function loadedFlowRows(page: Page): Promise<number> {
|
||||
}
|
||||
|
||||
async function openSeed(page: Page, fixture: ChatScrollFixture, tailMarker?: string): Promise<void> {
|
||||
if (await page.locator('[data-sidebar-drawer][data-sidebar-collapsed]').count() > 0) {
|
||||
await page.locator('[data-shell-leading]').getByRole('button', { name: 'Open sidebar', exact: true }).click()
|
||||
}
|
||||
// Search collapsed into a header action; expand it before filling.
|
||||
const searchButton = page.getByRole('button', { name: 'Search sessions' })
|
||||
if (await searchButton.getAttribute('aria-expanded') !== 'true') await searchButton.click()
|
||||
@@ -1700,9 +1703,6 @@ describe('web e2e: long Chat scroll contract', () => {
|
||||
await world.page.getByRole('tab', { name: 'Trajectory', exact: true }).click()
|
||||
await world.page.getByLabel('Trajectory timeline').waitFor({ timeout: 30_000 })
|
||||
await world.page.setViewportSize({ width: 700, height: 900 })
|
||||
// The narrow breakpoint auto-collapses the sidebar. Re-open it because
|
||||
// this scenario switches sessions while pinning the narrow Chat scroll owner.
|
||||
await world.page.getByRole('button', { name: 'Open sidebar', exact: true }).click()
|
||||
await world.page.getByRole('tab', { name: 'Chat', exact: true }).click()
|
||||
await nextPaint(world.page)
|
||||
await expectSameFlowTop(world.page, sessionAnchor, RESPONSIVE_REFLOW_TOLERANCE)
|
||||
|
||||
@@ -113,7 +113,7 @@ it('places dynamic Session menu rows by order among the shipped ones and removes
|
||||
await page.mouse.move(0, 0)
|
||||
await observe('blur', true, false)
|
||||
await page.setViewportSize({ width: 390, height: 844 })
|
||||
await page.getByRole('button', { name: 'Open sidebar', exact: true }).first().click()
|
||||
await page.locator('[data-shell-leading]').getByRole('button', { name: 'Open sidebar', exact: true }).click()
|
||||
await page.mouse.move(0, 0)
|
||||
await observe('narrow', true, false)
|
||||
const bounds = await row.evaluate((element) => {
|
||||
@@ -133,7 +133,7 @@ it('places dynamic Session menu rows by order among the shipped ones and removes
|
||||
try {
|
||||
const touchConsole = watchConsole(touchPage)
|
||||
await touchPage.goto(scaffold.authenticatedUrl, { waitUntil: 'load' })
|
||||
await touchPage.getByRole('button', { name: 'Open sidebar', exact: true }).first().click()
|
||||
await touchPage.locator('[data-shell-leading]').getByRole('button', { name: 'Open sidebar', exact: true }).click()
|
||||
const touchRow = touchPage.getByRole('treeitem').filter({ has: touchPage.getByText(SESSION_TITLE, { exact: true }) })
|
||||
const touchTrigger = touchRow.getByRole('button', { name: `Session actions for ${SESSION_TITLE}` })
|
||||
await touchTrigger.waitFor()
|
||||
|
||||
@@ -188,7 +188,7 @@ describe.skipIf(MODE === 'record')('web e2e: details panel follows the current S
|
||||
await blankColumn.locator('[data-sidebar-right-toggle]').click()
|
||||
await blankColumn.locator('[data-dockkit-pane]').first().waitFor({ state: 'hidden' })
|
||||
await page.setViewportSize({ width: 767, height: blankViewport.height })
|
||||
await expect.poll(() => columns(page)).toEqual([56, 711, 0])
|
||||
await expect.poll(() => columns(page)).toEqual([0, 767, 0])
|
||||
await page.locator('[data-sidebar-right-expand]').click()
|
||||
// The fullscreen shell keeps its viewport box while its docked content closes.
|
||||
await expect.poll(() => blankColumn.locator('[data-sidebar-right-open]').count()).toBe(1)
|
||||
@@ -425,7 +425,7 @@ describe.skipIf(MODE === 'record')('web e2e: details panel follows the current S
|
||||
await expect.poll(() => columns(page)).toEqual([420, viewport.width - 420 - normalWidth, normalWidth])
|
||||
await page.setViewportSize({ width: 767, height: viewport.height })
|
||||
await expect.poll(() => panel.boundingBox()).toEqual({ x: 0, y: 0, width: 767, height: viewport.height })
|
||||
await expect.poll(() => columns(page)).toEqual([56, 711, 0])
|
||||
await expect.poll(() => columns(page)).toEqual([0, 767, 0])
|
||||
expect(await sidebarSnapshot(page)).toMatchObject({ mode: 'fullscreen', resizeHandleWidth: 0, coversViewport: true })
|
||||
await checkpoint('A automatic fullscreen at 767px')
|
||||
await column.locator('[data-sidebar-right-mode="push"]').click()
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
- 'tooltip "Current branch: feature/a-long-current-branch-name-for-mobile-review"'
|
||||
@@ -1,5 +1,6 @@
|
||||
- img "变更请求状态:需要处理"
|
||||
- text: "Add the pull request panel #7"
|
||||
- button "提交评审"
|
||||
- button "在浏览器中打开"
|
||||
- button "全部 2 个文件"
|
||||
- text: +4 −2
|
||||
@@ -7,16 +8,64 @@
|
||||
- button "全部折叠"
|
||||
- button "左右对比" [pressed]
|
||||
- button "自动换行" [pressed]
|
||||
- button "收起 panel.ts" [expanded]
|
||||
- 'button "复制路径: src/panel.ts"': src/panel.ts
|
||||
- text: +2 −2
|
||||
- button "panel.ts 的更多操作"
|
||||
- text: 1 export const n1 = 1 1 export const n1 = 1 2 export const n2 = 2 2 export const n2 = 'two' 3 export const n3 = 3 3 export const n3 = 3 4 export const n4 = 4 4 export const n4 = 4 5 export const n5 = 5 5 export const n5 = 5
|
||||
- button "6 行未变更"
|
||||
- text: 12 export const n12 = 12 12 export const n12 = 12 13 export const n13 = 13 13 export const n13 = 13 14 export const n14 = 14 14 export const n14 = 14 15 export const n15 = 15 15 export const n15 = 'fifteen' 16 export const n16 = 16 16 export const n16 = 16 17 export const n17 = 17 17 export const n17 = 17 18 export const n18 = 18 18 export const n18 = 18
|
||||
- button "其余未变更的行"
|
||||
- button "收起 panel.md" [expanded]
|
||||
- 'button "复制路径: docs/panel.md"': docs/panel.md
|
||||
- text: 新文件 +2 −0
|
||||
- button "panel.md 的更多操作"
|
||||
- text: "1 + # Panel 2 + Shows the change requests of a Session."
|
||||
- region "全部 2 个文件":
|
||||
- button "收起 panel.ts" [expanded]
|
||||
- text: src/panel.ts +2 −2
|
||||
- button "panel.ts 的更多操作"
|
||||
- button "选择第 L1 行": "1"
|
||||
- text: export const n1 = 1
|
||||
- button "选择第 R1 行": "1"
|
||||
- text: export const n1 = 1
|
||||
- button "选择第 L2 行": "2"
|
||||
- text: export const n2 = 2
|
||||
- button "选择第 R2 行": "2"
|
||||
- text: export const n2 = 'two'
|
||||
- button "选择第 L3 行": "3"
|
||||
- text: export const n3 = 3
|
||||
- button "选择第 R3 行": "3"
|
||||
- text: export const n3 = 3
|
||||
- button "选择第 L4 行": "4"
|
||||
- text: export const n4 = 4
|
||||
- button "选择第 R4 行": "4"
|
||||
- text: export const n4 = 4
|
||||
- button "选择第 L5 行": "5"
|
||||
- text: export const n5 = 5
|
||||
- button "选择第 R5 行": "5"
|
||||
- text: export const n5 = 5
|
||||
- button "6 行未变更"
|
||||
- button "选择第 L12 行": "12"
|
||||
- text: export const n12 = 12
|
||||
- button "选择第 R12 行": "12"
|
||||
- text: export const n12 = 12
|
||||
- button "选择第 L13 行": "13"
|
||||
- text: export const n13 = 13
|
||||
- button "选择第 R13 行": "13"
|
||||
- text: export const n13 = 13
|
||||
- button "选择第 L14 行": "14"
|
||||
- text: export const n14 = 14
|
||||
- button "选择第 R14 行": "14"
|
||||
- text: export const n14 = 14
|
||||
- button "选择第 L15 行": "15"
|
||||
- text: export const n15 = 15
|
||||
- button "选择第 R15 行": "15"
|
||||
- text: export const n15 = 'fifteen'
|
||||
- button "选择第 L16 行": "16"
|
||||
- text: export const n16 = 16
|
||||
- button "选择第 R16 行": "16"
|
||||
- text: export const n16 = 16
|
||||
- button "选择第 L17 行": "17"
|
||||
- text: export const n17 = 17
|
||||
- button "选择第 R17 行": "17"
|
||||
- text: export const n17 = 17
|
||||
- button "选择第 L18 行": "18"
|
||||
- text: export const n18 = 18
|
||||
- button "选择第 R18 行": "18"
|
||||
- text: export const n18 = 18
|
||||
- button "其余未变更的行"
|
||||
- button "收起 panel.md" [expanded]
|
||||
- text: docs/panel.md 新文件 +2 −0
|
||||
- button "panel.md 的更多操作"
|
||||
- button "选择第 R1 行": "1"
|
||||
- text: "+ # Panel"
|
||||
- button "选择第 R2 行": "2"
|
||||
- text: + Shows the change requests of a Session.
|
||||
@@ -0,0 +1,77 @@
|
||||
- img "变更请求状态:需要处理"
|
||||
- text: "Add the pull request panel #7"
|
||||
- button "提交评审"
|
||||
- button "在浏览器中打开"
|
||||
- button "全部 2 个文件"
|
||||
- text: +4 −2
|
||||
- button "刷新变更"
|
||||
- button "全部折叠"
|
||||
- button "左右对比" [pressed]
|
||||
- button "自动换行" [pressed]
|
||||
- button "文件树" [expanded] [pressed]
|
||||
- region "全部 2 个文件":
|
||||
- button "收起 panel.ts" [expanded]
|
||||
- text: src/panel.ts +2 −2
|
||||
- button "panel.ts 的更多操作"
|
||||
- button "选择第 L1 行": "1"
|
||||
- text: export const n1 = 1
|
||||
- button "选择第 R1 行": "1"
|
||||
- text: export const n1 = 1
|
||||
- button "选择第 L2 行": "2"
|
||||
- text: export const n2 = 2
|
||||
- button "选择第 R2 行": "2"
|
||||
- text: export const n2 = 'two'
|
||||
- button "选择第 L3 行": "3"
|
||||
- text: export const n3 = 3
|
||||
- button "选择第 R3 行": "3"
|
||||
- text: export const n3 = 3
|
||||
- button "选择第 L4 行": "4"
|
||||
- text: export const n4 = 4
|
||||
- button "选择第 R4 行": "4"
|
||||
- text: export const n4 = 4
|
||||
- button "选择第 L5 行": "5"
|
||||
- text: export const n5 = 5
|
||||
- button "选择第 R5 行": "5"
|
||||
- text: export const n5 = 5
|
||||
- button "6 行未变更"
|
||||
- button "选择第 L12 行": "12"
|
||||
- text: export const n12 = 12
|
||||
- button "选择第 R12 行": "12"
|
||||
- text: export const n12 = 12
|
||||
- button "选择第 L13 行": "13"
|
||||
- text: export const n13 = 13
|
||||
- button "选择第 R13 行": "13"
|
||||
- text: export const n13 = 13
|
||||
- button "选择第 L14 行": "14"
|
||||
- text: export const n14 = 14
|
||||
- button "选择第 R14 行": "14"
|
||||
- text: export const n14 = 14
|
||||
- button "选择第 L15 行": "15"
|
||||
- text: export const n15 = 15
|
||||
- button "选择第 R15 行": "15"
|
||||
- text: export const n15 = 'fifteen'
|
||||
- button "选择第 L16 行": "16"
|
||||
- text: export const n16 = 16
|
||||
- button "选择第 R16 行": "16"
|
||||
- text: export const n16 = 16
|
||||
- button "选择第 L17 行": "17"
|
||||
- text: export const n17 = 17
|
||||
- button "选择第 R17 行": "17"
|
||||
- text: export const n17 = 17
|
||||
- button "选择第 L18 行": "18"
|
||||
- text: export const n18 = 18
|
||||
- button "选择第 R18 行": "18"
|
||||
- text: export const n18 = 18
|
||||
- button "其余未变更的行"
|
||||
- button "收起 panel.md" [expanded]
|
||||
- text: docs/panel.md 新文件 +2 −0
|
||||
- button "panel.md 的更多操作"
|
||||
- button "选择第 R1 行": "1"
|
||||
- text: "+ # Panel"
|
||||
- button "选择第 R2 行": "2"
|
||||
- text: + Shows the change requests of a Session.
|
||||
- separator "调整文件树宽度"
|
||||
- navigation "全部 2 个文件":
|
||||
- textbox "筛选文件…": src
|
||||
- button "src" [expanded]
|
||||
- button "src/panel.ts": panel.ts +2 −2
|
||||
@@ -0,0 +1,4 @@
|
||||
- button "Local changes"
|
||||
- text: HEAD → origin/main
|
||||
- 'button "View the changes of this Session: 60 files, 60 lines added, 0 lines deleted"': +60 −0 60 files
|
||||
- button "Create change request"
|
||||
@@ -0,0 +1,7 @@
|
||||
- region "评论 R2–4":
|
||||
- text: 评论 R2–4
|
||||
- textbox "留下评论…": 请核对边界条件
|
||||
- button "取消"
|
||||
- button "添加到输入框"
|
||||
- button "开始评审"
|
||||
- button "GitHub 评论选项"
|
||||
@@ -0,0 +1,25 @@
|
||||
> ## User Comment 2
|
||||
> File: src/extra.ts
|
||||
> Side: R
|
||||
> Lines: 1
|
||||
> Source: Local (branch)
|
||||
> Diff hunk:
|
||||
> ```diff
|
||||
> @@ -0,0 +1,1 @@
|
||||
> +export const extra = 1
|
||||
> ```
|
||||
> Comment:
|
||||
> 请检查这项修改
|
||||
|
||||
> ## User Comment 1
|
||||
> File: src/app.ts
|
||||
> Side: R
|
||||
> Lines: 1
|
||||
> Source: Local (branch)
|
||||
> Diff hunk:
|
||||
> ```diff
|
||||
> @@ -0,0 +1,1 @@
|
||||
> +export const app = 1
|
||||
> ```
|
||||
> Comment:
|
||||
> 请解释这行代码
|
||||
@@ -0,0 +1,6 @@
|
||||
- textbox "发消息或创建任务, / 调用指令, @ 文件或对话":
|
||||
- paragraph:
|
||||
- button "移除引用"
|
||||
- text: "## User Comment 2 File: src/extra.ts Side: R Lines: 1 Source: Local (branch) Diff hunk: ```diff @@ -0,0 +1,1 @@ +export const extra = 1 ``` Comment: 请检查这项修改"
|
||||
- button "移除引用"
|
||||
- text: "## User Comment 1 File: src/app.ts Side: R Lines: 1 Source: Local (branch) Diff hunk: ```diff @@ -0,0 +1,1 @@ +export const app = 1 ``` Comment: 请解释这行代码"
|
||||
@@ -0,0 +1,4 @@
|
||||
- region "评论 R2–4":
|
||||
- text: 你的评论 R2–4 已发布到 GitHub 请核对边界条件
|
||||
- button "添加到输入框"
|
||||
- button "在 GitHub 查看"
|
||||
@@ -0,0 +1,13 @@
|
||||
- dialog "提交评审":
|
||||
- heading "提交评审" [level=2]
|
||||
- button "关闭"
|
||||
- text: 待提交评论(1)
|
||||
- textbox "评审总结…": 需要补充边界检查
|
||||
- radio "评论"
|
||||
- text: 评论
|
||||
- radio "批准"
|
||||
- text: 批准
|
||||
- radio "请求更改" [checked]
|
||||
- text: 请求更改
|
||||
- button "取消"
|
||||
- button "提交评审"
|
||||
@@ -0,0 +1,3 @@
|
||||
- button "当前分支:main": main
|
||||
- checkbox "新建工作树"
|
||||
- text: 新建工作树
|
||||
@@ -4,6 +4,6 @@ grown: {"bottom":{"top":440,"height":360,"bottom":800},"main":{"top":0,"height":
|
||||
darwin: {"bottom":{"top":440,"height":360,"bottom":800},"main":{"top":0,"height":440,"bottom":440},"sidebar":{"top":0,"height":440,"bottom":440},"rightbar":{"top":0,"height":440,"bottom":440},"overlay":{"top":0,"height":800,"bottom":800},"handles":[{"top":0,"height":440,"bottom":440}],"pageHeight":800}
|
||||
windows: {"bottom":{"top":440,"height":360,"bottom":800},"main":{"top":40,"height":400,"bottom":440},"sidebar":{"top":40,"height":400,"bottom":440},"rightbar":{"top":40,"height":400,"bottom":440},"overlay":{"top":0,"height":800,"bottom":800},"handles":[{"top":40,"height":400,"bottom":440}],"pageHeight":800}
|
||||
browser: {"bottom":{"top":440,"height":360,"bottom":800},"main":{"top":0,"height":440,"bottom":440},"sidebar":{"top":0,"height":440,"bottom":440},"rightbar":{"top":0,"height":440,"bottom":440},"overlay":{"top":0,"height":800,"bottom":800},"handles":[{"top":0,"height":440,"bottom":440}],"pageHeight":800}
|
||||
narrow: {"bottom":{"top":240,"height":360,"bottom":600},"main":{"top":0,"height":240,"bottom":240},"sidebar":{"top":0,"height":240,"bottom":240},"rightbar":{"top":0,"height":240,"bottom":240},"overlay":{"top":0,"height":600,"bottom":600},"handles":[],"pageHeight":600}
|
||||
narrow: {"bottom":{"top":240,"height":360,"bottom":600},"main":{"top":0,"height":240,"bottom":240},"sidebar":{"top":0,"height":600,"bottom":600},"rightbar":{"top":0,"height":240,"bottom":240},"overlay":{"top":0,"height":600,"bottom":600},"handles":[],"pageHeight":600}
|
||||
unregistered: {"bottom":{"top":600,"height":0,"bottom":600},"main":{"top":0,"height":600,"bottom":600},"sidebar":{"top":0,"height":600,"bottom":600},"rightbar":{"top":0,"height":600,"bottom":600},"overlay":{"top":0,"height":600,"bottom":600},"handles":[],"pageHeight":600}
|
||||
collapsed: {"bottom":{"top":600,"height":0,"bottom":600},"main":{"top":0,"height":600,"bottom":600},"sidebar":{"top":0,"height":600,"bottom":600},"rightbar":{"top":0,"height":600,"bottom":600},"overlay":{"top":0,"height":600,"bottom":600},"handles":[],"pageHeight":600}
|
||||
@@ -6,4 +6,5 @@
|
||||
- Tabs / 1280px: resting title 28, actions 28, tabs 96; pinned actions 17, tabs 16, bar 66; stable range, reversible coordinates, same controls.
|
||||
- Tabs / 600px: resting title 28, actions 97, tabs 96; pinned actions 17, tabs 16, bar 66; stable range, reversible coordinates, same controls.
|
||||
- Tabs / 470px: resting title 28, actions 97, tabs 96; pinned actions 17, tabs 16, bar 66; stable range, reversible coordinates, same controls.
|
||||
- Tabs / 390px: resting title 28, actions 146, tabs 96; pinned actions 66, tabs 16, bar 114; stable range, reversible coordinates, same controls.
|
||||
- Tabs / 390px: resting title 28, actions 97, tabs 96; pinned actions 17, tabs 16, bar 66; stable range, reversible coordinates, same controls.
|
||||
- Tabs / 334px: resting title 28, actions 146, tabs 96; pinned actions 66, tabs 16, bar 114; stable range, reversible coordinates, same controls.
|
||||
@@ -7,7 +7,7 @@ en 440px: title and New single-line, New beside the title; contained; New retain
|
||||
en 390px: title and New single-line, New beside the title; contained; New retains focus
|
||||
en 430px: title and New single-line, New beside the title; contained; New retains focus
|
||||
en 1024px: title and New single-line, New beside the title; contained; New retains focus
|
||||
en 509px with sidebar expanded: title single-line; New moves below the title
|
||||
en 220px page column: title single-line; New moves below the title
|
||||
zh 1680px: title and New single-line, New beside the title; contained; New retains focus
|
||||
zh 800px: title and New single-line, New beside the title; contained; New retains focus
|
||||
zh 520px: title and New single-line, New beside the title; contained; New retains focus
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
390px: closed sidebar has no rail; main width 390px
|
||||
open: main geometry retained; background inert; no resize handle
|
||||
close: Session navigation, Plugins navigation, mask and Escape
|
||||
retained: sidebar DOM and opener focus
|
||||
768px: 56px rail; main width 712px; drawer focus transfers to the rail toggle
|
||||
breakpoint motion: collapsed rail hides immediately and returns compact without crossfades; expanded sidebar and explicit toggles retain their slides
|
||||
767px: hidden drawer; main width 767px; no page overflow
|
||||
global panels: browser top inset 48px; macOS keeps its existing clearance
|
||||
tooltips: sidebar and workspace controls escape the drawer and fit the viewport
|
||||
search input: 16px on touch; 13px with a fine pointer
|
||||
simulated keyboard: homepage and drawer retain 844px layout height without following the 360px visual viewport; Settings stays within the viewport
|
||||
keyboard close: layout height stays 844px; sidebar search retained; Settings close remains reachable
|
||||
shell coverage: drawer backing and mask cover 844px without synthetic safe-area insets
|
||||
rotation: 844x390 then 390x844 restores shell height and sidebar breakpoint
|
||||
folded landscape: 951px frame splits at 475.5px without a resize handle; unfolding restores 280px and search focus; portrait retains the drawer
|
||||
fold transitions: sidebar controls follow the divider in both directions; reduced motion changes width without animation
|
||||
drawer mask: opacity transitions from 0 to 1 on open and 1 to 0 on close
|
||||
reduced motion: drawer and mask settle without transitions
|
||||
touch selected Session: More remains visible; archive and pin stay in its menu; pin marker retained
|
||||
touch Workspace: actions appear only while expanded, including after folding the focused row
|
||||
fine pointer: folded Workspace actions remain available on hover
|
||||
fine pointer: selected Session actions stay hidden until hover, including at 390px
|
||||
@@ -0,0 +1,2 @@
|
||||
View options and Session menus close when the sidebar becomes an inert drawer.
|
||||
Focus returns to the visible sidebar opener; retained Session rows keep their DOM identity.
|
||||
@@ -77,13 +77,23 @@ if (args[0] === 'api' && args[5] === 'repos/octo/demo/pulls/9/merge') {
|
||||
process.stdout.write(JSON.stringify({ sha: 'c'.repeat(40), merged: true, message: 'Pull Request successfully merged' }))
|
||||
process.exit(0)
|
||||
}
|
||||
if (args[0] === 'api' && args[3] === 'repos/octo/demo/pulls/7') {
|
||||
process.stdout.write(JSON.stringify({ head: { sha: 'a'.repeat(40) }, state: 'open' }))
|
||||
process.exit(0)
|
||||
}
|
||||
if (args[0] === 'api' && args[4] === 'POST' && ['repos/octo/demo/pulls/7/comments', 'repos/octo/demo/pulls/7/reviews'].includes(args[5])) {
|
||||
const body = JSON.parse(readFileSync(0, 'utf8'))
|
||||
appendFileSync(join(here, 'reviews.jsonl'), JSON.stringify({ endpoint: args[5], body }) + '\\n')
|
||||
process.stdout.write(JSON.stringify({ html_url: 'https://github.com/octo/demo/pull/7#pullrequestreview-1' }))
|
||||
process.exit(0)
|
||||
}
|
||||
if (args[0] === 'pr' && args[1] === 'diff') {
|
||||
const refused = join(here, 'pr-' + args[2] + '.refused')
|
||||
if (existsSync(refused)) {
|
||||
process.stderr.write(readFileSync(refused, 'utf8'))
|
||||
process.exit(1)
|
||||
}
|
||||
process.stdout.write(readFileSync(join(here, 'pr-' + args[2] + '.diff'), 'utf8'))
|
||||
await new Promise(resolve => process.stdout.write(readFileSync(join(here, 'pr-' + args[2] + '.diff'), 'utf8'), resolve))
|
||||
process.exit(0)
|
||||
}
|
||||
if (args[0] === 'api' && args[3] === '-H' && args[4] === 'Accept: application/vnd.github.raw+json') {
|
||||
@@ -207,9 +217,12 @@ interface PanelLaunch {
|
||||
* Launch the bundle against a GitHub checkout of `main` and `release` and open the New Session screen of that workspace.
|
||||
* @param failureShot - name of the screenshot saved when the test fails.
|
||||
* @param scenario - normal conversation, a restoration follow-up, or a numbered PR lookup.
|
||||
* @param options - desktop transport, initial checkout branch, and touch input for the browser.
|
||||
* @returns the scaffold, page, and checkout.
|
||||
*/
|
||||
async function launchPanel(failureShot: string, scenario: 'normal' | 'follow-up' | 'reference' = 'normal', desktop?: 'darwin' | 'win32'): Promise<PanelLaunch> {
|
||||
async function launchPanel(failureShot: string, scenario: 'normal' | 'follow-up' | 'reference' = 'normal',
|
||||
options: { desktop?: 'darwin' | 'win32'; branch?: string; hasTouch?: boolean } = {}): Promise<PanelLaunch> {
|
||||
const { desktop } = options
|
||||
const resources: { scaffold?: WebScaffold; browser?: Browser } = {}
|
||||
const root = await mkdtemp(join(tmpdir(), 'dsh-forge-panel-'))
|
||||
onTestFinished(async () => {
|
||||
@@ -265,6 +278,7 @@ async function launchPanel(failureShot: string, scenario: 'normal' | 'follow-up'
|
||||
await git(project, 'remote', 'add', 'origin', 'https://github.com/octo/demo.git')
|
||||
await git(project, 'branch', 'release')
|
||||
await git(project, 'commit', '--quiet', '--allow-empty', '-m', 'main only')
|
||||
if (options.branch !== undefined) await git(project, 'checkout', '--quiet', '-b', options.branch)
|
||||
if (scenario === 'reference') {
|
||||
// The model's confined command must own the CLI double's writable call log.
|
||||
const modelBin = join(project, '.fixture-bin')
|
||||
@@ -275,7 +289,8 @@ async function launchPanel(failureShot: string, scenario: 'normal' | 'follow-up'
|
||||
|
||||
const browser = await chromium.launch()
|
||||
resources.browser = browser
|
||||
const page = await browser.newPage({ viewport: { width: 1680, height: 1000 }, locale: ZH_BROWSER_LOCALE, timezoneId: 'Asia/Shanghai' })
|
||||
const page = await browser.newPage({ viewport: { width: 1680, height: 1000 }, locale: ZH_BROWSER_LOCALE, timezoneId: 'Asia/Shanghai',
|
||||
hasTouch: options.hasTouch ?? false })
|
||||
if (desktop !== undefined) {
|
||||
// Only Electron's keyboard transport is substituted; the product registry and menus remain real.
|
||||
await page.addInitScript(({ device, config }) => {
|
||||
@@ -328,7 +343,7 @@ async function requestReleaseWorktree(failureShot: string, followUp = false): Pr
|
||||
const { page } = launched
|
||||
const option = page.locator('[data-forge-worktree]')
|
||||
await option.waitFor({ timeout: 20_000 })
|
||||
await option.getByRole('checkbox', { name: '工作树', exact: true }).check()
|
||||
await option.getByRole('checkbox', { name: '新建工作树', exact: true }).check()
|
||||
await option.getByRole('button', { name: '基于 main', exact: true }).click()
|
||||
await page.getByRole('menuitem', { name: 'release', exact: true }).click()
|
||||
await option.getByRole('button', { name: '基于 release', exact: true }).waitFor()
|
||||
@@ -427,6 +442,11 @@ it.skipIf(MODE === 'record')('starts a Session in a worktree before its first me
|
||||
const row = page.locator(`[data-row-key="session:${sessionId}"]`)
|
||||
await row.getByRole('img', { name: '在自己的工作树中', exact: true }).waitFor({ timeout: 20_000 })
|
||||
await row.getByRole('img', { name: '变更请求状态:需要处理 · 检查失败', exact: true }).waitFor({ timeout: 20_000 })
|
||||
// A fresh page cannot retain the previous browser source's status values.
|
||||
await page.goto('about:blank')
|
||||
await expect.poll(() => scaffold.ctx.storageDomain.get('forge_panel_change_requests')).toBeUndefined()
|
||||
await page.goto(scaffold.authenticatedUrl, { waitUntil: 'load' })
|
||||
await row.getByRole('img', { name: '变更请求状态:需要处理 · 检查失败', exact: true }).waitFor({ timeout: 20_000 })
|
||||
await row.hover()
|
||||
const rowHover = page.locator('[data-forge-session-hover]')
|
||||
await rowHover.getByText('#7 Add the pull request panel', { exact: true }).waitFor({ timeout: 20_000 })
|
||||
@@ -590,7 +610,7 @@ it.skipIf(MODE === 'record')('marks a draft change request ready for review and
|
||||
})
|
||||
|
||||
it.skipIf(MODE === 'record')('shows the local changes of the Session by scope and the changes of its change requests, expanding unchanged lines', async () => {
|
||||
const { scaffold, page, root, project, tripwire } = await launchPanel('web-e2e-forge-panel-changes')
|
||||
const { scaffold, page, root, project, tripwire } = await launchPanel('web-e2e-forge-panel-changes', 'follow-up')
|
||||
// origin/main stops at the twelve-line README; the branch adds a commit, a staged file, an edit, and an untracked file.
|
||||
await writeFile(join(project, 'README.md'), Array.from({ length: 12 }, (_, index) => `line ${index + 1}\n`).join(''))
|
||||
await git(project, 'commit', '--quiet', '-am', 'readme')
|
||||
@@ -626,13 +646,46 @@ it.skipIf(MODE === 'record')('shows the local changes of the Session by scope an
|
||||
await local.locator('[data-forge-diff-file="notes.md"]').getByText('新文件 · 未提交', { exact: true }).waitFor()
|
||||
const readme = local.locator('[data-forge-diff-file="README.md"]')
|
||||
await page.context().grantPermissions(['clipboard-read', 'clipboard-write'])
|
||||
await readme.getByRole('button', { name: '复制路径: README.md', exact: true }).click()
|
||||
await expect.poll(() => page.evaluate(() => navigator.clipboard.readText())).toBe('README.md')
|
||||
await page.evaluate(() => navigator.clipboard.writeText('unchanged'))
|
||||
await readme.locator('[data-forge-file-label]').click()
|
||||
await expect.poll(() => page.evaluate(() => navigator.clipboard.readText())).toBe('unchanged')
|
||||
await readme.locator('[data-forge-path-spacer]').click()
|
||||
await expect.poll(() => page.evaluate(() => navigator.clipboard.readText())).toBe('unchanged')
|
||||
await readme.getByRole('button', { name: '6 行未变更', exact: true }).click()
|
||||
await readme.getByText('line 1', { exact: true }).first().waitFor({ timeout: 20_000 })
|
||||
await local.getByRole('button', { name: '全部 4 个文件', exact: true }).click()
|
||||
const tree = page.getByRole('menu')
|
||||
await tree.getByRole('textbox', { name: '筛选文件…' }).fill('extra')
|
||||
await tree.getByRole('menuitem', { name: 'src/extra.ts', exact: true }).click()
|
||||
for (const [path, comment] of [['src/app.ts', '请解释这行代码'], ['src/extra.ts', '请检查这项修改']] as const) {
|
||||
const section = local.locator(`[data-forge-diff-file="${path}"]`)
|
||||
const lineNumber = section.getByRole('button', { name: '选择第 R1 行', exact: true })
|
||||
await lineNumber.hover()
|
||||
expect(await lineNumber.evaluate(element => getComputedStyle(element).backgroundColor)).toBe('rgba(0, 0, 0, 0)')
|
||||
const content = await section.locator('[data-review-code]').first().boundingBox()
|
||||
const fileBox = await section.boundingBox()
|
||||
if (content === null || fileBox === null) throw new Error('Added file must be visible')
|
||||
expect(content.x - fileBox.x).toBeLessThan(70)
|
||||
await lineNumber.click()
|
||||
expect(await section.getByRole('textbox', { name: '留下评论…' }).count()).toBe(0)
|
||||
await section.getByRole('button', { name: '添加评论', exact: true }).click()
|
||||
await section.getByRole('textbox', { name: '留下评论…' }).fill(comment)
|
||||
await section.locator('[data-forge-comment]').getByRole('button', { name: '添加到输入框', exact: true }).click()
|
||||
await section.locator('[data-forge-review-thread="agent"]').getByText(comment, { exact: true }).waitFor()
|
||||
}
|
||||
await compareOrRefreshGolden(join(EXPECTED, 'review-quotes.expected.md'),
|
||||
await captureStableAria(page, '[data-composer-input]', scaffold.workspaceCwd), MODE)
|
||||
expect((await readPersistedEvents(scaffold, sessionId)).some(event => event.type === 'user/message'
|
||||
&& event.data.content.some(block => block.type === 'text' && block.text.includes('## User Comment')))).toBe(false)
|
||||
const reviewed = scaffold.whenTurnSettled()
|
||||
await page.locator('[data-composer-input]').first().press('Enter')
|
||||
await reviewed
|
||||
await page.getByText(FOLLOW_UP_REPLY, { exact: true }).waitFor()
|
||||
const comments = (await readPersistedEvents(scaffold, sessionId)).flatMap(event => event.type === 'user/message'
|
||||
? event.data.content.flatMap(block => block.type === 'text' && block.text.includes('## User Comment') ? [block.text] : []) : [])
|
||||
expect(comments).toHaveLength(1)
|
||||
await compareOrRefreshGolden(join(EXPECTED, 'review-message.expected.md'), comments.join('').trimEnd(), MODE)
|
||||
|
||||
await local.getByRole('button', { name: '分支', exact: true }).click()
|
||||
await page.getByRole('menuitem', { name: '已暂存', exact: true }).click()
|
||||
await local.getByText('暂存区与 HEAD 比较', { exact: true }).waitFor()
|
||||
@@ -648,20 +701,139 @@ it.skipIf(MODE === 'record')('shows the local changes of the Session by scope an
|
||||
await change.getByRole('button', { name: '查看 #7 的变更:新增 128 行,删除 14 行', exact: true }).click()
|
||||
const view = page.locator('[data-forge-changes="change"]')
|
||||
const panelFile = view.locator('[data-forge-diff-file="src/panel.ts"]')
|
||||
const title = await view.getByText('Add the pull request panel', { exact: true }).boundingBox()
|
||||
const submit = await view.getByRole('button', { name: '提交评审', exact: true }).boundingBox()
|
||||
if (title === null || submit === null) throw new Error('PR title and submit action must be visible')
|
||||
expect(Math.abs(title.y + title.height / 2 - submit.y - submit.height / 2)).toBeLessThan(1)
|
||||
|
||||
await panelFile.getByRole('button', { name: '6 行未变更', exact: true }).waitFor({ timeout: 20_000 })
|
||||
await compareOrRefreshGolden(join(EXPECTED, 'changes-view.expected.md'),
|
||||
await captureStableAria(page, '[data-forge-changes="change"]', scaffold.workspaceCwd), MODE)
|
||||
await page.getByRole('button', { name: '全屏', exact: true }).click()
|
||||
await view.getByRole('navigation').getByRole('button', { name: 'src/panel.ts', exact: true }).waitFor()
|
||||
const fileTree = view.getByRole('navigation')
|
||||
const directoryName = await fileTree.getByText('src', { exact: true }).boundingBox()
|
||||
const fileName = await fileTree.getByText('panel.ts', { exact: true }).boundingBox()
|
||||
if (directoryName === null || fileName === null) throw new Error('Tree entries must be visible')
|
||||
expect(fileName.x).toBeGreaterThan(directoryName.x)
|
||||
await fileTree.getByRole('textbox', { name: '筛选文件…' }).fill('src')
|
||||
await fileTree.getByRole('textbox', { name: '筛选文件…' }).fill('')
|
||||
await fileTree.getByRole('button', { name: 'src', exact: true }).click()
|
||||
await view.getByRole('button', { name: '文件树', exact: true }).click()
|
||||
expect(await fileTree.isVisible()).toBe(false)
|
||||
await view.getByRole('button', { name: '文件树', exact: true }).click()
|
||||
expect(await fileTree.getByRole('button', { name: 'src', exact: true }).getAttribute('aria-expanded')).toBe('false')
|
||||
await fileTree.getByRole('textbox', { name: '筛选文件…' }).fill('src')
|
||||
await view.getByRole('button', { name: '文件树', exact: true }).click()
|
||||
await view.getByRole('button', { name: '文件树', exact: true }).click()
|
||||
expect(await fileTree.getByRole('textbox', { name: '筛选文件…' }).inputValue()).toBe('src')
|
||||
await compareOrRefreshGolden(join(EXPECTED, 'file-tree-toggle.expected.md'),
|
||||
await captureStableAria(page, '[data-forge-changes="change"]', scaffold.workspaceCwd), MODE)
|
||||
await fileTree.getByRole('textbox', { name: '筛选文件…' }).fill('')
|
||||
await fileTree.getByRole('button', { name: 'src', exact: true }).click()
|
||||
const resizeTree = view.getByRole('separator', { name: '调整文件树宽度', exact: true })
|
||||
const originalWidth = Number(await resizeTree.getAttribute('aria-valuenow'))
|
||||
const handle = await resizeTree.boundingBox()
|
||||
if (handle === null) throw new Error('Tree resize handle must be visible')
|
||||
await page.mouse.move(handle.x + handle.width / 2, handle.y + 100)
|
||||
await page.mouse.down()
|
||||
await page.mouse.move(handle.x - 80, handle.y + 100, { steps: 5 })
|
||||
await page.mouse.up()
|
||||
expect(Number(await resizeTree.getAttribute('aria-valuenow'))).toBeGreaterThan(originalWidth)
|
||||
await resizeTree.press('Home')
|
||||
expect(await fileTree.evaluate(element => element.scrollWidth <= element.clientWidth)).toBe(true)
|
||||
const searchBounds = await fileTree.getByRole('textbox').boundingBox()
|
||||
const treeBounds = await fileTree.boundingBox()
|
||||
if (searchBounds === null || treeBounds === null) throw new Error('Tree search must be visible')
|
||||
expect(searchBounds.x + searchBounds.width).toBeLessThanOrEqual(treeBounds.x + treeBounds.width)
|
||||
await resizeTree.press('ArrowLeft')
|
||||
const resizedWidth = await resizeTree.getAttribute('aria-valuenow')
|
||||
await view.getByRole('button', { name: '文件树', exact: true }).click()
|
||||
await view.getByRole('button', { name: '文件树', exact: true }).click()
|
||||
expect(await resizeTree.getAttribute('aria-valuenow')).toBe(resizedWidth)
|
||||
for (const side of ['old', 'new'] as const) {
|
||||
const firstLine = await panelFile.locator(`[data-review-code][data-${side}-line="2"]`).boundingBox()
|
||||
const lastLine = await panelFile.locator(`[data-review-code][data-${side}-line="4"]`).boundingBox()
|
||||
if (firstLine === null || lastLine === null) throw new Error('Review text must be visible')
|
||||
await page.mouse.move(firstLine.x + 7, firstLine.y + firstLine.height / 2)
|
||||
await page.mouse.down()
|
||||
await page.mouse.move(lastLine.x + 120, lastLine.y + lastLine.height / 2, { steps: 5 })
|
||||
await page.mouse.up()
|
||||
await panelFile.getByRole('button', { name: '添加评论', exact: true }).waitFor()
|
||||
expect(await panelFile.getByRole('textbox', { name: '留下评论…' }).count()).toBe(0)
|
||||
const opposite = panelFile.locator(`[data-diff-side="${side === 'old' ? 'R' : 'L'}"]`).first()
|
||||
expect(await opposite.evaluate(element => getComputedStyle(element).userSelect)).toBe('none')
|
||||
await page.keyboard.press('ControlOrMeta+c')
|
||||
const copied = await page.evaluate(() => navigator.clipboard.readText())
|
||||
expect(copied).toContain(side === 'old' ? 'n2 = 2' : "n2 = 'two'")
|
||||
expect(copied).not.toContain(side === 'old' ? "n2 = 'two'" : 'n2 = 2')
|
||||
expect(copied.match(/n3 = 3/g)).toHaveLength(1)
|
||||
}
|
||||
await panelFile.getByRole('button', { name: '添加评论', exact: true }).click()
|
||||
await panelFile.getByRole('region', { name: '评论 R2–4', exact: true }).waitFor()
|
||||
await panelFile.getByRole('textbox', { name: '留下评论…' }).fill('请核对边界条件')
|
||||
await panelFile.getByRole('button', { name: 'GitHub 评论选项', exact: true }).click()
|
||||
await page.getByRole('menuitem', { name: '发布单条评论', exact: true }).waitFor()
|
||||
await page.keyboard.press('Escape')
|
||||
await compareOrRefreshGolden(join(EXPECTED, 'review-composer.expected.md'),
|
||||
await captureStableAria(page, '[data-forge-comment]', scaffold.workspaceCwd), MODE)
|
||||
await page.getByRole('button', { name: '退出全屏', exact: true }).click()
|
||||
const commentForm = panelFile.locator('[data-forge-comment]')
|
||||
expect(await commentForm.evaluate(element => element.scrollWidth <= element.clientWidth)).toBe(true)
|
||||
await page.getByRole('button', { name: '全屏', exact: true }).click()
|
||||
await page.setViewportSize({ width: 390, height: 780 })
|
||||
await commentForm.getByRole('textbox').focus()
|
||||
expect(await commentForm.evaluate(element => element.scrollWidth <= element.clientWidth)).toBe(true)
|
||||
const narrowComment = await commentForm.boundingBox()
|
||||
if (narrowComment === null) throw new Error('Comment form must remain visible')
|
||||
expect(narrowComment.x + narrowComment.width).toBeLessThanOrEqual(390)
|
||||
await page.setViewportSize({ width: 1680, height: 1000 })
|
||||
await panelFile.getByRole('button', { name: '开始评审', exact: true }).click()
|
||||
await panelFile.locator('[data-forge-review-thread="pending"]').getByText('请核对边界条件', { exact: true }).waitFor()
|
||||
await page.setViewportSize({ width: 1680, height: 500 })
|
||||
const changesScroll = view.locator('[data-forge-changes-scroll]')
|
||||
await changesScroll.evaluate((element) => { element.scrollTop = element.scrollHeight })
|
||||
const reviewScroll = await changesScroll.evaluate(element => element.scrollTop)
|
||||
expect(reviewScroll).toBeGreaterThan(0)
|
||||
await view.getByRole('button', { name: '提交评审 (1)', exact: true }).click()
|
||||
const reviewDialog = page.getByRole('dialog', { name: '提交评审', exact: true })
|
||||
await reviewDialog.waitFor()
|
||||
expect(await reviewDialog.getByRole('textbox').count()).toBe(1)
|
||||
expect(await reviewDialog.getByText('请核对边界条件', { exact: true }).count()).toBe(0)
|
||||
expect(await changesScroll.evaluate(element => element.scrollTop)).toBe(reviewScroll)
|
||||
await page.setViewportSize({ width: 390, height: 780 })
|
||||
expect(await reviewDialog.evaluate(element => element.scrollWidth <= element.clientWidth)).toBe(true)
|
||||
const narrowDialog = await reviewDialog.boundingBox()
|
||||
if (narrowDialog === null) throw new Error('Review dialog must remain visible')
|
||||
expect(narrowDialog.x + narrowDialog.width).toBeLessThanOrEqual(390)
|
||||
await page.setViewportSize({ width: 1680, height: 500 })
|
||||
await page.keyboard.press('Escape')
|
||||
expect(await reviewDialog.count()).toBe(0)
|
||||
await view.getByRole('button', { name: '提交评审 (1)', exact: true }).click()
|
||||
await reviewDialog.getByRole('textbox', { name: '评审总结…', exact: true }).fill('需要补充边界检查')
|
||||
await reviewDialog.getByRole('radio', { name: '请求更改', exact: true }).check()
|
||||
await compareOrRefreshGolden(join(EXPECTED, 'submit-review.expected.md'),
|
||||
await captureStableAria(page, '[role="dialog"][aria-label="提交评审"]', scaffold.workspaceCwd), MODE)
|
||||
await reviewDialog.getByRole('button', { name: '提交评审', exact: true }).click()
|
||||
await page.getByRole('alert').filter({ hasText: '已提交评审' }).waitFor()
|
||||
await panelFile.locator('[data-forge-review-thread="published"]').getByText('请核对边界条件', { exact: true }).waitFor()
|
||||
await compareOrRefreshGolden(join(EXPECTED, 'review-record.expected.md'), await captureStableAria(page, '[data-forge-review-thread="published"]', scaffold.workspaceCwd), MODE)
|
||||
const published: unknown = JSON.parse((await readFile(join(root, 'reviews.jsonl'), 'utf8')).trim())
|
||||
expect(published).toEqual({ endpoint: 'repos/octo/demo/pulls/7/reviews', body: { commit_id: HEAD7, event: 'REQUEST_CHANGES', body: '需要补充边界检查',
|
||||
comments: [{ path: 'src/panel.ts', side: 'RIGHT', line: 4, start_line: 2, start_side: 'RIGHT', body: '请核对边界条件' }] } })
|
||||
await page.getByRole('button', { name: '退出全屏', exact: true }).click()
|
||||
await panelFile.getByRole('button', { name: '6 行未变更', exact: true }).click()
|
||||
await panelFile.getByText('export const n6 = 6', { exact: true }).first().waitFor({ timeout: 20_000 })
|
||||
await panelFile.getByRole('button', { name: '2 行未变更', exact: true }).waitFor()
|
||||
await panelFile.getByRole('button', { name: '复制路径: src/panel.ts', exact: true }).click()
|
||||
await panelFile.getByRole('button', { name: 'panel.ts 的更多操作', exact: true }).click()
|
||||
await page.getByRole('menuitem', { name: '复制路径', exact: true }).click()
|
||||
await expect.poll(() => page.evaluate(() => navigator.clipboard.readText())).toBe('src/panel.ts')
|
||||
const docsFile = view.locator('[data-forge-diff-file="docs/panel.md"]')
|
||||
await docsFile.getByRole('button', { name: '收起 panel.md', exact: true }).click()
|
||||
await page.setViewportSize({ width: 1280, height: 500 })
|
||||
const scrollport = view.locator('[data-forge-changes-scroll]')
|
||||
await scrollport.evaluate((element) => { element.scrollTop = 100; element.dispatchEvent(new Event('scroll')) })
|
||||
await panelFile.getByRole('button', { name: '复制路径: src/panel.ts', exact: true }).click()
|
||||
await panelFile.locator('[data-forge-file-label]').click()
|
||||
const position = await scrollport.evaluate(element => element.scrollTop)
|
||||
expect(position).toBeGreaterThan(0)
|
||||
const originalFile = await panelFile.elementHandle()
|
||||
@@ -672,7 +844,19 @@ it.skipIf(MODE === 'record')('shows the local changes of the Session by scope an
|
||||
expect(await panelFile.evaluate((element, original) => element === original, originalFile)).toBe(true)
|
||||
await expect.poll(() => docsFile.getAttribute('data-expanded')).toBe(null)
|
||||
await expect.poll(() => scrollport.evaluate(element => element.scrollTop)).toBe(position)
|
||||
expect(await panelFile.locator('[data-forge-review-thread="published"]').count()).toBe(1)
|
||||
await page.setViewportSize({ width: 1680, height: 1000 })
|
||||
await page.locator('[data-dockkit-tab]').filter({ hasText: '#7 的变更' }).locator('[data-dockkit-tab-close]').click()
|
||||
await expect.poll(() => view.count()).toBe(0)
|
||||
if (await header.getAttribute('aria-pressed') !== 'true') await header.click()
|
||||
await change.getByRole('button', { name: '查看 #7 的变更:新增 128 行,删除 14 行', exact: true }).click()
|
||||
await panelFile.getByRole('button', { name: '6 行未变更', exact: true }).waitFor()
|
||||
expect(await panelFile.locator('[data-forge-review-thread]').count()).toBe(0)
|
||||
await view.getByRole('button', { name: '提交评审', exact: true }).click()
|
||||
await reviewDialog.waitFor()
|
||||
expect(await reviewDialog.getByRole('textbox').inputValue()).toBe('')
|
||||
expect(await reviewDialog.getByRole('radio', { name: '评论', exact: true }).isChecked()).toBe(true)
|
||||
await page.keyboard.press('Escape')
|
||||
|
||||
// GitHub refuses the diff of pull request 9 as too large, so its view offers the web page instead of a retry.
|
||||
scaffold.ctx.forgeSession.track(session, DRAFT)
|
||||
@@ -697,8 +881,300 @@ it.skipIf(MODE === 'record')('shows the local changes of the Session by scope an
|
||||
})
|
||||
|
||||
|
||||
it.skipIf(MODE === 'record')('retains a wrapped code line and tree width across tab and Session switches', async () => {
|
||||
const { page, scaffold, root, tripwire } = await launchPanel('web-e2e-forge-reading-position')
|
||||
const paths = ['src/before-0.ts', 'src/before-1.ts', 'src/before-2.ts', 'src/server.ts', 'src/after.ts']
|
||||
const patch = paths.map(path => [
|
||||
`diff --git a/${path} b/${path}`, 'index 1111111..2222222 100644', `--- a/${path}`, `+++ b/${path}`,
|
||||
'@@ -1,650 +1,650 @@', '-const oldValue = true;', '+const newValue = true;',
|
||||
...Array.from({ length: 649 }, (_, index) => ` const value_${index + 2} = "${'x'.repeat(24 + (index + 2) % 70)}";`), '',
|
||||
].join('\n')).join('\n')
|
||||
await writeFile(join(root, 'pr-7.diff'), patch)
|
||||
const { settled } = await sendPrompt(page, scaffold)
|
||||
const sessionId = await settled
|
||||
const session = scaffold.ctx.sessions.get(sessionId)
|
||||
if (session === undefined) throw new Error('Session must stay loaded')
|
||||
scaffold.ctx.forgeSession.track(session, PULL)
|
||||
// Keep the file tree and the Session sidebar visible together on every platform.
|
||||
await page.setViewportSize({ width: 2400, height: 700 })
|
||||
await page.locator('[data-forge-header]').click()
|
||||
await page.locator(`[data-forge-change="${PULL}"]`).getByRole('button', { name: /查看 #7 的变更/ }).click()
|
||||
const view = page.locator('[data-forge-changes="change"]')
|
||||
const scroll = view.locator('[data-forge-changes-scroll]')
|
||||
const file = view.locator('[data-forge-diff-file="src/server.ts"]')
|
||||
const code = file.locator('[data-review-code][data-new-line="300"]')
|
||||
const separator = view.getByRole('separator', { name: '调整文件树宽度', exact: true })
|
||||
const beforeFile = view.locator('[data-forge-diff-file="src/before-0.ts"]')
|
||||
// ResizeObserver runs between rendering frames, including when an ancestor becomes hidden.
|
||||
const layout = () => page.evaluate(() => new Promise<void>((resolve) => {
|
||||
requestAnimationFrame(() => { requestAnimationFrame(() => { resolve() }) })
|
||||
}))
|
||||
const reading = () => file.evaluate((element) => {
|
||||
const viewport = element.closest('[data-forge-changes-scroll]')!
|
||||
const top = Math.max(viewport.getBoundingClientRect().top, element.firstElementChild!.getBoundingClientRect().bottom)
|
||||
const line = [...element.querySelectorAll<HTMLElement>('[data-review-code][data-new-line]')]
|
||||
.find(row => row.getBoundingClientRect().bottom > top + 1)!
|
||||
return { path: element.getAttribute('data-forge-diff-file'), line: line.dataset.newLine,
|
||||
offset: line.getBoundingClientRect().top - top, scrollTop: viewport.scrollTop }
|
||||
})
|
||||
await code.waitFor()
|
||||
for (const width of [240, 320]) {
|
||||
if (width === 320) {
|
||||
for (let step = 0; step < 4; step += 1) await separator.press('ArrowLeft')
|
||||
await beforeFile.getByRole('button', { name: '收起 before-0.ts', exact: true }).click()
|
||||
}
|
||||
await layout()
|
||||
await code.evaluate((element) => {
|
||||
const viewport = element.closest('[data-forge-changes-scroll]')!
|
||||
const header = element.closest('[data-forge-diff-file]')!.firstElementChild!
|
||||
const top = viewport.getBoundingClientRect().top + header.getBoundingClientRect().height
|
||||
viewport.scrollTop += element.getBoundingClientRect().top - top + 7
|
||||
})
|
||||
await layout()
|
||||
const position = await reading()
|
||||
expect(position.line).toBe('300')
|
||||
expect(position.offset).toBe(-7)
|
||||
for (const destination of ['tab', 'session', 'tab', 'session']) {
|
||||
if (destination === 'tab') await page.getByRole('tab').filter({ hasText: '变更请求' }).click()
|
||||
else await page.getByRole('button', { name: '新建会话', exact: true }).last().click()
|
||||
await expect.poll(() => view.isVisible()).toBe(false)
|
||||
await layout()
|
||||
expect(await scroll.evaluate(element => element.clientWidth)).toBe(0)
|
||||
if (destination === 'tab') await page.getByRole('tab').filter({ hasText: '#7 的变更' }).click()
|
||||
else await page.locator(`[data-row-key="session:${sessionId}"]`).click()
|
||||
await view.waitFor()
|
||||
await layout()
|
||||
expect(await separator.getAttribute('aria-valuenow')).toBe(String(width))
|
||||
expect(await reading()).toEqual(position)
|
||||
expect(await beforeFile.getAttribute('data-expanded')).toBe(width === 240 ? '' : null)
|
||||
}
|
||||
}
|
||||
expect(tripwire.pageErrors).toEqual([])
|
||||
expect(tripwire.warnings).toEqual([])
|
||||
})
|
||||
|
||||
it.skipIf(MODE === 'record')('uses horizontal arrows to navigate files while preserving vertical scrolling and comment editing', async () => {
|
||||
const { scaffold, page, project, tripwire } = await launchPanel('web-e2e-forge-file-keys')
|
||||
await git(project, 'update-ref', 'refs/remotes/origin/main', 'HEAD')
|
||||
await git(project, 'symbolic-ref', 'refs/remotes/origin/HEAD', 'refs/remotes/origin/main')
|
||||
for (const path of ['a.txt', 'b.txt', 'c.txt']) {
|
||||
await writeFile(join(project, path), Array.from({ length: path === 'c.txt' ? 1 : 80 }, (_, line) => `line ${line + 1}\n`).join(''))
|
||||
}
|
||||
const { settled } = await sendPrompt(page, scaffold)
|
||||
await settled
|
||||
await page.locator('[data-forge-header]').click()
|
||||
await page.locator('[data-forge-panel]').getByRole('button', { name: '刷新状态', exact: true }).click()
|
||||
await page.locator('[data-forge-local]').getByRole('button', { name: /查看本会话的变更:3 个文件/ }).click()
|
||||
const view = page.locator('[data-forge-changes="local"]')
|
||||
const scroll = view.getByRole('region', { name: '全部 3 个文件', exact: true })
|
||||
await scroll.waitFor()
|
||||
await page.getByRole('button', { name: '全屏', exact: true }).click()
|
||||
await page.setViewportSize({ width: 1280, height: 500 })
|
||||
const tree = view.getByRole('navigation')
|
||||
const a = view.locator('[data-forge-diff-file="a.txt"]')
|
||||
const b = view.locator('[data-forge-diff-file="b.txt"]')
|
||||
const c = view.locator('[data-forge-diff-file="c.txt"]')
|
||||
await b.getByRole('button', { name: '收起 b.txt', exact: true }).click()
|
||||
await scroll.evaluate((element) => { element.scrollTop = 0 })
|
||||
await scroll.focus()
|
||||
await page.keyboard.press('ArrowLeft')
|
||||
expect(await scroll.evaluate(element => element.scrollTop)).toBe(0)
|
||||
expect(await scroll.evaluate(element => getComputedStyle(element).outlineStyle)).toBe('none')
|
||||
await page.keyboard.press('ArrowDown')
|
||||
await expect.poll(() => scroll.evaluate(element => element.scrollTop)).toBeGreaterThan(0)
|
||||
await scroll.evaluate((element) => { element.scrollTop = 0 })
|
||||
await page.keyboard.press('ArrowRight')
|
||||
await expect.poll(() => tree.getByRole('button', { name: 'b.txt', exact: true }).getAttribute('aria-current')).toBe('true')
|
||||
expect(await b.getAttribute('data-expanded')).toBe('')
|
||||
expect(await scroll.evaluate(element => document.activeElement === element)).toBe(true)
|
||||
await page.keyboard.press('ArrowRight')
|
||||
await expect.poll(() => tree.getByRole('button', { name: 'c.txt', exact: true }).getAttribute('aria-current')).toBe('true')
|
||||
const lastPosition = await scroll.evaluate(element => element.scrollTop)
|
||||
const lastBox = await c.boundingBox(), viewport = await scroll.boundingBox()
|
||||
if (lastBox === null || viewport === null) throw new Error('The last file and scroll viewport must be rendered')
|
||||
expect(lastBox.y).toBeGreaterThan(viewport.y)
|
||||
expect(lastBox.y).toBeLessThan(viewport.y + viewport.height)
|
||||
await page.keyboard.press('ArrowRight')
|
||||
expect(await scroll.evaluate(element => element.scrollTop)).toBe(lastPosition)
|
||||
await page.keyboard.press('ArrowLeft')
|
||||
await expect.poll(() => tree.getByRole('button', { name: 'b.txt', exact: true }).getAttribute('aria-current')).toBe('true')
|
||||
await page.keyboard.press('ArrowLeft')
|
||||
await expect.poll(() => tree.getByRole('button', { name: 'a.txt', exact: true }).getAttribute('aria-current')).toBe('true')
|
||||
await b.evaluate((element) => {
|
||||
const viewport = element.closest('[data-forge-changes-scroll]')!
|
||||
viewport.scrollTop += element.getBoundingClientRect().top - viewport.getBoundingClientRect().top + 100
|
||||
})
|
||||
await page.keyboard.press('ArrowRight')
|
||||
await expect.poll(() => tree.getByRole('button', { name: 'c.txt', exact: true }).getAttribute('aria-current')).toBe('true')
|
||||
await tree.getByRole('button', { name: 'a.txt', exact: true }).click()
|
||||
await a.getByRole('button', { name: '选择第 R1 行', exact: true }).click()
|
||||
await a.getByRole('button', { name: '添加评论', exact: true }).click()
|
||||
const input = a.getByRole('textbox', { name: '留下评论…', exact: true })
|
||||
await input.fill('keep editing')
|
||||
await input.press('ArrowLeft')
|
||||
expect(await input.evaluate(element => (element as HTMLTextAreaElement).selectionStart)).toBe(11)
|
||||
await input.press('ArrowRight')
|
||||
expect(await input.inputValue()).toBe('keep editing')
|
||||
expect(await tree.getByRole('button', { name: 'a.txt', exact: true }).getAttribute('aria-current')).toBe('true')
|
||||
expect(await input.evaluate(element => document.activeElement === element)).toBe(true)
|
||||
expect(tripwire.pageErrors).toEqual([])
|
||||
expect(tripwire.warnings).toEqual([])
|
||||
})
|
||||
|
||||
it.skipIf(MODE === 'record')('keeps localized status columns separate and long file lists inside one vertical scroller', async () => {
|
||||
const { scaffold, page, project, tripwire } = await launchPanel('web-e2e-forge-layout')
|
||||
await page.locator('[data-forge-current-branch]').waitFor()
|
||||
await compareOrRefreshGolden(join(EXPECTED, 'worktree-option.expected.md'),
|
||||
await captureStableAria(page, '[data-forge-worktree]', scaffold.workspaceCwd), MODE)
|
||||
await page.getByRole('button', { name: '收起侧边栏', exact: true }).click()
|
||||
await page.setViewportSize({ width: 390, height: 844 })
|
||||
await expect.poll(() => page.locator('[data-forge-worktree]')
|
||||
.evaluate(element => element.getBoundingClientRect().right)).toBeLessThanOrEqual(390)
|
||||
await page.setViewportSize({ width: 1680, height: 1000 })
|
||||
await git(project, 'update-ref', 'refs/remotes/origin/main', 'HEAD')
|
||||
await git(project, 'symbolic-ref', 'refs/remotes/origin/HEAD', 'refs/remotes/origin/main')
|
||||
await mkdir(join(project, 'src'))
|
||||
await Promise.all(Array.from({ length: 60 }, (_, index) => writeFile(join(project, 'src', `file-${index}.ts`), `export const value = ${index}\n`)))
|
||||
const { settled } = await sendPrompt(page, scaffold)
|
||||
const session = scaffold.ctx.sessions.get(await settled)
|
||||
if (session === undefined) throw new Error('The Session must stay loaded')
|
||||
scaffold.ctx.forgeSession.track(session, PULL)
|
||||
await page.locator('[data-forge-header]').click()
|
||||
const panel = page.locator('[data-forge-panel]')
|
||||
await panel.getByRole('button', { name: '刷新状态', exact: true }).click()
|
||||
const local = panel.locator('[data-forge-local]')
|
||||
await local.locator('button[aria-expanded]').click()
|
||||
await expect.poll(() => local.locator('li').count(), { timeout: 20_000 }).toBe(60)
|
||||
for (const width of [1280, 390]) {
|
||||
await page.setViewportSize({ width, height: 700 })
|
||||
const outerScrollers = await panel.evaluate((element) => {
|
||||
const scrollers: string[] = []
|
||||
for (let ancestor = element.parentElement; ancestor !== null; ancestor = ancestor.parentElement) {
|
||||
if (/auto|scroll/.test(getComputedStyle(ancestor).overflowY) && ancestor.scrollHeight > ancestor.clientHeight + 1) {
|
||||
scrollers.push(ancestor.className)
|
||||
}
|
||||
}
|
||||
return scrollers
|
||||
})
|
||||
expect(outerScrollers).toEqual([])
|
||||
expect(await panel.evaluate(element => element.scrollHeight > element.clientHeight)).toBe(true)
|
||||
await local.locator('li').last().scrollIntoViewIfNeeded()
|
||||
expect(await local.locator('li').last().isVisible()).toBe(true)
|
||||
}
|
||||
await local.locator('button[aria-expanded]').click()
|
||||
const change = panel.locator(`[data-forge-change="${PULL}"]`)
|
||||
for (const [locale, labels] of [
|
||||
['zh', ['检查', '评审', '合并', '变更']],
|
||||
['en', ['Checks', 'Review', 'Merge', 'Changes']],
|
||||
['de', ['Prüfungen', 'Review', 'Zusammenführen', 'Änderungen']],
|
||||
] as const) {
|
||||
await scaffold.ctx.settings.update('locale', { preference: locale })
|
||||
await change.getByText(labels[0], { exact: true }).waitFor()
|
||||
if (locale === 'en') {
|
||||
await compareOrRefreshGolden(join(EXPECTED, 'local-card.expected.md'),
|
||||
await captureStableAria(page, '[data-forge-local]', scaffold.workspaceCwd), MODE)
|
||||
}
|
||||
for (const width of [1280, 390]) {
|
||||
await page.setViewportSize({ width, height: 700 })
|
||||
await expect.poll(() => change.evaluate(element => element.getBoundingClientRect().right)).toBeLessThanOrEqual(width)
|
||||
await change.getByText(labels[3], { exact: true }).hover()
|
||||
for (const label of labels) {
|
||||
const geometry = await change.getByText(label, { exact: true }).evaluate((element) => {
|
||||
const value = element.nextElementSibling
|
||||
if (value === null) throw new Error('Status label must have a value')
|
||||
const range = document.createRange()
|
||||
range.selectNodeContents(element)
|
||||
const name = range.getBoundingClientRect()
|
||||
const content = value.getBoundingClientRect()
|
||||
const row = element.parentElement!
|
||||
const icon = element.previousElementSibling!
|
||||
const rowRect = row.getBoundingClientRect()
|
||||
return {
|
||||
gap: content.left - name.right,
|
||||
iconInset: icon.getBoundingClientRect().left - rowRect.left,
|
||||
rowInset: rowRect.left - row.closest('[data-forge-change]')!.getBoundingClientRect().left,
|
||||
labelWidth: element.getBoundingClientRect().width,
|
||||
valueOffset: content.left - rowRect.left,
|
||||
right: content.right,
|
||||
width: document.documentElement.clientWidth,
|
||||
}
|
||||
})
|
||||
expect(geometry.gap).toBeGreaterThanOrEqual(8)
|
||||
expect(geometry.iconInset).toBe(8)
|
||||
expect(geometry.rowInset).toBeGreaterThanOrEqual(6)
|
||||
expect(geometry.rowInset).toBeLessThanOrEqual(7)
|
||||
if (locale === 'zh') {
|
||||
expect(geometry.labelWidth).toBe(32)
|
||||
expect(geometry.valueOffset).toBe(76)
|
||||
}
|
||||
expect(geometry.right).toBeLessThanOrEqual(geometry.width)
|
||||
}
|
||||
}
|
||||
}
|
||||
expect(tripwire.pageErrors).toEqual([])
|
||||
expect(tripwire.warnings).toEqual([])
|
||||
})
|
||||
|
||||
it.skipIf(MODE === 'record')('keeps long branch details accessible by touch and keyboard across the hero row breakpoints', async () => {
|
||||
const branch = 'feature/a-long-current-branch-name-for-mobile-review'
|
||||
const { page, scaffold, tripwire } = await launchPanel('web-e2e-forge-branch-details', 'normal', { branch, hasTouch: true })
|
||||
const option = page.locator('[data-forge-worktree]')
|
||||
const chip = option.locator('[data-forge-current-branch]')
|
||||
await chip.waitFor()
|
||||
await page.getByRole('button', { name: '收起侧边栏', exact: true }).click()
|
||||
for (const [locale, label] of [['zh', `当前分支:${branch}`], ['en', `Current branch: ${branch}`], ['de', `Aktueller Branch: ${branch}`]] as const) {
|
||||
await scaffold.ctx.settings.update('locale', { preference: locale })
|
||||
await option.getByRole('button', { name: label, exact: true }).waitFor()
|
||||
for (const width of [390, 600, 601, 700, 1280]) {
|
||||
await page.setViewportSize({ width, height: 844 })
|
||||
await chip.scrollIntoViewIfNeeded()
|
||||
await expect.poll(() => option.evaluate((element) => {
|
||||
const row = element.closest('[class*="heroWorkspaceRow"]')!
|
||||
const ancestors: Element[] = []
|
||||
for (let node: Element | null = row; node !== null; node = node.parentElement) ancestors.push(node)
|
||||
return {
|
||||
fits: element.getBoundingClientRect().right <= innerWidth,
|
||||
overflow: ancestors.filter(node => node.scrollWidth > node.clientWidth + 1).map(node => node.className),
|
||||
}
|
||||
})).toEqual({ fits: true, overflow: [] })
|
||||
}
|
||||
}
|
||||
await scaffold.ctx.settings.update('locale', { preference: 'en' })
|
||||
await option.getByRole('button', { name: `Current branch: ${branch}`, exact: true }).waitFor()
|
||||
await page.setViewportSize({ width: 390, height: 844 })
|
||||
expect(await chip.locator('span').evaluate(element => element.scrollWidth > element.clientWidth)).toBe(true)
|
||||
const tooltip = page.getByRole('tooltip', { exact: true, name: `Current branch: ${branch}` })
|
||||
await chip.tap()
|
||||
await tooltip.waitFor()
|
||||
await compareOrRefreshGolden(join(EXPECTED, 'branch-details.expected.md'), await tooltip.ariaSnapshot(), MODE)
|
||||
await chip.tap()
|
||||
await tooltip.waitFor({ state: 'hidden' })
|
||||
await chip.tap()
|
||||
await tooltip.waitFor()
|
||||
await page.locator('[class*="heroWorkspaceRow"]').tap({ position: { x: 1, y: 1 } })
|
||||
await tooltip.waitFor({ state: 'hidden' })
|
||||
await chip.focus()
|
||||
await page.keyboard.press('Tab')
|
||||
await page.keyboard.press('Shift+Tab')
|
||||
await tooltip.waitFor()
|
||||
await page.keyboard.press('Escape')
|
||||
await tooltip.waitFor({ state: 'hidden' })
|
||||
await page.keyboard.press('Enter')
|
||||
await tooltip.waitFor()
|
||||
await page.keyboard.press('Escape')
|
||||
await tooltip.waitFor({ state: 'hidden' })
|
||||
expect(await option.getByRole('checkbox').isChecked()).toBe(false)
|
||||
expect(await page.getByRole('menu').count()).toBe(0)
|
||||
await scaffold.ctx.settings.update('locale', { preference: 'zh' })
|
||||
await option.getByRole('checkbox', { name: '新建工作树', exact: true }).waitFor()
|
||||
const { settled } = await sendPrompt(page, scaffold)
|
||||
await settled
|
||||
expect(tripwire.pageErrors).toEqual([])
|
||||
expect(tripwire.warnings).toEqual([])
|
||||
})
|
||||
|
||||
it.skipIf(MODE === 'record').each(['darwin', 'win32'] as const)('closes diff menus when the %s desktop shortcut deactivates a retained tab', async (platform) => {
|
||||
const { page, scaffold, project, tripwire } = await launchPanel(`web-e2e-forge-menu-${platform}`, 'normal', platform)
|
||||
const { page, scaffold, project, tripwire } = await launchPanel(`web-e2e-forge-menu-${platform}`, 'normal', { desktop: platform })
|
||||
await git(project, 'update-ref', 'refs/remotes/origin/main', 'HEAD')
|
||||
await git(project, 'symbolic-ref', 'refs/remotes/origin/HEAD', 'refs/remotes/origin/main')
|
||||
await writeFile(join(project, 'README.md'), 'review this change\n')
|
||||
@@ -708,7 +1184,7 @@ it.skipIf(MODE === 'record').each(['darwin', 'win32'] as const)('closes diff men
|
||||
await page.locator('[data-forge-panel]').getByRole('button', { name: '刷新状态', exact: true }).click()
|
||||
await page.locator('[data-forge-local]').getByRole('button', { name: /查看本会话的变更:1 个文件/ }).click()
|
||||
const view = page.locator('[data-forge-changes="local"]')
|
||||
await view.getByRole('button', { name: '复制路径: README.md', exact: true }).waitFor()
|
||||
await view.locator('[data-forge-diff-file="README.md"]').waitFor()
|
||||
for (const name of ['分支', '全部 1 个文件', 'README.md 的更多操作']) {
|
||||
await view.getByRole('button', { name, exact: true }).click()
|
||||
await page.getByRole('menu').waitFor()
|
||||
@@ -724,3 +1200,59 @@ it.skipIf(MODE === 'record').each(['darwin', 'win32'] as const)('closes diff men
|
||||
}
|
||||
expect(tripwire.warnings).toEqual([])
|
||||
})
|
||||
|
||||
it.skipIf(MODE === 'record').each([120, 4000])('types a review comment beside %i changed lines', async (count) => {
|
||||
const { scaffold, page, root, tripwire } = await launchPanel('web-e2e-forge-review-typing')
|
||||
const patch = ['diff --git a/src/typing.ts b/src/typing.ts', 'index 1111111..2222222 100644',
|
||||
'--- a/src/typing.ts', '+++ b/src/typing.ts', `@@ -1,${count} +1,${count} @@`,
|
||||
...Array.from({ length: count }, (_, index) => {
|
||||
const context = index % 80 === 0 ? 'wrapped context '.repeat(600) : index % 5 === 0 ? 'context '.repeat(30) : ''
|
||||
return `-export const value${index} = [${index}, '${context}']\n+export const value${index} = [${index + 1}, '${context}']`
|
||||
}), ''].join('\n')
|
||||
await writeFile(join(root, 'pr-7.diff'), patch)
|
||||
const { settled } = await sendPrompt(page, scaffold)
|
||||
const sessionId = await settled
|
||||
const session = scaffold.ctx.sessions.get(sessionId)
|
||||
if (session === undefined) throw new Error('Session must stay loaded')
|
||||
scaffold.ctx.forgeSession.track(session, PULL)
|
||||
await page.locator('[data-forge-header]').click()
|
||||
const change = page.locator(`[data-forge-change="${PULL}"]`)
|
||||
await change.getByRole('button', { name: '查看 #7 的变更:新增 128 行,删除 14 行', exact: true }).click()
|
||||
const file = page.locator('[data-forge-diff-file="src/typing.ts"]')
|
||||
const collapsed = file.getByRole('button', { name: /^文件较大,/ })
|
||||
await file.waitFor()
|
||||
if (count > 120) await collapsed.click()
|
||||
await file.getByRole('button', { name: '选择第 R5 行', exact: true }).click()
|
||||
await file.getByRole('button', { name: '添加评论', exact: true }).click()
|
||||
const input = file.getByRole('textbox', { name: '留下评论…', exact: true })
|
||||
await input.waitFor()
|
||||
const field = await input.boundingBox()
|
||||
if (field === null) throw new Error('Comment field must be visible')
|
||||
await page.mouse.move(field.x + field.width - 3, field.y + field.height - 3)
|
||||
await page.mouse.down()
|
||||
await page.mouse.move(field.x + field.width - 3, field.y + field.height + 77, { steps: 5 })
|
||||
await page.mouse.up()
|
||||
const resized = await input.boundingBox()
|
||||
if (resized === null) throw new Error('Resized comment field must remain visible')
|
||||
expect(resized.height).toBeGreaterThan(field.height + 50)
|
||||
await input.fill('Review a wrapped line. '.repeat(80))
|
||||
expect(await input.evaluate(element => element.scrollHeight > element.clientHeight)).toBe(true)
|
||||
expect(await input.evaluate(element => element.scrollWidth <= element.clientWidth)).toBe(true)
|
||||
await input.fill('')
|
||||
await page.keyboard.type('Check the boundary')
|
||||
await page.keyboard.press('Enter')
|
||||
const cdp = await page.context().newCDPSession(page)
|
||||
try {
|
||||
await cdp.send('Input.imeSetComposition', { text: '检查', selectionStart: 2, selectionEnd: 2 })
|
||||
expect(await input.inputValue()).toBe('Check the boundary\n检查')
|
||||
expect(await file.locator('[data-forge-review-thread]').count()).toBe(0)
|
||||
await cdp.send('Input.insertText', { text: '检查边界条件' })
|
||||
} finally { await cdp.detach() }
|
||||
expect(await input.inputValue()).toBe('Check the boundary\n检查边界条件')
|
||||
await input.fill(' \n')
|
||||
expect(await file.getByRole('button', { name: '开始评审', exact: true }).isDisabled()).toBe(true)
|
||||
await input.fill('检查边界条件')
|
||||
await file.getByRole('button', { name: '开始评审', exact: true }).click()
|
||||
await file.locator('[data-forge-review-thread="pending"]').getByText('检查边界条件', { exact: true }).waitFor()
|
||||
expect(tripwire.pageErrors).toEqual([])
|
||||
})
|
||||
@@ -95,18 +95,24 @@ it.each([false, true])('keeps workspace and archived search actions reachable wi
|
||||
expect(await shortcut.count()).toBe(1)
|
||||
expect(await page.evaluate(() => matchMedia('(pointer: coarse)').matches)).toBe(hasTouch)
|
||||
expect(await shortcut.isVisible()).toBe(!hasTouch)
|
||||
if (hasTouch) {
|
||||
await page.keyboard.press('Escape')
|
||||
await page.setViewportSize({ width: 390, height: 900 })
|
||||
await page.locator('[data-sidebar-drawer]').waitFor()
|
||||
await page.locator('[data-shell-leading]').getByRole('button', { name: 'Open sidebar', exact: true }).tap()
|
||||
await activate(actions)
|
||||
await archive.waitFor()
|
||||
}
|
||||
for (const key of ['ArrowDown', 'Tab']) {
|
||||
await page.keyboard.press(key)
|
||||
expect(await page.locator('html').getAttribute('data-input-modality')).toBe('keyboard')
|
||||
expect(await page.getByRole('menu').evaluate(menu => menu.contains(document.activeElement))).toBe(true)
|
||||
expect(await shortcut.isVisible()).toBe(true)
|
||||
if (hasTouch) {
|
||||
await page.setViewportSize({ width: 390, height: 900 })
|
||||
await expect.poll(() => shortcut.evaluate((element) => {
|
||||
const bounds = element.getBoundingClientRect()
|
||||
return bounds.left >= 0 && bounds.right <= window.innerWidth
|
||||
})).toBe(true)
|
||||
await page.setViewportSize({ width: 1280, height: 900 })
|
||||
}
|
||||
await page.keyboard.press('Escape')
|
||||
if (!hasTouch) await row.hover()
|
||||
@@ -114,6 +120,13 @@ it.each([false, true])('keeps workspace and archived search actions reachable wi
|
||||
await archive.waitFor()
|
||||
expect(await shortcut.isVisible()).toBe(!hasTouch)
|
||||
}
|
||||
if (hasTouch) {
|
||||
await page.keyboard.press('Escape')
|
||||
await page.setViewportSize({ width: 1280, height: 900 })
|
||||
await page.locator('[data-sidebar-drawer]').waitFor({ state: 'detached' })
|
||||
await activate(actions)
|
||||
await archive.waitFor()
|
||||
}
|
||||
await activate(archive)
|
||||
await row.waitFor({ state: 'detached' })
|
||||
await activate(page.getByRole('button', { name: 'View options', exact: true }))
|
||||
@@ -224,19 +237,23 @@ it.each([false, true])('keeps actions and focus usable with touch=%s across layo
|
||||
await page.getByRole('tooltip').waitFor({ state: 'detached' })
|
||||
const blockedSplit = panel.locator('[data-dockkit-split-button]').last()
|
||||
expect(await blockedSplit.isDisabled()).toBe(true)
|
||||
const hit = await blockedSplit.evaluate((button) => {
|
||||
const bounds = button.getBoundingClientRect()
|
||||
const x = bounds.x + bounds.width / 2
|
||||
const y = bounds.y + bounds.height / 2
|
||||
const target = document.elementFromPoint(x, y)
|
||||
return { x, y, wrapperReceivesInput: target === button.parentElement, cursor: target && getComputedStyle(target).cursor }
|
||||
})
|
||||
expect(hit.wrapperReceivesInput).toBe(true)
|
||||
expect(['auto', 'default']).toContain(hit.cursor)
|
||||
// Coordinate input exercises CSS hit testing over the disabled button itself.
|
||||
if (hasTouch) await page.touchscreen.tap(hit.x, hit.y)
|
||||
else await page.mouse.click(hit.x, hit.y)
|
||||
await page.getByRole('tooltip').filter({ hasText: 'Two panes is the limit' }).waitFor()
|
||||
if (hasTouch) {
|
||||
expect(await blockedSplit.isVisible()).toBe(false)
|
||||
expect(await page.getByRole('tooltip').count()).toBe(0)
|
||||
} else {
|
||||
const hit = await blockedSplit.evaluate((button) => {
|
||||
const bounds = button.getBoundingClientRect()
|
||||
const x = bounds.x + bounds.width / 2
|
||||
const y = bounds.y + bounds.height / 2
|
||||
const target = document.elementFromPoint(x, y)
|
||||
return { x, y, wrapperReceivesInput: target === button.parentElement, cursor: target && getComputedStyle(target).cursor }
|
||||
})
|
||||
expect(hit.wrapperReceivesInput).toBe(true)
|
||||
expect(['auto', 'default']).toContain(hit.cursor)
|
||||
// Coordinate input exercises CSS hit testing over the disabled button itself.
|
||||
await page.mouse.click(hit.x, hit.y)
|
||||
await page.getByRole('tooltip').filter({ hasText: 'Two panes is the limit' }).waitFor()
|
||||
}
|
||||
expect(await panel.locator('[data-dockkit-pane]').count()).toBe(2)
|
||||
expect(consoleWatch.pageErrors).toEqual([])
|
||||
})
|
||||
@@ -42,7 +42,8 @@ it('reserves bottom content height without remounting it on main-panel navigatio
|
||||
const viewportHeight = page.viewportSize()!.height
|
||||
expect(result.bottom).toEqual({ top: viewportHeight - height, height, bottom: viewportHeight })
|
||||
expect(result.main).toEqual({ top: caption, height: viewportHeight - caption - height, bottom: viewportHeight - height })
|
||||
expect(result.sidebar).toEqual(result.main)
|
||||
expect(result.sidebar).toEqual(page.viewportSize()!.width < 768
|
||||
? { top: 0, height: viewportHeight, bottom: viewportHeight } : result.main)
|
||||
expect(result.rightbar).toEqual(result.main)
|
||||
expect(result.overlay).toEqual({ top: 0, height: viewportHeight, bottom: viewportHeight })
|
||||
for (const handle of result.handles) expect(handle).toEqual(result.main)
|
||||
|
||||
@@ -216,8 +216,8 @@ async function awaitTableLayout(target: Page): Promise<void> {
|
||||
if (element === null) return false
|
||||
const tracks = getComputedStyle(element).gridTemplateColumns.split(' ').map(Number.parseFloat)
|
||||
const root = element.querySelector<HTMLElement>('div[data-phase]')
|
||||
// Mirrored from ui-layout's SIDEBAR_COLLAPSED; these tests use the Host compiler face.
|
||||
return tracks[0] === 56 && tracks.at(-1) === 0
|
||||
// Desktop retains the rail; the mobile drawer leaves the whole width to the transcript.
|
||||
return tracks[0] === (element.hasAttribute('data-sidebar-drawer') ? 0 : 56) && tracks.at(-1) === 0
|
||||
&& element.getAnimations().every(animation =>
|
||||
animation.playState === 'finished' || animation.playState === 'idle')
|
||||
&& root !== null
|
||||
|
||||
@@ -27,5 +27,11 @@ export async function assertModelInputLayout(page: Page, editor: Locator): Promi
|
||||
}
|
||||
} finally {
|
||||
await page.setViewportSize(original)
|
||||
// The frame reports its own width to the layout store from a rAF-throttled
|
||||
// ResizeObserver, so the restored viewport is only in force once the shell
|
||||
// has left drawer mode; a capture taken in between reads the narrow frame.
|
||||
if (await page.locator('[data-sidebar-drawer]').count() > 0) {
|
||||
await expect.poll(async () => page.locator('[data-sidebar-drawer]').count(), { timeout: 5_000 }).toBe(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,17 @@ async function controlLayout(page: Page) {
|
||||
|
||||
/** Wait for the responsive column and control row to finish changing width. */
|
||||
async function resizeControls(page: Page, width: number): Promise<void> {
|
||||
const previousWidth = page.viewportSize()!.width
|
||||
await page.setViewportSize({ width, height: VIEWPORT.height })
|
||||
if (width >= 768 && width < 1024) {
|
||||
const frame = page.locator('[data-sidebar-collapsed][data-rightbar-collapsed]')
|
||||
if (previousWidth >= 1024) await frame.waitFor()
|
||||
const open = page.getByRole('button', { name: 'Open sidebar', exact: true })
|
||||
if (await open.isVisible()) {
|
||||
await open.click()
|
||||
await expect.poll(() => frame.count()).toBe(0)
|
||||
}
|
||||
}
|
||||
await page.locator('[data-composer-card]').evaluate(async (card) => {
|
||||
let previous = card.getBoundingClientRect().width
|
||||
let stable = 0
|
||||
@@ -201,7 +211,7 @@ describe('web e2e: plan chip click area at the narrow viewport', () => {
|
||||
// Find the content-dependent transition on this platform's fonts, never a
|
||||
// committed pixel threshold. The old 360px rule cannot satisfy this case.
|
||||
let narrowViewport: number | undefined
|
||||
for (let width = 1100; width >= 650; width -= 10) {
|
||||
for (let width = 1100; width >= 770; width -= 10) {
|
||||
await resizeControls(page, width)
|
||||
const layout = await controlLayout(page)
|
||||
if (layout.width > 360 && layout.icon && !layout.text) {
|
||||
@@ -267,7 +277,7 @@ describe('web e2e: plan chip click area at the narrow viewport', () => {
|
||||
await selectModel(page, LONG_MODEL)
|
||||
await expectControlLayout(page, false)
|
||||
|
||||
await resizeControls(page, 440)
|
||||
await resizeControls(page, 384)
|
||||
await expectControlLayout(page, true)
|
||||
const trigger = page.getByRole('button', { name: /Select model/ })
|
||||
expect(await trigger.getAttribute('title')).toContain(LONG_MODEL)
|
||||
|
||||
@@ -268,8 +268,8 @@ describe('web e2e: plugin manager', () => {
|
||||
await bar.getByRole('tablist').waitFor()
|
||||
await add.focus()
|
||||
for (const [width, icons, narrowTabs, wraps] of [
|
||||
[1280, false, false, false], [600, true, false, false],
|
||||
[470, true, true, false], [390, true, true, true], [300, true, true, true],
|
||||
[1280, false, false, false], [544, true, false, false],
|
||||
[414, true, true, false], [334, true, true, true], [244, true, true, true],
|
||||
] as const) {
|
||||
await probe.setViewportSize({ width, height: 480 })
|
||||
await body.evaluate((element) => { element.scrollTop = 180 })
|
||||
|
||||
@@ -83,8 +83,8 @@ it('preserves both header layouts and follows the scroll position without changi
|
||||
await page.locator('[data-plugin-bar][data-natural]').waitFor()
|
||||
await page.evaluate(() => document.fonts.ready)
|
||||
// Without tabs, whether the actions fit beside the title at 470px depends on the platform font,
|
||||
// so that width is pinned only with tabs.
|
||||
for (const width of hasTabs ? [1280, 600, 470, 390] : [1280, 600, 390]) {
|
||||
// so that width is pinned only with tabs. At 334px the tabs and actions wrap onto separate rows.
|
||||
for (const width of hasTabs ? [1280, 600, 470, 390, 334] : [1280, 600, 390]) {
|
||||
await page.setViewportSize({ width, height: 480 })
|
||||
await scrollTo(page, 0)
|
||||
const resting = await reference(page, false)
|
||||
@@ -95,7 +95,7 @@ it('preserves both header layouts and follows the scroll position without changi
|
||||
expect(initial.tabs).toEqual(resting.tabs)
|
||||
if (hasTabs && width <= 600) {
|
||||
const tabs = initial.tabs!
|
||||
if (width === 390) {
|
||||
if (width === 334) {
|
||||
expect(initial.toolbar.y).toBeGreaterThanOrEqual(tabs.y + tabs.height)
|
||||
} else {
|
||||
expect(initial.toolbar.x).toBeGreaterThanOrEqual(tabs.x + tabs.width)
|
||||
|
||||
@@ -868,6 +868,7 @@ describe.skipIf(MODE === 'record')('web e2e: active Schedule catalog', () => {
|
||||
await page.getByRole('menuitem', { name: 'Delete task', exact: true }).click()
|
||||
const confirmation = page.getByRole('dialog', { name: 'Delete this task?' })
|
||||
await confirmation.getByRole('button', { name: 'Cancel', exact: true }).click()
|
||||
expect(await moreActions.evaluate(button => button === document.activeElement)).toBe(true)
|
||||
expect((await scaffold.ctx.schedule.catalog()).some(task => task.id === other.id)).toBe(true)
|
||||
await moreActions.click()
|
||||
await page.getByRole('menuitem', { name: 'Delete task', exact: true }).click()
|
||||
|
||||
@@ -58,10 +58,8 @@ it('keeps the automation title intact before moving New to another line', async
|
||||
facts.push(`${language} ${width}px: title and New single-line, New beside the title; contained; New retains focus`)
|
||||
}
|
||||
if (language === 'en') {
|
||||
// 509px collapses the left sidebar to its rail; expanding it leaves the
|
||||
// page column narrow enough (measured 172px) to force the wrap.
|
||||
await page.setViewportSize({ width: 509, height: 1000 })
|
||||
await page.getByRole('button', { name: 'Open sidebar', exact: true }).first().click()
|
||||
// Constrain this page independently of the shell's drawer breakpoint.
|
||||
await header.evaluate((element) => { element.style.width = '220px' })
|
||||
await expect.poll(() => header.evaluate((element) => {
|
||||
const title = element.querySelector('h1')!
|
||||
const button = element.querySelector('button')!
|
||||
@@ -76,7 +74,7 @@ it('keeps the automation title intact before moving New to another line', async
|
||||
: buttonRect.top >= titleRect.bottom - 1 ? 'below' as const : 'overlapping' as const,
|
||||
}
|
||||
})).toEqual({ titleSingleLine: true, placement: 'below' })
|
||||
facts.push('en 509px with sidebar expanded: title single-line; New moves below the title')
|
||||
facts.push('en 220px page column: title single-line; New moves below the title')
|
||||
}
|
||||
expect(consoleWatch.pageErrors).toEqual([])
|
||||
} finally {
|
||||
|
||||
@@ -7,6 +7,7 @@ import { expect, it } from 'vitest'
|
||||
import { SessionId } from '@deepseek-ai/dsh-session'
|
||||
import type {} from '@deepseek-ai/dsh-schedule'
|
||||
import { launchWebScaffold, watchConsole } from './scaffold.ts'
|
||||
import { revealNavigationDrawer } from './support.ts'
|
||||
|
||||
const PHONE_TASK_SESSION = SessionId('schedule-phone-web-e2e')
|
||||
const PHONE_TASK_TITLE = 'Review overdue deployment'
|
||||
@@ -25,6 +26,7 @@ interface ViewFacts {
|
||||
/** Open the Automation tasks page and return its panel. */
|
||||
async function openTaskManager(page: Page, url: string): Promise<Locator> {
|
||||
await page.goto(url, { waitUntil: 'load' })
|
||||
await revealNavigationDrawer(page, 'zh')
|
||||
await page.getByRole('button', { name: '自动化任务', exact: true }).click()
|
||||
const panel = page.getByTestId('task-manager-page')
|
||||
await panel.getByRole('heading', { name: '自动化任务', exact: true }).waitFor({ timeout: 30_000 })
|
||||
|
||||
@@ -0,0 +1,667 @@
|
||||
/** Narrow sidebar geometry, navigation, focus and retained content in the shipped profile. */
|
||||
import { readFile } from 'node:fs/promises'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import type { Locator } from 'playwright'
|
||||
import { chromium } from 'playwright'
|
||||
import { expect, it } from 'vitest'
|
||||
import { compareOrRefreshGolden, launchWebScaffold, seedSession, watchConsole, webSnapshotMode } from './scaffold.ts'
|
||||
|
||||
/** A returning rail uses its compact layout without wide-content or icon-entry animations. */
|
||||
async function assertCompactRail(sidebar: Locator): Promise<void> {
|
||||
expect(await sidebar.getByRole('button', { name: 'New session', exact: true }).count()).toBe(1)
|
||||
expect(await sidebar.evaluate((el) => {
|
||||
const root = el.firstElementChild!
|
||||
return {
|
||||
fits: root.getBoundingClientRect().width <= el.parentElement!.getBoundingClientRect().width,
|
||||
animations: root.getAnimations({ subtree: true })
|
||||
.filter((animation): animation is CSSAnimation =>
|
||||
animation instanceof CSSAnimation && /wide-in|rail-in|rail-fade-in/.test(animation.animationName))
|
||||
.map(animation => animation.animationName),
|
||||
}
|
||||
})).toEqual({ fits: true, animations: [] })
|
||||
}
|
||||
|
||||
it.each(['light', 'dark'] as const)('keeps the macOS drawer opaque and excludes inert content from window drag regions in %s mode', async (colorScheme) => {
|
||||
const scaffold = await launchWebScaffold({
|
||||
extraOverlayPath: fileURLToPath(new URL('./pin-browse-picker.overlay.yml', import.meta.url)),
|
||||
})
|
||||
try {
|
||||
const browser = await chromium.launch()
|
||||
try {
|
||||
const page = await browser.newPage({ viewport: { width: 520, height: 680 }, colorScheme, locale: 'en-US' })
|
||||
await page.goto(scaffold.authenticatedUrl)
|
||||
const opener = page.getByRole('button', { name: 'Open sidebar', exact: true })
|
||||
await opener.waitFor()
|
||||
await page.evaluate(() => { document.documentElement.dataset.platform = 'darwin' })
|
||||
await opener.click()
|
||||
const drawer = page.getByRole('dialog', { name: 'Navigation', exact: true })
|
||||
await drawer.waitFor()
|
||||
const column = page.locator('[data-slot="sidebar"]').locator('..')
|
||||
const background = await column.evaluate((el) => {
|
||||
const style = getComputedStyle(el)
|
||||
return { color: style.backgroundColor, image: style.backgroundImage }
|
||||
})
|
||||
expect(background.image).toBe('none')
|
||||
expect(background.color).toMatch(/^rgb\(/)
|
||||
expect(await drawer.getByRole('button', { name: 'New session', exact: true }).last().evaluate((el) => {
|
||||
const actual = getComputedStyle(el).backgroundColor
|
||||
const root = document.documentElement
|
||||
const platform = root.dataset.platform
|
||||
delete root.dataset.platform
|
||||
try {
|
||||
return actual === getComputedStyle(el).backgroundColor
|
||||
} finally {
|
||||
root.dataset.platform = platform
|
||||
}
|
||||
})).toBe(true)
|
||||
const inactiveContent = page.locator('[inert], [inert] *')
|
||||
expect(await inactiveContent.count()).toBeGreaterThan(0)
|
||||
expect(await inactiveContent.evaluateAll(elements => elements
|
||||
.filter(el => getComputedStyle(el).getPropertyValue('app-region') !== 'none')
|
||||
.map(el => `${el.tagName}.${el.getAttribute('class')}: ${getComputedStyle(el).getPropertyValue('app-region')}`)))
|
||||
.toEqual([])
|
||||
expect(await drawer.locator('[data-window-drag]').first().evaluate(el => getComputedStyle(el).getPropertyValue('app-region')))
|
||||
.toBe('drag')
|
||||
const collapse = drawer.getByRole('button', { name: 'Collapse sidebar', exact: true })
|
||||
await collapse.click()
|
||||
await drawer.waitFor({ state: 'hidden' })
|
||||
await page.setViewportSize({ width: 1200, height: 800 })
|
||||
const sidebar = page.locator('[data-slot="sidebar"]').locator('..')
|
||||
await expect.poll(() => sidebar.evaluate(el => getComputedStyle(el).backgroundImage)).not.toBe('none')
|
||||
const activeDragRows = page.locator('[data-window-drag]:not([inert] [data-window-drag])')
|
||||
expect(await activeDragRows.count()).toBeGreaterThan(0)
|
||||
expect(await activeDragRows.evaluateAll(rows => rows.every(row => getComputedStyle(row).getPropertyValue('app-region') === 'drag')))
|
||||
.toBe(true)
|
||||
} finally {
|
||||
await browser.close()
|
||||
}
|
||||
} finally {
|
||||
await scaffold.close()
|
||||
}
|
||||
})
|
||||
|
||||
it('hides a collapsed rail immediately when it becomes a drawer', async () => {
|
||||
const scaffold = await launchWebScaffold({
|
||||
extraOverlayPath: fileURLToPath(new URL('./pin-browse-picker.overlay.yml', import.meta.url)),
|
||||
})
|
||||
try {
|
||||
const browser = await chromium.launch()
|
||||
try {
|
||||
const page = await browser.newPage({ viewport: { width: 768, height: 844 }, locale: 'en-US' })
|
||||
await page.goto(scaffold.authenticatedUrl)
|
||||
await page.getByRole('button', { name: 'Open sidebar', exact: true }).waitFor()
|
||||
const sidebar = page.locator('[data-slot="sidebar"]')
|
||||
const sidebarColumn = sidebar.locator('..')
|
||||
await expect.poll(async () => (await sidebarColumn.boundingBox())?.width).toBe(56)
|
||||
await sidebarColumn.evaluate((el) => {
|
||||
el.parentElement!.style.setProperty('--ds-transition-duration-slow', '100s')
|
||||
})
|
||||
await page.setViewportSize({ width: 767, height: 844 })
|
||||
await page.locator('[data-sidebar-drawer]').waitFor()
|
||||
const state = await sidebarColumn.evaluate(el => ({
|
||||
visibility: getComputedStyle(el).visibility,
|
||||
transitions: el.getAnimations().filter(animation => animation instanceof CSSTransition)
|
||||
.map(animation => animation.transitionProperty),
|
||||
}))
|
||||
expect(state).toEqual({ visibility: 'hidden', transitions: [] })
|
||||
await page.setViewportSize({ width: 768, height: 844 })
|
||||
await page.locator('[data-sidebar-drawer]').waitFor({ state: 'detached' })
|
||||
await assertCompactRail(sidebar)
|
||||
await page.setViewportSize({ width: 767, height: 844 })
|
||||
await page.locator('[data-sidebar-drawer]').waitFor()
|
||||
await page.getByRole('button', { name: 'Open sidebar', exact: true }).click()
|
||||
const drawer = page.getByRole('dialog', { name: 'Navigation', exact: true })
|
||||
await drawer.waitFor()
|
||||
expect(await sidebarColumn.evaluate(el => el.getAnimations().some(animation =>
|
||||
animation instanceof CSSTransition && animation.transitionProperty === 'transform'))).toBe(true)
|
||||
await sidebarColumn.evaluate((el) => {
|
||||
for (const animation of el.parentElement!.getAnimations({ subtree: true })) animation.finish()
|
||||
})
|
||||
await drawer.getByRole('button', { name: 'Collapse sidebar', exact: true }).click()
|
||||
expect(await sidebarColumn.evaluate(el => el.getAnimations().some(animation =>
|
||||
animation instanceof CSSTransition && animation.transitionProperty === 'transform'))).toBe(true)
|
||||
await sidebarColumn.evaluate((el) => {
|
||||
for (const animation of el.parentElement!.getAnimations({ subtree: true })) animation.finish()
|
||||
})
|
||||
await page.setViewportSize({ width: 768, height: 844 })
|
||||
await page.locator('[data-sidebar-drawer]').waitFor({ state: 'detached' })
|
||||
await assertCompactRail(sidebar)
|
||||
} finally {
|
||||
await browser.close()
|
||||
}
|
||||
} finally {
|
||||
await scaffold.close()
|
||||
}
|
||||
})
|
||||
|
||||
it('retains the closing slide when an expanded sidebar becomes a collapsed drawer', async () => {
|
||||
const scaffold = await launchWebScaffold({
|
||||
extraOverlayPath: fileURLToPath(new URL('./pin-browse-picker.overlay.yml', import.meta.url)),
|
||||
})
|
||||
try {
|
||||
const browser = await chromium.launch()
|
||||
try {
|
||||
const page = await browser.newPage({ viewport: { width: 1024, height: 844 }, locale: 'en-US' })
|
||||
await page.goto(scaffold.authenticatedUrl)
|
||||
await page.getByRole('button', { name: 'Collapse sidebar', exact: true }).waitFor()
|
||||
const sidebarColumn = page.locator('[data-slot="sidebar"]').locator('..')
|
||||
await expect.poll(async () => (await sidebarColumn.boundingBox())?.width).toBe(280)
|
||||
await sidebarColumn.evaluate((el) => {
|
||||
el.parentElement!.style.setProperty('--ds-transition-duration-slow', '100s')
|
||||
})
|
||||
await page.setViewportSize({ width: 767, height: 844 })
|
||||
await page.locator('[data-sidebar-drawer][data-sidebar-collapsed]').waitFor()
|
||||
expect(await sidebarColumn.evaluate(el => el.getAnimations().some(animation =>
|
||||
animation instanceof CSSTransition && animation.transitionProperty === 'transform'))).toBe(true)
|
||||
} finally {
|
||||
await browser.close()
|
||||
}
|
||||
} finally {
|
||||
await scaffold.close()
|
||||
}
|
||||
})
|
||||
|
||||
/** Sample the CSS fade at its midpoint without depending on the host's frame rate. */
|
||||
async function assertMaskFade(frame: Locator, from: number, to: number): Promise<void> {
|
||||
const sample = await frame.locator('[data-sidebar-mask]').evaluate((el) => {
|
||||
const fade = el.getAnimations().find(animation => animation instanceof CSSTransition && animation.transitionProperty === 'opacity')
|
||||
if (fade === undefined || !(fade.effect instanceof KeyframeEffect)) throw new Error('Drawer mask opacity transition is missing')
|
||||
fade.pause()
|
||||
fade.currentTime = Number(fade.effect.getComputedTiming().duration) / 2
|
||||
return {
|
||||
endpoints: fade.effect.getKeyframes().map(keyframe => Number(keyframe.opacity)),
|
||||
opacity: Number(getComputedStyle(el).opacity),
|
||||
}
|
||||
})
|
||||
expect(sample.endpoints).toEqual([from, to])
|
||||
expect(sample.opacity).toBeGreaterThan(0)
|
||||
expect(sample.opacity).toBeLessThan(1)
|
||||
await frame.evaluate((el) => {
|
||||
for (const animation of el.getAnimations({ subtree: true })) {
|
||||
if (animation instanceof CSSTransition) animation.finish()
|
||||
}
|
||||
el.style.removeProperty('--ds-transition-duration-slow')
|
||||
})
|
||||
}
|
||||
|
||||
/** Sample both width transitions on the same clock to detect detached sidebar controls. */
|
||||
async function assertFoldResize(toggle: Locator, from: number, to: number): Promise<void> {
|
||||
await expect.poll(() => toggle.evaluate((button, target) => {
|
||||
const frame = button.closest<HTMLElement>('[data-animating]')
|
||||
return frame !== null && parseFloat(frame.style.gridTemplateColumns) === target && frame.getAnimations().some(animation =>
|
||||
animation instanceof CSSTransition && animation.transitionProperty === 'grid-template-columns')
|
||||
}, to)).toBe(true)
|
||||
const sample = await toggle.evaluate((button) => {
|
||||
const frame = button.closest<HTMLElement>('[data-animating]')!
|
||||
const transitions = frame.getAnimations({ subtree: true }).filter((animation): animation is CSSTransition =>
|
||||
animation instanceof CSSTransition && ['grid-template-columns', 'width'].includes(animation.transitionProperty))
|
||||
const grid = transitions.find(animation => animation.transitionProperty === 'grid-template-columns')
|
||||
if (grid === undefined) throw new Error('Fold width transition is missing')
|
||||
const at = (progress: number) => {
|
||||
for (const transition of transitions) {
|
||||
transition.pause()
|
||||
transition.currentTime = Number(transition.effect!.getComputedTiming().duration) * progress
|
||||
}
|
||||
const width = parseFloat(getComputedStyle(frame).gridTemplateColumns)
|
||||
return { width, gap: frame.getBoundingClientRect().left + width - button.getBoundingClientRect().right }
|
||||
}
|
||||
const start = at(0)
|
||||
const middle = at(0.5)
|
||||
const end = at(1)
|
||||
for (const transition of transitions) transition.finish()
|
||||
frame.style.removeProperty('--ds-transition-duration-slow')
|
||||
return { endpoints: [start.width, end.width], start, middle }
|
||||
})
|
||||
expect(sample.endpoints).toEqual([from, to])
|
||||
expect(sample.middle.width).toBeGreaterThan(Math.min(from, to))
|
||||
expect(sample.middle.width).toBeLessThan(Math.max(from, to))
|
||||
expect(sample.middle.gap).toBeCloseTo(sample.start.gap, 1)
|
||||
}
|
||||
|
||||
it('overlays the conversation and closes after navigation without losing its sidebar content', async () => {
|
||||
const scaffold = await launchWebScaffold({
|
||||
extraOverlayPath: fileURLToPath(new URL('./pin-browse-picker.overlay.yml', import.meta.url)),
|
||||
})
|
||||
try {
|
||||
const workspace = await scaffold.ctx.workspaceRegistry.create(scaffold.workspaceCwd)
|
||||
const seed = await readFile(new URL('../../../snapshots/web/seeded-history/session.v3.jsonl', import.meta.url), 'utf8')
|
||||
const sessionId = await seedSession(scaffold, seed, 'session-c4421b66-252e-44c0-80ed-6e320abeba25')
|
||||
await workspace.attachSession(sessionId)
|
||||
await scaffold.ctx.sessionController.rename({ sessionId, title: 'Drawer navigation' })
|
||||
const browser = await chromium.launch()
|
||||
try {
|
||||
const page = await browser.newPage({ viewport: { width: 390, height: 844 }, hasTouch: true, locale: 'en-US' })
|
||||
const console = watchConsole(page)
|
||||
await page.goto(scaffold.authenticatedUrl)
|
||||
const opener = page.getByRole('button', { name: 'Open sidebar', exact: true })
|
||||
await opener.waitFor()
|
||||
const frame = page.locator('[data-sidebar-drawer]')
|
||||
await expect.poll(() => frame.getAttribute('data-sidebar-collapsed')).toBe('true')
|
||||
const sidebar = page.locator('[data-slot="sidebar"]')
|
||||
const original = await sidebar.elementHandle()
|
||||
const main = page.locator('[data-slot="main"]').locator('..')
|
||||
const closed = await main.boundingBox()
|
||||
// A long test-owned duration keeps the transition available until its
|
||||
// animation clock is sampled and finished explicitly.
|
||||
await frame.evaluate((el) => { el.style.setProperty('--ds-transition-duration-slow', '100s') })
|
||||
await opener.tap()
|
||||
const drawer = page.getByRole('dialog', { name: 'Navigation', exact: true })
|
||||
await drawer.waitFor()
|
||||
await assertMaskFade(frame, 0, 1)
|
||||
await expect.poll(() => main.boundingBox()).toEqual(closed)
|
||||
expect(closed?.width).toBe(390)
|
||||
expect(await main.evaluate(el => el.closest('[inert]') !== null)).toBe(true)
|
||||
expect(await page.locator('[data-side="sidebar"]').count()).toBe(0)
|
||||
const workspaceRow = drawer.locator('[data-row-key^="workspace:"]').first()
|
||||
const workspaceButtons = workspaceRow.getByRole('button', { includeHidden: true })
|
||||
expect(await workspaceRow.getAttribute('aria-expanded')).toBe('true')
|
||||
expect(await workspaceButtons.count()).toBe(2)
|
||||
for (const button of await workspaceButtons.all()) await button.waitFor()
|
||||
await workspaceRow.tap()
|
||||
expect(await workspaceRow.getAttribute('aria-expanded')).toBe('false')
|
||||
for (const button of await workspaceButtons.all()) expect(await button.isVisible()).toBe(false)
|
||||
await workspaceRow.tap()
|
||||
for (const button of await workspaceButtons.all()) await button.waitFor()
|
||||
await drawer.getByRole('button', { name: 'Search sessions', exact: true }).tap()
|
||||
const search = drawer.getByPlaceholder('Search session names')
|
||||
expect(await search.evaluate(el => getComputedStyle(el).fontSize)).toBe('16px')
|
||||
await drawer.getByRole('button', { name: 'Clear search', exact: true }).tap()
|
||||
await frame.evaluate((el) => { el.style.setProperty('--ds-transition-duration-slow', '100s') })
|
||||
await page.getByRole('treeitem').filter({ has: page.getByText('Drawer navigation', { exact: true }) }).tap()
|
||||
await assertMaskFade(frame, 1, 0)
|
||||
await drawer.waitFor({ state: 'hidden' })
|
||||
await page.getByRole('navigation', { name: 'Session hierarchy' }).getByText('Drawer navigation', { exact: true }).waitFor()
|
||||
await opener.click()
|
||||
const selectedRow = drawer.getByRole('treeitem', { selected: true })
|
||||
const more = selectedRow.getByRole('button', { name: 'Session actions for Drawer navigation', exact: true })
|
||||
await more.waitFor()
|
||||
expect(await selectedRow.getByRole('button', { name: 'Archive session', exact: true }).isVisible()).toBe(false)
|
||||
expect(await selectedRow.getByRole('button', { name: 'Pin session', exact: true }).isVisible()).toBe(false)
|
||||
expect(await selectedRow.getByRole('button').count()).toBe(1)
|
||||
await more.tap()
|
||||
const menu = page.getByRole('menu')
|
||||
await menu.getByRole('menuitem', { name: 'Archive session', exact: true }).waitFor()
|
||||
await menu.getByRole('menuitem', { name: 'Pin session', exact: true }).tap()
|
||||
await menu.waitFor({ state: 'hidden' })
|
||||
await selectedRow.getByLabel('Pinned', { exact: true }).waitFor()
|
||||
await more.tap()
|
||||
await menu.getByRole('menuitem', { name: 'Unpin session', exact: true }).tap()
|
||||
await menu.waitFor({ state: 'hidden' })
|
||||
await expect.poll(() => selectedRow.getByLabel('Pinned', { exact: true }).count()).toBe(0)
|
||||
await drawer.getByRole('button', { name: 'Plugins', exact: true }).tap()
|
||||
await drawer.waitFor({ state: 'hidden' })
|
||||
await page.locator('[data-plugin-panel]').waitFor()
|
||||
await opener.click()
|
||||
await drawer.waitFor()
|
||||
await page.touchscreen.tap(370, 420)
|
||||
await drawer.waitFor({ state: 'hidden' })
|
||||
await opener.click()
|
||||
await page.keyboard.press('Escape')
|
||||
await drawer.waitFor({ state: 'hidden' })
|
||||
expect(await opener.evaluate(el => el === document.activeElement)).toBe(true)
|
||||
expect(await sidebar.evaluate((el, previous) => el === previous, original)).toBe(true)
|
||||
await original?.dispose()
|
||||
|
||||
await page.setViewportSize({ width: 768, height: 844 })
|
||||
await expect.poll(() => frame.count()).toBe(0)
|
||||
await expect.poll(async () => Math.round((await main.boundingBox())!.width)).toBe(712)
|
||||
await page.setViewportSize({ width: 767, height: 844 })
|
||||
await expect.poll(() => frame.count()).toBe(1)
|
||||
|
||||
await page.emulateMedia({ reducedMotion: 'reduce' })
|
||||
await opener.tap()
|
||||
const mask = frame.locator('[data-sidebar-mask]')
|
||||
expect(await mask.evaluate(el => getComputedStyle(el).opacity)).toBe('1')
|
||||
expect(await mask.evaluate(el => el.getAnimations().length)).toBe(0)
|
||||
await drawer.getByRole('button', { name: 'Collapse sidebar', exact: true }).tap()
|
||||
expect(await mask.evaluate(el => getComputedStyle(el).opacity)).toBe('0')
|
||||
await page.emulateMedia({ reducedMotion: 'no-preference' })
|
||||
await expect.poll(async () => Math.round((await main.boundingBox())!.width)).toBe(767)
|
||||
expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBe(767)
|
||||
await page.evaluate(() => { document.documentElement.dataset.platform = 'darwin' })
|
||||
await expect.poll(() => main.evaluate(el => getComputedStyle(el).paddingTop)).toBe('0px')
|
||||
await page.evaluate(() => { delete document.documentElement.dataset.platform })
|
||||
await expect.poll(() => main.evaluate(el => getComputedStyle(el).paddingTop)).toBe('48px')
|
||||
|
||||
await page.setViewportSize({ width: 390, height: 844 })
|
||||
await drawer.waitFor({ state: 'hidden' })
|
||||
await opener.tap()
|
||||
await drawer.getByRole('button', { name: 'New session', exact: true }).last().tap()
|
||||
await drawer.waitFor({ state: 'hidden' })
|
||||
const home = page.locator('[data-phase="hero"]')
|
||||
await home.waitFor()
|
||||
const editor = home.locator('[contenteditable="true"]')
|
||||
await editor.tap()
|
||||
const homeEditorBox = await editor.boundingBox()
|
||||
// Chromium cannot raise a phone keyboard; simulate document panning
|
||||
// before the visual viewport publishes the matching offset.
|
||||
const restoreViewport = await page.evaluateHandle(() => {
|
||||
const viewport = window.visualViewport!
|
||||
const scrollY = Object.getOwnPropertyDescriptor(window, 'scrollY')!
|
||||
Object.defineProperty(window, 'scrollY', { configurable: true, value: 80 })
|
||||
Object.defineProperties(viewport, {
|
||||
height: { configurable: true, value: 360 },
|
||||
offsetTop: { configurable: true, value: 0 },
|
||||
})
|
||||
viewport.dispatchEvent(new Event('resize'))
|
||||
viewport.dispatchEvent(new Event('scroll'))
|
||||
window.dispatchEvent(new Event('scroll'))
|
||||
return () => {
|
||||
Object.defineProperty(window, 'scrollY', scrollY)
|
||||
Reflect.deleteProperty(viewport, 'height')
|
||||
Reflect.deleteProperty(viewport, 'offsetTop')
|
||||
window.dispatchEvent(new Event('scroll'))
|
||||
viewport.dispatchEvent(new Event('resize'))
|
||||
}
|
||||
})
|
||||
const root = page.locator('#root')
|
||||
await expect.poll(() => root.boundingBox()).toEqual({ x: 0, y: 0, width: 390, height: 844 })
|
||||
expect(await editor.boundingBox()).toEqual(homeEditorBox)
|
||||
await page.evaluate(() => {
|
||||
Object.defineProperty(window.visualViewport!, 'offsetTop', { configurable: true, value: 80 })
|
||||
window.visualViewport!.dispatchEvent(new Event('scroll'))
|
||||
})
|
||||
await expect.poll(() => root.boundingBox()).toEqual({ x: 0, y: 0, width: 390, height: 844 })
|
||||
await expect.poll(async () => (await main.boundingBox())?.height).toBe(844)
|
||||
await opener.tap()
|
||||
await expect.poll(async () => (await drawer.boundingBox())?.height).toBe(844)
|
||||
const searchWithKeyboard = drawer.getByPlaceholder('Search session names')
|
||||
await drawer.getByRole('button', { name: 'Search sessions', exact: true }).tap()
|
||||
await searchWithKeyboard.tap()
|
||||
await searchWithKeyboard.fill('retained search')
|
||||
await drawer.getByRole('button', { name: 'Account menu', exact: true }).tap()
|
||||
await page.getByRole('menuitem', { name: 'Settings', exact: true }).tap()
|
||||
const settings = page.getByRole('dialog', { name: 'Settings', exact: true })
|
||||
await settings.waitFor()
|
||||
const settingsBox = (await settings.boundingBox())!
|
||||
expect(settingsBox.x).toBeGreaterThanOrEqual(0)
|
||||
expect(settingsBox.y).toBeGreaterThanOrEqual(0)
|
||||
expect(settingsBox.x + settingsBox.width).toBeLessThanOrEqual(390)
|
||||
expect(settingsBox.y + settingsBox.height).toBeLessThanOrEqual(844)
|
||||
const closeSettings = settings.getByRole('button', { name: 'Close', exact: true })
|
||||
const closeBox = (await closeSettings.boundingBox())!
|
||||
expect(closeBox.y).toBeGreaterThanOrEqual(0)
|
||||
expect(closeBox.y + closeBox.height).toBeLessThanOrEqual(844)
|
||||
await closeSettings.tap()
|
||||
await settings.waitFor({ state: 'hidden' })
|
||||
await expect.poll(() => searchWithKeyboard.inputValue()).toBe('retained search')
|
||||
await restoreViewport.evaluate((restore) => { restore() })
|
||||
await restoreViewport.dispose()
|
||||
await expect.poll(() => root.boundingBox()).toEqual({ x: 0, y: 0, width: 390, height: 844 })
|
||||
await expect.poll(async () => (await drawer.boundingBox())?.height).toBe(844)
|
||||
await frame.evaluate((el) => { el.scrollLeft = 10 })
|
||||
expect(await frame.evaluate(el => el.scrollLeft)).toBe(0)
|
||||
await expect.poll(() => mask.boundingBox()).toEqual({ x: 0, y: 0, width: 390, height: 844 })
|
||||
await expect.poll(() => drawer.evaluate((el) => {
|
||||
const frame = el.closest('[data-sidebar-drawer]')!
|
||||
let column = el
|
||||
while (column.parentElement !== frame) column = column.parentElement!
|
||||
const { y, height } = column.getBoundingClientRect()
|
||||
return { y, height }
|
||||
})).toEqual({ y: 0, height: 844 })
|
||||
await expect.poll(async () => (await drawer.boundingBox())?.height).toBe(844)
|
||||
await page.setViewportSize({ width: 844, height: 390 })
|
||||
await expect.poll(async () => (await root.boundingBox())?.height).toBe(390)
|
||||
await expect.poll(() => frame.count()).toBe(0)
|
||||
await page.setViewportSize({ width: 390, height: 844 })
|
||||
await expect.poll(async () => (await root.boundingBox())?.height).toBe(844)
|
||||
await expect.poll(() => frame.count()).toBe(1)
|
||||
|
||||
const posture = await page.context().newCDPSession(page)
|
||||
try {
|
||||
await page.setViewportSize({ width: 951, height: 669 })
|
||||
await expect.poll(() => frame.count()).toBe(0)
|
||||
await posture.send('Emulation.setDevicePostureOverride', { posture: { type: 'folded' } })
|
||||
await opener.tap()
|
||||
await expect.poll(() => main.boundingBox()).toEqual({ x: 475.5, y: 0, width: 475.5, height: 669 })
|
||||
expect(await page.locator('[data-side="sidebar"]').count()).toBe(0)
|
||||
const foldSearch = page.getByPlaceholder('Search session names')
|
||||
if (!(await foldSearch.isVisible())) await page.getByRole('button', { name: 'Search sessions', exact: true }).tap()
|
||||
await foldSearch.fill('fold search')
|
||||
const wideFrame = page.locator('[data-rightbar-collapsed]')
|
||||
const collapseSidebar = page.getByRole('button', { name: 'Collapse sidebar', exact: true })
|
||||
await wideFrame.evaluate((el) => { el.style.setProperty('--ds-transition-duration-slow', '100s') })
|
||||
await posture.send('Emulation.clearDevicePostureOverride')
|
||||
await assertFoldResize(collapseSidebar, 475.5, 280)
|
||||
await expect.poll(() => main.boundingBox()).toEqual({ x: 280, y: 0, width: 671, height: 669 })
|
||||
expect(await page.locator('[data-side="sidebar"]').count()).toBe(1)
|
||||
expect(await foldSearch.evaluate(el => el === document.activeElement)).toBe(true)
|
||||
expect(await foldSearch.inputValue()).toBe('fold search')
|
||||
await wideFrame.evaluate((el) => { el.style.setProperty('--ds-transition-duration-slow', '100s') })
|
||||
await posture.send('Emulation.setDevicePostureOverride', { posture: { type: 'folded' } })
|
||||
await assertFoldResize(collapseSidebar, 280, 475.5)
|
||||
await expect.poll(async () => (await main.boundingBox())?.x).toBe(475.5)
|
||||
expect(await foldSearch.evaluate(el => el === document.activeElement)).toBe(true)
|
||||
await page.emulateMedia({ reducedMotion: 'reduce' })
|
||||
await posture.send('Emulation.clearDevicePostureOverride')
|
||||
await expect.poll(async () => (await main.boundingBox())?.x).toBe(280)
|
||||
// Scroll-driven text fades remain registered even with reduced motion.
|
||||
expect(await wideFrame.evaluate(el => el.getAnimations({ subtree: true })
|
||||
.filter(animation => animation.timeline === document.timeline).length)).toBe(0)
|
||||
await posture.send('Emulation.setDevicePostureOverride', { posture: { type: 'folded' } })
|
||||
await expect.poll(async () => (await main.boundingBox())?.x).toBe(475.5)
|
||||
await page.emulateMedia({ reducedMotion: 'no-preference' })
|
||||
await page.setViewportSize({ width: 669, height: 951 })
|
||||
await expect.poll(() => frame.getAttribute('data-sidebar-collapsed')).toBe('true')
|
||||
await drawer.waitFor({ state: 'hidden' })
|
||||
await opener.tap()
|
||||
await expect.poll(async () => (await drawer.boundingBox())?.width).toBe(280)
|
||||
expect(await main.boundingBox()).toEqual({ x: 0, y: 0, width: 669, height: 951 })
|
||||
} finally {
|
||||
await posture.detach()
|
||||
}
|
||||
|
||||
const pointerPage = await browser.newPage({ viewport: { width: 390, height: 844 }, locale: 'en-US' })
|
||||
try {
|
||||
await pointerPage.goto(scaffold.authenticatedUrl)
|
||||
await pointerPage.getByRole('button', { name: 'Open sidebar', exact: true }).click()
|
||||
expect(await pointerPage.getByPlaceholder('Search session names').evaluate(el => getComputedStyle(el).fontSize)).toBe('13px')
|
||||
const pointerWorkspace = pointerPage.locator('[data-row-key^="workspace:"]').first()
|
||||
const pointerWorkspaceButtons = pointerWorkspace.getByRole('button', { includeHidden: true })
|
||||
await pointerWorkspace.click()
|
||||
expect(await pointerWorkspace.getAttribute('aria-expanded')).toBe('false')
|
||||
const collapseSidebar = pointerPage.getByRole('button', { name: 'Collapse sidebar', exact: true })
|
||||
await collapseSidebar.focus()
|
||||
await collapseSidebar.hover()
|
||||
for (const button of await pointerWorkspaceButtons.all()) expect(await button.isVisible()).toBe(false)
|
||||
await pointerWorkspace.hover()
|
||||
for (const button of await pointerWorkspaceButtons.all()) await button.waitFor()
|
||||
await pointerWorkspace.click()
|
||||
for (const label of ['Collapse sidebar', 'View options']) {
|
||||
await pointerPage.getByRole('button', { name: label, exact: true }).hover()
|
||||
const tooltip = pointerPage.getByRole('tooltip').filter({ hasText: label })
|
||||
await tooltip.waitFor()
|
||||
expect(await tooltip.evaluate(el => el.closest('[data-slot="sidebar"]'))).toBeNull()
|
||||
const box = (await tooltip.boundingBox())!
|
||||
expect(box.x).toBeGreaterThanOrEqual(12)
|
||||
expect(box.x + box.width).toBeLessThanOrEqual(378)
|
||||
}
|
||||
const pointerRow = pointerPage.getByRole('treeitem').filter({ has: pointerPage.getByText('Drawer navigation', { exact: true }) })
|
||||
await pointerRow.click()
|
||||
await pointerPage.getByRole('dialog', { name: 'Navigation', exact: true }).waitFor({ state: 'hidden' })
|
||||
await pointerPage.getByRole('button', { name: 'Open sidebar', exact: true }).click()
|
||||
await pointerPage.getByRole('button', { name: 'Collapse sidebar', exact: true }).hover()
|
||||
await expect.poll(() => pointerRow.getByRole('button', { name: 'Session actions for Drawer navigation', exact: true }).isVisible()).toBe(false)
|
||||
await pointerRow.hover()
|
||||
for (const label of ['Session actions for Drawer navigation', 'Archive session', 'Pin session']) {
|
||||
await pointerRow.getByRole('button', { name: label, exact: true }).waitFor()
|
||||
}
|
||||
await pointerPage.getByRole('button', { name: 'Collapse sidebar', exact: true }).click()
|
||||
const pointerDrawer = pointerPage.getByRole('dialog', { name: 'Navigation', exact: true })
|
||||
await pointerDrawer.waitFor({ state: 'hidden' })
|
||||
await pointerPage.setViewportSize({ width: 767, height: 844 })
|
||||
await pointerPage.getByRole('button', { name: 'Open sidebar', exact: true }).press('Enter')
|
||||
await pointerDrawer.waitFor()
|
||||
expect(await pointerDrawer.evaluate(el => el.contains(document.activeElement))).toBe(true)
|
||||
await pointerPage.getByRole('button', { name: 'Search sessions', exact: true }).click()
|
||||
await expect.poll(() => pointerPage.getByPlaceholder('Search session names')
|
||||
.evaluate(el => el === document.activeElement)).toBe(true)
|
||||
await pointerPage.setViewportSize({ width: 768, height: 844 })
|
||||
await pointerPage.locator('[data-sidebar-drawer]').waitFor({ state: 'detached' })
|
||||
const pointerSidebar = pointerPage.locator('[data-slot="sidebar"]')
|
||||
await expect.poll(() => pointerSidebar.getByRole('button', { name: 'New session', exact: true }).count()).toBe(1)
|
||||
const railToggle = pointerSidebar.getByRole('button', { name: 'Open sidebar', exact: true })
|
||||
expect(await railToggle.evaluate(el => el === document.activeElement)).toBe(true)
|
||||
} finally {
|
||||
await pointerPage.close()
|
||||
}
|
||||
expect(console.pageErrors).toEqual([])
|
||||
expect(console.warnings).toEqual([])
|
||||
const result = [
|
||||
'390px: closed sidebar has no rail; main width 390px',
|
||||
'open: main geometry retained; background inert; no resize handle',
|
||||
'close: Session navigation, Plugins navigation, mask and Escape',
|
||||
'retained: sidebar DOM and opener focus',
|
||||
'768px: 56px rail; main width 712px; drawer focus transfers to the rail toggle',
|
||||
'breakpoint motion: collapsed rail hides immediately and returns compact without crossfades; expanded sidebar and explicit toggles retain their slides',
|
||||
'767px: hidden drawer; main width 767px; no page overflow',
|
||||
'global panels: browser top inset 48px; macOS keeps its existing clearance',
|
||||
'tooltips: sidebar and workspace controls escape the drawer and fit the viewport',
|
||||
'search input: 16px on touch; 13px with a fine pointer',
|
||||
'simulated keyboard: homepage and drawer retain 844px layout height without following the 360px visual viewport; Settings stays within the viewport',
|
||||
'keyboard close: layout height stays 844px; sidebar search retained; Settings close remains reachable',
|
||||
'shell coverage: drawer backing and mask cover 844px without synthetic safe-area insets',
|
||||
'rotation: 844x390 then 390x844 restores shell height and sidebar breakpoint',
|
||||
'folded landscape: 951px frame splits at 475.5px without a resize handle; unfolding restores 280px and search focus; portrait retains the drawer',
|
||||
'fold transitions: sidebar controls follow the divider in both directions; reduced motion changes width without animation',
|
||||
'drawer mask: opacity transitions from 0 to 1 on open and 1 to 0 on close',
|
||||
'reduced motion: drawer and mask settle without transitions',
|
||||
'touch selected Session: More remains visible; archive and pin stay in its menu; pin marker retained',
|
||||
'touch Workspace: actions appear only while expanded, including after folding the focused row',
|
||||
'fine pointer: folded Workspace actions remain available on hover',
|
||||
'fine pointer: selected Session actions stay hidden until hover, including at 390px',
|
||||
].join('\n')
|
||||
await compareOrRefreshGolden(fileURLToPath(new URL('./expected/sidebar-drawer.expected.md', import.meta.url)), result, webSnapshotMode())
|
||||
} finally {
|
||||
await browser.close()
|
||||
}
|
||||
} finally {
|
||||
await scaffold.close()
|
||||
}
|
||||
})
|
||||
|
||||
it('dismisses retained sidebar menus at the drawer breakpoint and preserves their rows', async () => {
|
||||
const scaffold = await launchWebScaffold({
|
||||
extraOverlayPath: fileURLToPath(new URL('./pin-browse-picker.overlay.yml', import.meta.url)),
|
||||
})
|
||||
try {
|
||||
const workspace = await scaffold.ctx.workspaceRegistry.create(scaffold.workspaceCwd)
|
||||
const seed = await readFile(new URL('../../../snapshots/web/seeded-history/session.v3.jsonl', import.meta.url), 'utf8')
|
||||
const sessionId = await seedSession(scaffold, seed, 'session-c4421b66-252e-44c0-80ed-6e320abeba25')
|
||||
await workspace.attachSession(sessionId)
|
||||
await scaffold.ctx.sessionController.rename({ sessionId, title: 'Menu regression' })
|
||||
const browser = await chromium.launch()
|
||||
try {
|
||||
const page = await browser.newPage({ viewport: { width: 1024, height: 844 }, locale: 'en-US' })
|
||||
await page.goto(scaffold.authenticatedUrl)
|
||||
const row = page.locator(`[data-row-key="session:${sessionId}"]`)
|
||||
await row.waitFor()
|
||||
const original = await row.elementHandle()
|
||||
for (const label of ['View options', 'Session actions for Menu regression']) {
|
||||
await page.setViewportSize({ width: 1024, height: 844 })
|
||||
await page.getByRole('button', { name: 'Collapse sidebar', exact: true }).waitFor()
|
||||
if (label.startsWith('Session')) await row.hover()
|
||||
await page.getByRole('button', { name: label, exact: true }).click()
|
||||
await page.getByRole('menu').waitFor()
|
||||
await page.setViewportSize({ width: 767, height: 844 })
|
||||
await page.getByRole('menu').waitFor({ state: 'hidden' })
|
||||
const opener = page.getByRole('button', { name: 'Open sidebar', exact: true })
|
||||
await expect.poll(() => opener.evaluate(element => element === document.activeElement)).toBe(true)
|
||||
await opener.click()
|
||||
await row.waitFor()
|
||||
expect(await row.evaluate((element, before) => element === before, original)).toBe(true)
|
||||
}
|
||||
await original?.dispose()
|
||||
await compareOrRefreshGolden(fileURLToPath(new URL('./expected/sidebar-menu-dismissal.expected.md', import.meta.url)), [
|
||||
'View options and Session menus close when the sidebar becomes an inert drawer.',
|
||||
'Focus returns to the visible sidebar opener; retained Session rows keep their DOM identity.',
|
||||
].join('\n'), webSnapshotMode())
|
||||
} finally { await browser.close() }
|
||||
} finally { await scaffold.close() }
|
||||
})
|
||||
|
||||
it('keeps drawer shortcuts and hit targets above fullscreen and floating right panels', async () => {
|
||||
const scaffold = await launchWebScaffold({
|
||||
extraOverlayPath: fileURLToPath(new URL('./pin-browse-picker.overlay.yml', import.meta.url)),
|
||||
})
|
||||
try {
|
||||
const workspace = await scaffold.ctx.workspaceRegistry.create(scaffold.workspaceCwd)
|
||||
const seed = await readFile(new URL('../../../snapshots/web/seeded-history/session.v3.jsonl', import.meta.url), 'utf8')
|
||||
const sessionId = await seedSession(scaffold, seed, 'session-c4421b66-252e-44c0-80ed-6e320abeba25')
|
||||
await workspace.attachSession(sessionId)
|
||||
await scaffold.ctx.sessionController.rename({ sessionId, title: 'Drawer overlay checks' })
|
||||
const browser = await chromium.launch()
|
||||
try {
|
||||
const page = await browser.newPage({ viewport: { width: 1280, height: 844 }, locale: 'en-US' })
|
||||
await page.addInitScript(() => { Object.defineProperty(navigator, 'platform', { value: 'MacIntel' }) })
|
||||
await page.goto(scaffold.authenticatedUrl)
|
||||
const row = page.getByRole('treeitem').filter({ has: page.getByText('Drawer overlay checks', { exact: true }) })
|
||||
await row.click()
|
||||
await page.locator('[data-sidebar-right-expand]').click()
|
||||
await page.locator('[data-sidebar-right-guide-entry="files"]').click()
|
||||
const panel = page.locator('[data-sidebar-right-open]')
|
||||
const primary = await page.evaluate(() => /mac/i.test(navigator.platform) ? 'Meta' : 'Control')
|
||||
const toggle = `${primary}+Alt+b`
|
||||
await row.hover()
|
||||
const card = page.getByRole('button', { name: 'Copy: Drawer overlay checks', exact: true })
|
||||
await card.waitFor()
|
||||
await page.setViewportSize({ width: 390, height: 844 })
|
||||
await card.waitFor({ state: 'hidden' })
|
||||
expect(await row.count()).toBe(1)
|
||||
const drawer = page.getByRole('dialog', { name: 'Navigation', exact: true })
|
||||
await expect.poll(() => panel.getAttribute('data-sidebar-right-panel')).toBe('fullscreen')
|
||||
const assertAboveRightPanel = async (coveredPoint?: { x: number; y: number }) => {
|
||||
await page.locator('[data-sidebar-drawer][data-sidebar-collapsed]').waitFor()
|
||||
await page.keyboard.press(toggle)
|
||||
await drawer.waitFor()
|
||||
const collapse = drawer.getByRole('button', { name: 'Collapse sidebar', exact: true })
|
||||
await expect.poll(() => collapse.evaluate(el => document.activeElement === el)).toBe(true)
|
||||
await expect.poll(() => drawer.evaluate((el) => {
|
||||
const box = el.getBoundingClientRect()
|
||||
return el.contains(document.elementFromPoint(box.left + 140, 30))
|
||||
})).toBe(true)
|
||||
expect(await page.evaluate(() => document.elementFromPoint(380, 420)?.hasAttribute('data-sidebar-mask'))).toBe(true)
|
||||
if (coveredPoint !== undefined) {
|
||||
expect(await drawer.evaluate((el, point) => {
|
||||
const hit = document.elementFromPoint(point.x, point.y)
|
||||
return el.contains(hit) || hit?.hasAttribute('data-sidebar-mask')
|
||||
}, coveredPoint)).toBe(true)
|
||||
}
|
||||
await page.keyboard.press(`${primary}+Alt+k`)
|
||||
await expect.poll(() => drawer.getByPlaceholder('Search session names').evaluate(el => document.activeElement === el)).toBe(true)
|
||||
await page.keyboard.press(toggle)
|
||||
await drawer.waitFor({ state: 'hidden' })
|
||||
expect(await panel.evaluate(el => el.closest('[inert]') === null)).toBe(true)
|
||||
}
|
||||
await page.keyboard.press(`${primary}+Alt+k`)
|
||||
await drawer.waitFor()
|
||||
await expect.poll(() => drawer.getByPlaceholder('Search session names')
|
||||
.evaluate(el => el === document.activeElement)).toBe(true)
|
||||
await page.keyboard.press(toggle)
|
||||
await drawer.waitFor({ state: 'hidden' })
|
||||
await assertAboveRightPanel()
|
||||
await page.setViewportSize({ width: 1280, height: 844 })
|
||||
await expect.poll(() => panel.getAttribute('data-sidebar-right-panel')).toBe('push')
|
||||
const tab = panel.locator('[data-dockkit-tab]').filter({ hasText: 'Files' })
|
||||
const bounds = (await tab.boundingBox())!
|
||||
await page.mouse.move(bounds.x + 6, bounds.y + bounds.height / 2)
|
||||
await page.mouse.down()
|
||||
try {
|
||||
await page.mouse.move(190, 400, { steps: 8 })
|
||||
} finally { await page.mouse.up() }
|
||||
const floating = page.locator('[data-dockkit-float]')
|
||||
await floating.waitFor()
|
||||
await page.setViewportSize({ width: 390, height: 844 })
|
||||
const box = (await floating.boundingBox())!
|
||||
expect(box.x).toBeLessThan(390)
|
||||
expect(box.x + box.width).toBeGreaterThan(0)
|
||||
const point = { x: (Math.max(0, box.x) + Math.min(390, box.x + box.width)) / 2, y: box.y + 40 }
|
||||
await expect.poll(() => floating.evaluate((el, at) => el.contains(document.elementFromPoint(at.x, at.y)), point)).toBe(true)
|
||||
await assertAboveRightPanel(point)
|
||||
} finally {
|
||||
await browser.close()
|
||||
}
|
||||
} finally {
|
||||
await scaffold.close()
|
||||
}
|
||||
})
|
||||
@@ -92,7 +92,7 @@ describe('web e2e: truncated composer statistics', () => {
|
||||
const cut = () => label.evaluate(element => element.scrollWidth > element.clientWidth)
|
||||
expect(await cut()).toBe(false)
|
||||
|
||||
await page.setViewportSize({ width: 390, height: 900 })
|
||||
await page.setViewportSize({ width: 334, height: 900 })
|
||||
await expect.poll(cut).toBe(true)
|
||||
await usagePill.hover()
|
||||
await expect.poll(() => tooltip.textContent()).toBe(USAGE_READING)
|
||||
|
||||
@@ -200,6 +200,23 @@ export function probeFreePort(): Promise<number> {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Open collapsed mobile navigation before using a sidebar action.
|
||||
* @param page - browser page with the mounted sidebar.
|
||||
* @param locale - current UI language.
|
||||
*/
|
||||
export async function revealNavigationDrawer(page: Page, locale: 'en' | 'zh' | 'ja'): Promise<void> {
|
||||
const drawer = await page.evaluate(() => window.innerWidth < 768
|
||||
&& !document.documentElement.hasAttribute('data-windows-titlebar'))
|
||||
await page.waitForFunction(expected => Boolean(document.querySelector('[data-sidebar-drawer]')) === expected, drawer)
|
||||
const closed = page.locator('[data-sidebar-drawer][data-sidebar-collapsed]')
|
||||
if (await closed.count() === 0) return
|
||||
await page.locator('[data-shell-leading]').getByRole('button', {
|
||||
name: { en: 'Open sidebar', zh: '打开侧边栏', ja: 'サイドバーを開く' }[locale], exact: true,
|
||||
}).click()
|
||||
await closed.waitFor({ state: 'detached' })
|
||||
}
|
||||
|
||||
/**
|
||||
* Drive the hero's workspace picker through the composed directory dialog
|
||||
* until the live composer unlocks. A fresh world has no Workspace, so the boot
|
||||
@@ -219,6 +236,7 @@ export function probeFreePort(): Promise<number> {
|
||||
*/
|
||||
export async function connectFreshWorkspace(page: Page, root: string, name = 'workspace'): Promise<void> {
|
||||
mkdirSync(join(root, name), { recursive: true })
|
||||
await revealNavigationDrawer(page, 'en')
|
||||
await page.getByRole('button', { name: 'Add workspace', exact: true }).click()
|
||||
const dialog = page.getByRole('dialog', { name: 'Select Workspace Directory' })
|
||||
await dialog.waitFor({ timeout: 10_000 })
|
||||
@@ -245,6 +263,7 @@ export async function connectFreshWorkspace(page: Page, root: string, name = 'wo
|
||||
*/
|
||||
export async function connectFreshWorkspaceZh(page: Page, root: string, name = 'workspace', modelAvailable = true): Promise<void> {
|
||||
mkdirSync(join(root, name), { recursive: true })
|
||||
await revealNavigationDrawer(page, 'zh')
|
||||
await page.getByRole('button', { name: '添加工作区', exact: true }).click()
|
||||
const dialog = page.getByRole('dialog', { name: '选择工作区目录' })
|
||||
await dialog.waitFor({ timeout: 10_000 })
|
||||
@@ -346,6 +365,14 @@ export function conversationContextKey(kind: string, id: string): string {
|
||||
*/
|
||||
export async function openSettings(page: Page, locale: 'en' | 'zh' | 'ja'): Promise<void> {
|
||||
const labels = { en: ['Account menu', 'Settings'], zh: ['账号菜单', '设置'], ja: ['アカウントメニュー', '設定'] } as const
|
||||
await page.getByRole('button', { name: labels[locale][0], exact: true }).click()
|
||||
const trigger = page.getByRole('button', {
|
||||
name: labels[locale][0], exact: true, includeHidden: true,
|
||||
})
|
||||
await trigger.waitFor({ state: 'attached' })
|
||||
await revealNavigationDrawer(page, locale)
|
||||
if (!await trigger.isVisible()) {
|
||||
await page.getByRole('button', { name: { en: 'Open sidebar', zh: '打开侧边栏', ja: 'サイドバーを開く' }[locale], exact: true }).click()
|
||||
}
|
||||
await trigger.click()
|
||||
await page.getByRole('menuitem', { name: labels[locale][1], exact: true }).click()
|
||||
}
|
||||
@@ -107,10 +107,10 @@ async function collectedRegions(page: Page, selector: string): Promise<Collected
|
||||
const hits = interactive
|
||||
? samples.filter(([x, y]) => {
|
||||
const top = document.elementFromPoint(x, y)
|
||||
// A pane's programmatic focus target also contains its window-drag strip.
|
||||
// The strip owns those pixels; controls inside it still need their own subtraction.
|
||||
const strip = top?.closest('[data-dockkit-strip][data-window-drag]')
|
||||
if (element.matches('[data-dockkit-pane][tabindex="-1"]')
|
||||
// Panes and the navigation dialog contain their own window-drag rows.
|
||||
// Those rows own their pixels; controls inside still subtract themselves.
|
||||
const strip = top?.closest('[data-window-drag]')
|
||||
if (element.matches('[data-dockkit-pane][tabindex="-1"], [data-shortcut-modal="sidebar"][role="dialog"]')
|
||||
&& strip != null && element.contains(strip)) return false
|
||||
return top !== null && (top === element || element.contains(top))
|
||||
})
|
||||
@@ -503,6 +503,32 @@ describe('web e2e: macOS window drag coverage', () => {
|
||||
}
|
||||
}, 120_000)
|
||||
|
||||
it('keeps the drawer titlebar draggable without swallowing its close button', async () => {
|
||||
const { page, tripwire } = await desktopPage()
|
||||
try {
|
||||
await page.setViewportSize({ width: 571, height: 696 })
|
||||
await page.locator('[data-sidebar-drawer][data-sidebar-collapsed]').waitFor()
|
||||
await page.locator('[data-shell-leading]').getByRole('button', { name: 'Open sidebar', exact: true }).click()
|
||||
const drawer = page.getByRole('dialog', { name: 'Navigation', exact: true })
|
||||
await drawer.waitFor()
|
||||
await settled(page)
|
||||
const toggle = drawer.getByRole('button', { name: 'Collapse sidebar', exact: true })
|
||||
const button = (await toggle.boundingBox())!
|
||||
const seat = await rectOf(page, '[data-shell-leading]')
|
||||
const regions = await collectedRegions(page, INTERACTIVE_SELECTOR)
|
||||
const y = button.y + button.height / 2
|
||||
expect(isDraggableAt(regions, seat.x + seat.width / 2, y), 'the inactive header controls behind the drawer').toBe(true)
|
||||
expect(isDraggableAt(regions, (seat.x + seat.width + button.x) / 2, y), 'the gap before the close button').toBe(true)
|
||||
expect(isDraggableAt(regions, button.x + button.width / 2, y), 'the close button').toBe(false)
|
||||
expect(swallowedBoxes(regions)).toEqual([])
|
||||
await toggle.click()
|
||||
await drawer.waitFor({ state: 'hidden' })
|
||||
expect(tripwire.pageErrors).toEqual([])
|
||||
} finally {
|
||||
await page.close()
|
||||
}
|
||||
})
|
||||
|
||||
it('keeps an entry page’s chrome row draggable', async () => {
|
||||
const { page, tripwire } = await desktopPage()
|
||||
try {
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
// this client-registered project must not also hold them (one program
|
||||
// cannot see both sides of the cordis Context merges).
|
||||
"exclude": [
|
||||
"tests/sidebar-drawer.e2e.ts",
|
||||
"tests/creation-recommendations.e2e.ts",
|
||||
"tests/plugin-recommendations.e2e.ts",
|
||||
"tests/japanese-plugin-metadata.e2e.ts",
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
en: 66a769ce60d49ff3
|
||||
zh: 7e0bfa7c598157fa
|
||||
/session-corpus-benchmarks/run:
|
||||
en: 2560e832041ae481
|
||||
zh: 2fbbff71135e52ab
|
||||
en: c770082e58aa8194
|
||||
zh: 339d659595a1f97d
|
||||
/session-corpus-benchmarks/measurements:
|
||||
en: c357c231c3bfb588
|
||||
zh: 3d901a2caccf2587
|
||||
|
||||
@@ -18,7 +18,7 @@ Measure the Web Host's Session list, content search, and fork over synthetic cor
|
||||
|
||||
From the repository root, build the libraries and workers with `pnpm run build:bench`, then run `pnpm exec vitest run --config vitest.bench.config.ts benchmarks/session-corpus/session-corpus.bench.ts`. Do not overlap timing runs with builds or other benchmarks. Seeding writes about 1.5 GB of Zstandard logs under a private temporary root, which the test removes after success or failure.
|
||||
|
||||
The test reports every fresh-process sample, the CPU model, available parallelism, platform, and Node version, and enforces median budgets. Its last case fails when the file, including seeding, exceeds five minutes. A failed worker reports its exit, signal, timeout, and stderr tail. The required benchmark lane discovers this file automatically.
|
||||
The test reports every fresh-process sample, the CPU model, available parallelism, platform, and Node version, and enforces median budgets. Its last case fails when the file, including seeding, exceeds five minutes. Fork workers use a fixed V8 heap limit; peak RSS still measures the whole process. A failed worker reports its exit, signal, timeout, and stderr tail. The required benchmark lane discovers this file automatically.
|
||||
|
||||
<a id="measurements"></a>
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
在仓库根目录使用 `pnpm run build:bench` 构建库和 worker,然后运行 `pnpm exec vitest run --config vitest.bench.config.ts benchmarks/session-corpus/session-corpus.bench.ts`。不要让计时运行与构建或其他基准重叠。播种过程会在私有临时根目录下写入约 1.5 GB 的 Zstandard 日志,测试成功或失败后都会删除该目录。
|
||||
|
||||
测试报告每个新进程样本、CPU 型号、可用并行度、平台和 Node 版本,并约束中位数预算。当整个文件(包括播种)超过五分钟时,最后一个用例失败。worker 失败时报告退出状态、信号、超时和 stderr 末尾。必需基准通道自动发现此文件。
|
||||
测试报告每个新进程样本、CPU 型号、可用并行度、平台和 Node 版本,并约束中位数预算。当整个文件(包括播种)超过五分钟时,最后一个用例失败。Fork worker 使用固定的 V8 堆上限;峰值 RSS 仍测量整个进程。worker 失败时报告退出状态、信号、超时和 stderr 末尾。必需基准通道自动发现此文件。
|
||||
|
||||
<a id="measurements"></a>
|
||||
|
||||
|
||||
@@ -29,6 +29,8 @@ const CORPUS = { search: 1_000, fork: 1_000, list: 3_000 } as const
|
||||
const FILE_LIMIT_MS = 300_000
|
||||
/** Per-child deadline: an endpoint slower than its budget still reports a measurement instead of a kill. */
|
||||
const WORKER_TIMEOUT_MS = FILE_LIMIT_MS
|
||||
/** Fixed old-space capacity makes fork RSS comparable across hosted V8 heap defaults. */
|
||||
const FORK_HEAP_LIMIT_MB = 512
|
||||
/** Fresh processes per list and fork-strata scenario; the median enforces each budget. */
|
||||
const ATTEMPTS = { list: 3, fork: 3 } as const
|
||||
/** Concurrent anchor-preparation processes; standard hosted runners have two CPUs. */
|
||||
@@ -119,7 +121,10 @@ function serialDeadline(workers: number): number {
|
||||
}
|
||||
|
||||
async function run<Report extends SessionCorpusReport>(args: readonly string[]): Promise<Report> {
|
||||
const outcome = await runBuiltBenchmarkWorker<Report>({ worker: WORKER, args, timeoutMs: WORKER_TIMEOUT_MS, exposeGc: true })
|
||||
const outcome = await runBuiltBenchmarkWorker<Report>({
|
||||
worker: WORKER, args, timeoutMs: WORKER_TIMEOUT_MS, exposeGc: true,
|
||||
...(args[1] === 'fork' ? { heapLimitMb: FORK_HEAP_LIMIT_MB } : {}),
|
||||
})
|
||||
if (outcome.report === undefined) {
|
||||
const stderr = outcome.stderr.trim().split('\n').slice(-20).join('\n')
|
||||
throw new Error(`session-corpus worker ${args[1] ?? ''} failed: exit=${String(outcome.exitCode)}, `
|
||||
|
||||
@@ -6,5 +6,5 @@
|
||||
en: 41d772192075e133
|
||||
zh: 5ef3da69b4de1d8a
|
||||
/capability-seams-and-core-services:
|
||||
en: fb590ba0e99cef86
|
||||
zh: 1acbf97138a4ec37
|
||||
en: 6dfe441b758583b2
|
||||
zh: fb28de0533f07432
|
||||
@@ -84,9 +84,10 @@ flowchart LR
|
||||
pkg_llm_replay["llm-replay"]
|
||||
pkg_agent_loop["agent-loop"]
|
||||
pkg_compaction_basic["compaction-basic"]
|
||||
pkg_session_log_deepseek["session-log-deepseek"]
|
||||
svc_sessionLogDeepSeek["ctx.sessionLogDeepSeek<br/>Session-log upload policy"]
|
||||
pkg_deepseek_llm_api_extensions["deepseek-llm-api-extensions"]
|
||||
svc_deepseekLlmApiExtensions["ctx.deepseekLlmApiExtensions<br/>Official DeepSeek request extensions"]
|
||||
pkg_session_log_deepseek["session-log-deepseek"]
|
||||
pkg_plugin_package_inventory_deepseek["plugin-package-inventory-deepseek"]
|
||||
pkg_token_meter["token-meter"]
|
||||
svc_tokenMeter["ctx.tokenMeter<br/>Replay token measurement"]
|
||||
@@ -422,6 +423,7 @@ flowchart LR
|
||||
pkg_schedule --> svc_schedule
|
||||
pkg_session --> svc_sessions
|
||||
pkg_session_log_deepseek --> svc_deepseekLlmApiExtensions
|
||||
pkg_session_log_deepseek --> svc_sessionLogDeepSeek
|
||||
pkg_session_persistence --> svc_sessionPersistence
|
||||
pkg_session_persistence_jsonl --> svc_sessionPersistence
|
||||
pkg_session_projection --> svc_sessionProjections
|
||||
@@ -672,6 +674,7 @@ flowchart LR
|
||||
| `ctx.attachments` | `seam` | [`attachment`](../packages/attachment/attachment) | [`attachment-local`](../packages/attachment/attachment-local) | [`api-session-controller`](../packages/api/session-controller), [`tool-fs`](../packages/fs/tool-fs), [`llm-pi-ai`](../packages/llm/llm-pi-ai), [`llm-deepseek`](../packages/llm/llm-deepseek) | - | The host commits accepted images before session events; provider adapters resolve authorized durable references into provider-native content. |
|
||||
| `ctx.fileUploads` | `core` | [`client-file-upload`](../packages/client/file-upload) | - | [`api-session-controller`](../packages/api/session-controller) | - | Owns streaming intake, durable storage, and staged receipt lifetime; the Session controller binds receipts to accepted submissions. |
|
||||
| `ctx.llm` | `seam` | [`llm`](../packages/llm/llm) | [`llm-deepseek`](../packages/llm/llm-deepseek), [`llm-pi-ai`](../packages/llm/llm-pi-ai), [`llm-replay`](../packages/test-support/llm-replay) | [`agent-loop`](../packages/core/agent-loop), [`compaction-basic`](../packages/compaction/compaction-basic) | - | Adapters register provider implementations; the loop and compaction call the provider-neutral stream service. |
|
||||
| `ctx.sessionLogDeepSeek` | `core` | [`session-log-deepseek`](../packages/session/session-log-deepseek) | - | - | - | Plugins register caller-owned exclusions before the canonical Session-log request contribution is prepared; unmatched requests use normal upload eligibility. |
|
||||
| `ctx.deepseekLlmApiExtensions` | `seam` | [`deepseek-llm-api-extensions`](../packages/llm/deepseek-llm-api-extensions) | [`session-log-deepseek`](../packages/session/session-log-deepseek), [`plugin-package-inventory-deepseek`](../packages/llm/plugin-package-inventory-deepseek) | [`llm-deepseek`](../packages/llm/llm-deepseek) | - | Plugins prepare independent top-level fields; the official adapter merges them and commits their delivery state after HTTP acceptance. |
|
||||
| `ctx.tokenMeter` | `core` | [`token-meter`](../packages/llm/token-meter) | - | [`compaction-basic`](../packages/compaction/compaction-basic) | - | Owns isolated per-session replay folds; pressure consumers share immutable revisioned measurements. |
|
||||
| `ctx.toolResultPruner` | `core` | [`compaction-tool-result-pruner`](../packages/compaction/compaction-tool-result-pruner) | - | [`compaction-basic`](../packages/compaction/compaction-basic) | - | Rewrites oversized current tool results through replayable single-node surface replacements before summary compaction. |
|
||||
|
||||
@@ -86,9 +86,10 @@ flowchart LR
|
||||
pkg_llm_replay["llm-replay"]
|
||||
pkg_agent_loop["agent-loop"]
|
||||
pkg_compaction_basic["compaction-basic"]
|
||||
pkg_session_log_deepseek["session-log-deepseek"]
|
||||
svc_sessionLogDeepSeek["ctx.sessionLogDeepSeek<br/>Session-log upload policy"]
|
||||
pkg_deepseek_llm_api_extensions["deepseek-llm-api-extensions"]
|
||||
svc_deepseekLlmApiExtensions["ctx.deepseekLlmApiExtensions<br/>Official DeepSeek request extensions"]
|
||||
pkg_session_log_deepseek["session-log-deepseek"]
|
||||
pkg_plugin_package_inventory_deepseek["plugin-package-inventory-deepseek"]
|
||||
pkg_token_meter["token-meter"]
|
||||
svc_tokenMeter["ctx.tokenMeter<br/>Replay token measurement"]
|
||||
@@ -424,6 +425,7 @@ flowchart LR
|
||||
pkg_schedule --> svc_schedule
|
||||
pkg_session --> svc_sessions
|
||||
pkg_session_log_deepseek --> svc_deepseekLlmApiExtensions
|
||||
pkg_session_log_deepseek --> svc_sessionLogDeepSeek
|
||||
pkg_session_persistence --> svc_sessionPersistence
|
||||
pkg_session_persistence_jsonl --> svc_sessionPersistence
|
||||
pkg_session_projection --> svc_sessionProjections
|
||||
@@ -674,6 +676,7 @@ flowchart LR
|
||||
| `ctx.attachments` | `seam` | [`attachment`](../packages/attachment/attachment) | [`attachment-local`](../packages/attachment/attachment-local) | [`api-session-controller`](../packages/api/session-controller), [`tool-fs`](../packages/fs/tool-fs), [`llm-pi-ai`](../packages/llm/llm-pi-ai), [`llm-deepseek`](../packages/llm/llm-deepseek) | - | 宿主会在会话事件之前提交已接受的图片;提供方适配器将已授权的持久引用解析为提供方原生内容。 |
|
||||
| `ctx.fileUploads` | `core` | [`client-file-upload`](../packages/client/file-upload) | - | [`api-session-controller`](../packages/api/session-controller) | - | 负责流式接收、持久存储和暂存回执生命周期;Session Controller 将回执绑定到已接受的提交。 |
|
||||
| `ctx.llm` | `seam` | [`llm`](../packages/llm/llm) | [`llm-deepseek`](../packages/llm/llm-deepseek), [`llm-pi-ai`](../packages/llm/llm-pi-ai), [`llm-replay`](../packages/test-support/llm-replay) | [`agent-loop`](../packages/core/agent-loop), [`compaction-basic`](../packages/compaction/compaction-basic) | - | 适配器注册提供方实现;agent loop(智能体循环)与压缩功能调用提供方无关的流服务。 |
|
||||
| `ctx.sessionLogDeepSeek` | `core` | [`session-log-deepseek`](../packages/session/session-log-deepseek) | - | - | - | 插件在准备权威 Session 日志请求贡献前注册归调用方所有的排除条件;没有条件匹配的请求应用普通上传资格判断。 |
|
||||
| `ctx.deepseekLlmApiExtensions` | `seam` | [`deepseek-llm-api-extensions`](../packages/llm/deepseek-llm-api-extensions) | [`session-log-deepseek`](../packages/session/session-log-deepseek), [`plugin-package-inventory-deepseek`](../packages/llm/plugin-package-inventory-deepseek) | [`llm-deepseek`](../packages/llm/llm-deepseek) | - | 插件准备彼此独立的顶层字段;官方适配器会合并这些字段,并在 HTTP 接受后提交其交付状态。 |
|
||||
| `ctx.tokenMeter` | `core` | [`token-meter`](../packages/llm/token-meter) | - | [`compaction-basic`](../packages/compaction/compaction-basic) | - | 拥有按会话隔离的回放折叠区;压力消费方共享不可变且带修订版本的测量结果。 |
|
||||
| `ctx.toolResultPruner` | `core` | [`compaction-tool-result-pruner`](../packages/compaction/compaction-tool-result-pruner) | - | [`compaction-basic`](../packages/compaction/compaction-basic) | - | 在摘要压缩前,通过可回放的单节点表层替换来改写过大的当前工具结果。 |
|
||||
|
||||
@@ -729,7 +729,7 @@ export interface Config {
|
||||
## `@deepseek-ai/dsh-compaction-basic`
|
||||
|
||||
- `inject`: `llm` · `tokenMeter` · `sessions`
|
||||
- `source`: [`packages/compaction/compaction-basic/src/types.ts:40`](../packages/compaction/compaction-basic/src/types.ts)
|
||||
- `source`: [`packages/compaction/compaction-basic/src/types.ts:46`](../packages/compaction/compaction-basic/src/types.ts)
|
||||
|
||||
```ts config-catalog
|
||||
/** Basic compaction configuration with an optional exact-target policy table. */
|
||||
@@ -1126,7 +1126,7 @@ export type Config = CuaConfig
|
||||
|
||||
## `@deepseek-ai/dsh-experimental-forge`
|
||||
|
||||
- `source`: [`packages/experimental/forge/src/types.ts:205`](../packages/experimental/forge/src/types.ts)
|
||||
- `source`: [`packages/experimental/forge/src/types.ts:230`](../packages/experimental/forge/src/types.ts)
|
||||
|
||||
```ts config-catalog
|
||||
/** Poll cadence and fetch deadline for watched change requests. */
|
||||
@@ -2997,7 +2997,7 @@ export interface JsonRpcConfig {
|
||||
|
||||
- `inject`: `deepseekLlmApiExtensions` · `sessions`
|
||||
- `refs`: `Volatile` (`@deepseek-ai/cordis`)
|
||||
- `source`: [`packages/session/session-log-deepseek/src/index.ts:39`](../packages/session/session-log-deepseek/src/index.ts)
|
||||
- `source`: [`packages/session/session-log-deepseek/src/index.ts:47`](../packages/session/session-log-deepseek/src/index.ts)
|
||||
|
||||
```ts config-catalog
|
||||
/** Session-log request contribution configuration. */
|
||||
|
||||
@@ -731,7 +731,7 @@ export interface Config {
|
||||
## `@deepseek-ai/dsh-compaction-basic`
|
||||
|
||||
- `inject`: `llm` · `tokenMeter` · `sessions`
|
||||
- `source`: [`packages/compaction/compaction-basic/src/types.ts:40`](../packages/compaction/compaction-basic/src/types.ts)
|
||||
- `source`: [`packages/compaction/compaction-basic/src/types.ts:46`](../packages/compaction/compaction-basic/src/types.ts)
|
||||
|
||||
```ts config-catalog
|
||||
/** Basic compaction configuration with an optional exact-target policy table. */
|
||||
@@ -1128,7 +1128,7 @@ export type Config = CuaConfig
|
||||
|
||||
## `@deepseek-ai/dsh-experimental-forge`
|
||||
|
||||
- `source`: [`packages/experimental/forge/src/types.ts:205`](../packages/experimental/forge/src/types.ts)
|
||||
- `source`: [`packages/experimental/forge/src/types.ts:230`](../packages/experimental/forge/src/types.ts)
|
||||
|
||||
```ts config-catalog
|
||||
/** Poll cadence and fetch deadline for watched change requests. */
|
||||
@@ -2999,7 +2999,7 @@ export interface JsonRpcConfig {
|
||||
|
||||
- `inject`: `deepseekLlmApiExtensions` · `sessions`
|
||||
- `refs`: `Volatile` (`@deepseek-ai/cordis`)
|
||||
- `source`: [`packages/session/session-log-deepseek/src/index.ts:39`](../packages/session/session-log-deepseek/src/index.ts)
|
||||
- `source`: [`packages/session/session-log-deepseek/src/index.ts:47`](../packages/session/session-log-deepseek/src/index.ts)
|
||||
|
||||
```ts config-catalog
|
||||
/** Session-log request contribution configuration. */
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
en: 1da81051addc4b47
|
||||
zh: 3e8d7cd3f8c1cdba
|
||||
/official-deepseek-llm-api-wire-extensions/request-headers:
|
||||
en: 740e92e903ecb594
|
||||
zh: f934d3c9e5c56bfe
|
||||
en: d3d6a2c8240b80e9
|
||||
zh: debf42ed01233728
|
||||
/official-deepseek-llm-api-wire-extensions/body-extension-transaction:
|
||||
en: 48001cfd1281a23b
|
||||
zh: d410530ae8aa2823
|
||||
@@ -18,8 +18,8 @@
|
||||
en: f89059050613f3e8
|
||||
zh: da5cf2a4eeb81b75
|
||||
/official-deepseek-llm-api-wire-extensions/dsh-session-log:
|
||||
en: de1a3f2c377d74e3
|
||||
zh: 7c803345f71117c5
|
||||
en: 0d033f72951e2920
|
||||
zh: 767efca0dc39ac03
|
||||
/official-deepseek-llm-api-wire-extensions/dsh-session-log/wire-session-header:
|
||||
en: ccd8fcd773df21c4
|
||||
zh: 7ea020068ad093ae
|
||||
|
||||
@@ -28,7 +28,7 @@ The [`DeepSeekLlmApiExtensionRegistry`](../packages/llm/deepseek-llm-api-extensi
|
||||
| `x-deepseek-harness-session-id` | Model requests carrying a Session id | The exact request `sessionId` string |
|
||||
| `x-deepseek-harness-compact` | Model requests whose purpose is `compaction` | The literal string `1` |
|
||||
|
||||
Credential failure happens before anonymous-user-id resolution, so an unauthorized request neither sends these headers nor creates the identity file. A direct request without a Session omits `x-deepseek-harness-session-id`. Session-title requests have no additional purpose header; the ordinary Session-id rule still applies when one carries a `sessionId`.
|
||||
Credential failure happens before anonymous-user-id resolution, so an unauthorized request neither sends these headers nor creates the identity file. A direct request without a Session omits `x-deepseek-harness-session-id`. Session-title and Auto review requests have no additional purpose header; the ordinary Session-id rule still applies when one carries a `sessionId`.
|
||||
|
||||
## Body-extension transaction
|
||||
|
||||
@@ -73,7 +73,7 @@ An enabled inventory with no qualifying entries sends `packages: []`; disabling
|
||||
|
||||
## `dsh_session_log`
|
||||
|
||||
[`@deepseek-ai/dsh-session-log-deepseek`](../packages/session/session-log-deepseek/README.md) contributes one contiguous suffix of the canonical Session log. The field is enabled by default. It applies to a request with a live Session and at least one event; a direct request, a stale Session id, or an empty log omits the field, as does a request whose first pending event alone exceeds `maxBytes` or cannot be serialized; a composition disables it with `enabled: false`. The examples below use logical Session format 2 only to illustrate the wire fields; they do not identify the [current writer format](session-format-status.md).
|
||||
[`@deepseek-ai/dsh-session-log-deepseek`](../packages/session/session-log-deepseek/README.md) contributes one contiguous suffix of the canonical Session log. The field is enabled by default. It applies to a request with a live Session and at least one event; a direct request, a stale Session id, an empty log, or a request matched by a registered upload exclusion omits the field, as does a request whose first pending event alone exceeds `maxBytes` or cannot be serialized; a composition disables it with `enabled: false`. The examples below use logical Session format 2 only to illustrate the wire fields; they do not identify the [current writer format](session-format-status.md).
|
||||
|
||||
```json
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
| `x-deepseek-harness-session-id` | 携带会话 id 的模型请求 | 确切的请求 `sessionId` 字符串 |
|
||||
| `x-deepseek-harness-compact` | 用途为 `compaction` 的模型请求 | 字面字符串 `1` |
|
||||
|
||||
凭据失败发生在解析匿名用户 id 之前,因此未授权请求既不会发送这些标头,也不会创建身份文件。没有会话的直接请求会省略 `x-deepseek-harness-session-id`。会话标题请求没有额外的用途标头;请求携带 `sessionId` 时,仍然适用普通的会话 id 规则。
|
||||
凭据失败发生在解析匿名用户 id 之前,因此未授权请求既不会发送这些标头,也不会创建身份文件。没有会话的直接请求会省略 `x-deepseek-harness-session-id`。会话标题请求和 Auto 审查请求没有额外的用途标头;请求携带 `sessionId` 时,仍然适用普通的会话 id 规则。
|
||||
|
||||
## 正文扩展事务
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
|
||||
## `dsh_session_log`
|
||||
|
||||
[`@deepseek-ai/dsh-session-log-deepseek`](../packages/session/session-log-deepseek/README.zh.md) 贡献权威会话日志的一段连续后缀。该字段默认启用。它适用于携带存活会话且至少存在一个事件的请求;直接请求、陈旧会话 id 或空日志会省略该字段,第一条待发事件本身超过 `maxBytes` 或无法序列化的请求也会省略该字段;组合可用 `enabled: false` 禁用它。下方示例使用逻辑 Session 格式 2 仅为说明协议字段,并不标识[当前写入格式](session-format-status.zh.md)。
|
||||
[`@deepseek-ai/dsh-session-log-deepseek`](../packages/session/session-log-deepseek/README.zh.md) 贡献权威会话日志的一段连续后缀。该字段默认启用。它适用于携带存活会话且至少存在一个事件的请求;直接请求、陈旧会话 id、空日志或命中已注册上传排除条件的请求会省略该字段,第一条待发事件本身超过 `maxBytes` 或无法序列化的请求也会省略该字段;组合可用 `enabled: false` 禁用它。下方示例使用逻辑 Session 格式 2 仅为说明协议字段,并不标识[当前写入格式](session-format-status.zh.md)。
|
||||
|
||||
```json
|
||||
{
|
||||
|
||||
@@ -186,14 +186,14 @@
|
||||
en: 6c6a27578dff5828
|
||||
zh: 9a5add2bc0df2d0a
|
||||
/session-persistence-event-catalog/events/session/session-title-llm-request-log-only:
|
||||
en: 50d9e29d3d2bfe52
|
||||
zh: 3ff1d959cf7776b9
|
||||
en: 59b02baa2be32ca0
|
||||
zh: 3637c99652ca89cf
|
||||
/session-persistence-event-catalog/events/session-log-deepseek:
|
||||
en: 7b827672c80aecdd
|
||||
zh: 7b827672c80aecdd
|
||||
/session-persistence-event-catalog/events/session-log-deepseek/session-log-deepseek-delivery-accepted-log-only:
|
||||
en: 4e9ce9182ec05808
|
||||
zh: 7f643a6756ec8f76
|
||||
en: a3e2059fcc540b64
|
||||
zh: cc9933fd677560f0
|
||||
/session-persistence-event-catalog/events/step:
|
||||
en: bd0dcbbc352b771a
|
||||
zh: bd0dcbbc352b771a
|
||||
@@ -1209,8 +1209,8 @@
|
||||
en: 1f9f610fa0e05abf
|
||||
zh: 11560710a1b871de
|
||||
/session-persistence-event-catalog/resolved-persistence-types/sessiontitlellmrequesteventdata:
|
||||
en: aed2a9c4310d2cb8
|
||||
zh: 5d96d69c322286ec
|
||||
en: 465fe144e60dd62f
|
||||
zh: 29e1029426106c3b
|
||||
/session-persistence-event-catalog/resolved-persistence-types/sessiontitlemodelidentity:
|
||||
en: 9531468264499498
|
||||
zh: 9da23c0ad2776563
|
||||
@@ -1932,8 +1932,8 @@
|
||||
en: 04b34b8ffe7e7764
|
||||
zh: a792d5371516fd9d
|
||||
/session-persistence-event-catalog/resolved-persistence-types/sessionformatversion-sessionid-throughseq:
|
||||
en: 8aaa02b06896492d
|
||||
zh: 4dd0e1ee40d8f22d
|
||||
en: 8063597183ef767f
|
||||
zh: b064698c54089f07
|
||||
/session-persistence-event-catalog/resolved-persistence-types/shadowedrange-shadowedseqs-shadowedtokencount:
|
||||
en: 7a2ab7b62244f43b
|
||||
zh: 1084e3f8876feebc
|
||||
|
||||
@@ -878,7 +878,7 @@ Source: [`packages/session/session-title/src/index.ts:77`](../packages/session/s
|
||||
|
||||
Types: [SessionTitleLlmRequestEventData](subsystems/session-title.md)
|
||||
|
||||
Source: [`packages/session/session-title-llm/src/index.ts:57`](../packages/session/session-title-llm/src/index.ts)
|
||||
Source: [`packages/session/session-title-llm/src/index.ts:63`](../packages/session/session-title-llm/src/index.ts)
|
||||
|
||||
### `session-log-deepseek/*`
|
||||
|
||||
@@ -898,7 +898,7 @@ Source: [`packages/session/session-title-llm/src/index.ts:57`](../packages/sessi
|
||||
}
|
||||
```
|
||||
|
||||
Source: [`packages/session/session-log-deepseek/src/types.ts:81`](../packages/session/session-log-deepseek/src/types.ts)
|
||||
Source: [`packages/session/session-log-deepseek/src/types.ts:96`](../packages/session/session-log-deepseek/src/types.ts)
|
||||
|
||||
### `step/*`
|
||||
|
||||
@@ -4709,7 +4709,7 @@ Sources: [`packages/session/session-title/src/types.ts:41`](../packages/session/
|
||||
|
||||
SHA-256: `7ff62f6599c083ceb5a0d7a8940ff85ba80dc1d7ddd6ba9339903e93f74cba54`
|
||||
|
||||
Sources: [`packages/session/session-title-llm/src/index.ts:37`](../packages/session/session-title-llm/src/index.ts)
|
||||
Sources: [`packages/session/session-title-llm/src/index.ts:43`](../packages/session/session-title-llm/src/index.ts)
|
||||
|
||||
| Property | Presence | Type |
|
||||
|---|---|---|
|
||||
@@ -7979,7 +7979,7 @@ Sources: [`packages/web/web-search-deepseek/src/provider.ts:64`](../packages/web
|
||||
|
||||
SHA-256: `8bb8c3751a6ce64b61aba1ec7ae798c00a5803c4d868a0430873216c6569ed52`
|
||||
|
||||
Sources: [`packages/session/session-log-deepseek/src/types.ts:81`](../packages/session/session-log-deepseek/src/types.ts)
|
||||
Sources: [`packages/session/session-log-deepseek/src/types.ts:96`](../packages/session/session-log-deepseek/src/types.ts)
|
||||
|
||||
| Property | Presence | Type |
|
||||
|---|---|---|
|
||||
|
||||
@@ -880,7 +880,7 @@ export type SessionEvent<T extends SessionEventType = SessionEventType> = {
|
||||
|
||||
类型:[SessionTitleLlmRequestEventData](subsystems/session-title.zh.md)
|
||||
|
||||
来源:[`packages/session/session-title-llm/src/index.ts:57`](../packages/session/session-title-llm/src/index.ts)
|
||||
来源:[`packages/session/session-title-llm/src/index.ts:63`](../packages/session/session-title-llm/src/index.ts)
|
||||
|
||||
### `session-log-deepseek/*`
|
||||
|
||||
@@ -900,7 +900,7 @@ export type SessionEvent<T extends SessionEventType = SessionEventType> = {
|
||||
}
|
||||
```
|
||||
|
||||
来源:[`packages/session/session-log-deepseek/src/types.ts:81`](../packages/session/session-log-deepseek/src/types.ts)
|
||||
来源:[`packages/session/session-log-deepseek/src/types.ts:96`](../packages/session/session-log-deepseek/src/types.ts)
|
||||
|
||||
### `step/*`
|
||||
|
||||
@@ -4711,7 +4711,7 @@ SHA-256: `b56f6a885da3dc394c69a3e3cc5c0cfc4da15601b63fda4989eee8f40efc5be4`
|
||||
|
||||
SHA-256: `7ff62f6599c083ceb5a0d7a8940ff85ba80dc1d7ddd6ba9339903e93f74cba54`
|
||||
|
||||
来源:[`packages/session/session-title-llm/src/index.ts:37`](../packages/session/session-title-llm/src/index.ts)
|
||||
来源:[`packages/session/session-title-llm/src/index.ts:43`](../packages/session/session-title-llm/src/index.ts)
|
||||
|
||||
| 属性 | 存在性 | 类型 |
|
||||
|---|---|---|
|
||||
@@ -7981,7 +7981,7 @@ SHA-256: `9a2a9029f8d7ede05336980d8342737557f487b913bfd28853d0ab5214600ab5`
|
||||
|
||||
SHA-256: `8bb8c3751a6ce64b61aba1ec7ae798c00a5803c4d868a0430873216c6569ed52`
|
||||
|
||||
来源:[`packages/session/session-log-deepseek/src/types.ts:81`](../packages/session/session-log-deepseek/src/types.ts)
|
||||
来源:[`packages/session/session-log-deepseek/src/types.ts:96`](../packages/session/session-log-deepseek/src/types.ts)
|
||||
|
||||
| 属性 | 存在性 | 类型 |
|
||||
|---|---|---|
|
||||
|
||||
Generated
+2
-2
@@ -380,7 +380,7 @@
|
||||
{"digest":"7f7fd5a6b0064f597534b29ff62ef26e786dffccf5e14f654a7d4fcea2c35f04","names":[],"sources":[]},
|
||||
{"digest":"7f9365bae9fcb73e1e34061a1acfe0422c1a5fd351848cace9bebbe806f28462","names":["packages/workflow/tool-workflow/src/types.ts#ToolWorkflowRunEndData"],"sources":["packages/workflow/tool-workflow/src/types.ts:36"]},
|
||||
{"digest":"7f959241c24128b4983b559984811861dc59774b85905c8fa57c6cb0148a3dbc","names":["packages/goal/goal/src/domain.ts#GoalMessageSource"],"sources":["packages/goal/goal/src/domain.ts:47"]},
|
||||
{"digest":"7ff62f6599c083ceb5a0d7a8940ff85ba80dc1d7ddd6ba9339903e93f74cba54","names":["packages/session/session-title-llm/src/index.ts#SessionTitleLlmRequestEventData"],"sources":["packages/session/session-title-llm/src/index.ts:37"]},
|
||||
{"digest":"7ff62f6599c083ceb5a0d7a8940ff85ba80dc1d7ddd6ba9339903e93f74cba54","names":["packages/session/session-title-llm/src/index.ts#SessionTitleLlmRequestEventData"],"sources":["packages/session/session-title-llm/src/index.ts:43"]},
|
||||
{"digest":"8064c03c87c357fd1575cb9395ce86e6dcbe2d275bf7717864a02cddf01827d5","names":["packages/llm/llm/src/types.ts#ContentBlock"],"sources":["packages/llm/llm/src/types.ts:157"]},
|
||||
{"digest":"80677c8c8b804189a0fde8aa70dd4ad7af8bb12dfd03027e8e023c8592c838bc","names":[],"sources":[]},
|
||||
{"digest":"8067b0d232c350f189738e60ee3c9939d46ca3b32b45db5525237b077893f649","names":[],"sources":[]},
|
||||
@@ -413,7 +413,7 @@
|
||||
{"digest":"8a9c990773f798eac10ca8878e6bcc531ee080bc589cac956730e462cc6a09ad","names":[],"sources":["packages/interaction/permission-presets/src/index.ts:53"]},
|
||||
{"digest":"8ad45ad053b4d89f8865c17cc9ff3b8748e86045f3f0fb816269a34af2619141","names":[],"sources":["packages/experimental/hook-protocol/src/types.ts:31"]},
|
||||
{"digest":"8af841fc9b265ade3441caf9fe40dd24db24226befba48150e6d0eeccc1389c3","names":[],"sources":[]},
|
||||
{"digest":"8bb8c3751a6ce64b61aba1ec7ae798c00a5803c4d868a0430873216c6569ed52","names":[],"sources":["packages/session/session-log-deepseek/src/types.ts:81"]},
|
||||
{"digest":"8bb8c3751a6ce64b61aba1ec7ae798c00a5803c4d868a0430873216c6569ed52","names":[],"sources":["packages/session/session-log-deepseek/src/types.ts:96"]},
|
||||
{"digest":"8c1c4f72755a78ea163523a46565316e36e9b644382eb48e6635c71a6f412dd2","names":[],"sources":[]},
|
||||
{"digest":"8c627d7a45fa406cea879a3922105e27ed4c3c7966e264afaf11ea7a330f2dd1","names":[],"sources":[]},
|
||||
{"digest":"8cdd3fdd295cee53035de16a1b23411716f75e9f994fe9510cac5d7fef605c76","names":[],"sources":[]},
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
en: 057db6d8bf356c0f
|
||||
zh: 1441b39e5142b0bf
|
||||
/core/repo-wide-type-patterns/the-map-derived-union-pattern:
|
||||
en: 84c039e929edb897
|
||||
zh: 84241bb993f23ef2
|
||||
en: 87a19311e2a97270
|
||||
zh: 8df92c72793e8275
|
||||
/core/repo-wide-type-patterns/branded-ids:
|
||||
en: 10f8ac0f97e7c54a
|
||||
zh: 75cd2311aabfe464
|
||||
|
||||
@@ -450,12 +450,13 @@ declare module '@deepseek-ai/dsh-llm' {
|
||||
}
|
||||
```
|
||||
|
||||
Five canonical maps use this pattern; a plugin author extends these:
|
||||
Six canonical maps use this pattern; a plugin author extends these:
|
||||
|
||||
| Map | Package | Derives | Catalog |
|
||||
|---|---|---|---|
|
||||
| `ContentBlockMap` | dsh-llm | `ContentBlock` | [llm-streaming.md](llm-streaming.md#content-blocks-and-messages) |
|
||||
| `MessageSourceMap` | dsh-llm | `MessageSource` | [llm-streaming.md](llm-streaming.md#content-blocks-and-messages) |
|
||||
| `LlmRequestPurposeMap` | dsh-llm | `LlmRequestPurpose` | [llm-streaming.md](llm-streaming.md#the-model-request-and-result) |
|
||||
| `FinishReasonMap` | dsh-llm | `FinishReason` | [llm-streaming.md](llm-streaming.md#the-model-request-and-result) |
|
||||
| `TurnEndReasonMap` | dsh-session | `TurnEndReason` | [session.md](session.md) |
|
||||
| `SessionEventMap` | dsh-session | `SessionEvent` | [session.md](session.md) |
|
||||
|
||||
@@ -460,12 +460,13 @@ declare module '@deepseek-ai/dsh-llm' {
|
||||
}
|
||||
```
|
||||
|
||||
五个规范 map 使用此模式;插件作者扩展它们:
|
||||
六个规范 map 使用此模式;插件作者扩展它们:
|
||||
|
||||
| Map | 包 | 派生 | 目录 |
|
||||
|---|---|---|---|
|
||||
| `ContentBlockMap` | dsh-llm | `ContentBlock` | [llm-streaming.md](llm-streaming.zh.md#content-blocks-and-messages) |
|
||||
| `MessageSourceMap` | dsh-llm | `MessageSource` | [llm-streaming.md](llm-streaming.zh.md#content-blocks-and-messages) |
|
||||
| `LlmRequestPurposeMap` | dsh-llm | `LlmRequestPurpose` | [llm-streaming.zh.md](llm-streaming.zh.md#the-model-request-and-result) |
|
||||
| `FinishReasonMap` | dsh-llm | `FinishReason` | [llm-streaming.md](llm-streaming.zh.md#the-model-request-and-result) |
|
||||
| `TurnEndReasonMap` | dsh-session | `TurnEndReason` | [session.md](session.zh.md) |
|
||||
| `SessionEventMap` | dsh-session | `SessionEvent` | [session.md](session.zh.md) |
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
en: 26ccfa2e342e3e67
|
||||
zh: fe6cc2a622757c48
|
||||
/forges/change-request-actions:
|
||||
en: 00e4490e416099d2
|
||||
zh: 5724d08b6ae230f7
|
||||
en: 87d2c81d9514267f
|
||||
zh: 1daf31c5b0127a1c
|
||||
/forges/session-bindings:
|
||||
en: 13dfd36f2166bba0
|
||||
zh: a369434f52f04d57
|
||||
|
||||
@@ -45,6 +45,8 @@ type ChangeRequestKey = Branded<'ChangeRequestKey'>
|
||||
interface ForgeProvider {
|
||||
/** Forge family name stored in every repository this provider returns. */
|
||||
readonly forge: string
|
||||
/** Publish a comment or completed review. Omission declares that this provider cannot write reviews. */
|
||||
submitReview?(ref: ChangeRequestRef, request: ForgeReviewRequest, signal: AbortSignal): Promise<ForgeReviewResult>
|
||||
/** Map a Git remote URL to its repository, or undefined when this provider does not serve it. */
|
||||
repositoryFromRemote(url: string): ForgeRepository | undefined
|
||||
/** Map a change request web URL to its reference, or undefined when this provider does not serve it. */
|
||||
@@ -246,6 +248,37 @@ interface ForgeActionFailure {
|
||||
}
|
||||
```
|
||||
|
||||
`ctx.forge.submitReview` delegates an explicit comment or completed review to the provider. A provider that omits this capability returns unsupported. Consumers retain pending drafts and reconcile unknown write outcomes before resubmitting.
|
||||
|
||||
```ts type-equiv
|
||||
/** One inline comment addressed to the old or new side of a pull request diff. */
|
||||
interface ForgeLineComment {
|
||||
readonly path: string
|
||||
readonly side: 'L' | 'R'
|
||||
readonly startLine: number
|
||||
readonly endLine: number
|
||||
readonly body: string
|
||||
}
|
||||
```
|
||||
|
||||
```ts type-equiv
|
||||
/** A single published comment or one completed review containing all pending comments. */
|
||||
type ForgeReviewRequest = {
|
||||
/** Commit the user reviewed; providers must check it before writing and address that commit explicitly. */
|
||||
readonly headSha: string
|
||||
} & (
|
||||
| { readonly kind: 'comment'; readonly comment: ForgeLineComment }
|
||||
| { readonly kind: 'review'; readonly event: 'comment' | 'approve' | 'request-changes'; readonly body: string; readonly comments: readonly ForgeLineComment[] }
|
||||
)
|
||||
```
|
||||
|
||||
```ts type-equiv
|
||||
/** Result of a review write; unknown outcomes must be checked on the host before another submission. */
|
||||
type ForgeReviewResult =
|
||||
| { readonly ok: true; readonly url: string }
|
||||
| { readonly ok: false; readonly code: 'unsupported' | 'stale' | 'failed' | 'unknown'; readonly message: string }
|
||||
```
|
||||
|
||||
## Session bindings
|
||||
|
||||
`ctx.forgeSession` derives each Session's bindings from its own log: `gh pr create` results bind the URLs they print, `gh pr view`, `gh pr edit`, and `gh pr checkout` calls bind the change request they act on, and `git push` results trigger head-branch discovery through `ctx.forge`; the panel also reports the branch its checkout tracks for the same discovery. Track, dismiss, and discovery actions are `plugin:forge-session/binding` records, which stay outside the model-visible conversation. The `forgeChangeRequests` projection's client view, which the Session summary carries, lists the bindings without their status. The [Session binding README](../../packages/experimental/forge-session/README.md#use-this-package) owns the recognition and discovery rules.
|
||||
@@ -744,6 +777,15 @@ async merge(ref: ChangeRequestRef, request: MergeRequest, signal: AbortSignal):
|
||||
*/
|
||||
async diff(ref: ChangeRequestRef, signal: AbortSignal): Promise<string | ForgeFailure>
|
||||
|
||||
/**
|
||||
* Publish one comment or a completed review, then refresh the watched status.
|
||||
* @param ref - change request served by a registered provider.
|
||||
* @param request - explicitly selected commit, comments, and review decision.
|
||||
* @param signal - request cancellation.
|
||||
* @returns a publication URL or a failure, including an unknown write outcome.
|
||||
*/
|
||||
async submitReview(ref: ChangeRequestRef, request: ForgeReviewRequest, signal: AbortSignal): Promise<ForgeReviewResult>
|
||||
|
||||
/**
|
||||
* Read the text of one file at a commit of a change request's repository.
|
||||
* @param ref - change request served by a registered provider.
|
||||
@@ -915,6 +957,16 @@ Serves the forge panel. Following a Session inspects the checkout of its current
|
||||
*/
|
||||
@Remote async changeRequestText(session: Session, url: string, commit: string, path: string, signal: AbortSignal): Promise<string>
|
||||
|
||||
/**
|
||||
* Publish a line comment or completed review for a visible Session binding.
|
||||
* @param session - Session retaining the change request.
|
||||
* @param url - visible binding URL.
|
||||
* @param request - reviewed head, ranges, plain text, and explicit review decision.
|
||||
* @param signal - request cancellation.
|
||||
* @returns confirmed publication or a typed failure; unknown outcomes require reconciliation on the host.
|
||||
*/
|
||||
@Remote async submitReview(session: Session, url: string, request: ForgeReviewRequest, signal: AbortSignal): Promise<ForgeReviewResult>
|
||||
|
||||
/**
|
||||
* Mark a draft change request of a Session ready for review; the change
|
||||
* request is polled again once the host answers.
|
||||
|
||||
@@ -45,6 +45,8 @@ type ChangeRequestKey = Branded<'ChangeRequestKey'>
|
||||
interface ForgeProvider {
|
||||
/** Forge family name stored in every repository this provider returns. */
|
||||
readonly forge: string
|
||||
/** Publish a comment or completed review. Omission declares that this provider cannot write reviews. */
|
||||
submitReview?(ref: ChangeRequestRef, request: ForgeReviewRequest, signal: AbortSignal): Promise<ForgeReviewResult>
|
||||
/** Map a Git remote URL to its repository, or undefined when this provider does not serve it. */
|
||||
repositoryFromRemote(url: string): ForgeRepository | undefined
|
||||
/** Map a change request web URL to its reference, or undefined when this provider does not serve it. */
|
||||
@@ -246,6 +248,37 @@ interface ForgeActionFailure {
|
||||
}
|
||||
```
|
||||
|
||||
`ctx.forge.submitReview` 将明确指定的评论或完整评审交给 provider;未实现此能力的 provider 返回不支持。消费者保存待提交草稿,并在再次提交前核对结果不明的写操作。
|
||||
|
||||
```ts type-equiv
|
||||
/** One inline comment addressed to the old or new side of a pull request diff. */
|
||||
interface ForgeLineComment {
|
||||
readonly path: string
|
||||
readonly side: 'L' | 'R'
|
||||
readonly startLine: number
|
||||
readonly endLine: number
|
||||
readonly body: string
|
||||
}
|
||||
```
|
||||
|
||||
```ts type-equiv
|
||||
/** A single published comment or one completed review containing all pending comments. */
|
||||
type ForgeReviewRequest = {
|
||||
/** Commit the user reviewed; providers must check it before writing and address that commit explicitly. */
|
||||
readonly headSha: string
|
||||
} & (
|
||||
| { readonly kind: 'comment'; readonly comment: ForgeLineComment }
|
||||
| { readonly kind: 'review'; readonly event: 'comment' | 'approve' | 'request-changes'; readonly body: string; readonly comments: readonly ForgeLineComment[] }
|
||||
)
|
||||
```
|
||||
|
||||
```ts type-equiv
|
||||
/** Result of a review write; unknown outcomes must be checked on the host before another submission. */
|
||||
type ForgeReviewResult =
|
||||
| { readonly ok: true; readonly url: string }
|
||||
| { readonly ok: false; readonly code: 'unsupported' | 'stale' | 'failed' | 'unknown'; readonly message: string }
|
||||
```
|
||||
|
||||
## Session 绑定
|
||||
|
||||
`ctx.forgeSession` 从每个 Session 自己的日志派生其绑定:`gh pr create` 的结果绑定其输出的 URL,`gh pr view`、`gh pr edit` 与 `gh pr checkout` 调用绑定它们所操作的变更请求,`git push` 的结果通过 `ctx.forge` 触发按 head 分支的发现;面板也会报告其检出所跟踪的分支,触发同样的发现。track、dismiss 与发现操作都是 `plugin:forge-session/binding` 插件记录,位于模型可见对话之外。`forgeChangeRequests` 投影的客户端视图随 Session 摘要下发,列出绑定但不含其状态。识别与发现规则见 [Session 绑定 README](../../packages/experimental/forge-session/README.zh.md#use-this-package)。
|
||||
@@ -744,6 +777,15 @@ async merge(ref: ChangeRequestRef, request: MergeRequest, signal: AbortSignal):
|
||||
*/
|
||||
async diff(ref: ChangeRequestRef, signal: AbortSignal): Promise<string | ForgeFailure>
|
||||
|
||||
/**
|
||||
* Publish one comment or a completed review, then refresh the watched status.
|
||||
* @param ref - change request served by a registered provider.
|
||||
* @param request - explicitly selected commit, comments, and review decision.
|
||||
* @param signal - request cancellation.
|
||||
* @returns a publication URL or a failure, including an unknown write outcome.
|
||||
*/
|
||||
async submitReview(ref: ChangeRequestRef, request: ForgeReviewRequest, signal: AbortSignal): Promise<ForgeReviewResult>
|
||||
|
||||
/**
|
||||
* Read the text of one file at a commit of a change request's repository.
|
||||
* @param ref - change request served by a registered provider.
|
||||
@@ -915,6 +957,16 @@ Serves the forge panel. Following a Session inspects the checkout of its current
|
||||
*/
|
||||
@Remote async changeRequestText(session: Session, url: string, commit: string, path: string, signal: AbortSignal): Promise<string>
|
||||
|
||||
/**
|
||||
* Publish a line comment or completed review for a visible Session binding.
|
||||
* @param session - Session retaining the change request.
|
||||
* @param url - visible binding URL.
|
||||
* @param request - reviewed head, ranges, plain text, and explicit review decision.
|
||||
* @param signal - request cancellation.
|
||||
* @returns confirmed publication or a typed failure; unknown outcomes require reconciliation on the host.
|
||||
*/
|
||||
@Remote async submitReview(session: Session, url: string, request: ForgeReviewRequest, signal: AbortSignal): Promise<ForgeReviewResult>
|
||||
|
||||
/**
|
||||
* Mark a draft change request of a Session ready for review; the change
|
||||
* request is polled again once the host answers.
|
||||
|
||||
@@ -642,8 +642,21 @@ type RequestMessage = Message | RequestUserInput
|
||||
```
|
||||
|
||||
```ts type-equiv
|
||||
/** A single model request, fully assembled. */
|
||||
interface GenerateOptions {
|
||||
/** Auxiliary request purposes declared by their producer packages. */
|
||||
interface LlmRequestPurposeMap {}
|
||||
```
|
||||
|
||||
```ts type-equiv
|
||||
/** Declared auxiliary request purpose; ordinary conversation requests leave it absent. */
|
||||
type LlmRequestPurpose = Extract<keyof LlmRequestPurposeMap, string>
|
||||
```
|
||||
|
||||
```ts type-equiv
|
||||
/**
|
||||
* A single model request, fully assembled.
|
||||
* @typeParam Purpose - declared purpose keys for callers; forwarding adapters may accept `string`.
|
||||
*/
|
||||
interface GenerateOptions<Purpose extends string = LlmRequestPurpose> {
|
||||
/** Registered provider route selecting the adapter instance. */
|
||||
provider: string
|
||||
model: string
|
||||
@@ -684,7 +697,7 @@ interface GenerateOptions {
|
||||
* map the purpose to model-hidden transport metadata. Ordinary conversation
|
||||
* requests leave it unset.
|
||||
*/
|
||||
purpose?: 'compaction' | 'session-title'
|
||||
purpose?: Purpose
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -648,8 +648,21 @@ type RequestMessage = Message | RequestUserInput
|
||||
```
|
||||
|
||||
```ts type-equiv
|
||||
/** A single model request, fully assembled. */
|
||||
interface GenerateOptions {
|
||||
/** Auxiliary request purposes declared by their producer packages. */
|
||||
interface LlmRequestPurposeMap {}
|
||||
```
|
||||
|
||||
```ts type-equiv
|
||||
/** Declared auxiliary request purpose; ordinary conversation requests leave it absent. */
|
||||
type LlmRequestPurpose = Extract<keyof LlmRequestPurposeMap, string>
|
||||
```
|
||||
|
||||
```ts type-equiv
|
||||
/**
|
||||
* A single model request, fully assembled.
|
||||
* @typeParam Purpose - declared purpose keys for callers; forwarding adapters may accept `string`.
|
||||
*/
|
||||
interface GenerateOptions<Purpose extends string = LlmRequestPurpose> {
|
||||
/** Registered provider route selecting the adapter instance. */
|
||||
provider: string
|
||||
model: string
|
||||
@@ -690,7 +703,7 @@ interface GenerateOptions {
|
||||
* map the purpose to model-hidden transport metadata. Ordinary conversation
|
||||
* requests leave it unset.
|
||||
*/
|
||||
purpose?: 'compaction' | 'session-title'
|
||||
purpose?: Purpose
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -68,3 +68,6 @@
|
||||
/sessions/remote-catalog-and-workspace-opening:
|
||||
en: dd27307e0d7c893c
|
||||
zh: b77d2a749b7b641c
|
||||
/sessions/session-log-upload-exclusions:
|
||||
en: cfe3323aade972be
|
||||
zh: 8423b490c47c5013
|
||||
@@ -817,6 +817,29 @@ The backends that consume this contract are on [persistence.md](persistence.md).
|
||||
|
||||
The optional `application` selects a registered file handler without changing the system default; `workspacePathApplications({ path })` returns current handlers, names, icons, and default selection after Host path verification.
|
||||
|
||||
## Session-log upload exclusions
|
||||
|
||||
`ctx.sessionLogDeepSeek.registerExclusion()` registers a caller-owned predicate over `SessionLogUploadRequest`. Any match omits the log contribution and its acceptance callback before reading Session events. No match preserves normal upload eligibility. The [package README](../../packages/session/session-log-deepseek/README.md#upload-exclusions) defines failure and disposal behavior.
|
||||
|
||||
```ts type-equiv
|
||||
/** Request identity inspected before preparing a Session-log contribution. */
|
||||
interface SessionLogUploadRequest {
|
||||
/** Live Session whose canonical log would be contributed. */
|
||||
readonly sessionId: SessionId
|
||||
/** Auxiliary request classification; absent for ordinary conversation requests. */
|
||||
readonly purpose?: string
|
||||
}
|
||||
```
|
||||
|
||||
```ts type-equiv
|
||||
/**
|
||||
* Synchronous, side-effect-free upload exclusion owned by its registering plugin.
|
||||
* @param request - request identity; the predicate must not mutate it.
|
||||
* @returns `true` to omit the log field and acceptance callback, or `false` to keep checking eligibility.
|
||||
*/
|
||||
type SessionLogUploadExclusion = (request: SessionLogUploadRequest) => boolean
|
||||
```
|
||||
|
||||
<!-- BEGIN GENERATED cordis-surface (gen-cordis-catalog.ts) — do not edit between markers -->
|
||||
|
||||
<a id="cordis-surface"></a>
|
||||
@@ -1035,6 +1058,26 @@ Types: [SessionId](core.md) · [SessionSearchRequest](session-query.md)
|
||||
|
||||
Source: [`packages/api/session-controller/src/index.ts`](../../packages/api/session-controller/src/index.ts)
|
||||
|
||||
<a id="ctxsessionlogdeepseek--sessionlogdeepseekservice"></a>
|
||||
|
||||
### `ctx.sessionLogDeepSeek` — `SessionLogDeepSeekService`
|
||||
|
||||
Incremental Session-log contributor with caller-owned upload exclusions.
|
||||
|
||||
```ts cordis-catalog
|
||||
/**
|
||||
* Exclude matching requests before reading or preparing their log contribution.
|
||||
* Any matching rule suppresses both the field and its acceptance callback. With
|
||||
* no matching rules, normal upload eligibility applies. A throwing rule fails
|
||||
* this contribution; the request-extension registry omits it and reports the error.
|
||||
* @param exclude - synchronous, side-effect-free predicate; `true` skips this upload.
|
||||
* @returns effect disposer that removes this registration when called or when the caller unloads.
|
||||
*/
|
||||
registerExclusion(exclude: SessionLogUploadExclusion): () => Promise<void>
|
||||
```
|
||||
|
||||
Source: [`packages/session/session-log-deepseek/src/index.ts`](../../packages/session/session-log-deepseek/src/index.ts)
|
||||
|
||||
<a id="ctxsessions--sessionstore"></a>
|
||||
|
||||
### `ctx.sessions` — `SessionStore`
|
||||
|
||||
@@ -821,6 +821,29 @@ interface PluginRecord {
|
||||
|
||||
可选的 `application` 指定文件关联应用,不修改系统默认值;`workspacePathApplications({ path })` 在校验 Host 路径后返回当前关联应用、名称、图标和默认项。
|
||||
|
||||
## Session 日志上传排除条件
|
||||
|
||||
`ctx.sessionLogDeepSeek.registerExclusion()` 注册归调用方所有的判断函数,输入为 `SessionLogUploadRequest`。任意条件匹配时,在读取 Session 事件前省略日志贡献与接受回调。没有条件匹配时保留普通上传资格判断。[包 README](../../packages/session/session-log-deepseek/README.zh.md#upload-exclusions) 定义失败与释放行为。
|
||||
|
||||
```ts type-equiv
|
||||
/** Request identity inspected before preparing a Session-log contribution. */
|
||||
interface SessionLogUploadRequest {
|
||||
/** Live Session whose canonical log would be contributed. */
|
||||
readonly sessionId: SessionId
|
||||
/** Auxiliary request classification; absent for ordinary conversation requests. */
|
||||
readonly purpose?: string
|
||||
}
|
||||
```
|
||||
|
||||
```ts type-equiv
|
||||
/**
|
||||
* Synchronous, side-effect-free upload exclusion owned by its registering plugin.
|
||||
* @param request - request identity; the predicate must not mutate it.
|
||||
* @returns `true` to omit the log field and acceptance callback, or `false` to keep checking eligibility.
|
||||
*/
|
||||
type SessionLogUploadExclusion = (request: SessionLogUploadRequest) => boolean
|
||||
```
|
||||
|
||||
<!-- BEGIN GENERATED cordis-surface (gen-cordis-catalog.ts) — do not edit between markers -->
|
||||
|
||||
<a id="cordis-surface"></a>
|
||||
@@ -1039,6 +1062,26 @@ Types: [SessionId](core.zh.md) · [SessionSearchRequest](session-query.zh.md)
|
||||
|
||||
Source: [`packages/api/session-controller/src/index.ts`](../../packages/api/session-controller/src/index.ts)
|
||||
|
||||
<a id="ctxsessionlogdeepseek--sessionlogdeepseekservice"></a>
|
||||
|
||||
### `ctx.sessionLogDeepSeek` — `SessionLogDeepSeekService`
|
||||
|
||||
Incremental Session-log contributor with caller-owned upload exclusions.
|
||||
|
||||
```ts cordis-catalog
|
||||
/**
|
||||
* Exclude matching requests before reading or preparing their log contribution.
|
||||
* Any matching rule suppresses both the field and its acceptance callback. With
|
||||
* no matching rules, normal upload eligibility applies. A throwing rule fails
|
||||
* this contribution; the request-extension registry omits it and reports the error.
|
||||
* @param exclude - synchronous, side-effect-free predicate; `true` skips this upload.
|
||||
* @returns effect disposer that removes this registration when called or when the caller unloads.
|
||||
*/
|
||||
registerExclusion(exclude: SessionLogUploadExclusion): () => Promise<void>
|
||||
```
|
||||
|
||||
Source: [`packages/session/session-log-deepseek/src/index.ts`](../../packages/session/session-log-deepseek/src/index.ts)
|
||||
|
||||
<a id="ctxsessions--sessionstore"></a>
|
||||
|
||||
### `ctx.sessions` — `SessionStore`
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
# Bilingual-pair consistency record for guide.md (docs/i18n/README.md): per heading
|
||||
# section, a hash of its English and Chinese blocks outside code blocks and generated regions.
|
||||
# After editing either side, bring the other along and re-record with:
|
||||
# pnpm run verify-translation-pairing --write docs/upgrade-guide/v0.2.2-alpha.2/llm-request-purpose-declarations/guide.md
|
||||
/:
|
||||
en: 0a5cfa851101f3e9
|
||||
zh: 1c8e0e437718d4e2
|
||||
/declare-auxiliary-llm-request-purposes:
|
||||
en: 5d5e1b6cb5b9c95e
|
||||
zh: 11cf31babb07da28
|
||||
/declare-auxiliary-llm-request-purposes/change:
|
||||
en: 0682a43eb52792fd
|
||||
zh: 954b186cc66fdb08
|
||||
/declare-auxiliary-llm-request-purposes/migration:
|
||||
en: eae671d1e185ecbf
|
||||
zh: c042a276a1a7ad17
|
||||
@@ -0,0 +1,29 @@
|
||||
---
|
||||
kind: upgrade-guide
|
||||
description: "Auxiliary LLM request purposes require producer-owned type declarations instead of a shared fixed union."
|
||||
---
|
||||
|
||||
# Declare auxiliary LLM request purposes
|
||||
|
||||
English | [中文](guide.zh.md)
|
||||
|
||||
## Change
|
||||
|
||||
`GenerateOptions.purpose` derives from the declaration-mergeable `LlmRequestPurposeMap` exported by `@deepseek-ai/dsh-llm/types`. The shared package no longer declares `compaction` or `session-title`. Plugins that construct auxiliary requests must load the producer's declarations or declare their own purpose. Existing runtime purpose strings keep their meaning.
|
||||
|
||||
## Migration
|
||||
|
||||
1. Import `@deepseek-ai/dsh-compaction-basic` for direct compaction requests, or `@deepseek-ai/dsh-session-title-llm` for title requests, using a type-only import when only the declaration is needed.
|
||||
2. For a plugin-owned purpose, augment `LlmRequestPurposeMap` from the plugin's public type entry. Map the purpose key to `true`:
|
||||
|
||||
```ts
|
||||
import type {} from '@deepseek-ai/dsh-llm/types'
|
||||
|
||||
declare module '@deepseek-ai/dsh-llm/types' {
|
||||
interface LlmRequestPurposeMap {
|
||||
'my-plugin-purpose': true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
3. Compile the plugin against the new package declarations. Confirm that its request accepts the declared purpose and rejects an undeclared key.
|
||||
@@ -0,0 +1,29 @@
|
||||
---
|
||||
kind: upgrade-guide
|
||||
description: "辅助 LLM 请求用途改为生产方拥有的类型声明,不再使用共享固定联合。"
|
||||
---
|
||||
|
||||
# 声明辅助 LLM 请求用途
|
||||
|
||||
[English](guide.md) | 中文
|
||||
|
||||
## 变更
|
||||
|
||||
`GenerateOptions.purpose` 由 `@deepseek-ai/dsh-llm/types` 导出的可声明合并的 `LlmRequestPurposeMap` 派生。共享包不再声明 `compaction` 或 `session-title`。构造辅助请求的插件必须加载生产方的声明,或声明自己的用途。现有运行时用途字符串保持原有含义。
|
||||
|
||||
## 迁移
|
||||
|
||||
1. 直接构造压缩请求时导入 `@deepseek-ai/dsh-compaction-basic`,构造标题请求时导入 `@deepseek-ai/dsh-session-title-llm`;只需要声明时使用仅类型导入。
|
||||
2. 对插件拥有的用途,在插件公开类型入口中扩展 `LlmRequestPurposeMap`,将用途键映射到 `true`:
|
||||
|
||||
```ts
|
||||
import type {} from '@deepseek-ai/dsh-llm/types'
|
||||
|
||||
declare module '@deepseek-ai/dsh-llm/types' {
|
||||
interface LlmRequestPurposeMap {
|
||||
'my-plugin-purpose': true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
3. 使用新包的声明编译插件,确认请求接受已声明用途,并拒绝未声明的键。
|
||||
@@ -18,8 +18,8 @@
|
||||
en: 718f52cfce426009
|
||||
zh: e8282e2e3713d242
|
||||
/deepseek-ai-dsh-client-ui-dockkit/embedding-it:
|
||||
en: 87fab28e0608044e
|
||||
zh: 2d5f80a367f1852b
|
||||
en: 53bbabeb910c6f77
|
||||
zh: 51fb4f8fb78cfd02
|
||||
/deepseek-ai-dsh-client-ui-dockkit/interaction-rules-worth-keeping:
|
||||
en: cf2d00ce2b7d5719
|
||||
zh: 5510420f8872e23a
|
||||
|
||||
@@ -60,6 +60,8 @@ Everything host-specific arrives through props:
|
||||
|
||||
`dropZones="horizontal"` offers two half-pane hints; once budget or width forbids another split, the whole body accepts a move. A hint is a dashed card inset 8px inside its region, showing the zone's glyph and `labels.dropZone[zone]`; the preview layer covers all tab-body content, while the card under the pointer takes the accent and its neighbour stays a quiet outline. `minPaneFraction` sets the preview minimum, and `planResizeSplit` accepts the same minimum for the committed operation. The Sidebar uses 0.2 and enforces two panes in its own store. The generic engine retains its tree and other split directions. `hideSplitWhenBlocked` hides a blocked split control — pane budget spent or pane too narrow — instead of rendering it disabled; its default is false.
|
||||
|
||||
The split control wrapper exposes `data-dockkit-split-control` for embedder styling, independently of its element tag.
|
||||
|
||||
A tab's `kind` is an opaque string. Seeded tabs are factories (`DockControllerOptions`), so what a fresh pane contains is the embedder's decision, not this package's. Content identity is the pair (`kind`, `contentId`): `findContentTab(state, contentId, kind?)` finds the tab showing it anywhere and `findPaneContentTab(state, paneId, contentId, kind?)` within one pane, and `planOpenContent` focuses that tab instead of opening another unless told `revealIfOpened: false`; an explicit `index` seats a new tab at a strip slot rather than at the end.
|
||||
|
||||
`DockLayout`, used by the Sidebar, keeps each tab in a stable DOM cell across selection, pane moves and floating. It accepts one docked pane or two horizontal panes; CSS Grid resolves their widths. `keepMounted(tab)` retains visited bodies and `active` controls Session visibility without reparenting content.
|
||||
|
||||
@@ -60,6 +60,8 @@ kind: "package-reference"
|
||||
|
||||
`dropZones="horizontal"` 提供左右两个半区提示;预算或宽度不允许再拆时,正文整格接收移动。提示是一张内缩 8px 的虚线卡片,显示该落区的图形和 `labels.dropZone[zone]`;预览层覆盖全部 tab 正文,指针所在的卡片取强调色,另一张保持安静的轮廓。`minPaneFraction` 控制预览的最小比例,`planResizeSplit` 接受相同最小值以约束提交;Sidebar使用0.2并在自己的store限制两格。通用引擎仍保留原有树与其它分割方向。 `hideSplitWhenBlocked` 在分栏被阻止时(窗格预算已满或格太窄)直接隐藏分栏控件而不是渲染禁用态,默认值为 false。
|
||||
|
||||
分栏控件的包裹元素通过 `data-dockkit-split-control` 提供宿主样式入口,不依赖具体元素标签。
|
||||
|
||||
tab 的 `kind` 是不透明字符串。种子 tab 是工厂(`DockControllerOptions`),因此新格里放什么由嵌入方决定,与本包无关。内容身份是二元组(`kind`、`contentId`):`findContentTab(state, contentId, kind?)` 在任意位置找到展示它的 tab,`findPaneContentTab(state, paneId, contentId, kind?)` 在一个格内找;`planOpenContent` 会聚焦该 tab 而非再开一个,除非被告知 `revealIfOpened: false`;显式的 `index` 把新 tab 放到 tab 条的某个位置而非末尾。
|
||||
|
||||
Sidebar 使用的 `DockLayout` 在选中项变化、跨格移动与浮动期间,把每个 tab 保留在稳定的 DOM 容器中。它接受一个停靠格或左右两个格,由 CSS Grid 计算宽度。`keepMounted(tab)` 保留已访问正文,`active` 控制 Session 可见性,不改变内容的父子关系。
|
||||
|
||||
@@ -427,6 +427,7 @@ export function TabStrip({ state, pane, callbacks, offsets }: TabStripProps): Re
|
||||
{!(callbacks.hideSplitWhenBlocked && block !== undefined) && (
|
||||
<Tooltip label={block === undefined ? callbacks.labels.splitPane : splitBlockedTitle(callbacks.labels, block)} shortcutKeys={callbacks.labels.splitPaneKeys} side="bottom" delayMs={500} openOnClick={block !== undefined}>
|
||||
<span
|
||||
data-dockkit-split-control
|
||||
tabIndex={block === undefined ? undefined : 0}
|
||||
aria-label={block === undefined ? undefined : splitBlockedTitle(callbacks.labels, block)}
|
||||
onClick={(event) => { if (block !== undefined) event.stopPropagation() }}
|
||||
|
||||
@@ -281,6 +281,7 @@ describe('DockSurface', () => {
|
||||
expect(disabled.hasAttribute('disabled')).toBe(true)
|
||||
expect(disabled.parentElement?.getAttribute('aria-label')).toBe(TEST_LABELS.splitPaneDisabled)
|
||||
expect(disabled.getAttribute('data-dockkit-split-blocked')).toBe('budget')
|
||||
expect(disabled.parentElement?.hasAttribute('data-dockkit-split-control')).toBe(true)
|
||||
intents.splitPane.mockClear()
|
||||
const hint = disabled.parentElement!
|
||||
fireEvent.pointerDown(hint, { pointerType: 'touch' })
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
en: d152484eb41ac6b4
|
||||
zh: 09388d293f9be9cb
|
||||
/deepseek-ai-dsh-client-ui-layout/use-this-package:
|
||||
en: cc6e9021ba3001bc
|
||||
zh: 97444857762b4e8e
|
||||
en: 2a0687d0683eaa9a
|
||||
zh: 402c55259770f565
|
||||
/deepseek-ai-dsh-client-ui-layout/use-this-package/window-chrome-seat:
|
||||
en: 7eac53b38d0777fe
|
||||
zh: 7f9422dff671ba50
|
||||
@@ -24,8 +24,8 @@
|
||||
en: 5ac34303ad90b484
|
||||
zh: abcc4a1dcf28391e
|
||||
/deepseek-ai-dsh-client-ui-layout/understand-the-implementation:
|
||||
en: 5ab6b311a912fb06
|
||||
zh: d7e88894686b1682
|
||||
en: e3cb25f05902369a
|
||||
zh: c1a8f049a7a4effb
|
||||
/deepseek-ai-dsh-client-ui-layout/further-exploration:
|
||||
en: 74de780b4592e28e
|
||||
zh: a413f06f8ec406d0
|
||||
@@ -36,8 +36,8 @@
|
||||
en: ca75c51c89c2c9b0
|
||||
zh: de54f3467ef3b9be
|
||||
/deepseek-ai-dsh-client-ui-layout/known-limitations-and-deferred-work:
|
||||
en: da92b97ac60d989f
|
||||
zh: 5816b861728f1a04
|
||||
en: 834ae31817179718
|
||||
zh: d2cff416fd0f643a
|
||||
/deepseek-ai-dsh-client-ui-layout/known-limitations-and-deferred-work/dev-note:
|
||||
en: e67f633dc6fe7773
|
||||
zh: 3bb0c20c93f16f98
|
||||
@@ -25,9 +25,13 @@ This package provides the Web GUI's three-column AppFrame, edge-column widths, a
|
||||
<a id="use-this-package"></a>
|
||||
## Use this package
|
||||
|
||||
Desktop Mod+B toggles the left sidebar through the same layout action used by its controls. The shortcut command is unavailable behind modal dialogs and yields to terminal input.
|
||||
Desktop Mod+B toggles the left sidebar through the same layout action used by its controls. The shortcut remains available inside the navigation drawer, is unavailable behind other modal dialogs, and yields to terminal input.
|
||||
|
||||
The root slot composes the sidebar, main content, and right column. The sidebar spans 264–420px, defaults to 280px, and retains a 56px rail when collapsed; below 1024px it collapses automatically, and opening the right panel collapses a manually expanded sidebar. The right panel first opens at 45% of the viewport, then retains the user's pixel preference, capped at 70%. To protect 400px for the center, the frame first reduces the right panel to 300px, then reports insufficient room so its occupant closes it, and only then compresses the center further. Dragging has no transition delay; the right handle is absent while closed or fullscreen.
|
||||
The root slot composes the sidebar, main content, and right column. The sidebar spans 264–420px, defaults to 280px, and retains a 56px rail when collapsed at widths of 768px and above. Below 768px, without a native Windows caption, it uses a modal drawer without reserving a column; the header retains the reopen controls, and navigation closes the drawer. Below 1024px it collapses automatically, and opening the right panel collapses a manually expanded sidebar. The right panel first opens at 45% of the viewport, then retains the user's pixel preference, capped at 70%. To protect 400px for the center, the frame first reduces the right panel to 300px, then reports insufficient room so its occupant closes it, and only then compresses the center further. Dragging has no transition delay; the right handle is absent while closed or fullscreen.
|
||||
|
||||
When the browser reports a folded device in landscape and the frame is at least 768px wide, the expanded sidebar occupies half the frame. This midpoint heuristic targets book postures with a vertical center fold; it does not identify the hinge direction or reserve its physical width, so horizontal or off-center folds are not supported by this adjustment. Its resize handle is hidden; unfolding restores the saved width. Fold changes at a stable viewport width use the existing track transition; reduced motion disables it. Browsers without the device-posture media feature keep the ordinary layout.
|
||||
|
||||
The drawer mask fades with the panel’s transition duration and easing on both open and close; reduced motion disables both transitions. Entering drawer mode from an already collapsed sidebar hides the drawer immediately; an expanded sidebar keeps its closing slide. The drawer has no edge divider, and its frame does not scroll. On macOS, the drawer uses the same opaque background as Web; window vibrancy applies only to the ordinary sidebar. The frame fills the shell’s layout viewport, retaining its height while the keyboard opens. Drawer backing and mask cover the shell’s full height, including `shell.bottom`, above fullscreen and floating right panels. Browser-owned status and address bars remain outside the shell; the layout adds no synthetic safe-area insets.
|
||||
|
||||
Global panels occupy the root-scoped `main` keyed slot; `conversation` is the reserved key for the Conversation. `ctx.layout.selectPanel(id)` selects a registered panel, and `null` selects the Conversation without changing the current Session. The Plugins page contributes one of the shipped global panels.
|
||||
|
||||
@@ -54,6 +58,8 @@ The presenter consumes resolved theme snapshots and projects them onto the docum
|
||||
<details>
|
||||
<summary>Implementation internals — click to expand</summary>
|
||||
|
||||
The root registration supplies folded-landscape posture through an injected observable. The renderer owns its media-query subscription; AppFrame reads the snapshot through the bound hook. Client registrations running without browser media APIs use the ordinary layout.
|
||||
|
||||
`selectPanel(id)` checks the live `main` registry before changing selection; an absent key throws and leaves the current panel intact. `beginNavigation()` returns an abort signal for an asynchronous UI navigation. A later call, a valid panel selection (including repeated selection), or layout disposal aborts that signal without cancelling underlying Session creation. Consumers check the signal before committing navigation or moving drafts.
|
||||
|
||||
One registration declares the frame slots and binds `ctx.layout` methods `selectPanel`, `toggleSidebar`, `openRightbar(track, fullscreen)`, and `closeRightbar`. One root store separates `panelInfo` selection from `layoutInfo` measurements, width preferences, and presentation reports. `ctx.layout.panelInfo` and the standard `usePanelInfo` hook share the same selection source; AppFrame subscribes to the stable layout object. The `rightbar` owner supplies actual `width`, `viewportWidth`, and normal-presentation eligibility `canShow`; insufficient room causes a deterministic close, never automatic reopening on widening. Fullscreen hides the width handle without releasing a track the occupant retains. AppFrame keeps the column containers mounted. The right column's root controller renders `rightbar.session` through `SessionProvider` only while the Conversation is selected; its unmount report releases the track. The independent title component uses the selected Session title only while the Conversation is visible, with the build-configured product title or localized `common.brand.localBuild` as its fallback; locale revisions update that fallback. The theme presenter is a second effect: pure DOM writes from resolved snapshots — initial state through the getter once, then event-driven only, with no React path. It applies palette, font-size, font-list, and token variables before measuring the rendered background as the single color authority. Fullscreen presentation suppresses grid and handle transitions; its occupant reports the new columns only after covering the frame. Fullscreen exit keeps transitions suppressed while the frame installs its destination geometry: close removes the right track, and restore retains it. Subsequent normal geometry actions restore ordinary transitions.
|
||||
@@ -92,7 +98,7 @@ None; this package neither assembles nor sends a provider request.
|
||||
These limits define the current layout behavior. They are current package constraints, not a general window-manager comparison or a task backlog.
|
||||
|
||||
- **Panel geometry is transient** — reload restores the sidebar default and the right panel hidden; each dragged width is one frame-wide preference, not a per-Session fact.
|
||||
- **Extremely narrow windows** — after the right panel closes, the center may still fall below 400px; the left 56px rail remains.
|
||||
- **Extremely narrow windows** — after the right panel closes, the center may still fall below 400px; browser drawers reserve no sidebar width below 768px.
|
||||
- **Track and panel travel on one shared curve only while animating** — during a discrete open/close the frame sets `data-animating` and its track transition and the occupant's slide read the same duration and easing variables; an occupant that used its own would detach the panel's edge from the conversation's while squeezing. Drags and instant presentation switches run transition-free, so the curve does not cover them.
|
||||
- **No scroll anchoring during squeeze reflow** — layout changes may move the reader's viewport.
|
||||
|
||||
|
||||
@@ -25,9 +25,13 @@ kind: "package-reference"
|
||||
<a id="use-this-package"></a>
|
||||
## 使用本包
|
||||
|
||||
桌面 Mod+B 通过与控件共用的布局操作切换左侧栏。模态弹窗打开时此快捷键不可用;终端输入优先。
|
||||
桌面 Mod+B 通过与控件共用的布局操作切换左侧栏。此快捷键在导航抽屉内仍可用,在其他模态弹窗打开时不可用;终端输入优先。
|
||||
|
||||
本插件在 root slot 中组合侧边栏、主内容和右栏。侧边栏宽度为 264~420px,默认为 280px,收起后保留 56px 控制栏;窗口宽度低于 1024px 时自动收起,打开右侧面板也会收起手动展开的侧边栏。右侧面板首次打开时使用视口宽度的 45%,之后保留用户的像素宽度偏好,上限为 70%。为给中栏保留 400px,框架先将右侧面板缩减至 300px,再报告空间不足,使占用方将其关闭,最后才进一步压缩中栏。拖动没有过渡延迟;右侧手柄在关闭或全屏时不显示。
|
||||
本插件在 root slot 中组合侧边栏、主内容和右栏。侧边栏宽度为 264~420px,默认为 280px,在宽度不低于 768px 时,收起后保留 56px 控制栏。低于 768px 且没有原生 Windows 顶栏时,采用模态抽屉,不占据列宽;标题区域保留重新打开的控件,导航后关闭抽屉。窗口宽度低于 1024px 时自动收起,打开右侧面板也会收起手动展开的侧边栏。右侧面板首次打开时使用视口宽度的 45%,之后保留用户的像素宽度偏好,上限为 70%。为给中栏保留 400px,框架先将右侧面板缩减至 300px,再报告空间不足,使占用方将其关闭,最后才进一步压缩中栏。拖动没有过渡延迟;右侧手柄在关闭或全屏时不显示。
|
||||
|
||||
当浏览器报告设备处于横屏半折叠状态,且框架宽度不低于 768px 时,展开的侧边栏占据一半宽度。这一中点启发式面向折痕竖直且位于中央的书本姿态;它不识别铰链方向,也不为实体铰链宽度留空,因此这项调整不支持水平或偏离中央的折痕。此时隐藏拖拽手柄;完全展开后恢复保存的宽度。视口宽度不变时,折叠状态切换复用现有的列宽过渡;减少动态效果时禁用该过渡。不支持 device-posture 媒体特性的浏览器继续使用常规布局。
|
||||
|
||||
抽屉遮罩使用与面板相同的时长和缓动,在打开与关闭时渐变透明度;减少动态效果时两者均不播放动画。从已收起的侧栏切换到抽屉布局时,抽屉立即隐藏;已展开的侧栏保留收起动画。抽屉边缘不绘制分隔线,外层框架不滚动。macOS 抽屉与 Web 使用相同的不透明背景,毛玻璃仅用于普通侧栏。框架铺满外壳的布局视口,在键盘抬起时保留原有高度。抽屉背景和遮罩覆盖外壳完整高度,包括 `shell.bottom`,并显示在全屏和浮动右侧面板之上。浏览器管理的状态栏和地址栏位于外壳之外;布局不添加模拟安全区边距。
|
||||
|
||||
全局面板占据 root 作用域的 `main` keyed slot;`conversation` 是为会话界面保留的 key。`ctx.layout.selectPanel(id)` 选中已注册面板,`null` 则选中会话界面,但不改变当前会话。Plugins 页面是默认组合中的一个全局面板。
|
||||
|
||||
@@ -54,6 +58,8 @@ Windows Electron 的 `data-windows-titlebar` 标记在所有列上方预留顶
|
||||
<details>
|
||||
<summary>实现细节——点击展开</summary>
|
||||
|
||||
root 注册通过注入的可观察源提供横屏折叠状态,由渲染器负责媒体查询订阅,AppFrame 只通过绑定的 hook 读取快照。在没有浏览器媒体 API 的环境中运行客户端注册时,使用常规布局。
|
||||
|
||||
`selectPanel(id)` 在改变选中态前检查实时 `main` 注册表;缺失的 key 会抛错并保留当前面板。`beginNavigation()` 为异步 UI 导航返回 abort signal。后续调用、有效面板选择(包括重复选择)或布局释放会中止该 signal,但不取消底层会话创建。消费方在提交导航或搬移草稿前检查 signal。
|
||||
|
||||
一次注册声明框架的子 slot,并绑定 `ctx.layout` 的 `selectPanel`、`toggleSidebar`、`openRightbar(track, fullscreen)` 与 `closeRightbar`。同一个 root 存储把 `panelInfo` 选中态与 `layoutInfo` 测量、宽度偏好、呈现报告分开。`ctx.layout.panelInfo` 与标准 `usePanelInfo` hook 共用同一个选中态来源;AppFrame 订阅引用稳定的布局对象。`rightbar` owner 提供实际 `width`、`viewportWidth`,以及表示能否以普通模式呈现的 `canShow`;占用方在空间不足时执行确定性的收起,变宽不自行重新展开。全屏隐藏宽度手柄,但不自行释放占用方要求保留的轨道。AppFrame 保持各列容器挂载。右栏的 root 控制器仅在选中会话界面时,经 `SessionProvider` 渲染 `rightbar.session`;内容卸载时的报告释放轨道。独立的标题组件仅在会话界面可见时使用所选会话标题,以构建配置的产品标题或本地化 `common.brand.localBuild` 为回退值;语言变化会更新该回退值。主题呈现器是第二个 effect:从解析后的快照做纯 DOM 写入——初始状态经 getter 读取一次,此后仅事件驱动,不经过 React。它先应用调色板、字号、字体列表与 token 变量,再把渲染出的背景测量为唯一的颜色依据。全屏呈现禁用网格和手柄过渡;占用方完全覆盖框架后才报告新的列布局。退出全屏时,框架先保持无过渡并安装目标布局:关闭移除右轨道,恢复保留右轨道。后续普通几何操作恢复正常过渡。
|
||||
@@ -92,7 +98,7 @@ Windows Electron 的 `data-windows-titlebar` 标记在所有列上方预留顶
|
||||
这些限制界定了当前布局行为。它们是当前包约束,不是通用窗口管理器对比或任务积压。
|
||||
|
||||
- **面板几何是瞬时状态**——重新加载会恢复侧栏默认值并隐藏右侧面板;拖动设置的宽度是整个框架共用的一份偏好,而非每个会话各自的属性。
|
||||
- **极窄窗口**——右侧面板关闭后,中栏仍可能小于 400px;左侧 56px 控制栏仍会保留。
|
||||
- **极窄窗口**——右侧面板关闭后,中栏仍可能小于 400px;低于 768px 时,浏览器抽屉不占据侧栏宽度。
|
||||
- **轨道与面板仅在动画期间沿同一条曲线运动**——离散开合时框架设置 `data-animating`,其轨道过渡和占用方的滑入读取同一组时长与缓动变量;占用方若自用一套,挤压时面板边缘就会与会话界面的边缘脱开。拖拽和即时呈现切换不带过渡,因此该曲线不覆盖它们。
|
||||
- **挤压重排期间无滚动锚定**——布局变化可能移动读者的视口。
|
||||
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
display: grid;
|
||||
grid-template-rows: minmax(0, 1fr) auto;
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
overflow: hidden;
|
||||
background: var(--dsw-alias-bg-base);
|
||||
}
|
||||
|
||||
/* Only a discrete collapse/expand toggle eases the tracks (the TSX holds
|
||||
/* Only discrete collapse/expand and fold changes ease the tracks (the TSX holds
|
||||
data-animating across the toggle on the deepsuite sider curve). Steady-state
|
||||
tracks move only with the viewport, and those updates must land instantly:
|
||||
an eased track chases the live window edge and the centre column visibly
|
||||
@@ -56,6 +57,8 @@
|
||||
}
|
||||
|
||||
.sidebarCol {
|
||||
grid-column: 1;
|
||||
grid-row: 1;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
background: var(--dsw-specific-sidebar-fill);
|
||||
@@ -63,12 +66,22 @@
|
||||
}
|
||||
|
||||
.centerCol {
|
||||
grid-column: 2;
|
||||
grid-row: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.mainPanel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
/* macOS desktop: the frame goes transparent so window vibrancy reaches the
|
||||
sidebar column, which keeps only a translucent tint; the centre paints the
|
||||
base background itself to stay opaque. The sidebar/centre separator moves
|
||||
@@ -107,7 +120,7 @@
|
||||
--dsh-frame-chrome-top: 0px;
|
||||
}
|
||||
|
||||
:global([data-platform='darwin']) .sidebarCol {
|
||||
:global([data-platform='darwin']) .frame:not([data-sidebar-drawer]) .sidebarCol {
|
||||
/* A blue wash over the top of the translucent tint, gone by a third of the
|
||||
column; a faint blue-grey-violet rises through the bottom third; and a
|
||||
faint blue cast is mixed into the tint itself. Every layer stays
|
||||
@@ -126,7 +139,7 @@
|
||||
|
||||
/* Dark drops the blue cast (the light-mode wash reads purple over dark fills)
|
||||
and thins the fill so more wallpaper shows; the washes stay. */
|
||||
:global([data-platform='darwin']) :global([data-ds-dark-theme]) .sidebarCol {
|
||||
:global([data-platform='darwin']) :global([data-ds-dark-theme]) .frame:not([data-sidebar-drawer]) .sidebarCol {
|
||||
background:
|
||||
linear-gradient(
|
||||
to bottom,
|
||||
@@ -143,8 +156,8 @@
|
||||
them with a 90%-opaque fill of the same token in both themes (the dark
|
||||
selector repeats so this outranks its thinner fill). */
|
||||
@media (prefers-reduced-transparency: reduce) {
|
||||
:global([data-platform='darwin']) .sidebarCol,
|
||||
:global([data-platform='darwin']) :global([data-ds-dark-theme]) .sidebarCol {
|
||||
:global([data-platform='darwin']) .frame:not([data-sidebar-drawer]) .sidebarCol,
|
||||
:global([data-platform='darwin']) :global([data-ds-dark-theme]) .frame:not([data-sidebar-drawer]) .sidebarCol {
|
||||
background: color-mix(in srgb, var(--dsw-specific-sidebar-fill) 90%, transparent);
|
||||
}
|
||||
}
|
||||
@@ -265,11 +278,91 @@
|
||||
* where it is. The occupant draws its own left border.
|
||||
*/
|
||||
.rightbarCol {
|
||||
grid-column: 3;
|
||||
grid-row: 1;
|
||||
position: relative;
|
||||
min-width: 0;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.frame[data-sidebar-drawer] {
|
||||
--dsh-frame-leading-clearance: 84px;
|
||||
overflow: clip;
|
||||
}
|
||||
|
||||
.frame[data-sidebar-drawer] .mainPanel[data-global-panel] {
|
||||
padding-top: max(0px, calc(48px - var(--dsh-frame-top-clearance, 0px)));
|
||||
}
|
||||
|
||||
.frame[data-sidebar-drawer] .sidebarCol {
|
||||
position: absolute;
|
||||
grid-area: auto;
|
||||
inset: 0 auto 0 0;
|
||||
z-index: 71;
|
||||
box-sizing: border-box;
|
||||
border-right: none;
|
||||
transform: translateX(0);
|
||||
visibility: visible;
|
||||
transition: transform var(--ds-transition-duration-slow) var(--ds-ease-in-out);
|
||||
}
|
||||
|
||||
.frame[data-sidebar-drawer][data-sidebar-collapsed] .sidebarCol {
|
||||
transform: translateX(-100%);
|
||||
visibility: hidden;
|
||||
transition:
|
||||
transform var(--ds-transition-duration-slow) var(--ds-ease-in-out),
|
||||
visibility 0s linear var(--ds-transition-duration-slow);
|
||||
}
|
||||
|
||||
.frame[data-sidebar-drawer][data-sidebar-instant] .sidebarCol {
|
||||
transition: none;
|
||||
}
|
||||
|
||||
.drawerMask {
|
||||
position: absolute;
|
||||
inset: var(--dsh-frame-chrome-top, 0px) 0 0;
|
||||
z-index: 70;
|
||||
background: var(--dsw-alias-bg-mask-1);
|
||||
backdrop-filter: var(--dsw-mask-blur);
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition: opacity var(--ds-transition-duration-slow) var(--ds-ease-in-out);
|
||||
}
|
||||
|
||||
.frame[data-sidebar-drawer]:not([data-sidebar-collapsed]) .drawerMask {
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.frame[data-sidebar-drawer] .leadingSeat {
|
||||
top: 11px;
|
||||
left: 12px;
|
||||
}
|
||||
|
||||
:global([data-platform='darwin']) .frame[data-sidebar-drawer] {
|
||||
--dsh-frame-leading-clearance: 160px;
|
||||
}
|
||||
|
||||
:global([data-platform='darwin']) .frame[data-sidebar-drawer] .leadingSeat {
|
||||
left: 88px;
|
||||
}
|
||||
|
||||
:global([data-platform='darwin'][data-fullscreen]) .frame[data-sidebar-drawer] {
|
||||
--dsh-frame-leading-clearance: 84px;
|
||||
}
|
||||
|
||||
:global([data-platform='darwin'][data-fullscreen]) .frame[data-sidebar-drawer] .leadingSeat {
|
||||
left: 12px;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.frame[data-sidebar-drawer] .sidebarCol,
|
||||
.frame[data-sidebar-drawer][data-sidebar-collapsed] .sidebarCol,
|
||||
.drawerMask {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
|
||||
.bottomRow {
|
||||
grid-column: 1 / -1;
|
||||
min-width: 0;
|
||||
|
||||
@@ -17,29 +17,37 @@
|
||||
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'
|
||||
import type { ReactNode } from 'react'
|
||||
import type {
|
||||
PropsLocale, PropsRenderSlots, PropsRuntime, PropsStore,
|
||||
HostObservable, InjectFace, PropsLocale, PropsRenderSlots, PropsRuntime, PropsStore,
|
||||
} from '@deepseek-ai/dsh-client-ui-slots'
|
||||
import { CENTER_MIN, clampWidth, computeColumns, RIGHTBAR_DEFAULT_RATIO, RIGHTBAR_MAX_RATIO, RIGHTBAR_MIN, SIDEBAR_AUTO_COLLAPSE, SIDEBAR_COLLAPSED, SIDEBAR_DEFAULT } from './columns.ts'
|
||||
import { CENTER_MIN, clampWidth, computeColumns, RIGHTBAR_DEFAULT_RATIO, RIGHTBAR_MAX_RATIO, RIGHTBAR_MIN, SIDEBAR_AUTO_COLLAPSE, SIDEBAR_COLLAPSED, SIDEBAR_DEFAULT, SIDEBAR_DRAWER_BREAKPOINT } from './columns.ts'
|
||||
import { DocumentTitle } from './DocumentTitle.tsx'
|
||||
import type { createLayoutStore } from './stores.ts'
|
||||
import css from './AppFrame.module.css'
|
||||
|
||||
/** Full composed props: runtime share + child-slot render share + store share. */
|
||||
/** Browser posture supplied by the root registration. */
|
||||
export interface AppFrameInjected {
|
||||
hooks: { foldedLandscape: HostObservable<boolean> }
|
||||
}
|
||||
|
||||
/** Full composed props: runtime, child slots, store, locale, and injected posture. */
|
||||
export type AppFrameProps =
|
||||
& PropsRuntime<'root'>
|
||||
& PropsRenderSlots<'sidebar' | 'main' | 'rightbar' | 'shell.bottom' | 'shell.overlay' | 'shell.leading'>
|
||||
& PropsStore<ReturnType<typeof createLayoutStore>>
|
||||
& PropsLocale<'common'>
|
||||
& InjectFace<AppFrameInjected>
|
||||
|
||||
/** Center column grid item (session-body building block). */
|
||||
function CenterColumn(props: { children?: ReactNode }) {
|
||||
return <div className={css.centerCol}>{props.children}</div>
|
||||
function CenterColumn(props: { children?: ReactNode; inert: boolean }) {
|
||||
return <div className={css.centerCol} {...{ inert: props.inert ? '' : undefined }}>{props.children}</div>
|
||||
}
|
||||
|
||||
/** Subscribe to the main key without subscribing the column frame to each panel id. */
|
||||
function MainPanel({ usePanelInfo, renderSlot }: Pick<PropsRuntime<'root'>, 'usePanelInfo'> & PropsRenderSlots<'main'>) {
|
||||
const panelId = usePanelInfo(info => info.activePanelId)
|
||||
return renderSlot('main', {}, { entryKey: panelId ?? 'conversation' })
|
||||
return <div className={css.mainPanel} data-global-panel={panelId !== null || undefined}>
|
||||
{renderSlot('main', {}, { entryKey: panelId ?? 'conversation' })}
|
||||
</div>
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,8 +55,8 @@ function MainPanel({ usePanelInfo, renderSlot }: Pick<PropsRuntime<'root'>, 'use
|
||||
* occupant's panel is positioned against the column's right edge, which never
|
||||
* moves, so it can hang over the centre when there is no track.
|
||||
*/
|
||||
function RightbarColumn(props: { children?: ReactNode }) {
|
||||
return <div className={css.rightbarCol} data-rightbar-col>{props.children}</div>
|
||||
function RightbarColumn(props: { children?: ReactNode; inert: boolean }) {
|
||||
return <div className={css.rightbarCol} data-rightbar-col {...{ inert: props.inert ? '' : undefined }}>{props.children}</div>
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,6 +130,7 @@ export function AppFrame({
|
||||
useStore,
|
||||
useSessions,
|
||||
usePanelInfo,
|
||||
useFoldedLandscape,
|
||||
actions,
|
||||
renderSlot,
|
||||
t,
|
||||
@@ -129,6 +138,7 @@ export function AppFrame({
|
||||
const layoutInfo = useStore(state => state.layoutInfo)
|
||||
const frameRef = useRef<HTMLDivElement | null>(null)
|
||||
const viewport = layoutInfo.viewportWidth
|
||||
const foldedLandscape = useFoldedLandscape(matches => matches)
|
||||
|
||||
// Track the frame's own box (not the window): rAF-throttled ResizeObserver.
|
||||
useLayoutEffect(() => {
|
||||
@@ -158,7 +168,16 @@ export function AppFrame({
|
||||
}, [actions])
|
||||
|
||||
const narrow = viewport < SIDEBAR_AUTO_COLLAPSE
|
||||
const windowsTitlebar = document.documentElement.hasAttribute('data-windows-titlebar')
|
||||
const drawer = viewport < SIDEBAR_DRAWER_BREAKPOINT && !windowsTitlebar
|
||||
const centeredSidebar = foldedLandscape && viewport >= SIDEBAR_DRAWER_BREAKPOINT
|
||||
const sidebarCollapsed = narrow ? !layoutInfo.narrowExpanded : layoutInfo.sidebar === 0
|
||||
const drawerOpen = drawer && !sidebarCollapsed
|
||||
// Entering drawer mode from a collapsed rail hides the backing immediately.
|
||||
const [sidebarTransition, setSidebarTransition] = useState({ drawer, collapsed: sidebarCollapsed, instant: true })
|
||||
if (sidebarTransition.drawer !== drawer || sidebarTransition.collapsed !== sidebarCollapsed) {
|
||||
setSidebarTransition({ drawer, collapsed: sidebarCollapsed, instant: drawer && sidebarCollapsed && sidebarTransition.collapsed })
|
||||
}
|
||||
const sidebarPreference = sidebarCollapsed
|
||||
? 0
|
||||
: layoutInfo.sidebar === 0 ? SIDEBAR_DEFAULT : layoutInfo.sidebar
|
||||
@@ -166,12 +185,15 @@ export function AppFrame({
|
||||
// Desktop reopen controls occupy the frame's shell.leading seat (macOS) or
|
||||
// the Windows caption row; neither platform keeps an icon rail.
|
||||
const darwin = document.documentElement.dataset.platform === 'darwin'
|
||||
const collapsedWidth = darwin
|
||||
|| document.documentElement.hasAttribute('data-windows-titlebar') ? 0 : SIDEBAR_COLLAPSED
|
||||
const collapsedWidth = drawer || darwin || windowsTitlebar ? 0 : SIDEBAR_COLLAPSED
|
||||
// Opening on a narrow frame collapses the left sidebar. Eligibility must
|
||||
// include that space before the occupant's first shown report arrives.
|
||||
const normal = computeColumns(viewport, !layoutInfo.rightbarShown && narrow ? 0 : sidebarPreference, rightbarPreference, collapsedWidth)
|
||||
const cols = computeColumns(viewport, sidebarPreference, layoutInfo.rightbarTrack ? rightbarPreference : 0, collapsedWidth)
|
||||
const normal = computeColumns(
|
||||
viewport, !layoutInfo.rightbarShown && narrow ? 0 : sidebarPreference, rightbarPreference, collapsedWidth, centeredSidebar,
|
||||
)
|
||||
const cols = computeColumns(
|
||||
viewport, drawer ? 0 : sidebarPreference, layoutInfo.rightbarTrack ? rightbarPreference : 0, collapsedWidth, centeredSidebar,
|
||||
)
|
||||
const colsRef = useRef(cols)
|
||||
colsRef.current = cols
|
||||
const rightbarWidth = useRef(normal.rightbar)
|
||||
@@ -185,8 +207,8 @@ export function AppFrame({
|
||||
// Track-level transitions pause for the whole gesture: eased tracks would
|
||||
// detach the column edge from the pointer (AppFrame.module.css).
|
||||
const [dragging, setDragging] = useState(false)
|
||||
// Track easing is scoped to a discrete open/close toggle: data-animating
|
||||
// goes up when the collapse state or the rightbar track flips and comes down
|
||||
// Track easing is scoped to discrete open/close and fold changes: data-animating
|
||||
// goes up when the sidebar presentation or the rightbar track flips and comes down
|
||||
// at transition end (timeout as the reduced-motion/covered-frame fallback).
|
||||
// Steady-state viewport updates stay instant (AppFrame.module.css), and so
|
||||
// does a toggle arriving together with a viewport change — that is the
|
||||
@@ -194,15 +216,21 @@ export function AppFrame({
|
||||
// chase the live window edge. The counter restarts the settle window when a
|
||||
// re-toggle interrupts a running transition.
|
||||
const [animating, setAnimating] = useState(0)
|
||||
const trackToggle = `${sidebarCollapsed}:${layoutInfo.rightbarTrack}`
|
||||
const trackToggle = `${sidebarCollapsed}:${layoutInfo.rightbarTrack}:${centeredSidebar}`
|
||||
const previousToggle = useRef(trackToggle)
|
||||
const previousViewport = useRef(viewport)
|
||||
// Arm the transition before child layout effects measure the new column widths.
|
||||
const animateTracks = previousViewport.current === viewport && (animating > 0 || previousToggle.current !== trackToggle)
|
||||
useLayoutEffect(() => {
|
||||
const viewportChanged = previousViewport.current !== viewport
|
||||
previousViewport.current = viewport
|
||||
if (viewportChanged) {
|
||||
previousToggle.current = trackToggle
|
||||
setAnimating(0)
|
||||
return
|
||||
}
|
||||
if (previousToggle.current === trackToggle) return
|
||||
previousToggle.current = trackToggle
|
||||
if (viewportChanged) return
|
||||
setAnimating(token => token + 1)
|
||||
}, [trackToggle, viewport])
|
||||
useEffect(() => {
|
||||
@@ -239,10 +267,14 @@ export function AppFrame({
|
||||
// whole and was corrected two frames later — visible jitter. cols keeps only
|
||||
// the discrete decisions (track present, collapse state) and the drag base.
|
||||
const rightbarMax = cols.rightbar === 0 ? 0 : clampWidth(rightbarPreference, RIGHTBAR_MIN, viewport * RIGHTBAR_MAX_RATIO)
|
||||
const sidebarWidth = drawer
|
||||
? Math.min(layoutInfo.sidebar || SIDEBAR_DEFAULT, Math.max(0, viewport - 48))
|
||||
: cols.sidebar
|
||||
const sidebar = useMemo(() => renderSlot('sidebar', {
|
||||
collapsed: sidebarCollapsed,
|
||||
width: cols.sidebar,
|
||||
}), [renderSlot, sidebarCollapsed, cols.sidebar])
|
||||
width: sidebarWidth,
|
||||
drawer,
|
||||
}), [renderSlot, sidebarCollapsed, sidebarWidth, drawer])
|
||||
const main = useMemo(() => (
|
||||
<MainPanel usePanelInfo={usePanelInfo} renderSlot={renderSlot} />
|
||||
), [usePanelInfo, renderSlot])
|
||||
@@ -253,52 +285,58 @@ export function AppFrame({
|
||||
// row (ui-sidebar). AppFrame.module.css publishes the matching
|
||||
// --dsh-frame-leading-clearance under the same collapsed condition.
|
||||
const leading = useMemo(() => renderSlot('shell.leading', {}), [renderSlot])
|
||||
const leadingMounted = darwin && sidebarCollapsed
|
||||
const leadingMounted = drawer || darwin && sidebarCollapsed
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={frameRef}
|
||||
className={css.frame}
|
||||
style={{
|
||||
...(document.documentElement.hasAttribute('data-windows-titlebar')
|
||||
...(windowsTitlebar
|
||||
? { '--dsh-windows-sidebar-width': `${cols.sidebar}px` } : {}),
|
||||
gridTemplateColumns:
|
||||
`${cols.sidebar}px minmax(${cols.rightbar === 0 ? 0 : CENTER_MIN}px, 1fr) minmax(0px, ${rightbarMax}px)`,
|
||||
}}
|
||||
data-sidebar-collapsed={sidebarCollapsed || undefined}
|
||||
data-sidebar-drawer={drawer || undefined}
|
||||
data-sidebar-instant={drawer && sidebarCollapsed && sidebarTransition.instant || undefined}
|
||||
data-rightbar-collapsed={cols.rightbar === 0 || undefined}
|
||||
data-rightbar-fullscreen={layoutInfo.rightbarFullscreen || undefined}
|
||||
data-rightbar-instant={layoutInfo.rightbarInstant || undefined}
|
||||
data-dragging={dragging || undefined}
|
||||
data-animating={animating > 0 || undefined}
|
||||
data-animating={animateTracks || undefined}
|
||||
>
|
||||
<DocumentTitle
|
||||
productTitle={productTitle}
|
||||
useSessions={useSessions}
|
||||
usePanelInfo={usePanelInfo}
|
||||
/>
|
||||
<div className={css.sidebarCol}>
|
||||
{drawer && <div className={css.drawerMask} data-sidebar-mask aria-hidden="true"
|
||||
onClick={drawerOpen ? () => { actions.toggleSidebar() } : undefined} />}
|
||||
<div className={css.sidebarCol}
|
||||
style={drawer ? { width: sidebarWidth } : undefined}
|
||||
{...{ inert: drawer && sidebarCollapsed ? '' : undefined }}>
|
||||
{sidebar}
|
||||
</div>
|
||||
<>
|
||||
<CenterColumn>{main}</CenterColumn>
|
||||
<RightbarColumn>
|
||||
<CenterColumn inert={drawerOpen}>{main}</CenterColumn>
|
||||
<RightbarColumn inert={drawerOpen}>
|
||||
{renderSlot('rightbar', { width: normal.rightbar, viewportWidth: viewport, canShow: normal.rightbar > 0 })}
|
||||
</RightbarColumn>
|
||||
</>
|
||||
<div className={css.bottomRow} data-shell-bottom>
|
||||
<div className={css.bottomRow} data-shell-bottom {...{ inert: drawerOpen ? '' : undefined }}>
|
||||
{renderSlot('shell.bottom', {})}
|
||||
</div>
|
||||
<div className={css.overlayLayer} data-shell-overlay>
|
||||
{overlays}
|
||||
</div>
|
||||
{leadingMounted && (
|
||||
<div className={css.leadingSeat} data-shell-leading>
|
||||
<div className={css.leadingSeat} data-shell-leading {...{ inert: drawerOpen ? '' : undefined }}>
|
||||
{leading}
|
||||
</div>
|
||||
)}
|
||||
{/* The collapsed rail is fixed-width: no resize handle while closed. */}
|
||||
{!sidebarCollapsed && <DragHandle side="sidebar" left={cols.sidebar} onStart={onSidebarStart} onDrag={onSidebarDrag} onEnd={onDragEnd} />}
|
||||
{!drawer && !centeredSidebar && !sidebarCollapsed && <DragHandle side="sidebar" left={cols.sidebar} onStart={onSidebarStart} onDrag={onSidebarDrag} onEnd={onDragEnd} />}
|
||||
{layoutInfo.rightbarShown && !layoutInfo.rightbarFullscreen && normal.rightbar > 0 && (
|
||||
<DragHandle side="rightbar" left={viewport - normal.rightbar} onStart={onRightbarStart} onDrag={onRightbarDrag} onEnd={onDragEnd} />
|
||||
)}
|
||||
|
||||
@@ -17,6 +17,8 @@ export const SIDEBAR_MAX = 420
|
||||
export const SIDEBAR_DEFAULT = 280
|
||||
/** Closed-sidebar rail: a 24px icon column between 16px horizontal paddings. */
|
||||
export const SIDEBAR_COLLAPSED = 56
|
||||
/** Frame width below which the sidebar overlays the main content without a rail. */
|
||||
export const SIDEBAR_DRAWER_BREAKPOINT = 768
|
||||
/** Viewport width below which the sidebar auto-collapses to the rail (deepsuite
|
||||
* LG breakpoint); a manual toggle below it re-expands over the squeezed center
|
||||
* (stores.ts narrowExpanded). */
|
||||
@@ -46,11 +48,14 @@ export function clampWidth(px: number, min: number, max: number): number {
|
||||
* @param rightbar - requested right panel width in px (0 = no track).
|
||||
* @param collapsedWidth - track width of the closed sidebar; the default keeps
|
||||
* the icon rail, 0 hides the column entirely (macOS desktop).
|
||||
* @param centeredSidebar - place an expanded sidebar's edge at the frame midpoint.
|
||||
* @returns actual widths after shrinking or removing the right track; only
|
||||
* without that track may the center fall below its minimum, down to zero.
|
||||
*/
|
||||
export function computeColumns(viewport: number, sidebar: number, rightbar: number, collapsedWidth = SIDEBAR_COLLAPSED): Columns {
|
||||
const s = sidebar === 0 ? collapsedWidth : clampWidth(sidebar, SIDEBAR_MIN, SIDEBAR_MAX)
|
||||
export function computeColumns(
|
||||
viewport: number, sidebar: number, rightbar: number, collapsedWidth = SIDEBAR_COLLAPSED, centeredSidebar = false,
|
||||
): Columns {
|
||||
const s = sidebar === 0 ? collapsedWidth : centeredSidebar ? viewport / 2 : clampWidth(sidebar, SIDEBAR_MIN, SIDEBAR_MAX)
|
||||
const available = viewport - s - CENTER_MIN
|
||||
const r = rightbar === 0 || available < RIGHTBAR_MIN
|
||||
? 0
|
||||
|
||||
@@ -15,6 +15,7 @@ import type {} from '@deepseek-ai/dsh-client-ui-theme/client'
|
||||
import type { HostObservable, SnapshotSelectorHook } from '@deepseek-ai/dsh-client-ui-slots'
|
||||
import type { PanelInfo } from './service.ts'
|
||||
import { AppFrame } from './AppFrame.tsx'
|
||||
import type { AppFrameInjected } from './AppFrame.tsx'
|
||||
import { createLayoutStore } from './stores.ts'
|
||||
import { LayoutController } from './service.ts'
|
||||
import type { ShortcutCommandId } from '@deepseek-ai/dsh-client-shortcuts/client'
|
||||
@@ -62,8 +63,9 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
|
||||
* the seats it declares disappear with it. To add something to the
|
||||
* sidebar, register into one of those inner seats instead.
|
||||
*
|
||||
* The occupant receives the frame's live column state (collapsed, width)
|
||||
* and is expected to render the compact control rail while collapsed.
|
||||
* The occupant receives the frame's collapsed state, width and drawer mode.
|
||||
* Drawer content stays mounted while hidden; other browser columns retain
|
||||
* a compact control rail while collapsed.
|
||||
*/
|
||||
'sidebar': { kind: 'single'; scope: 'root'; owner: SidebarOwnerProps }
|
||||
/**
|
||||
@@ -105,9 +107,9 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
|
||||
'shell.overlay': { kind: 'list'; scope: 'root' }
|
||||
/**
|
||||
* Window-chrome seat at the frame's top-left, over every main panel.
|
||||
* Mounted only while the sidebar column is fully hidden (macOS desktop
|
||||
* collapse; other platforms keep the rail), so the occupant can assume the
|
||||
* frame edge is the window edge and the macOS traffic lights sit before it.
|
||||
* Mounted for narrow drawers and collapsed macOS desktop sidebars. macOS
|
||||
* traffic lights sit before it outside native fullscreen; browser controls
|
||||
* start at the frame edge.
|
||||
* OCCUPIED by ui-sidebar's reopen/New Session controls.
|
||||
*
|
||||
* While the seat is mounted the frame publishes
|
||||
@@ -127,10 +129,12 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
|
||||
|
||||
/** Sidebar owner share: live column state from the frame's concession solve. */
|
||||
export interface SidebarOwnerProps {
|
||||
/** True when the sidebar is closed (the column renders the compact control rail). */
|
||||
/** True when closed; a drawer is hidden, while other browser columns retain a rail. */
|
||||
collapsed: boolean
|
||||
/** Rendered column width in px (SIDEBAR_COLLAPSED when collapsed). */
|
||||
/** Rendered sidebar width in px; a hidden drawer retains its expanded width. */
|
||||
width: number
|
||||
/** Present the retained sidebar content as an overlay drawer. */
|
||||
drawer: boolean
|
||||
}
|
||||
|
||||
/** Right column owner share: resolved normal geometry and opening eligibility. */
|
||||
@@ -160,6 +164,16 @@ export function apply(ctx: ClientContext): void {
|
||||
const t = ctx.locale.bind('shortcuts.layout')
|
||||
|
||||
ctx.effect(() => {
|
||||
// Headless profiles can instantiate client registrations without browser media APIs.
|
||||
const query = typeof matchMedia === 'function'
|
||||
? matchMedia('(device-posture: folded) and (orientation: landscape)') : undefined
|
||||
const foldedLandscape: HostObservable<boolean> = {
|
||||
getSnapshot: () => query?.matches ?? false,
|
||||
subscribe: (listener) => {
|
||||
query?.addEventListener('change', listener)
|
||||
return () => { query?.removeEventListener('change', listener) }
|
||||
},
|
||||
}
|
||||
const handle = createLayoutStore()
|
||||
const instance = handle.create()
|
||||
const store: typeof handle = { ...handle, create: () => instance }
|
||||
@@ -187,6 +201,7 @@ export function apply(ctx: ClientContext): void {
|
||||
'shell.leading': { kind: 'single', scope: 'root' },
|
||||
},
|
||||
store,
|
||||
inject: (): AppFrameInjected => ({ hooks: { foldedLandscape } }),
|
||||
}, AppFrame)
|
||||
const disposeShortcut = ctx.shortcuts.register({
|
||||
id: 'sidebar.left.toggle' as ShortcutCommandId, label: () => t('toggle'), aliases: ['sidebar', 'toggle left sidebar'],
|
||||
@@ -197,8 +212,10 @@ export function apply(ctx: ClientContext): void {
|
||||
'web:macos': { code: 'KeyB', modifiers: ['primary', 'alt'] },
|
||||
'web:windows': { code: 'KeyB', modifiers: ['primary', 'alt'] },
|
||||
},
|
||||
regions: ['page', 'editable'], modals: [],
|
||||
resolve: () => ({ status: 'handled', run: () => { layout.toggleSidebar() } }),
|
||||
regions: ['page', 'editable'], modals: ['sidebar'],
|
||||
resolve: ({ modal }) => modal !== null && modal !== 'sidebar'
|
||||
? { status: 'pass' }
|
||||
: { status: 'handled', run: () => { layout.toggleSidebar() } },
|
||||
})
|
||||
const disposePanels = ctx.slots.subscribe('main', retainMainPanels)
|
||||
retainMainPanels()
|
||||
|
||||
@@ -6,7 +6,7 @@ import { defineStore, type EngineStoreHandle } from '@deepseek-ai/dsh-client-sto
|
||||
import type { MainPanelId } from './service.ts'
|
||||
import {
|
||||
clampWidth, RIGHTBAR_DEFAULT_RATIO, RIGHTBAR_MAX_RATIO, RIGHTBAR_MIN,
|
||||
SIDEBAR_AUTO_COLLAPSE, SIDEBAR_DEFAULT, SIDEBAR_MAX, SIDEBAR_MIN,
|
||||
SIDEBAR_AUTO_COLLAPSE, SIDEBAR_DEFAULT, SIDEBAR_DRAWER_BREAKPOINT, SIDEBAR_MAX, SIDEBAR_MIN,
|
||||
} from './columns.ts'
|
||||
|
||||
/**
|
||||
@@ -93,6 +93,7 @@ export function createLayoutStore(): EngineStoreHandle<LayoutState, LayoutAction
|
||||
actions: {
|
||||
selectPanel: (d, panelId: MainPanelId | null) => {
|
||||
d.panelInfo.activePanelId = panelId
|
||||
if (d.layoutInfo.viewportWidth < SIDEBAR_DRAWER_BREAKPOINT) d.layoutInfo.narrowExpanded = false
|
||||
},
|
||||
retainMainPanels: (d, panelIds: readonly string[]) => {
|
||||
if (d.panelInfo.activePanelId !== null && !panelIds.includes(d.panelInfo.activePanelId)) {
|
||||
@@ -115,7 +116,8 @@ export function createLayoutStore(): EngineStoreHandle<LayoutState, LayoutAction
|
||||
setViewportWidth: (d, width: number) => {
|
||||
if (d.layoutInfo.viewportWidth === width) return
|
||||
d.layoutInfo.rightbarInstant = false
|
||||
if ((d.layoutInfo.viewportWidth < SIDEBAR_AUTO_COLLAPSE) !== (width < SIDEBAR_AUTO_COLLAPSE)) {
|
||||
if ((d.layoutInfo.viewportWidth < SIDEBAR_AUTO_COLLAPSE) !== (width < SIDEBAR_AUTO_COLLAPSE)
|
||||
|| (d.layoutInfo.viewportWidth < SIDEBAR_DRAWER_BREAKPOINT) !== (width < SIDEBAR_DRAWER_BREAKPOINT)) {
|
||||
d.layoutInfo.narrowExpanded = false
|
||||
}
|
||||
d.layoutInfo.viewportWidth = width
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
/** Frame interactions with a real store and explicitly driven browser measurements. */
|
||||
import type { GlobalStandardProps, RenderOpts } from '@deepseek-ai/dsh-client-ui-slots'
|
||||
import { allowAllAccess, bindSnapshotSelector } from '@deepseek-ai/dsh-client-test-runtime'
|
||||
import { createSnapshotStore, type SnapshotStore } from '@deepseek-ai/dsh-client-store'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { act, cleanup, render } from '@testing-library/react'
|
||||
import { act, cleanup, fireEvent, render } from '@testing-library/react'
|
||||
import { AppFrame } from '../src/client/AppFrame.tsx'
|
||||
import type { AppFrameProps } from '../src/client/AppFrame.tsx'
|
||||
import type { MainPanelId, RightbarOwnerProps, SidebarOwnerProps } from '../src/client/index.ts'
|
||||
@@ -33,6 +34,7 @@ let frameWidth: number
|
||||
let animationFrames: Map<number, FrameRequestCallback>
|
||||
let nextFrame: number
|
||||
let originalTitle: string
|
||||
let foldedLandscape: SnapshotStore<boolean>
|
||||
const restoreProperties: (() => void)[] = []
|
||||
|
||||
function replaceProperty<T extends object, K extends keyof T>(target: T, key: K, value: T[K]): void {
|
||||
@@ -60,13 +62,13 @@ function resize(width: number): void {
|
||||
})
|
||||
}
|
||||
|
||||
function mountFrame(windowWidth = frameWidth) {
|
||||
function mountFrame(windowWidth = frameWidth, content?: AppFrameProps['renderSlot']) {
|
||||
vi.stubGlobal('innerWidth', windowWidth)
|
||||
const instance = createLayoutStore().create()
|
||||
const slotCalls: { key: string; props: object; options: RenderOpts | undefined }[] = []
|
||||
const renderSlot: AppFrameProps['renderSlot'] = (key, owner, options) => {
|
||||
slotCalls.push({ key, props: owner, options })
|
||||
return <div data-testid={`${key}-content`} data-entry-key={options?.entryKey} />
|
||||
return content?.(key, owner, options) ?? <div data-testid={`${key}-content`} data-entry-key={options?.entryKey} />
|
||||
}
|
||||
const useSessions: AppFrameProps['useSessions'] = sel => sel({
|
||||
ids: selectedSession === undefined ? [] : [selectedSession],
|
||||
@@ -95,6 +97,7 @@ function mountFrame(windowWidth = frameWidth) {
|
||||
renderSlot={renderSlot}
|
||||
useSessions={useSessions}
|
||||
usePanelInfo={usePanelInfo}
|
||||
useFoldedLandscape={bindSnapshotSelector(foldedLandscape)}
|
||||
useSessionStatus={useSessionStatus}
|
||||
useSessionRetainInfo={() => undefined}
|
||||
useResource={useResource}
|
||||
@@ -152,6 +155,8 @@ beforeEach(() => {
|
||||
nextFrame = 1
|
||||
vi.stubEnv('DSH_CLIENT_TITLE', undefined)
|
||||
vi.stubGlobal('ResizeObserver', ResizeObserverStub)
|
||||
foldedLandscape = createSnapshotStore(false)
|
||||
vi.stubGlobal('matchMedia', () => ({ matches: false }))
|
||||
vi.stubGlobal('requestAnimationFrame', (callback: FrameRequestCallback) => {
|
||||
const id = nextFrame++
|
||||
animationFrames.set(id, callback)
|
||||
@@ -205,7 +210,7 @@ describe('AppFrame', () => {
|
||||
it('renders owner props for the default sidebar and prospective right panel', () => {
|
||||
const { frame, rightOwner, sidebarOwner, slotCalls } = mountFrame()
|
||||
expect(tracks(frame)).toEqual([280, 0])
|
||||
expect(sidebarOwner()).toEqual({ collapsed: false, width: 280 })
|
||||
expect(sidebarOwner()).toEqual({ collapsed: false, width: 280, drawer: false })
|
||||
expect(rightOwner()).toEqual({ width: 864, viewportWidth: 1920, canShow: true })
|
||||
expect(slotCalls.find(c => c.key === 'main')).toEqual({ key: 'main', props: {}, options: { entryKey: 'conversation' } })
|
||||
})
|
||||
@@ -227,14 +232,16 @@ describe('AppFrame', () => {
|
||||
expect(getByTestId('rightbar-content')).toBeTruthy()
|
||||
})
|
||||
|
||||
it('keeps Windows caption controls mounted with a zero-width collapsed column', () => {
|
||||
it.each([1920, 390])('keeps Windows caption controls mounted at %ipx with a zero-width collapsed column', (width) => {
|
||||
document.documentElement.setAttribute('data-windows-titlebar', '')
|
||||
try {
|
||||
const { frame, instance, sidebarOwner, getByTestId, queryByTestId } = mountFrame()
|
||||
act(() => { instance.actions.toggleSidebar() })
|
||||
if (width < 1024) resize(width)
|
||||
else act(() => { instance.actions.toggleSidebar() })
|
||||
expect(tracks(frame)[0]).toBe(0)
|
||||
expect(sidebarOwner()).toMatchObject({ collapsed: true, width: 0 })
|
||||
expect(sidebarOwner()).toMatchObject({ collapsed: true, width: 0, drawer: false })
|
||||
expect(getByTestId('sidebar-content')).toBeTruthy()
|
||||
expect(getByTestId('sidebar-content').closest('[inert]')).toBeNull()
|
||||
// The caption row keeps the reopen controls; the darwin-only
|
||||
// shell.leading seat must not mount a duplicate set.
|
||||
expect(queryByTestId('shell.leading-content')).toBeNull()
|
||||
@@ -247,7 +254,7 @@ describe('AppFrame', () => {
|
||||
const { frame, instance, sidebarOwner, getByTestId, queryByTestId } = mountFrame()
|
||||
act(() => { instance.actions.toggleSidebar() })
|
||||
expect(tracks(frame)).toEqual([56, 0])
|
||||
expect(sidebarOwner()).toEqual({ collapsed: true, width: 56 })
|
||||
expect(sidebarOwner()).toEqual({ collapsed: true, width: 56, drawer: false })
|
||||
expect(getByTestId('sidebar-content')).toBeTruthy()
|
||||
expect(frame.querySelector('[data-side="sidebar"]')).toBeNull()
|
||||
// The rail keeps the window chrome housed: no shell.leading seat.
|
||||
@@ -264,7 +271,7 @@ describe('AppFrame', () => {
|
||||
expect(queryByTestId('shell.leading-content')).toBeNull()
|
||||
act(() => { instance.actions.toggleSidebar() })
|
||||
expect(tracks(frame)).toEqual([0, 0])
|
||||
expect(sidebarOwner()).toEqual({ collapsed: true, width: 0 })
|
||||
expect(sidebarOwner()).toEqual({ collapsed: true, width: 0, drawer: false })
|
||||
expect(frame.querySelector('[data-shell-leading]')).not.toBeNull()
|
||||
expect(queryByTestId('shell.leading-content')).toBeTruthy()
|
||||
act(() => { instance.actions.toggleSidebar() })
|
||||
@@ -291,6 +298,37 @@ describe('AppFrame', () => {
|
||||
})
|
||||
|
||||
describe('AppFrame normal width concessions', () => {
|
||||
it('centers the sidebar while folded in landscape and restores its width without remounting', () => {
|
||||
frameWidth = 951
|
||||
const { frame, instance, sidebarOwner, getByTestId, unmount } = mountFrame()
|
||||
act(() => { instance.actions.setSidebar(360); instance.actions.toggleSidebar() })
|
||||
const sidebar = getByTestId('sidebar-content')
|
||||
expect(tracks(frame)[0]).toBe(360)
|
||||
fireEvent.transitionEnd(frame, { propertyName: 'grid-template-columns' })
|
||||
act(() => { foldedLandscape.set(true) })
|
||||
expect(tracks(frame)).toEqual([475.5, 0])
|
||||
expect(frame.dataset.animating).toBe('true')
|
||||
expect(sidebarOwner()).toEqual({ collapsed: false, width: 475.5, drawer: false })
|
||||
expect(frame.querySelector('[data-side="sidebar"]')).toBeNull()
|
||||
expect(getByTestId('sidebar-content')).toBe(sidebar)
|
||||
act(() => { instance.actions.toggleSidebar() })
|
||||
expect(tracks(frame)[0]).toBe(56)
|
||||
resize(767)
|
||||
expect(frame.dataset.animating).toBeUndefined()
|
||||
act(() => { instance.actions.toggleSidebar() })
|
||||
expect(sidebarOwner()).toEqual({ collapsed: false, width: 360, drawer: true })
|
||||
resize(951)
|
||||
act(() => { instance.actions.toggleSidebar() })
|
||||
expect(tracks(frame)[0]).toBe(475.5)
|
||||
fireEvent.transitionEnd(frame, { propertyName: 'grid-template-columns' })
|
||||
act(() => { foldedLandscape.set(false) })
|
||||
expect(tracks(frame)[0]).toBe(360)
|
||||
expect(frame.dataset.animating).toBe('true')
|
||||
expect(frame.querySelector('[data-side="sidebar"]')).not.toBeNull()
|
||||
expect(instance.getSnapshot().layoutInfo.sidebar).toBe(360)
|
||||
unmount()
|
||||
})
|
||||
|
||||
it('measures the frame, not the window, before choosing the first-open preference', () => {
|
||||
frameWidth = 1000
|
||||
const { instance, rightOwner } = mountFrame(1920)
|
||||
@@ -319,7 +357,7 @@ describe('AppFrame normal width concessions', () => {
|
||||
expect(instance.getSnapshot().layoutInfo).toMatchObject({ rightbarShown: true, rightbar: 864 })
|
||||
act(() => { instance.actions.closeRightbar() })
|
||||
resize(455)
|
||||
expect(tracks(frame)).toEqual([56, 0])
|
||||
expect(tracks(frame)).toEqual([0, 0])
|
||||
resize(1920)
|
||||
expect(tracks(frame)).toEqual([420, 0])
|
||||
})
|
||||
@@ -336,7 +374,7 @@ describe('AppFrame normal width concessions', () => {
|
||||
expect(rightOwner().canShow).toBe(true)
|
||||
})
|
||||
|
||||
it.each([[756, 300, true], [755, 0, false]] as const)('reports eligibility at %ipx', (width, rightbar, canShow) => {
|
||||
it.each([[768, 312, true], [767, 345, true], [700, 300, true], [699, 0, false]] as const)('reports eligibility at %ipx', (width, rightbar, canShow) => {
|
||||
frameWidth = width
|
||||
const { instance, rightOwner } = mountFrame()
|
||||
act(() => { instance.actions.toggleSidebar() })
|
||||
@@ -450,6 +488,30 @@ describe('AppFrame right panel presentation', () => {
|
||||
expect(frame.dataset.animating).toBe('true')
|
||||
})
|
||||
|
||||
it('skips drawer entry motion from a collapsed rail while retaining explicit toggle motion', () => {
|
||||
const { frame, instance } = mountFrame()
|
||||
resize(768)
|
||||
expect(frame.dataset.sidebarInstant).toBeUndefined()
|
||||
resize(767)
|
||||
expect(frame.dataset.sidebarInstant).toBe('true')
|
||||
resize(766)
|
||||
expect(frame.dataset.sidebarInstant).toBe('true')
|
||||
act(() => { instance.actions.toggleSidebar() })
|
||||
expect(frame.dataset.sidebarInstant).toBeUndefined()
|
||||
act(() => { instance.actions.toggleSidebar() })
|
||||
expect(frame.dataset.sidebarInstant).toBeUndefined()
|
||||
resize(768)
|
||||
resize(767)
|
||||
expect(frame.dataset.sidebarInstant).toBe('true')
|
||||
})
|
||||
|
||||
it('retains drawer entry motion when resizing an expanded sidebar', () => {
|
||||
const { frame } = mountFrame()
|
||||
resize(767)
|
||||
expect(frame.dataset.sidebarCollapsed).toBe('true')
|
||||
expect(frame.dataset.sidebarInstant).toBeUndefined()
|
||||
})
|
||||
|
||||
it('animates the rightbar track flip and settles by timeout without a transition end', () => {
|
||||
vi.useFakeTimers()
|
||||
try {
|
||||
@@ -506,11 +568,11 @@ describe('AppFrame right panel presentation', () => {
|
||||
})
|
||||
|
||||
it('retains fullscreen without a track when normal columns cannot fit', () => {
|
||||
frameWidth = 700
|
||||
frameWidth = 699
|
||||
const { frame, instance, rightOwner } = mountFrame()
|
||||
act(() => { instance.actions.openRightbar(false, true) })
|
||||
expect(tracks(frame)).toEqual([56, 0])
|
||||
expect(rightOwner()).toEqual({ width: 0, viewportWidth: 700, canShow: false })
|
||||
expect(tracks(frame)).toEqual([0, 0])
|
||||
expect(rightOwner()).toEqual({ width: 0, viewportWidth: 699, canShow: false })
|
||||
expect(instance.getSnapshot().layoutInfo.rightbarShown).toBe(true)
|
||||
expect(frame.querySelector('[data-side="rightbar"]')).toBeNull()
|
||||
})
|
||||
@@ -679,3 +741,58 @@ describe('AppFrame frame measurement lifecycle', () => {
|
||||
expect(animationFrames.size).toBe(0)
|
||||
})
|
||||
})
|
||||
|
||||
describe('sidebar drawer', () => {
|
||||
it('cancels an unfinished drawer toggle animation at the rail breakpoint', () => {
|
||||
frameWidth = 390
|
||||
const { frame, instance } = mountFrame()
|
||||
act(() => { instance.actions.toggleSidebar() })
|
||||
expect(frame.hasAttribute('data-animating')).toBe(true)
|
||||
resize(768)
|
||||
expect(frame.hasAttribute('data-animating')).toBe(false)
|
||||
})
|
||||
|
||||
it('keeps the main content at full width while opening and closing the retained drawer', () => {
|
||||
frameWidth = 390
|
||||
const { frame, instance, sidebarOwner, getByTestId } = mountFrame()
|
||||
const sidebar = getByTestId('sidebar-content')
|
||||
const main = getByTestId('main-content')
|
||||
const leading = getByTestId('shell.leading-content')
|
||||
expect(tracks(frame)).toEqual([0, 0])
|
||||
expect(sidebarOwner()).toEqual({ collapsed: true, width: 280, drawer: true })
|
||||
expect(sidebar.parentElement?.hasAttribute('inert')).toBe(true)
|
||||
const mask = frame.querySelector('[data-sidebar-mask]')
|
||||
expect(mask).not.toBeNull()
|
||||
fireEvent.click(mask!)
|
||||
expect(sidebarOwner().collapsed).toBe(true)
|
||||
act(() => { instance.actions.toggleSidebar() })
|
||||
expect(tracks(frame)).toEqual([0, 0])
|
||||
expect(sidebarOwner().collapsed).toBe(false)
|
||||
expect(sidebar.parentElement?.hasAttribute('inert')).toBe(false)
|
||||
expect(main.closest('[inert]')).not.toBeNull()
|
||||
expect(leading.closest('[inert]')).not.toBeNull()
|
||||
expect(frame.querySelector('[data-side="sidebar"]')).toBeNull()
|
||||
fireEvent.click(frame.querySelector('[aria-hidden="true"]')!)
|
||||
expect(sidebarOwner().collapsed).toBe(true)
|
||||
expect(main.closest('[inert]')).toBeNull()
|
||||
expect(getByTestId('sidebar-content')).toBe(sidebar)
|
||||
expect(getByTestId('main-content')).toBe(main)
|
||||
expect(getByTestId('shell.leading-content')).toBe(leading)
|
||||
expect(frame.querySelector('[data-sidebar-mask]')).toBe(mask)
|
||||
})
|
||||
|
||||
it('closes the drawer on navigation and restores the rail at 768px', () => {
|
||||
frameWidth = 767
|
||||
const { frame, instance, sidebarOwner } = mountFrame()
|
||||
act(() => { instance.actions.toggleSidebar() })
|
||||
act(() => { instance.actions.selectPanel('plugins' as MainPanelId) })
|
||||
expect(sidebarOwner().collapsed).toBe(true)
|
||||
act(() => { instance.actions.toggleSidebar() })
|
||||
resize(768)
|
||||
expect(sidebarOwner()).toEqual({ collapsed: true, width: 56, drawer: false })
|
||||
expect(tracks(frame)).toEqual([56, 0])
|
||||
resize(767)
|
||||
expect(sidebarOwner().collapsed).toBe(true)
|
||||
expect(tracks(frame)).toEqual([0, 0])
|
||||
})
|
||||
})
|
||||
@@ -6,13 +6,14 @@ import { Context, type Fiber } from '@deepseek-ai/cordis'
|
||||
import { stubConfigForm } from '@deepseek-ai/dsh-client-test-runtime'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { SlotRegistry } from '@deepseek-ai/dsh-client-ui-renderer/client'
|
||||
import type { SlotRendererHost } from '@deepseek-ai/dsh-client-ui-slots'
|
||||
import type { HostObservable, SlotRendererHost } from '@deepseek-ai/dsh-client-ui-slots'
|
||||
import { LocaleRuntime } from '@deepseek-ai/dsh-client-locale/client'
|
||||
import { apply as themeApply, inject as themeInject, ThemeRuntime } from '@deepseek-ai/dsh-client-ui-theme/client'
|
||||
import { apply, inject, LayoutController } from '@deepseek-ai/dsh-client-ui-layout/client'
|
||||
import { apply as nodeApply } from '@deepseek-ai/dsh-client-ui-layout'
|
||||
import type { MainPanelId } from '../src/client/service.ts'
|
||||
import type { createLayoutStore } from '../src/client/stores.ts'
|
||||
import { ShortcutRegistry } from '../../shortcuts/src/client/registry.ts'
|
||||
|
||||
const owners = new Set<Fiber>()
|
||||
let originalRootStyle: string | null
|
||||
@@ -93,12 +94,35 @@ describe('ui-layout client apply', () => {
|
||||
expect(slots.spec('shell.leading')).toEqual({ kind: 'single', scope: 'root' })
|
||||
})
|
||||
|
||||
it('keeps Desktop sidebar shortcuts behind a foreground modal', async () => {
|
||||
const { ctx, slots } = await bench()
|
||||
const shortcuts = ctx.get('shortcuts')
|
||||
if (shortcuts === undefined) throw new Error('shortcuts service is unavailable')
|
||||
const register = vi.spyOn(shortcuts, 'register')
|
||||
await ctx.plugin({ inject: [...inject], apply }).await()
|
||||
const command = register.mock.calls.find(([entry]) => entry.id === 'sidebar.left.toggle')?.[0]
|
||||
if (command === undefined) throw new Error('sidebar shortcut was not registered')
|
||||
const registry = new ShortcutRegistry('desktop', 'macos')
|
||||
registry.register(command)
|
||||
const handle = slots.entries('root')[0]!.store as ReturnType<typeof createLayoutStore>
|
||||
const width = () => handle.create().getSnapshot().layoutInfo.sidebar
|
||||
const gesture = { code: 'KeyB', meta: true, control: false, alt: false, shift: false,
|
||||
repeat: false, composing: false, defaultPrevented: false }
|
||||
const context = { region: 'editable' as const, target: null, modal: 'settings' }
|
||||
expect(registry.dispatch(gesture, context, vi.fn()).status).toBe('pass')
|
||||
expect(width()).toBe(280)
|
||||
expect(registry.dispatch(gesture, { ...context, modal: null }, vi.fn()).status).toBe('handled')
|
||||
expect(width()).toBe(0)
|
||||
expect(registry.dispatch(gesture, { ...context, modal: 'sidebar' }, vi.fn()).status).toBe('handled')
|
||||
expect(width()).toBe(280)
|
||||
})
|
||||
|
||||
it('shares a pre-created instance between service actions, root rendering, and panelInfo', async () => {
|
||||
const { ctx, slots, rendererHost } = await bench()
|
||||
const fiber = ctx.plugin({ inject: [...inject], apply })
|
||||
await fiber.await()
|
||||
const entry = slots.entries('root')[0]!
|
||||
expect(entry.inject).toBeUndefined()
|
||||
expect(entry.inject).toBeTypeOf('function')
|
||||
const handle = entry.store as ReturnType<typeof createLayoutStore>
|
||||
const instance = handle.create()
|
||||
expect(handle.create()).toBe(instance)
|
||||
@@ -149,6 +173,47 @@ describe('ui-layout client apply', () => {
|
||||
expect(document.body.hasAttribute('data-ds-dark-theme')).toBe(false)
|
||||
})
|
||||
|
||||
it('injects one live folded-landscape source and releases each subscription', async () => {
|
||||
const query = Object.assign(new EventTarget(), { matches: true })
|
||||
vi.stubGlobal('matchMedia', (media: string) => media === '(device-posture: folded) and (orientation: landscape)'
|
||||
? query : Object.assign(new EventTarget(), { matches: false }))
|
||||
const { ctx, slots } = await bench()
|
||||
const fiber = ctx.plugin({ inject: [...inject], apply })
|
||||
await fiber.await()
|
||||
const entry = slots.entries('root')[0]
|
||||
if (entry?.inject === undefined) throw new Error('the root entry must inject its media source')
|
||||
const first = entry.inject() as { hooks: { foldedLandscape: HostObservable<boolean> } }
|
||||
const second = entry.inject() as typeof first
|
||||
const source = first.hooks.foldedLandscape
|
||||
expect(second.hooks.foldedLandscape).toBe(source)
|
||||
expect(source.getSnapshot()).toBe(true)
|
||||
const listener = vi.fn()
|
||||
const unsubscribe = source.subscribe(listener)
|
||||
try {
|
||||
query.matches = false
|
||||
query.dispatchEvent(new Event('change'))
|
||||
expect(source.getSnapshot()).toBe(false)
|
||||
expect(listener).toHaveBeenCalledOnce()
|
||||
} finally { unsubscribe() }
|
||||
query.matches = true
|
||||
query.dispatchEvent(new Event('change'))
|
||||
expect(listener).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('provides ordinary layout when the client tree starts without browser media queries', async () => {
|
||||
vi.stubGlobal('matchMedia', undefined)
|
||||
const { ctx, slots } = await bench()
|
||||
const fiber = ctx.plugin({ inject: [...inject], apply })
|
||||
await fiber.await()
|
||||
const entry = slots.entries('root')[0]
|
||||
if (entry?.inject === undefined) throw new Error('the root entry must inject its media source')
|
||||
const source = (entry.inject() as { hooks: { foldedLandscape: HostObservable<boolean> } }).hooks.foldedLandscape
|
||||
expect(source.getSnapshot()).toBe(false)
|
||||
const listener = vi.fn()
|
||||
source.subscribe(listener)()
|
||||
expect(listener).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('teardown unwinds the service, the root registration, and the child declarations', async () => {
|
||||
const { ctx, slots, rendererHost } = await bench()
|
||||
const fiber = ctx.plugin({ inject: [...inject], apply })
|
||||
|
||||
@@ -18,6 +18,11 @@ describe('computeColumns', () => {
|
||||
expect(computeColumns(1920, 0, 0)).toEqual({ sidebar: 56, center: 1864, rightbar: 0 })
|
||||
})
|
||||
|
||||
it('aligns an expanded sidebar to the fold midpoint without widening a collapsed rail', () => {
|
||||
expect(computeColumns(951, 280, 864, 56, true)).toEqual({ sidebar: 475.5, center: 475.5, rightbar: 0 })
|
||||
expect(computeColumns(951, 0, 0, 56, true)).toEqual({ sidebar: 56, center: 895, rightbar: 0 })
|
||||
})
|
||||
|
||||
it('clamps sidebar preferences and limits the right panel to 70% of the frame', () => {
|
||||
expect(computeColumns(3000, 9999, 9999)).toEqual({ sidebar: 420, center: 480, rightbar: 2100 })
|
||||
expect(computeColumns(1920, 1, 1)).toEqual({ sidebar: 264, center: 1356, rightbar: 300 })
|
||||
|
||||
@@ -290,3 +290,21 @@ describe('right panel instant geometry', () => {
|
||||
expect(store.getSnapshot().layoutInfo).toMatchObject({ rightbarShown: true, rightbarFullscreen: fullscreen, rightbarInstant: false })
|
||||
})
|
||||
})
|
||||
|
||||
describe('drawer navigation', () => {
|
||||
it.each(['plugins' as MainPanelId, null])('closes the narrow drawer on navigation to %s', (panel) => {
|
||||
const { store, actions } = createLayoutStore().create()
|
||||
actions.setViewportWidth(390)
|
||||
actions.toggleSidebar()
|
||||
actions.selectPanel(panel)
|
||||
expect(store.getSnapshot().layoutInfo.narrowExpanded).toBe(false)
|
||||
})
|
||||
|
||||
it('keeps a tablet sidebar open when navigating', () => {
|
||||
const { store, actions } = createLayoutStore().create()
|
||||
actions.setViewportWidth(768)
|
||||
actions.toggleSidebar()
|
||||
actions.selectPanel(null)
|
||||
expect(store.getSnapshot().layoutInfo.narrowExpanded).toBe(true)
|
||||
})
|
||||
})
|
||||
Loaded 100 of 256 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user