@allbluecn/web-app 0.27.3 → 0.27.5

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.3",
3
+ "version": "0.27.5",
4
4
  "license": "AGPL-3.0-or-later",
5
5
  "type": "module",
6
6
  "files": [
@@ -37,7 +37,7 @@ vi.mock('@tanstack/react-router', () => ({
37
37
  useRouter: () => ({ invalidate: routerInvalidate }),
38
38
  }))
39
39
 
40
- import { QuickCaptureInvalidator } from '../quick-capture-invalidate'
40
+ import { QuickCaptureInvalidator, QUICK_CAPTURE_CREATED_EVENT } from '../quick-capture-invalidate'
41
41
 
42
42
  let client: QueryClient
43
43
 
@@ -71,6 +71,9 @@ describe('QuickCaptureInvalidator 主窗跨窗口失效', () => {
71
71
  it('桥推送记录创建事件 → invalidateQueries 全量失效 + router.invalidate 重跑 loader', async () => {
72
72
  mount()
73
73
  const invalidateSpy = vi.spyOn(client, 'invalidateQueries')
74
+ // 需求列表走组件内 state + listStoriesFn:需 window 事件直达 listRefresh
75
+ const listHandler = vi.fn()
76
+ window.addEventListener(QUICK_CAPTURE_CREATED_EVENT, listHandler)
74
77
  await act(async () => {
75
78
  captured?.({ kind: 'story', identifier: 'STORY-42', name: '托盘快捷记录' })
76
79
  await Promise.resolve()
@@ -78,9 +81,11 @@ describe('QuickCaptureInvalidator 主窗跨窗口失效', () => {
78
81
  expect(invalidateSpy).toHaveBeenCalledTimes(1)
79
82
  // 全量失效口径(复审 C2):无 queryKey 过滤参数——零参调用
80
83
  expect(invalidateSpy).toHaveBeenCalledWith()
81
- // 列表数据走 route loader(非 react-query):必须同时重跑 loader,
82
- // 否则新记录不会出现在需求列表(用户会以为要手动刷新)
84
+ // 列表数据走组件内 state(非 react-query,非 loader 直出):必须同时广播
85
+ // window 事件,否则只能等 presence 轮询兜底(用户实测 30-60s)
83
86
  expect(routerInvalidate).toHaveBeenCalledTimes(1)
87
+ expect(listHandler).toHaveBeenCalledTimes(1)
88
+ window.removeEventListener(QUICK_CAPTURE_CREATED_EVENT, listHandler)
84
89
  })
85
90
 
86
91
  it('desktopBridge 为 undefined(浏览器直开)→ 挂载不抛错、零订阅', () => {
@@ -4,12 +4,14 @@
4
4
 
5
5
  // 主窗跨窗口失效(托盘 mini 快捷记录面板闭环第 4 步):订阅
6
6
  // desktopBridge.onQuickCaptureCreated——mini 面板保存成功 → Electron main 广播
7
- // → 本组件刷新主窗数据。两条刷新通道缺一不可:
7
+ // → 本组件刷新主窗数据。三条通道缺一不可:
8
8
  // ① invalidateQueries() 全量失效(复审 C2 口径)——覆盖 projects-brief /
9
9
  // workspaces-brief / 通知等 react-query 缓存(灵感箱首建后侧边栏即时出现);
10
- // ② router.invalidate() 重跑 active route loader——需求列表/看板/日历的数据
11
- // 走 route loader + 组件内 reload 原语(非 react-query),仅失效 query 缓存
12
- // 不会让新记录出现在列表里(用户会以为「没保存,要手动刷新」)。
10
+ // ② router.invalidate() 重跑 active route loader——覆盖非列表页;
11
+ // ③ window 自定义事件 `allblue:quick-capture-created`——需求列表的数据走
12
+ // 组件内 state + listStoriesFn(非 react-query、非 loader 直出),前两条
13
+ // 对它只能靠 usePresenceListRefresh 的 30-60s 轮询兜底(用户实测延迟是
14
+ // 这个轮询),故额外广播事件让 story-list-view 立即调自己的 listRefresh()。
13
15
  // 旧壳(无此方法)undefined、浏览器直开(无桥)null——可选链双保险优雅降级。
14
16
  // 挂载点:providers(Providers 全页挂载,DesktopRenamedToast 旁)。
15
17
  import { useEffect } from "react"
@@ -17,6 +19,9 @@ import { useQueryClient } from "@tanstack/react-query"
17
19
  import { useRouter } from "@tanstack/react-router"
18
20
  import { getDesktopBridge } from "@/lib/desktop-bridge-types"
19
21
 
22
+ /** 快捷记录创建事件(window 级):story-list-view 订阅后走自身 listRefresh */
23
+ export const QUICK_CAPTURE_CREATED_EVENT = "allblue:quick-capture-created"
24
+
20
25
  export function QuickCaptureInvalidator() {
21
26
  const queryClient = useQueryClient()
22
27
  const router = useRouter()
@@ -25,6 +30,7 @@ export function QuickCaptureInvalidator() {
25
30
  const off = getDesktopBridge()?.onQuickCaptureCreated?.(() => {
26
31
  void queryClient.invalidateQueries()
27
32
  void router.invalidate()
33
+ window.dispatchEvent(new CustomEvent(QUICK_CAPTURE_CREATED_EVENT))
28
34
  })
29
35
  return off
30
36
  }, [queryClient, router])
@@ -115,6 +115,7 @@ export function QuickCapturePanel({ initialMode }: { initialMode: QuickCaptureMo
115
115
  const savingRef = useRef(false)
116
116
  const tiptapEditorRef = useRef<any>(null)
117
117
  const editorWrapRef = useRef<HTMLDivElement | null>(null)
118
+ const titleInputRef = useRef<HTMLInputElement | null>(null)
118
119
 
119
120
  const { model: aiModel, setModel: setAiModel, groups: aiGroups } = useStoryAiModel()
120
121
  // 项目花名册:listProjectsBriefFn 内部先 ensureBuiltinIndependentProject,
@@ -186,6 +187,21 @@ export function QuickCapturePanel({ initialMode }: { initialMode: QuickCaptureMo
186
187
  setMounted(true)
187
188
  }, [])
188
189
 
190
+ // 焦点管理:面板每次获得焦点(showInactive + webContents.focus / 用户切回)
191
+ // 时把焦点放到标题框。否则焦点停在第一个可聚焦元素(顶部图钉按钮)——表现为
192
+ // 图钉出现 focus ring、Enter/Esc 落到按钮上(快捷键像失效)。用户正在其他
193
+ // 输入控件里编辑时不抢焦点。
194
+ useEffect(() => {
195
+ const focusTitle = () => {
196
+ const active = document.activeElement
197
+ if (active && active !== document.body && active !== titleInputRef.current) return
198
+ titleInputRef.current?.focus()
199
+ }
200
+ focusTitle()
201
+ window.addEventListener('focus', focusTitle)
202
+ return () => window.removeEventListener('focus', focusTitle)
203
+ }, [])
204
+
189
205
  useEffect(() => {
190
206
  const bridge = getDesktopBridge()
191
207
  void bridge
@@ -449,6 +465,7 @@ export function QuickCapturePanel({ initialMode }: { initialMode: QuickCaptureMo
449
465
 
450
466
  <Input
451
467
  autoFocus
468
+ ref={titleInputRef}
452
469
  value={name}
453
470
  onChange={(e) => setName(e.target.value)}
454
471
  onKeyDown={handleTitleKeyDown}
@@ -47,6 +47,7 @@ import { flattenStoryGroups } from "./display/flatten-story-groups";
47
47
  import { toast } from "@/components/ui/toast";
48
48
  import { ConfirmDialog } from "@/components/confirm-dialog";
49
49
  import { usePresenceListRefresh } from "@/lib/collab/use-presence-list-refresh";
50
+ import { QUICK_CAPTURE_CREATED_EVENT } from "@/components/desktop/quick-capture-invalidate";
50
51
  import { m } from "@/paraglide/messages.js";
51
52
  import { toastError } from "@/lib/toast-error";
52
53
 
@@ -385,6 +386,15 @@ export function StoryListView({ stories: initialStories, users: initialUsers, pr
385
386
  // 轮询兜底 → 走既有重拉入口(协同落库不 bump updatedAt,列表无推送通道)
386
387
  usePresenceListRefresh({ module: "stories", refresh: listRefresh });
387
388
 
389
+ // 托盘 mini 面板快捷记录(跨窗口):立即重拉列表,不等 presence 轮询兜底的
390
+ // 30-60s。事件由 QuickCaptureInvalidator(Providers 全局)在主窗收到 Electron
391
+ // 广播后派发;本组件数据走组件内 state + listStoriesFn(非 react-query),
392
+ // 只有这条直达通道能做到「保存后立即出现」。
393
+ useEffect(() => {
394
+ window.addEventListener(QUICK_CAPTURE_CREATED_EVENT, listRefresh);
395
+ return () => window.removeEventListener(QUICK_CAPTURE_CREATED_EVENT, listRefresh);
396
+ }, [listRefresh]);
397
+
388
398
  const projectContext = useMemo(() => {
389
399
  if (!projectId) return null;
390
400
  const project = projects.find((p) => p.id === projectId);
@@ -58,13 +58,15 @@ interface MentionItemProps {
58
58
  }
59
59
 
60
60
  export const MentionDropdownMenu = (props: MentionDropdownMenuProps) => {
61
+ // useEditorServices 是 hook(内部 useContext),必须在组件渲染期调用——
62
+ // 放进 queryFn 会在 react-query 的异步上下文里触发 Invalid hook call,被
63
+ // query 全局 onError 捕获成「请求失败」toast(每次编辑器挂载即触发:
64
+ // mini 面板 / 创建需求弹窗 / 需求详情都会复现)。
65
+ const es = useEditorServices() ?? {}
66
+ const { mentionUserSource } = es
61
67
  const { data: teamUsers = [] } = useQuery({
62
68
  queryKey: ['teamUsers'],
63
- queryFn: () => {
64
- const es = useEditorServices() ?? {}
65
- const { mentionUserSource } = es
66
- return mentionUserSource?.listUsers?.() ?? []
67
- },
69
+ queryFn: () => mentionUserSource?.listUsers?.() ?? [],
68
70
  staleTime: 60_000,
69
71
  })
70
72
 
@@ -112,7 +112,7 @@ export const SDK_GROUPS: SdkGroup[] = [
112
112
  "items": [
113
113
  {
114
114
  "name": "@allbluecn/web-app",
115
- "version": "v0.27.3",
115
+ "version": "v0.27.5",
116
116
  "lastUpdate": "Nov 5, 2026",
117
117
  "source": "apps/web/package.json",
118
118
  "docsUrl": "https://github.com/allbluecn/allblue"