@allbluecn/web-app 0.4.8 → 0.4.10

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.
Files changed (43) hide show
  1. package/package.json +11 -8
  2. package/src/components/chat/ai-chat-history/components/conversation-item.tsx +1 -1
  3. package/src/components/chat/ai-chat-history/index.tsx +1 -1
  4. package/src/components/{command-palette.tsx → command/command-palette.tsx} +95 -47
  5. package/src/components/hextaui/command-menu.tsx +460 -0
  6. package/src/components/knowledge/editor/knowledge-doc-editor.tsx +4 -4
  7. package/src/components/knowledge/knowledge-settings-panel.tsx +2 -2
  8. package/src/components/knowledge/knowledge-toolbar.tsx +4 -4
  9. package/src/components/knowledge/knowledge-tree-item.tsx +3 -3
  10. package/src/components/knowledge/knowledge-tree.tsx +2 -2
  11. package/src/components/layout/sidebar-03/sidebar-search-trigger.tsx +21 -7
  12. package/src/components/settings/personal-team/account/account-client.tsx +1 -1
  13. package/src/components/story/detail/activity-timeline.tsx +7 -6
  14. package/src/lib/anyhub/manager.ts +17 -4
  15. package/src/lib/auth/auth.config.ts +2 -2
  16. package/src/lib/auth/sso-authorize.ts +1 -1
  17. package/src/lib/commands/registry.ts +2 -2
  18. package/src/lib/sanitize.ts +5 -0
  19. package/src/routes/_nav/chat/route.lazy.tsx +1 -1
  20. package/src/routes/_nav/design/index.lazy.tsx +1 -1
  21. package/src/routes/_nav/route.lazy.tsx +1 -1
  22. package/src/routes/_nav/settings/ai/route.tsx +1 -1
  23. package/src/routes/api/design/upload.ts +9 -1
  24. package/src/routes/design-files/$projectId/$artboardId/$filename.ts +6 -2
  25. package/src/routes/server.ai-stream.ts +1 -1
  26. package/src/server/audit.ts +1 -1
  27. package/src/server/keepalive/middleware.ts +1 -1
  28. package/src/server/knowledge-public/github-sync.ts +21 -3
  29. package/src/server/middlewares/audit-recorder.ts +1 -1
  30. package/src/server/middlewares/rate-limit.ts +27 -0
  31. package/src/server/references/engine.ts +11 -8
  32. package/src/server/serverFns/auth/forgot-password.ts +3 -1
  33. package/src/server/serverFns/auth/invitation.ts +1 -0
  34. package/src/server/serverFns/auth/register.ts +2 -0
  35. package/src/server/serverFns/auth/reset-password.ts +2 -0
  36. package/src/server/serverFns/auth/session.ts +2 -1
  37. package/src/server/serverFns/billing.ts +1 -1
  38. package/src/server/serverFns/compliance.ts +3 -2
  39. package/src/server/serverFns/design/settings.ts +1 -0
  40. package/src/server/serverFns/team.ts +1 -1
  41. package/src/server/sso/tokens.ts +18 -3
  42. package/src/start.ts +2 -2
  43. package/vite.shared.ts +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allbluecn/web-app",
3
- "version": "0.4.8",
3
+ "version": "0.4.10",
4
4
  "license": "AGPL-3.0-or-later",
5
5
  "type": "module",
6
6
  "files": [
@@ -27,9 +27,11 @@
27
27
  "@iconify/react": "^6.0.2",
28
28
  "@lobehub/icons": "^5.10.0",
29
29
  "@prisma/client": "^7.8.0",
30
+ "@radix-ui/react-dialog": "^1.1.23",
30
31
  "@radix-ui/react-dropdown-menu": "^2.1.16",
31
32
  "@radix-ui/react-popover": "^1.1.15",
32
33
  "@radix-ui/react-slot": "^1.2.4",
34
+ "@radix-ui/react-visually-hidden": "^1.2.11",
33
35
  "@tanstack/ai": "^0.43.0",
34
36
  "@tanstack/ai-anthropic": "^0.16.3",
35
37
  "@tanstack/ai-gemini": "^0.20.1",
@@ -102,6 +104,7 @@
102
104
  "i18next-browser-languagedetector": "^8.2.1",
103
105
  "ioredis": "^5.11.0",
104
106
  "is-hotkey": "^0.2.0",
107
+ "isomorphic-dompurify": "^3.22.0",
105
108
  "lowlight": "^3.3.0",
106
109
  "lucide-react": "^1.24.0",
107
110
  "mind-elixir": "^5.12.2",
@@ -130,14 +133,14 @@
130
133
  "three": "^0.180.0",
131
134
  "tw-animate-css": "^1.4.0",
132
135
  "zod": "^4.4.3",
133
- "@allbluecn/ai-gateway": "0.4.8",
134
- "@allbluecn/database": "0.4.8",
135
- "@allbluecn/shared": "0.4.8",
136
- "@allbluecn/prototype": "0.1.1",
136
+ "@allbluecn/database": "0.4.10",
137
137
  "@allbluecn/kernel": "0.3.0",
138
- "@allbluecn/plugins-core": "0.4.8",
139
- "@allbluecn/tiptap": "0.4.8",
140
- "@allbluecn/ui": "0.4.8"
138
+ "@allbluecn/ai-gateway": "0.4.10",
139
+ "@allbluecn/plugins-core": "0.4.10",
140
+ "@allbluecn/prototype": "0.1.1",
141
+ "@allbluecn/shared": "0.4.10",
142
+ "@allbluecn/tiptap": "0.4.10",
143
+ "@allbluecn/ui": "0.4.10"
141
144
  },
142
145
  "devDependencies": {
143
146
  "@babel/parser": "^8.0.4",
@@ -102,7 +102,7 @@ export function ConversationItem({
102
102
  await onDelete(conversation.id);
103
103
  setShowDeleteDialog(false);
104
104
  } catch (error) {
105
- console.error("Failed to delete conversation:", error);
105
+ console.error("Failed to delete conversation:", error instanceof Error ? error.message : String(error));
106
106
  } finally {
107
107
  setIsDeleting(false);
108
108
  }
@@ -107,7 +107,7 @@ export default function AIChatHistory({
107
107
  await onRename(conversationId, trimmedValue);
108
108
  setEditingId(null);
109
109
  } catch (error) {
110
- console.error("Failed to rename conversation:", error);
110
+ console.error("Failed to rename conversation:", error instanceof Error ? error.message : String(error));
111
111
  } finally {
112
112
  setLoadingStates((prev) => {
113
113
  const next = { ...prev };
@@ -21,15 +21,15 @@ import { useHotkey, useHotkeySequences } from "@tanstack/react-hotkeys"
21
21
  import type { HotkeySequence } from "@tanstack/hotkeys"
22
22
  import { useTranslation } from "react-i18next"
23
23
  import {
24
- Command,
25
- CommandDialog,
26
- CommandEmpty,
27
- CommandGroup,
28
- CommandInput,
29
- CommandItem,
30
- CommandList,
31
- CommandShortcut,
32
- } from "@/components/ui/command"
24
+ CommandMenu,
25
+ CommandMenuContent,
26
+ CommandMenuInput,
27
+ CommandMenuList,
28
+ CommandMenuEmpty,
29
+ CommandMenuGroup,
30
+ CommandMenuItem,
31
+ useCommandMenu,
32
+ } from "@/components/hextaui/command-menu"
33
33
  import { CreatePRDDialog } from "@allbluecn/plugins-core/prd/components/dialog/create-prd-dialog"
34
34
  import { useCommands, type ResolvedCommand } from "@/hooks/use-commands"
35
35
  import {
@@ -54,8 +54,8 @@ import {
54
54
  ShoppingCart,
55
55
  Building2,
56
56
  Settings,
57
- Users,
58
- Earth,
57
+ SunMoon,
58
+ LogOut,
59
59
  } from "lucide-react"
60
60
  import type { LucideIcon } from "lucide-react"
61
61
 
@@ -76,8 +76,8 @@ const PALETTE_ICON_MAP: Record<string, LucideIcon> = {
76
76
  cart: ShoppingCart,
77
77
  building2: Building2,
78
78
  settings: Settings,
79
- users: Users,
80
- earth: Earth,
79
+ sunMoon: SunMoon,
80
+ logOut: LogOut,
81
81
  }
82
82
 
83
83
  export function CommandPalette() {
@@ -100,15 +100,12 @@ export function CommandPalette() {
100
100
  },
101
101
  })
102
102
 
103
- const handleClose = () => setCommandPaletteOpen(false)
104
-
105
103
  const run = (cmd: ResolvedCommand) => {
106
- handleClose()
104
+ setCommandPaletteOpen(false)
107
105
  execute(cmd)
108
106
  }
109
107
 
110
108
  useHotkey("Mod+K", toggleCommandPalette, { ignoreInputs: false })
111
-
112
109
  useHotkey("Mod+Shift+L", () => setTheme(theme === "dark" ? "light" : "dark"), {
113
110
  ignoreInputs: false,
114
111
  })
@@ -123,50 +120,101 @@ export function CommandPalette() {
123
120
  })),
124
121
  )
125
122
 
123
+ return (
124
+ <>
125
+ <CommandMenu
126
+ open={open}
127
+ onOpenChange={(next) => {
128
+ if (next) toggleCommandPalette()
129
+ else setCommandPaletteOpen(false)
130
+ }}
131
+ >
132
+ <CommandMenuContent className="w-205">
133
+ <CommandMenuInput
134
+ placeholder={t("command.searchPlaceholder")}
135
+ />
136
+ <CommandMenuList maxHeight="500px">
137
+ <CommandPaletteList commands={commands} onRun={run} t={t} />
138
+ </CommandMenuList>
139
+ </CommandMenuContent>
140
+ </CommandMenu>
141
+ <CreatePRDDialog open={prdDialogOpen} onOpenChange={setPrdDialogOpen} />
142
+ </>
143
+ )
144
+ }
145
+
146
+ function resolveShortcut(shortcut: string[]): string {
147
+ const isMac = typeof navigator !== "undefined"
148
+ && (navigator.platform.toUpperCase().includes("MAC")
149
+ || navigator.userAgent.toUpperCase().includes("MAC"))
150
+ return shortcut.map((k) => {
151
+ const upper = k.toUpperCase()
152
+ if (upper === "MOD") return isMac ? "CMD" : "CTRL"
153
+ return upper
154
+ }).join("+")
155
+ }
156
+
157
+ function CommandPaletteList({
158
+ commands,
159
+ onRun,
160
+ t,
161
+ }: {
162
+ commands: ResolvedCommand[]
163
+ onRun: (cmd: ResolvedCommand) => void
164
+ t: (key: string) => string
165
+ }) {
166
+ const { value } = useCommandMenu()
167
+
126
168
  const navCommands = commands.filter((c) => c.group === "navigation")
127
169
  const actionCommands = commands.filter((c) => c.group === "action")
128
170
 
171
+ const filterCommands = (cmds: ResolvedCommand[]): ResolvedCommand[] => {
172
+ if (!value) return cmds
173
+ const lower = value.toLowerCase()
174
+ return cmds.filter(
175
+ (c) =>
176
+ c.title.toLowerCase().includes(lower) ||
177
+ (c.keywords ?? []).some((k) => k.toLowerCase().includes(lower)),
178
+ )
179
+ }
180
+
181
+ const filteredNav = filterCommands(navCommands)
182
+ const filteredAction = filterCommands(actionCommands)
183
+
184
+ if (filteredNav.length === 0 && filteredAction.length === 0) {
185
+ return <CommandMenuEmpty>{t("command.empty")}</CommandMenuEmpty>
186
+ }
187
+
188
+ let index = 0
189
+
129
190
  const renderItem = (cmd: ResolvedCommand) => {
130
191
  const Icon = cmd.icon ? PALETTE_ICON_MAP[cmd.icon] : undefined
192
+ const idx = index++
131
193
  return (
132
- <CommandItem
194
+ <CommandMenuItem
133
195
  key={cmd.id}
134
- value={[cmd.title, ...(cmd.keywords ?? [])].join(" ")}
135
- onSelect={() => run(cmd)}
196
+ index={idx}
197
+ onSelect={() => onRun(cmd)}
198
+ shortcut={cmd.shortcut ? resolveShortcut(cmd.shortcut) : undefined}
199
+ icon={Icon && <Icon className="size-4 shrink-0" />}
136
200
  >
137
- {Icon && <Icon className="size-4 shrink-0" />}
138
201
  <span className="truncate">{cmd.title}</span>
139
- {cmd.shortcut && (
140
- <CommandShortcut>{cmd.shortcut.join(" → ")}</CommandShortcut>
141
- )}
142
- </CommandItem>
202
+ </CommandMenuItem>
143
203
  )
144
204
  }
145
205
 
146
206
  return (
147
207
  <>
148
- <CommandDialog
149
- open={open}
150
- onOpenChange={(next) =>
151
- next ? toggleCommandPalette() : handleClose()
152
- }
153
- title={t("command.searchPlaceholder")}
154
- description={t("command.searchPlaceholder")}
155
- >
156
- <Command className="rounded-xl!">
157
- <CommandInput placeholder={t("command.searchPlaceholder")} />
158
- <CommandList className="max-h-100">
159
- <CommandEmpty>{t("command.empty")}</CommandEmpty>
160
- <CommandGroup heading={t("command.groupNavigation")}>
161
- {navCommands.map(renderItem)}
162
- </CommandGroup>
163
- <CommandGroup heading={t("command.groupAction")}>
164
- {actionCommands.map(renderItem)}
165
- </CommandGroup>
166
- </CommandList>
167
- </Command>
168
- </CommandDialog>
169
- <CreatePRDDialog open={prdDialogOpen} onOpenChange={setPrdDialogOpen} />
208
+ {filteredNav.length > 0 && (
209
+ <CommandMenuGroup heading={t("command.groupNavigation")}>
210
+ {filteredNav.map(renderItem)}
211
+ </CommandMenuGroup>
212
+ )}
213
+ {filteredAction.length > 0 && (
214
+ <CommandMenuGroup heading={t("command.groupAction")}>
215
+ {filteredAction.map(renderItem)}
216
+ </CommandMenuGroup>
217
+ )}
170
218
  </>
171
219
  )
172
220
  }