@nextclaw/ui 0.12.9 → 0.12.11

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 (245) hide show
  1. package/CHANGELOG.md +102 -0
  2. package/dist/assets/ChannelsList-SQ7Oxotv.js +8 -0
  3. package/dist/assets/DocBrowser-BCO2k6XD.js +1 -0
  4. package/dist/assets/{DocBrowser-6ReNjvzF.js → DocBrowser-rDOjI3ga.js} +1 -1
  5. package/dist/assets/{DocBrowserContext-B6SpA7Qs.js → DocBrowserContext-BUq3Wo8O.js} +1 -1
  6. package/dist/assets/{LogoBadge-ByNLYg65.js → LogoBadge-DP8Ye7wJ.js} +1 -1
  7. package/dist/assets/ModelConfig-C77Ae9ru.js +1 -0
  8. package/dist/assets/ProviderScopedModelInput-CEnK61uo.js +1 -0
  9. package/dist/assets/ProvidersList-BCupBayq.js +1 -0
  10. package/dist/assets/RuntimeConfig-Ad-CAcmy.js +1 -0
  11. package/dist/assets/SearchConfig-BfCz4wJ4.js +1 -0
  12. package/dist/assets/SecretsConfig-DjmBIhyy.js +3 -0
  13. package/dist/assets/{SessionsConfig-ChHQ7M5c.js → SessionsConfig-CvjxU40H.js} +2 -2
  14. package/dist/assets/{book-open-BdcxxoQu.js → book-open-BE8M56IM.js} +1 -1
  15. package/dist/assets/chat-page-JKC6ln-y.js +58 -0
  16. package/dist/assets/chat-session-display-YcRMrAMa.js +1 -0
  17. package/dist/assets/{chunk-JZWAC4HX-DK5HPmIK.js → chunk-JZWAC4HX-erTUn3b8.js} +1 -1
  18. package/dist/assets/client-CszWMVKi.js +7 -0
  19. package/dist/assets/config-split-page-BAGSzUR3.js +1 -0
  20. package/dist/assets/{createLucideIcon-BSeTgkZW.js → createLucideIcon-CCiTGX8L.js} +1 -1
  21. package/dist/assets/desktop-DfkLlkG2.js +1 -0
  22. package/dist/assets/desktop-update-config-BXeGlqHD.js +1 -0
  23. package/dist/assets/dialog-BghZFPch.js +5 -0
  24. package/dist/assets/{dist-6TrrnPCR.js → dist-Dd9cr-kz.js} +1 -1
  25. package/dist/assets/dist-ZwoAXs46.js +9 -0
  26. package/dist/assets/{download-BhDxnyvU.js → download-D7LOizcW.js} +1 -1
  27. package/dist/assets/es2015-CEAreese.js +41 -0
  28. package/dist/assets/{external-link-BgErLCNT.js → external-link-qsnCMhw1.js} +1 -1
  29. package/dist/assets/{hash-Bl7dr_UG.js → hash-0zjWsNl-.js} +1 -1
  30. package/dist/assets/{i18n-eDHeDY0n.js → i18n-DvzXOGQX.js} +1 -1
  31. package/dist/assets/index-DvVTC9FF.css +1 -0
  32. package/dist/assets/index-lr6rQUSd.js +2 -0
  33. package/dist/assets/key-round-BLe9D8ND.js +1 -0
  34. package/dist/assets/loader-circle-wj7kARHv.js +1 -0
  35. package/dist/assets/{logos-x89HbrZ4.js → logos-_v5b2SdG.js} +1 -1
  36. package/dist/assets/marketplace-page-CAAk1Khc.js +1 -0
  37. package/dist/assets/marketplace-page-CfCiq90S.js +49 -0
  38. package/dist/assets/mcp-marketplace-page-D0Pp9Hs-.js +40 -0
  39. package/dist/assets/play-o6NmwGTi.js +1 -0
  40. package/dist/assets/plus-I9pBS4Fl.js +1 -0
  41. package/dist/assets/{refresh-cw-C47QSEwg.js → refresh-cw-MNqgR3LZ.js} +1 -1
  42. package/dist/assets/remote-C9fXm4V5.js +1 -0
  43. package/dist/assets/{save-3S6-H3Xw.js → save-D4bObrmH.js} +1 -1
  44. package/dist/assets/search-DxmL3IWE.js +1 -0
  45. package/dist/assets/security-config-BUm6FFfl.js +1 -0
  46. package/dist/assets/select-BILPf7zs.js +1 -0
  47. package/dist/assets/setting-row-BATDgg4r.js +1 -0
  48. package/dist/assets/skeleton-COKMAnJy.js +1 -0
  49. package/dist/assets/{switch-BsLtHOH-.js → switch-CBOzecWS.js} +1 -1
  50. package/dist/assets/{tabs-custom-D3HYMt6k.js → tabs-custom-Bx3cNhD-.js} +1 -1
  51. package/dist/assets/tag-chip-zUaDE2-H.js +1 -0
  52. package/dist/assets/{trash-2-G48scll7.js → trash-2-CQUgYyRn.js} +1 -1
  53. package/dist/assets/use-infinite-scroll-loader-B5V2Klve.js +1 -0
  54. package/dist/assets/useConfirmDialog-patAnl1g.js +1 -0
  55. package/dist/assets/{useMutation-CBWjE2uj.js → useMutation-__AYv-Pz.js} +1 -1
  56. package/dist/assets/x-BHUGQIUv.js +1 -0
  57. package/dist/index.html +22 -22
  58. package/dist/runtime-icons/claude.ico +0 -0
  59. package/dist/runtime-icons/codex-openai.svg +6 -0
  60. package/dist/runtime-icons/hermes-agent.png +0 -0
  61. package/module-structure.config.json +7 -0
  62. package/package.json +6 -6
  63. package/public/runtime-icons/claude.ico +0 -0
  64. package/public/runtime-icons/codex-openai.svg +6 -0
  65. package/public/runtime-icons/hermes-agent.png +0 -0
  66. package/src/api/chat-session-type.types.ts +7 -0
  67. package/src/api/config.ts +10 -0
  68. package/src/api/raw-client.test.ts +1 -1
  69. package/src/api/{raw-client.ts → raw-client.utils.ts} +2 -0
  70. package/src/api/runtime-control.types.ts +8 -0
  71. package/src/api/types.ts +48 -0
  72. package/src/app/components/app-manager-provider.tsx +20 -0
  73. package/src/app/managers/app.manager.ts +12 -0
  74. package/src/app.tsx +223 -59
  75. package/src/components/agents/agent-dialogs.tsx +499 -0
  76. package/src/components/agents/agents-page.test.tsx +238 -0
  77. package/src/components/agents/agents-page.tsx +435 -0
  78. package/src/components/chat/chat-conversation-panel.test.tsx +30 -0
  79. package/src/components/chat/chat-conversation-panel.tsx +83 -13
  80. package/src/components/chat/chat-input/ncp-chat-input-availability.utils.test.ts +92 -0
  81. package/src/components/chat/chat-input/ncp-chat-input-availability.utils.ts +45 -0
  82. package/src/components/chat/chat-page-shell.tsx +19 -13
  83. package/src/components/chat/chat-session-type-option-item.test.tsx +46 -0
  84. package/src/components/chat/chat-session-type-option-item.tsx +68 -0
  85. package/src/components/chat/chat-session-workspace-file-preview.test.tsx +87 -0
  86. package/src/components/chat/chat-session-workspace-file-preview.tsx +14 -43
  87. package/src/components/chat/chat-session-workspace-panel-nav.tsx +8 -2
  88. package/src/components/chat/chat-sidebar-project-groups.tsx +11 -36
  89. package/src/components/chat/containers/chat-input-bar.container.tsx +24 -12
  90. package/src/components/chat/{ChatSidebar.test.tsx → containers/chat-sidebar.test.tsx} +5 -4
  91. package/src/components/chat/{ChatSidebar.tsx → containers/chat-sidebar.tsx} +24 -72
  92. package/src/components/chat/hooks/use-chat-sidebar-session-label-editor.ts +49 -0
  93. package/src/components/chat/ncp/__tests__/ncp-session-adapter.cancelled-tool.test.ts +77 -0
  94. package/src/components/chat/ncp/ncp-app-client-fetch.ts +3 -0
  95. package/src/components/chat/ncp/ncp-chat-input.manager.ts +13 -5
  96. package/src/components/chat/ncp/ncp-chat-page.tsx +23 -2
  97. package/src/components/chat/ncp/ncp-session-adapter.test.ts +1 -0
  98. package/src/components/chat/ncp/ncp-session-adapter.ts +3 -0
  99. package/src/components/chat/ncp/page/ncp-chat-derived-state.ts +10 -4
  100. package/src/components/chat/ncp/session-conversation/use-ncp-session-conversation.test.tsx +48 -4
  101. package/src/components/chat/ncp/session-conversation/use-ncp-session-conversation.ts +43 -5
  102. package/src/components/chat/ncp/tests/ncp-chat-input.manager.test.ts +51 -1
  103. package/src/components/chat/stores/chat-input.store.ts +2 -1
  104. package/src/components/chat/stores/chat-thread.store.ts +3 -1
  105. package/src/components/chat/useChatSessionTypeState.ts +10 -1
  106. package/src/components/chat/workspace/chat-session-workspace-file-breadcrumbs.tsx +86 -0
  107. package/src/components/common/BrandHeader.tsx +3 -1
  108. package/src/components/common/session-context-icon.tsx +15 -2
  109. package/src/components/common/{TagInput.tsx → tag-input.tsx} +25 -17
  110. package/src/components/config/ChannelForm.test.tsx +89 -3
  111. package/src/components/config/ChannelForm.tsx +157 -188
  112. package/src/components/config/ChannelsList.test.tsx +163 -119
  113. package/src/components/config/ChannelsList.tsx +90 -101
  114. package/src/components/config/ProviderForm.tsx +108 -146
  115. package/src/components/config/ProvidersList.tsx +100 -123
  116. package/src/components/config/SearchConfig.tsx +423 -393
  117. package/src/components/config/channel-form-fields-section.tsx +70 -37
  118. package/src/components/config/config-split-page.tsx +109 -0
  119. package/src/components/config/desktop-update-config.test.tsx +10 -4
  120. package/src/components/config/desktop-update-config.tsx +5 -3
  121. package/src/components/config/provider-enabled-field.tsx +17 -10
  122. package/src/components/config/runtime-control-card.test.tsx +136 -158
  123. package/src/components/config/runtime-control-card.tsx +43 -68
  124. package/src/components/config/runtime-presence-card.test.tsx +10 -14
  125. package/src/components/config/runtime-presence-card.tsx +97 -81
  126. package/src/components/layout/AppLayout.tsx +25 -37
  127. package/src/components/layout/Sidebar.tsx +4 -4
  128. package/src/components/layout/app-layout.test.tsx +46 -14
  129. package/src/components/layout/runtime-status-entry.test.tsx +101 -0
  130. package/src/components/layout/runtime-status-entry.tsx +95 -0
  131. package/src/components/layout/sidebar.layout.test.tsx +11 -5
  132. package/src/components/marketplace/marketplace-detail-doc.ts +93 -0
  133. package/src/components/marketplace/marketplace-list-card.tsx +288 -0
  134. package/src/components/marketplace/marketplace-page-data.ts +129 -0
  135. package/src/components/marketplace/marketplace-page.test.tsx +339 -0
  136. package/src/components/marketplace/marketplace-page.tsx +596 -0
  137. package/src/components/marketplace/mcp/mcp-marketplace-card.tsx +128 -0
  138. package/src/components/marketplace/mcp/mcp-marketplace-dialogs.tsx +191 -0
  139. package/src/components/marketplace/mcp/mcp-marketplace-doc.ts +152 -0
  140. package/src/components/marketplace/mcp/mcp-marketplace-page.test.tsx +223 -0
  141. package/src/components/marketplace/mcp/mcp-marketplace-page.tsx +414 -0
  142. package/src/components/ui/notice-card.tsx +129 -0
  143. package/src/components/ui/setting-row.tsx +51 -0
  144. package/src/components/ui/tag-chip.tsx +39 -0
  145. package/src/components/ui/textarea.tsx +19 -0
  146. package/src/features/account/components/account-panel.tsx +255 -0
  147. package/src/features/account/index.ts +6 -0
  148. package/src/{account → features/account}/managers/account.manager.ts +6 -5
  149. package/src/features/remote/components/remote-access-page.test.tsx +104 -0
  150. package/src/features/remote/components/remote-access-page.tsx +250 -0
  151. package/src/{hooks/useRemoteAccess.ts → features/remote/hooks/use-remote-access.ts} +1 -1
  152. package/src/features/remote/index.ts +27 -0
  153. package/src/{remote → features/remote}/managers/remote-access.manager.ts +3 -4
  154. package/src/{remote → features/remote/services}/remote-access-feedback.service.test.ts +1 -1
  155. package/src/features/system-status/hooks/use-system-status.ts +104 -0
  156. package/src/features/system-status/index.ts +12 -0
  157. package/src/features/system-status/managers/system-status.manager.bootstrap-polling.test.ts +126 -0
  158. package/src/features/system-status/managers/system-status.manager.test.ts +142 -0
  159. package/src/features/system-status/managers/system-status.manager.ts +511 -0
  160. package/src/features/system-status/stores/system-status.store.ts +32 -0
  161. package/src/features/system-status/types/system-status.types.ts +73 -0
  162. package/src/features/system-status/utils/system-status.utils.test.ts +132 -0
  163. package/src/features/system-status/utils/system-status.utils.ts +202 -0
  164. package/src/hooks/use-realtime-query-bridge.ts +34 -18
  165. package/src/hooks/useConfig.ts +2 -1
  166. package/src/index.css +24 -0
  167. package/src/lib/app-resource-uri.test.ts +20 -0
  168. package/src/lib/app-resource-uri.ts +29 -0
  169. package/src/lib/i18n.chat.ts +8 -0
  170. package/src/lib/i18n.remote.ts +1 -1
  171. package/src/lib/i18n.runtime-control.ts +31 -0
  172. package/src/lib/i18n.ts +5 -8
  173. package/src/lib/session-context.utils.test.ts +71 -0
  174. package/src/lib/session-context.utils.ts +28 -3
  175. package/src/lib/session-project/workspace-file-breadcrumb.test.ts +83 -0
  176. package/src/lib/session-project/workspace-file-breadcrumb.ts +188 -0
  177. package/src/platforms/desktop/index.ts +20 -0
  178. package/src/{desktop → platforms/desktop}/managers/desktop-presence.manager.ts +2 -2
  179. package/src/{desktop → platforms/desktop}/managers/desktop-update.manager.ts +2 -2
  180. package/src/{desktop → platforms/desktop}/stores/desktop-presence.store.ts +1 -1
  181. package/src/{desktop → platforms/desktop}/stores/desktop-update.store.ts +1 -1
  182. package/src/stores/ui.store.ts +0 -9
  183. package/src/transport/{app-client.ts → app-client.service.ts} +9 -9
  184. package/src/transport/app-client.test.ts +9 -5
  185. package/src/transport/index.ts +1 -1
  186. package/src/transport/{local.transport.ts → local-transport.service.ts} +14 -12
  187. package/dist/assets/ChannelsList-Ita2Zm1_.js +0 -8
  188. package/dist/assets/DocBrowser-BNwbPHf4.js +0 -1
  189. package/dist/assets/MarketplacePage-CjX2MWww.js +0 -1
  190. package/dist/assets/MarketplacePage-D0sDlYX4.js +0 -49
  191. package/dist/assets/McpMarketplacePage-BGKJm1sJ.js +0 -40
  192. package/dist/assets/ModelConfig-BzZenCH-.js +0 -1
  193. package/dist/assets/ProviderScopedModelInput-Da7khnBA.js +0 -1
  194. package/dist/assets/ProvidersList-BbVzRxjY.js +0 -1
  195. package/dist/assets/RemoteAccessPage-BaDH_X1Q.js +0 -1
  196. package/dist/assets/RuntimeConfig-F_XKGgLm.js +0 -1
  197. package/dist/assets/SearchConfig-BGkzXQP-.js +0 -1
  198. package/dist/assets/SecretsConfig-D281Rotl.js +0 -3
  199. package/dist/assets/app-query-client-VnFElj4E.js +0 -1
  200. package/dist/assets/chat-page-Doe0yTtB.js +0 -58
  201. package/dist/assets/chat-session-display-cw78aiI_.js +0 -1
  202. package/dist/assets/client-_i4MU2bB.js +0 -7
  203. package/dist/assets/config-DtIQwrHF.js +0 -1
  204. package/dist/assets/config-layout-CHs0mAaR.js +0 -1
  205. package/dist/assets/desktop-update-config-Dpcf4BKG.js +0 -1
  206. package/dist/assets/dist-ccBFUi-o.js +0 -9
  207. package/dist/assets/index-CF9xve0E.js +0 -6
  208. package/dist/assets/index-FgA52VBt.css +0 -1
  209. package/dist/assets/infiniteQueryBehavior-ZDS92Qpp.js +0 -1
  210. package/dist/assets/loader-circle-ACM1s51e.js +0 -1
  211. package/dist/assets/page-layout-vZnghcFy.js +0 -1
  212. package/dist/assets/play-CFUwCA2E.js +0 -1
  213. package/dist/assets/plus-rYsv72JG.js +0 -1
  214. package/dist/assets/popover-Bg1VoTZ6.js +0 -1
  215. package/dist/assets/refresh-ccw-DT98i__E.js +0 -1
  216. package/dist/assets/rotate-cw-JtFzpNn6.js +0 -1
  217. package/dist/assets/search-3kFR_zh9.js +0 -1
  218. package/dist/assets/security-config-BWaiARNk.js +0 -1
  219. package/dist/assets/select-DJ2MUjBB.js +0 -41
  220. package/dist/assets/skeleton-ByQepn0M.js +0 -1
  221. package/dist/assets/status-dot-vbanNPFU.js +0 -1
  222. package/dist/assets/use-infinite-scroll-loader-DkNhD-42.js +0 -1
  223. package/dist/assets/useConfirmDialog-BkvTN-vd.js +0 -1
  224. package/dist/assets/x-ByDbItbq.js +0 -1
  225. package/src/account/components/account-panel.tsx +0 -135
  226. package/src/components/agents/AgentDialogs.tsx +0 -400
  227. package/src/components/agents/AgentsPage.test.tsx +0 -217
  228. package/src/components/agents/AgentsPage.tsx +0 -352
  229. package/src/components/config/config-layout.ts +0 -10
  230. package/src/components/marketplace/MarketplacePage.test.tsx +0 -322
  231. package/src/components/marketplace/MarketplacePage.tsx +0 -827
  232. package/src/components/marketplace/mcp/McpMarketplacePage.test.tsx +0 -208
  233. package/src/components/marketplace/mcp/McpMarketplacePage.tsx +0 -580
  234. package/src/components/remote/RemoteAccessPage.test.tsx +0 -103
  235. package/src/components/remote/RemoteAccessPage.tsx +0 -144
  236. package/src/hooks/use-runtime-control.ts +0 -24
  237. package/src/presenter/app-presenter-context.tsx +0 -20
  238. package/src/presenter/app.presenter.ts +0 -12
  239. package/src/runtime-control/runtime-control.manager.ts +0 -118
  240. /package/dist/assets/{config-hints-BhTmc9P1.js → config-hints-DSQQbeOA.js} +0 -0
  241. /package/src/{account → features/account}/stores/account.store.ts +0 -0
  242. /package/src/{remote → features/remote/services}/remote-access-feedback.service.ts +0 -0
  243. /package/src/{remote/remote-access.query.ts → features/remote/services/remote-access-query.service.ts} +0 -0
  244. /package/src/{remote → features/remote}/stores/remote-access.store.ts +0 -0
  245. /package/src/{desktop → platforms/desktop/types}/desktop-update.types.ts +0 -0
@@ -0,0 +1,255 @@
1
+ import { Button } from "@/components/ui/button";
2
+ import {
3
+ Dialog,
4
+ DialogContent,
5
+ DialogDescription,
6
+ DialogHeader,
7
+ DialogTitle,
8
+ } from "@/components/ui/dialog";
9
+ import { Input } from "@/components/ui/input";
10
+ import { Label } from "@/components/ui/label";
11
+ import { NoticeCard } from "@/components/ui/notice-card";
12
+ import { useRemoteStatus } from "@/features/remote";
13
+ import { formatDateTime, t } from "@/lib/i18n";
14
+ import { useAppManager } from "@/app/components/app-manager-provider";
15
+ import { useAccountStore } from "@/features/account/stores/account.store";
16
+ import { KeyRound, LogOut, SquareArrowOutUpRight } from "lucide-react";
17
+ import { useEffect, useState } from "react";
18
+
19
+ function AccountValueRow({
20
+ label,
21
+ value,
22
+ }: {
23
+ label: string;
24
+ value?: string | null;
25
+ }) {
26
+ return (
27
+ <div className="flex items-start justify-between gap-4 py-2 text-sm">
28
+ <span className="text-gray-500">{label}</span>
29
+ <span className="text-right text-gray-900">{value?.trim() || "-"}</span>
30
+ </div>
31
+ );
32
+ }
33
+
34
+ function SignedInAccountSection(props: {
35
+ email?: string | null;
36
+ username?: string | null;
37
+ role?: string | null;
38
+ canSubmitUsername: boolean;
39
+ savingUsername: boolean;
40
+ usernameDraft: string;
41
+ onUsernameDraftChange: (value: string) => void;
42
+ onSubmitUsername: () => Promise<void>;
43
+ onOpenDeviceList: () => Promise<void>;
44
+ onLogout: () => Promise<void>;
45
+ }) {
46
+ const {
47
+ email,
48
+ username,
49
+ role,
50
+ canSubmitUsername,
51
+ savingUsername,
52
+ usernameDraft,
53
+ onUsernameDraftChange,
54
+ onSubmitUsername,
55
+ onOpenDeviceList,
56
+ onLogout,
57
+ } = props;
58
+
59
+ return (
60
+ <div className="space-y-4">
61
+ <NoticeCard
62
+ tone="success"
63
+ title={t("accountPanelSignedInTitle")}
64
+ description={t("accountPanelSignedInDescription")}
65
+ />
66
+ <NoticeCard tone="neutral">
67
+ <AccountValueRow label={t("remoteAccountEmail")} value={email} />
68
+ <AccountValueRow label={t("remoteAccountUsername")} value={username} />
69
+ <AccountValueRow label={t("remoteAccountRole")} value={role} />
70
+ </NoticeCard>
71
+ {username ? (
72
+ <p className="text-xs text-gray-500">
73
+ {t("remoteAccountUsernameLockedHelp")}
74
+ </p>
75
+ ) : (
76
+ <NoticeCard
77
+ tone="warning"
78
+ title={t("remoteAccountUsernameRequiredTitle")}
79
+ description={t("remoteAccountUsernameRequiredDescription")}
80
+ >
81
+ <div className="mt-4 space-y-2">
82
+ <Label htmlFor="account-panel-username">
83
+ {t("remoteAccountUsername")}
84
+ </Label>
85
+ <Input
86
+ id="account-panel-username"
87
+ value={usernameDraft}
88
+ onChange={(event) => onUsernameDraftChange(event.target.value)}
89
+ placeholder={t("remoteAccountUsernamePlaceholder")}
90
+ autoCapitalize="none"
91
+ autoCorrect="off"
92
+ spellCheck={false}
93
+ />
94
+ </div>
95
+ <div className="mt-4 flex flex-wrap gap-3">
96
+ <Button
97
+ disabled={!canSubmitUsername}
98
+ onClick={() => void onSubmitUsername()}
99
+ >
100
+ {savingUsername
101
+ ? t("remoteAccountUsernameSaving")
102
+ : t("remoteAccountUsernameSave")}
103
+ </Button>
104
+ </div>
105
+ </NoticeCard>
106
+ )}
107
+ <div className="flex flex-wrap gap-3">
108
+ <Button onClick={() => void onOpenDeviceList()}>
109
+ <SquareArrowOutUpRight className="mr-2 h-4 w-4" />
110
+ {t("remoteOpenDeviceList")}
111
+ </Button>
112
+ <Button variant="outline" onClick={() => void onLogout()}>
113
+ <LogOut className="mr-2 h-4 w-4" />
114
+ {t("remoteLogout")}
115
+ </Button>
116
+ </div>
117
+ </div>
118
+ );
119
+ }
120
+
121
+ function SignedOutAccountSection(props: {
122
+ authSessionId?: string | null;
123
+ authExpiresAt?: string | null;
124
+ authStatusMessage?: string | null;
125
+ authVerificationUri?: string | null;
126
+ onStartBrowserSignIn: () => Promise<void>;
127
+ onResumeBrowserSignIn: () => void;
128
+ }) {
129
+ const {
130
+ authSessionId,
131
+ authExpiresAt,
132
+ authStatusMessage,
133
+ authVerificationUri,
134
+ onStartBrowserSignIn,
135
+ onResumeBrowserSignIn,
136
+ } = props;
137
+
138
+ return (
139
+ <div className="space-y-4">
140
+ <NoticeCard
141
+ tone="neutral"
142
+ title={t("accountPanelSignedOutTitle")}
143
+ description={t("accountPanelSignedOutDescription")}
144
+ >
145
+ {authSessionId ? (
146
+ <div className="mt-3 border-t border-white/80 pt-3">
147
+ <AccountValueRow
148
+ label={t("remoteBrowserAuthSession")}
149
+ value={authSessionId}
150
+ />
151
+ <AccountValueRow
152
+ label={t("remoteBrowserAuthExpiresAt")}
153
+ value={authExpiresAt ? formatDateTime(authExpiresAt) : "-"}
154
+ />
155
+ </div>
156
+ ) : null}
157
+ </NoticeCard>
158
+ {authStatusMessage ? (
159
+ <p className="text-sm text-gray-600">{authStatusMessage}</p>
160
+ ) : null}
161
+ <div className="flex flex-wrap gap-3">
162
+ <Button onClick={() => void onStartBrowserSignIn()}>
163
+ {authSessionId
164
+ ? t("remoteBrowserAuthActionRetry")
165
+ : t("remoteBrowserAuthAction")}
166
+ </Button>
167
+ {authVerificationUri ? (
168
+ <Button variant="outline" onClick={onResumeBrowserSignIn}>
169
+ {t("remoteBrowserAuthResume")}
170
+ </Button>
171
+ ) : null}
172
+ </div>
173
+ </div>
174
+ );
175
+ }
176
+
177
+ export function AccountPanel() {
178
+ const manager = useAppManager();
179
+ const remoteStatus = useRemoteStatus();
180
+ const panelOpen = useAccountStore((state) => state.panelOpen);
181
+ const authSessionId = useAccountStore((state) => state.authSessionId);
182
+ const authVerificationUri = useAccountStore(
183
+ (state) => state.authVerificationUri,
184
+ );
185
+ const authExpiresAt = useAccountStore((state) => state.authExpiresAt);
186
+ const authStatusMessage = useAccountStore((state) => state.authStatusMessage);
187
+ const status = remoteStatus.data;
188
+ const [usernameDraft, setUsernameDraft] = useState("");
189
+ const [savingUsername, setSavingUsername] = useState(false);
190
+
191
+ useEffect(() => {
192
+ manager.accountManager.syncRemoteStatus(status);
193
+ }, [manager, status]);
194
+
195
+ const canSubmitUsername =
196
+ !savingUsername &&
197
+ usernameDraft.trim().length > 0 &&
198
+ !status?.account.username;
199
+
200
+ return (
201
+ <Dialog
202
+ open={panelOpen}
203
+ onOpenChange={(open) =>
204
+ open
205
+ ? manager.accountManager.openAccountPanel()
206
+ : manager.accountManager.closeAccountPanel()
207
+ }
208
+ >
209
+ <DialogContent className="max-w-xl">
210
+ <DialogHeader>
211
+ <DialogTitle className="flex items-center gap-2">
212
+ <KeyRound className="h-5 w-5 text-primary" />
213
+ {t("accountPanelTitle")}
214
+ </DialogTitle>
215
+ <DialogDescription>{t("accountPanelDescription")}</DialogDescription>
216
+ </DialogHeader>
217
+
218
+ {status?.account.loggedIn ? (
219
+ <SignedInAccountSection
220
+ email={status.account.email}
221
+ username={status.account.username}
222
+ role={status.account.role}
223
+ canSubmitUsername={canSubmitUsername}
224
+ savingUsername={savingUsername}
225
+ usernameDraft={usernameDraft}
226
+ onUsernameDraftChange={setUsernameDraft}
227
+ onSubmitUsername={async () => {
228
+ setSavingUsername(true);
229
+ try {
230
+ await manager.accountManager.updateUsername(usernameDraft);
231
+ } finally {
232
+ setSavingUsername(false);
233
+ }
234
+ }}
235
+ onOpenDeviceList={() => manager.accountManager.openNextClawWeb('/account')}
236
+ onLogout={() => manager.accountManager.logout()}
237
+ />
238
+ ) : (
239
+ <SignedOutAccountSection
240
+ authSessionId={authSessionId}
241
+ authExpiresAt={authExpiresAt}
242
+ authStatusMessage={authStatusMessage}
243
+ authVerificationUri={authVerificationUri}
244
+ onStartBrowserSignIn={() =>
245
+ manager.accountManager.startBrowserSignIn()
246
+ }
247
+ onResumeBrowserSignIn={() =>
248
+ manager.accountManager.resumeBrowserSignIn()
249
+ }
250
+ />
251
+ )}
252
+ </DialogContent>
253
+ </Dialog>
254
+ );
255
+ }
@@ -0,0 +1,6 @@
1
+ export { AccountPanel } from './components/account-panel';
2
+ export { AccountManager } from './managers/account.manager';
3
+ export {
4
+ useAccountStore,
5
+ type AccountPendingAction,
6
+ } from './stores/account.store';
@@ -1,15 +1,15 @@
1
1
  import { logoutRemote, pollRemoteBrowserAuth, startRemoteBrowserAuth, updateRemoteAccountProfile } from '@/api/remote';
2
2
  import type { RemoteAccessView } from '@/api/remote.types';
3
- import type { AccountPendingAction } from '@/account/stores/account.store';
4
- import { useAccountStore } from '@/account/stores/account.store';
5
3
  import {
6
4
  ensureRemoteStatus,
7
5
  refreshRemoteStatus,
8
6
  resolveRemotePlatformApiBase,
9
7
  resolveRemoteWebBase
10
- } from '@/remote/remote-access.query';
8
+ } from '@/features/remote';
11
9
  import { formatDateTime, t } from '@/lib/i18n';
12
10
  import { toast } from 'sonner';
11
+ import type { AccountPendingAction } from '@/features/account/stores/account.store';
12
+ import { useAccountStore } from '@/features/account/stores/account.store';
13
13
 
14
14
  type SignedInContinuation = (action: AccountPendingAction, status: RemoteAccessView) => Promise<void>;
15
15
 
@@ -118,14 +118,15 @@ export class AccountManager {
118
118
  }
119
119
  };
120
120
 
121
- openNextClawWeb = async () => {
121
+ openNextClawWeb = async (path = '/') => {
122
122
  const status = await ensureRemoteStatus();
123
123
  const webBase = resolveRemoteWebBase(status);
124
124
  if (!webBase) {
125
125
  toast.error(t('remoteOpenWebUnavailable'));
126
126
  return;
127
127
  }
128
- window.open(webBase, '_blank', 'noopener,noreferrer');
128
+ const targetUrl = new URL(path, `${webBase.replace(/\/+$/, '')}/`).toString();
129
+ window.open(targetUrl, '_blank', 'noopener,noreferrer');
129
130
  };
130
131
 
131
132
  private scheduleBrowserAuthPoll = () => {
@@ -0,0 +1,104 @@
1
+ import { render, screen } from "@testing-library/react";
2
+ import userEvent from "@testing-library/user-event";
3
+ import { RemoteAccessPage, useRemoteAccessStore } from "@/features/remote";
4
+ import { setLanguage } from "@/lib/i18n";
5
+
6
+ const mocks = vi.hoisted(() => ({
7
+ reauthorizeRemoteAccess: vi.fn(),
8
+ repairRemoteAccess: vi.fn(),
9
+ enableRemoteAccess: vi.fn(),
10
+ disableRemoteAccess: vi.fn(),
11
+ syncStatus: vi.fn(),
12
+ openNextClawWeb: vi.fn(),
13
+ statusQuery: {
14
+ data: undefined as unknown,
15
+ isLoading: false,
16
+ },
17
+ }));
18
+
19
+ vi.mock("@/features/remote/hooks/use-remote-access", () => ({
20
+ useRemoteStatus: () => mocks.statusQuery,
21
+ }));
22
+
23
+ vi.mock("@/app/components/app-manager-provider", () => ({
24
+ useAppManager: () => ({
25
+ remoteAccessManager: {
26
+ reauthorizeRemoteAccess: mocks.reauthorizeRemoteAccess,
27
+ repairRemoteAccess: mocks.repairRemoteAccess,
28
+ enableRemoteAccess: mocks.enableRemoteAccess,
29
+ disableRemoteAccess: mocks.disableRemoteAccess,
30
+ syncStatus: mocks.syncStatus,
31
+ },
32
+ accountManager: {
33
+ openNextClawWeb: mocks.openNextClawWeb,
34
+ },
35
+ }),
36
+ }));
37
+
38
+ describe("RemoteAccessPage", () => {
39
+ beforeEach(() => {
40
+ setLanguage("zh");
41
+ mocks.reauthorizeRemoteAccess.mockReset();
42
+ mocks.repairRemoteAccess.mockReset();
43
+ mocks.enableRemoteAccess.mockReset();
44
+ mocks.disableRemoteAccess.mockReset();
45
+ mocks.syncStatus.mockReset();
46
+ mocks.openNextClawWeb.mockReset();
47
+ useRemoteAccessStore.setState({
48
+ enabled: false,
49
+ deviceName: "",
50
+ platformApiBase: "",
51
+ draftTouched: false,
52
+ advancedOpen: false,
53
+ actionLabel: null,
54
+ doctor: null,
55
+ });
56
+ mocks.statusQuery = {
57
+ data: {
58
+ account: {
59
+ loggedIn: true,
60
+ email: "user@example.com",
61
+ apiBase: "https://ai-gateway-api.nextclaw.io/v1",
62
+ platformBase: "https://ai-gateway-api.nextclaw.io",
63
+ },
64
+ settings: {
65
+ enabled: true,
66
+ deviceName: "MacBook Pro",
67
+ platformApiBase: "https://ai-gateway-api.nextclaw.io/v1",
68
+ },
69
+ service: {
70
+ running: true,
71
+ currentProcess: false,
72
+ },
73
+ localOrigin: "http://127.0.0.1:55667",
74
+ configuredEnabled: true,
75
+ platformBase: "https://ai-gateway-api.nextclaw.io",
76
+ runtime: {
77
+ enabled: true,
78
+ mode: "service",
79
+ state: "error",
80
+ lastError: "Invalid or expired token.",
81
+ updatedAt: "2026-03-23T00:00:00.000Z",
82
+ },
83
+ },
84
+ isLoading: false,
85
+ };
86
+ });
87
+
88
+ it("shows a user-facing reauthorization flow instead of raw token errors", async () => {
89
+ const user = userEvent.setup();
90
+
91
+ render(<RemoteAccessPage />);
92
+
93
+ expect(screen.getByText("登录已过期,请重新登录 NextClaw")).toBeTruthy();
94
+ expect(screen.getByText("重新登录并恢复远程访问")).toBeTruthy();
95
+ expect(screen.queryByText("Invalid or expired token.")).toBeNull();
96
+
97
+ await user.click(
98
+ screen.getByRole("button", { name: "重新登录并恢复远程访问" }),
99
+ );
100
+
101
+ expect(mocks.reauthorizeRemoteAccess).toHaveBeenCalledTimes(1);
102
+ expect(mocks.repairRemoteAccess).not.toHaveBeenCalled();
103
+ });
104
+ });
@@ -0,0 +1,250 @@
1
+ import { PageHeader, PageLayout } from "@/components/layout/page-layout";
2
+ import { Button } from "@/components/ui/button";
3
+ import {
4
+ Card,
5
+ CardContent,
6
+ CardDescription,
7
+ CardHeader,
8
+ CardTitle,
9
+ } from "@/components/ui/card";
10
+ import { NoticeCard } from "@/components/ui/notice-card";
11
+ import { StatusDot } from "@/components/ui/status-dot";
12
+ import { useAppManager } from "@/app/components/app-manager-provider";
13
+ import {
14
+ buildRemoteAccessFeedbackView,
15
+ resolveRemoteWebBase,
16
+ useRemoteAccessStore,
17
+ } from "@/features/remote";
18
+ import { useRemoteStatus } from "@/features/remote/hooks/use-remote-access";
19
+ import { formatDateTime, t } from "@/lib/i18n";
20
+ import { Laptop, RefreshCcw, SquareArrowOutUpRight } from "lucide-react";
21
+ import { useEffect, useMemo } from "react";
22
+
23
+ function KeyValueRow(props: {
24
+ label: string;
25
+ value?: string | number | null;
26
+ muted?: boolean;
27
+ }) {
28
+ const { label, muted, value: rawValue } = props;
29
+ const value =
30
+ rawValue === undefined || rawValue === null || rawValue === ""
31
+ ? "-"
32
+ : String(rawValue);
33
+ return (
34
+ <div className="flex items-start justify-between gap-4 py-2 text-sm">
35
+ <span className="text-gray-500">{label}</span>
36
+ <span
37
+ className={
38
+ muted ? "text-right text-gray-500" : "text-right text-gray-900"
39
+ }
40
+ >
41
+ {value}
42
+ </span>
43
+ </div>
44
+ );
45
+ }
46
+
47
+ export function RemoteAccessPage() {
48
+ const manager = useAppManager();
49
+ const remoteStatus = useRemoteStatus();
50
+ const status = remoteStatus.data;
51
+ const actionLabel = useRemoteAccessStore((state) => state.actionLabel);
52
+ const feedbackView = useMemo(
53
+ () => buildRemoteAccessFeedbackView(status),
54
+ [status],
55
+ );
56
+ const busy = Boolean(actionLabel);
57
+ const deviceName =
58
+ status?.runtime?.deviceName?.trim() ||
59
+ status?.settings.deviceName?.trim() ||
60
+ t("remoteDeviceNameAuto");
61
+ const canOpenDeviceList = Boolean(
62
+ status?.account.loggedIn && resolveRemoteWebBase(status),
63
+ );
64
+ const { hero: heroView, issueHint } = feedbackView;
65
+
66
+ useEffect(() => {
67
+ manager.remoteAccessManager.syncStatus(status);
68
+ }, [manager, status]);
69
+
70
+ if (remoteStatus.isLoading && !status) {
71
+ return <div className="p-8 text-gray-400">{t("remoteLoading")}</div>;
72
+ }
73
+
74
+ return (
75
+ <PageLayout className="space-y-6">
76
+ <PageHeader
77
+ title={t("remotePageTitle")}
78
+ description={t("remotePageDescription")}
79
+ />
80
+
81
+ <div className="grid gap-6 xl:grid-cols-[1.2fr_0.8fr]">
82
+ <Card>
83
+ <CardHeader className="space-y-4">
84
+ <div className="flex flex-wrap items-center gap-3">
85
+ <CardTitle>{heroView.title}</CardTitle>
86
+ <StatusDot
87
+ status={heroView.badgeStatus}
88
+ label={heroView.badgeLabel}
89
+ />
90
+ </div>
91
+ <CardDescription>{heroView.description}</CardDescription>
92
+ </CardHeader>
93
+ <CardContent className="space-y-5">
94
+ <NoticeCard tone="neutral">
95
+ <KeyValueRow
96
+ label={t("remoteSignedInAccount")}
97
+ value={status?.account.email}
98
+ />
99
+ <KeyValueRow label={t("remoteDeviceName")} value={deviceName} />
100
+ <KeyValueRow
101
+ label={t("remoteConnectionStatus")}
102
+ value={heroView.badgeLabel}
103
+ />
104
+ <KeyValueRow
105
+ label={t("remoteLastConnectedAt")}
106
+ value={
107
+ status?.runtime?.lastConnectedAt
108
+ ? formatDateTime(status.runtime.lastConnectedAt)
109
+ : "-"
110
+ }
111
+ muted
112
+ />
113
+ </NoticeCard>
114
+
115
+ <div className="flex flex-wrap gap-3">
116
+ {feedbackView.primaryAction ? (
117
+ <Button
118
+ onClick={() => {
119
+ if (feedbackView.primaryAction?.kind === "reauthorize") {
120
+ void manager.remoteAccessManager.reauthorizeRemoteAccess(
121
+ status,
122
+ );
123
+ return;
124
+ }
125
+ if (feedbackView.primaryAction?.kind === "repair") {
126
+ void manager.remoteAccessManager.repairRemoteAccess(
127
+ status,
128
+ );
129
+ return;
130
+ }
131
+ void manager.remoteAccessManager.enableRemoteAccess(
132
+ status,
133
+ );
134
+ }}
135
+ disabled={busy}
136
+ >
137
+ {feedbackView.primaryAction.showRefreshIcon ? (
138
+ <RefreshCcw className="mr-2 h-4 w-4" />
139
+ ) : null}
140
+ {actionLabel || feedbackView.primaryAction.label}
141
+ </Button>
142
+ ) : null}
143
+
144
+ <Button
145
+ variant="outline"
146
+ onClick={() => void manager.accountManager.openNextClawWeb()}
147
+ disabled={busy || !canOpenDeviceList}
148
+ >
149
+ <SquareArrowOutUpRight className="mr-2 h-4 w-4" />
150
+ {t("remoteOpenDeviceList")}
151
+ </Button>
152
+
153
+ {status?.settings.enabled ? (
154
+ <Button
155
+ variant="outline"
156
+ onClick={() =>
157
+ void manager.remoteAccessManager.disableRemoteAccess(
158
+ status,
159
+ )
160
+ }
161
+ disabled={busy}
162
+ >
163
+ {t("remoteDisable")}
164
+ </Button>
165
+ ) : null}
166
+ </div>
167
+
168
+ {feedbackView.shouldShowIssueHint && issueHint ? (
169
+ <NoticeCard
170
+ tone="warning"
171
+ title={issueHint.title}
172
+ description={issueHint.body}
173
+ />
174
+ ) : null}
175
+
176
+ <p className="text-xs text-gray-500">{t("remoteOpenWebHint")}</p>
177
+ </CardContent>
178
+ </Card>
179
+
180
+ <Card>
181
+ <CardHeader>
182
+ <CardTitle className="flex items-center gap-2">
183
+ <Laptop className="h-4 w-4 text-primary" />
184
+ {t("remoteDeviceSectionTitle")}
185
+ </CardTitle>
186
+ <CardDescription>
187
+ {t("remoteDeviceSectionDescription")}
188
+ </CardDescription>
189
+ </CardHeader>
190
+ <CardContent className="space-y-5">
191
+ <div className="flex flex-wrap gap-2">
192
+ <StatusDot
193
+ status={status?.account.loggedIn ? "ready" : "inactive"}
194
+ label={
195
+ status?.account.loggedIn
196
+ ? t("remoteAccountConnected")
197
+ : t("remoteAccountNotConnected")
198
+ }
199
+ />
200
+ <StatusDot
201
+ status={status?.settings.enabled ? "active" : "inactive"}
202
+ label={
203
+ status?.settings.enabled
204
+ ? t("remoteEnabled")
205
+ : t("remoteStateDisabled")
206
+ }
207
+ />
208
+ <StatusDot
209
+ status={status?.service.running ? "active" : "inactive"}
210
+ label={
211
+ status?.service.running
212
+ ? t("remoteServiceRunning")
213
+ : t("remoteServiceStopped")
214
+ }
215
+ />
216
+ </div>
217
+
218
+ <NoticeCard tone="neutral">
219
+ <KeyValueRow label={t("remoteDeviceName")} value={deviceName} />
220
+ <KeyValueRow
221
+ label={t("remoteConnectionStatus")}
222
+ value={heroView.badgeLabel}
223
+ />
224
+ <KeyValueRow
225
+ label={t("remoteLastConnectedAt")}
226
+ value={
227
+ status?.runtime?.lastConnectedAt
228
+ ? formatDateTime(status.runtime.lastConnectedAt)
229
+ : "-"
230
+ }
231
+ muted
232
+ />
233
+ </NoticeCard>
234
+
235
+ <NoticeCard
236
+ tone="neutral"
237
+ borderStyle="dashed"
238
+ description={
239
+ status?.account.loggedIn
240
+ ? t("remoteOpenWebHint")
241
+ : t("remoteStatusNeedsSignInDescription")
242
+ }
243
+ className="text-sm"
244
+ />
245
+ </CardContent>
246
+ </Card>
247
+ </div>
248
+ </PageLayout>
249
+ );
250
+ }
@@ -9,8 +9,8 @@ import {
9
9
  startRemoteBrowserAuth,
10
10
  updateRemoteSettings
11
11
  } from '@/api/remote';
12
+ import { REMOTE_STATUS_QUERY_KEY } from '@/features/remote';
12
13
  import { t } from '@/lib/i18n';
13
- import { REMOTE_STATUS_QUERY_KEY } from '@/remote/remote-access.query';
14
14
  import { toast } from 'sonner';
15
15
 
16
16
  export function useRemoteStatus() {
@@ -0,0 +1,27 @@
1
+ export { RemoteAccessPage } from './components/remote-access-page';
2
+ export {
3
+ useRemoteBrowserAuthPoll,
4
+ useRemoteBrowserAuthStart,
5
+ useRemoteDoctor,
6
+ useRemoteLogin,
7
+ useRemoteLogout,
8
+ useRemoteServiceControl,
9
+ useRemoteSettings,
10
+ useRemoteStatus,
11
+ } from './hooks/use-remote-access';
12
+ export { RemoteAccessManager } from './managers/remote-access.manager';
13
+ export {
14
+ buildRemoteAccessFeedbackView,
15
+ requiresRemoteReauthorization,
16
+ type RemoteAccessFeedbackView,
17
+ } from './services/remote-access-feedback.service';
18
+ export {
19
+ REMOTE_STATUS_QUERY_KEY,
20
+ ensureRemoteStatus,
21
+ getRemoteStatusSnapshot,
22
+ refreshRemoteStatus,
23
+ resolveRemotePlatformApiBase,
24
+ resolveRemotePlatformBase,
25
+ resolveRemoteWebBase,
26
+ } from './services/remote-access-query.service';
27
+ export { useRemoteAccessStore } from './stores/remote-access.store';