@allbluecn/web-app 0.27.13 → 0.27.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allbluecn/web-app",
3
- "version": "0.27.13",
3
+ "version": "0.27.15",
4
4
  "license": "AGPL-3.0-or-later",
5
5
  "type": "module",
6
6
  "files": [
@@ -0,0 +1,87 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ // 回归哨兵(2026-11-06 桌面 0.9.13 实踩):「更多 → 选择模型」子菜单的
19
+ // 「本地工作区」DropdownMenuLabel 曾漏包 DropdownMenuGroup,打开本地模型
20
+ // 子菜单即抛 Base UI error #31(MenuGroupContext is missing)→ 整页错误。
21
+ import { describe, expect, it, vi } from "vitest"
22
+ import { render, screen } from "@testing-library/react"
23
+ import userEvent from "@testing-library/user-event"
24
+ import { MorePopover } from "../more-popover"
25
+ import type { StoryAiModelItem, StoryAiModelSelectState } from "../../model-types"
26
+
27
+ vi.mock("@/components/ai/model-brand-icon", () => ({
28
+ ModelBrandIcon: () => <span data-testid="model-icon" />,
29
+ }))
30
+
31
+ const MODEL_VALUE = "local:acp%3Aopencode:opencode-go%2Fdeepseek-v4-pro"
32
+
33
+ const selected: StoryAiModelItem = {
34
+ value: MODEL_VALUE,
35
+ label: "DeepSeek V4 Pro",
36
+ kind: "local",
37
+ iconModel: { id: "opencode-go/deepseek-v4-pro", name: "OpenCode Go/DeepSeek V4 Pro" },
38
+ providerLabel: "OpenCode",
39
+ local: {
40
+ agentId: "acp:opencode",
41
+ agentLabel: "OpenCode",
42
+ modelId: "opencode-go/deepseek-v4-pro",
43
+ },
44
+ }
45
+
46
+ function buildModelSelect(): StoryAiModelSelectState {
47
+ return {
48
+ model: MODEL_VALUE,
49
+ groups: [
50
+ {
51
+ label: "本地 · OPENCODE · DEEPSEEK",
52
+ items: [selected],
53
+ },
54
+ ],
55
+ onModelChange: vi.fn(),
56
+ selected,
57
+ workspaceState: {
58
+ supported: true,
59
+ workspaces: ["/Users/x/Downloads"],
60
+ cwd: "/Users/x/Downloads",
61
+ loading: false,
62
+ select: vi.fn(),
63
+ authorize: vi.fn(),
64
+ },
65
+ }
66
+ }
67
+
68
+ describe("MorePopover 本地模型子菜单", () => {
69
+ it("打开本地模型子菜单时渲染工作区分组,不抛 Base UI group context 错误", async () => {
70
+ const user = userEvent.setup()
71
+ render(
72
+ <MorePopover
73
+ collapsedActions={[]}
74
+ onActionClick={() => {}}
75
+ modelSelect={buildModelSelect()}
76
+ />,
77
+ )
78
+
79
+ await user.click(screen.getByRole("button", { name: /更多/ }))
80
+ const trigger = await screen.findByRole("menuitem", { name: /DeepSeek V4 Pro/ })
81
+ await user.hover(trigger)
82
+
83
+ expect(await screen.findByText("本地工作区")).toBeInTheDocument()
84
+ expect(screen.getByText("Downloads")).toBeInTheDocument()
85
+ expect(screen.getByText("授权工作区…")).toBeInTheDocument()
86
+ })
87
+ })
@@ -172,36 +172,41 @@ export function MorePopover({
172
172
  {showWorkspace && workspaceState !== undefined && (
173
173
  <>
174
174
  <DropdownMenuSeparator />
175
- <DropdownMenuLabel className="text-[10px] uppercase text-muted-foreground">
176
- {m.story_storyAi_model_localWorkspace()}
177
- </DropdownMenuLabel>
178
- {workspaceState.workspaces.length === 0 ? (
179
- <div className="px-2 py-1.5 text-[11px] text-muted-foreground">
180
- {m.story_storyAi_model_noWorkspace()}
181
- </div>
182
- ) : (
183
- workspaceState.workspaces.map((path) => (
184
- <DropdownMenuItem
185
- key={path}
186
- onClick={() => workspaceState.select(path)}
187
- className="gap-1.5 text-xs"
188
- >
189
- <span className="min-w-0 flex-1 truncate">
190
- {folderNameOf(path)}
191
- </span>
192
- {workspaceState.cwd === path && (
193
- <Check className="size-3.5 shrink-0 text-primary" />
194
- )}
195
- </DropdownMenuItem>
196
- ))
197
- )}
198
- <DropdownMenuItem
199
- onClick={() => void workspaceState.authorize()}
200
- className="gap-1.5 text-xs text-muted-foreground"
201
- >
202
- <FolderOpen className="size-3.5 shrink-0" />
203
- {m.story_storyAi_model_authorizeWorkspace()}
204
- </DropdownMenuItem>
175
+ {/* DropdownMenuLabel 是 Menu.GroupLabel:必须包在
176
+ DropdownMenuGroup 内,否则 Base UI error #31
177
+ (MenuGroupContext is missing)→ 路由错误页 */}
178
+ <DropdownMenuGroup>
179
+ <DropdownMenuLabel className="text-[10px] uppercase text-muted-foreground">
180
+ {m.story_storyAi_model_localWorkspace()}
181
+ </DropdownMenuLabel>
182
+ {workspaceState.workspaces.length === 0 ? (
183
+ <div className="px-2 py-1.5 text-[11px] text-muted-foreground">
184
+ {m.story_storyAi_model_noWorkspace()}
185
+ </div>
186
+ ) : (
187
+ workspaceState.workspaces.map((path) => (
188
+ <DropdownMenuItem
189
+ key={path}
190
+ onClick={() => workspaceState.select(path)}
191
+ className="gap-1.5 text-xs"
192
+ >
193
+ <span className="min-w-0 flex-1 truncate">
194
+ {folderNameOf(path)}
195
+ </span>
196
+ {workspaceState.cwd === path && (
197
+ <Check className="size-3.5 shrink-0 text-primary" />
198
+ )}
199
+ </DropdownMenuItem>
200
+ ))
201
+ )}
202
+ <DropdownMenuItem
203
+ onClick={() => void workspaceState.authorize()}
204
+ className="gap-1.5 text-xs text-muted-foreground"
205
+ >
206
+ <FolderOpen className="size-3.5 shrink-0" />
207
+ {m.story_storyAi_model_authorizeWorkspace()}
208
+ </DropdownMenuItem>
209
+ </DropdownMenuGroup>
205
210
  </>
206
211
  )}
207
212
  </div>
@@ -317,8 +317,11 @@ export function StoryAiToolbar(props: StoryAiToolbarProps) {
317
317
  const isTrailingPos = variant !== "leading"
318
318
  const isHover = variant === "trailing-hover"
319
319
  // 收起后 trailing 模型按钮改用 hidden(display:none 彻底让位,空间留给可见按钮 + 更多),
320
- // 模型选择移入「更多」按钮的右侧子菜单;overflow hook 用缓存宽度判断恢复(hysteresis)
321
- const collapsed = isTrailingPos && hasOverflow
320
+ // 模型选择移入「更多」按钮的右侧子菜单;overflow hook 用缓存宽度判断恢复(hysteresis)。
321
+ // ⚠ Popover 打开期间禁止隐藏触发器:锚点 display:none 后 getBoundingClientRect
322
+ // 归零,Floating UI 会把弹层钉到视口左上角(表现为选择模型后列表漂移)。
323
+ // 溢出收起推迟到弹层关闭后(下一次 re-render 时再隐藏)。
324
+ const collapsed = isTrailingPos && hasOverflow && !popoverOpen
322
325
  return (
323
326
  <Popover
324
327
  open={popoverOpen}
@@ -179,6 +179,28 @@ export function useToolbarOverflow(args: UseToolbarOverflowArgs): OverflowResult
179
179
  }
180
180
  }, [containerRef, measure, apply])
181
181
 
182
+ // 窗口 resize 兜底:Electron/PeekPanel 场景下容器 RO 可能被布局事务推迟,
183
+ // 表现为拖完窗口后 toolbar 仍按旧宽度堆叠,直到下一次交互 re-render 才更新。
184
+ // rAF 合并(拖拽期每帧最多一次),在布局稳定后再测一次,保证 resize 结束
185
+ // 即收敛到正确收起状态。
186
+ useEffect(() => {
187
+ if (typeof window === "undefined") return
188
+ let frame = 0
189
+ const schedule = () => {
190
+ if (frame !== 0) return
191
+ frame = window.requestAnimationFrame(() => {
192
+ frame = 0
193
+ const next = measure()
194
+ if (next) apply(next)
195
+ })
196
+ }
197
+ window.addEventListener("resize", schedule)
198
+ return () => {
199
+ window.removeEventListener("resize", schedule)
200
+ if (frame !== 0) window.cancelAnimationFrame(frame)
201
+ }
202
+ }, [measure, apply])
203
+
182
204
  return result
183
205
  }
184
206
 
@@ -112,7 +112,7 @@ export const SDK_GROUPS: SdkGroup[] = [
112
112
  "items": [
113
113
  {
114
114
  "name": "@allbluecn/web-app",
115
- "version": "v0.27.13",
115
+ "version": "v0.27.15",
116
116
  "lastUpdate": "Nov 6, 2026",
117
117
  "source": "apps/web/package.json",
118
118
  "docsUrl": "https://github.com/allbluecn/allblue"