moi-computer 0.5.2-next.1 → 0.6.1-next.0

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 (83) hide show
  1. package/README.md +39 -0
  2. package/client/AGENTS.md +9 -0
  3. package/client/api/app-ui-keys.ts +4 -0
  4. package/client/api/workspace-keys.ts +2 -2
  5. package/client/app/routes/WorkspaceRoute.tsx +8 -28
  6. package/client/components/shared/Composer.tsx +3 -6
  7. package/client/components/shared/IconGhost.tsx +130 -0
  8. package/client/components/ui/dropdown-menu.tsx +1 -1
  9. package/client/components/ui/spinner.tsx +18 -0
  10. package/client/components/ui/toast.tsx +220 -0
  11. package/client/features/chat/ChatComposer.tsx +3 -2
  12. package/client/features/chat/ChatPanel.tsx +7 -6
  13. package/client/features/chat/ChatPopup.tsx +10 -4
  14. package/client/features/chat/ChatSelector.tsx +263 -48
  15. package/client/features/chat/ModelPicker.tsx +13 -18
  16. package/client/features/chat/api.ts +36 -9
  17. package/client/features/chat/chat-frames.ts +35 -6
  18. package/client/features/chat/chat-send.ts +25 -1
  19. package/client/features/chat/chat-store.ts +43 -18
  20. package/client/features/chat/useChat.ts +54 -52
  21. package/client/features/chat/useSelectedSession.ts +151 -0
  22. package/client/features/chat/useStickToBottom.ts +3 -3
  23. package/client/features/home/api.ts +0 -2
  24. package/client/features/scratchpad/ScratchpadControls.tsx +2 -2
  25. package/client/features/settings/WorkspaceSettings.tsx +6 -6
  26. package/client/features/views/ViewBuilderTab.tsx +3 -4
  27. package/client/features/views/useViewBuilderActions.ts +3 -1
  28. package/client/features/workspace/WorkspaceScreen.tsx +38 -17
  29. package/client/features/workspace/WorkspaceTabs.tsx +10 -1
  30. package/client/main.tsx +2 -0
  31. package/client/runtime/useWorkspaceEvents.ts +1 -0
  32. package/client/store/ui.ts +2 -2
  33. package/dist/{chunk-zs4mte79.js → chunk-0pcdwjkp.js} +1 -1
  34. package/dist/chunk-175bm057.js +27 -0
  35. package/dist/chunk-55sh4dty.js +2 -0
  36. package/dist/{chunk-tzz101ea.js → chunk-9y2zbzqz.js} +1 -1
  37. package/dist/{chunk-jvhvme3z.js → chunk-afgbg75t.js} +1 -1
  38. package/dist/chunk-agtetn7n.css +1 -0
  39. package/dist/chunk-dfs36zgc.js +1 -0
  40. package/dist/chunk-exj6hr30.js +9 -0
  41. package/dist/{chunk-bcrkdhwe.js → chunk-m11ckkxd.js} +1 -1
  42. package/dist/{chunk-kfw1qwqe.js → chunk-rxvx4ta9.js} +3 -3
  43. package/dist/{chunk-xwhya7kb.js → chunk-w3tnv51j.js} +1 -1
  44. package/dist/index.html +1 -1
  45. package/lib/attachment-note.ts +18 -0
  46. package/lib/chat-title.ts +6 -0
  47. package/lib/types.ts +24 -10
  48. package/package.json +1 -1
  49. package/server/agent-caller.ts +16 -0
  50. package/server/api.ts +90 -9
  51. package/server/app-settings.ts +1 -1
  52. package/server/cli.ts +628 -45
  53. package/server/control.ts +18 -1
  54. package/server/data-dir.ts +1 -1
  55. package/server/harness/README.md +6 -0
  56. package/server/harness/claude-code/adapter.ts +2 -2
  57. package/server/harness/claude-code/index.ts +7 -1
  58. package/server/harness/claude-code/session-title.ts +106 -0
  59. package/server/harness/claude-code/session.ts +107 -17
  60. package/server/harness/claude-code/sessions.ts +63 -4
  61. package/server/harness/codex/client.ts +33 -13
  62. package/server/harness/codex/index.ts +2 -0
  63. package/server/harness/codex/session-title.ts +149 -0
  64. package/server/harness/codex/session.ts +84 -11
  65. package/server/harness/openclaw/adapter.ts +4 -2
  66. package/server/harness/openclaw/discovery.ts +2 -0
  67. package/server/harness/openclaw/session.ts +15 -7
  68. package/server/harness/session-title.ts +96 -0
  69. package/server/harness/types.ts +2 -0
  70. package/server/selected-session.ts +132 -0
  71. package/server/service.ts +786 -0
  72. package/server/{thread-config.ts → session-config.ts} +57 -39
  73. package/server/status.ts +2 -0
  74. package/server/update.ts +141 -0
  75. package/server/version.ts +41 -0
  76. package/server/web.ts +17 -1
  77. package/workspace/.claude/skills/moi-workspace/DESIGN.md +16 -26
  78. package/workspace/.claude/skills/moi-workspace/SKILL.md +8 -2
  79. package/dist/chunk-94m3q9ce.js +0 -1
  80. package/dist/chunk-k9dcnd73.js +0 -27
  81. package/dist/chunk-pk11vfzs.js +0 -9
  82. package/dist/chunk-r2bqaege.js +0 -2
  83. package/dist/chunk-y4g8j7mv.css +0 -1
package/README.md CHANGED
@@ -79,6 +79,45 @@ Then bring in your project, either way works:
79
79
  (or import an existing folder) right from the web UI;
80
80
  - or run `moi init` inside a folder to turn it into a workspace.
81
81
 
82
+ ## Run as a service
83
+
84
+ Instead of keeping `moi start` in a terminal, install moi as a user-level
85
+ service — it starts on login, restarts on crash, and survives reboots
86
+ (launchd on macOS, a systemd user unit on Linux; no root needed):
87
+
88
+ ```sh
89
+ moi service install # install and start
90
+ moi service # state, unit path, server version
91
+ moi service logs -f # follow server logs
92
+ moi service restart
93
+ moi service uninstall
94
+ ```
95
+
96
+ The service captures a small, fixed slice of your shell environment at
97
+ install time: `PATH`, system basics (home, locale, proxies), and moi/agent
98
+ vars (`MOI_*`, `ANTHROPIC_*`, `OPENCLAW_*`, `OPENAI_*`, `PUBLIC_*`).
99
+ Anything else your agents need belongs in the workspace env (`moi env set`,
100
+ `.env`) — or capture it by name: `moi service install --env MY_TOKEN,OTHER`.
101
+ Rerun `moi service install` after changing captured vars (or moving bun). On
102
+ macOS the first install may show a "background item added" notification for
103
+ "moi"; that is the moi service. On headless Linux, lingering is enabled
104
+ automatically when possible so the service outlives your SSH session.
105
+
106
+ ## Updating
107
+
108
+ ```sh
109
+ moi update # update to the latest release
110
+ moi update --check # only check; exit 0 up to date, 1 update available, 2 check failed
111
+ ```
112
+
113
+ `moi update` checks npm for the latest release and updates through whichever
114
+ package manager owns the install (bun, npm, pnpm, or yarn). A service-managed
115
+ server is restarted onto the new version; a foreground `moi start` only gets
116
+ a warning — restart it yourself. Prerelease installs (`…-next.N`) are left
117
+ alone. `--check` changes nothing and is made for scripts and agents.
118
+ `moi status` shows when the running server and CLI versions differ, however
119
+ the update happened.
120
+
82
121
  ## OpenClaw
83
122
 
84
123
  In OpenClaw, moi is installed per _agent workspace_. First, list the agents
package/client/AGENTS.md CHANGED
@@ -15,6 +15,15 @@ Before editing host-app UI, read `../DESIGN.md` and the relevant rules in `../.a
15
15
  - UI components in `components/ui/` are shadcn built on Base UI React.
16
16
  - `lib/cn.ts` is `clsx` + `tailwind-merge`.
17
17
 
18
+ ## Vendored React
19
+
20
+ React is not bundled into the app. It ships as locally-vendored ESM in `vendor/react/` (development and production builds, generated by `scripts/build-vendor.ts`) and is served at `/vendor/react/*`, so moi runs fully offline — no CDN fetch.
21
+
22
+ - An importmap in `index.html` maps `react`, `react-dom`, and the jsx runtimes to the `/vendor/react/*` URLs. A preload script in the same file imports them, stores the modules on `globalThis.__esm`, and only then calls `__init` to mount the app — this load order is load-bearing.
23
+ - `externalize-react.ts` is a Bun bundler plugin that replaces those specifiers in bundled code with reads from `globalThis.__esm`. The point is ONE shared React instance across the host app and every applet/widget bundle (which resolve the same importmap); bundling React in would give each its own copy and break hooks.
24
+ - `structured-clone-shim.ts` must be the first import in `index.tsx`, before any tldraw module loads.
25
+ - HMR works across the bundle/vendor boundary; the `import.meta.hot.accept()` in `externalize-react.ts` is what stops every edit from escalating to a full page reload. See the comment in `index.tsx` before touching any of this.
26
+
18
27
  ## Frontend boundaries
19
28
 
20
29
  - `app/` owns routes and the app shell. Route files load data and compose features; keep feature UI out of them.
@@ -0,0 +1,4 @@
1
+ export const appUiKeys = {
2
+ all: ['app-ui'] as const,
3
+ selectedSession: (workspaceId: string) => ['app-ui', 'selected-session', workspaceId] as const
4
+ }
@@ -9,8 +9,8 @@ export const workspaceKeys = {
9
9
  viewBuilders: (id: string) => ['workspaces', 'view-builders', id] as const,
10
10
  sessions: (id: string) => ['workspaces', 'sessions', id] as const,
11
11
  events: (id: string, sessionId: string) => ['workspaces', 'events', id, sessionId] as const,
12
- threadConfig: (id: string, sessionId: string) =>
13
- ['workspaces', 'threadConfig', id, sessionId] as const,
12
+ sessionConfig: (id: string, sessionId: string) =>
13
+ ['workspaces', 'sessionConfig', id, sessionId] as const,
14
14
  mcp: (id: string) => ['workspaces', 'mcp', id] as const,
15
15
  models: (id: string) => ['workspaces', 'models', id] as const,
16
16
  availability: (id: string) => ['workspaces', 'availability', id] as const,
@@ -1,12 +1,9 @@
1
- import { useEffect } from 'react'
2
-
3
1
  import { useQueryClient } from '@tanstack/react-query'
4
2
 
5
3
  import { workspaceKeys } from '@/client/api/workspace-keys'
6
4
  import { LedLogo } from '@/client/components/shared/LedLogo'
7
5
  import { SidebarLayout } from '@/client/app/shell/SidebarLayout'
8
- import { liveStore } from '@/client/features/chat/chat-store'
9
- import { useWorkspaceSessions } from '@/client/features/chat/api'
6
+ import { useSelectedSession } from '@/client/features/chat/useSelectedSession'
10
7
  import { useAppletCacheInvalidation } from '@/client/features/applets/useApplet'
11
8
  import { Workspace } from '@/client/features/workspace/WorkspaceContext'
12
9
  import {
@@ -18,7 +15,6 @@ import { useWorkspaceViews, useWorkspaceWidgets } from '@/client/features/worksp
18
15
  import { useViewBuilders } from '@/client/features/views/api'
19
16
  import { useGridReconcile } from '@/client/features/widgets/useGridReconcile'
20
17
  import { useWorkspaceEvent } from '@/client/runtime/useWorkspaceEvents'
21
- import type { SessionInfo } from '@/lib/types'
22
18
 
23
19
  type WorkspaceRouteProps = {
24
20
  id: string
@@ -38,12 +34,11 @@ export function WorkspaceRoute({ id }: WorkspaceRouteProps) {
38
34
 
39
35
  function WorkspaceLoader({ id }: WorkspaceRouteProps) {
40
36
  const queryClient = useQueryClient()
37
+ const [selectedSessionId] = useSelectedSession()
41
38
  const { layout, setLayout, isLoading: layoutLoading } = useWorkspaceLayoutCtx()
42
39
  const widgets = useWorkspaceWidgets(id)
43
40
  const views = useWorkspaceViews(id)
44
41
  const builders = useViewBuilders(id)
45
- const sessions = useWorkspaceSessions(id)
46
-
47
42
  useGridReconcile(id, widgets.data, layout, setLayout)
48
43
  useAppletCacheInvalidation()
49
44
 
@@ -59,11 +54,15 @@ function WorkspaceLoader({ id }: WorkspaceRouteProps) {
59
54
  }
60
55
  })
61
56
 
62
- const fresh = layoutLoading || widgets.isLoading || views.isLoading || builders.isLoading
57
+ const fresh =
58
+ layoutLoading ||
59
+ selectedSessionId === undefined ||
60
+ widgets.isLoading ||
61
+ views.isLoading ||
62
+ builders.isLoading
63
63
 
64
64
  return (
65
65
  <>
66
- <SeedActiveSession workspaceId={id} sessions={sessions.data} />
67
66
  <SidebarLayout>
68
67
  {fresh ? (
69
68
  <div className="flex h-full items-center justify-center">
@@ -80,22 +79,3 @@ function WorkspaceLoader({ id }: WorkspaceRouteProps) {
80
79
  </>
81
80
  )
82
81
  }
83
-
84
- type SeedActiveSessionProps = {
85
- workspaceId: string
86
- sessions: SessionInfo[] | undefined
87
- }
88
-
89
- function SeedActiveSession({ workspaceId, sessions }: SeedActiveSessionProps) {
90
- useEffect(() => {
91
- if (!sessions) return
92
- const activeByWorkspace = liveStore.getState().activeByWorkspace
93
- const hasActiveSelection = Object.prototype.hasOwnProperty.call(activeByWorkspace, workspaceId)
94
- const activeSessionId = activeByWorkspace[workspaceId]
95
- const activeStillValid =
96
- activeSessionId === null || sessions.some(session => session.sessionId === activeSessionId)
97
- if (hasActiveSelection && activeStillValid) return
98
- liveStore.getState().setActive(workspaceId, sessions[0]?.sessionId ?? null)
99
- }, [workspaceId, sessions])
100
- return null
101
- }
@@ -1,10 +1,11 @@
1
1
  import type { ComponentProps, RefObject } from 'react'
2
2
 
3
- import { IconArrowUp, IconLoader2 } from '@tabler/icons-react'
3
+ import { IconArrowUp } from '@tabler/icons-react'
4
4
 
5
5
  import { Button } from '@/client/components/ui/button'
6
6
  import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
7
7
  import { cn } from '@/client/lib/cn'
8
+ import { Spinner } from '../ui/spinner'
8
9
 
9
10
  type ComposerProps = Omit<ComponentProps<'form'>, 'ref'> & {
10
11
  composerRef: RefObject<HTMLTextAreaElement | null>
@@ -102,11 +103,7 @@ export function ComposerSubmitButton({
102
103
  const canSubmit = canSubmitComposerAction(hasContent, busy || loading, unavailableReason)
103
104
  const button = (
104
105
  <Button type="submit" size="icon" disabled={!canSubmit} aria-label={label}>
105
- {loading ? (
106
- <IconLoader2 stroke={1.5} className="animate-spin" />
107
- ) : (
108
- <IconArrowUp stroke={1.5} />
109
- )}
106
+ {loading ? <Spinner /> : <IconArrowUp stroke={1.5} />}
110
107
  </Button>
111
108
  )
112
109
 
@@ -0,0 +1,130 @@
1
+ import { forwardRef } from 'react'
2
+
3
+ import { motion, useReducedMotion } from 'motion/react'
4
+
5
+ import { IconGhost as TablerIconGhost, type IconProps } from '@tabler/icons-react'
6
+
7
+ import { cn } from '@/client/lib/cn'
8
+
9
+ type IconGhostProps = IconProps & {
10
+ animated?: boolean
11
+ }
12
+
13
+ type Point = {
14
+ x: number
15
+ y: number
16
+ }
17
+
18
+ const bodyPath =
19
+ 'M5 11a7 7 0 0 1 14 0v7a1.78 1.78 0 0 1 -3.1 1.4a1.65 1.65 0 0 0 -2.6 0a1.65 1.65 0 0 1 -2.6 0a1.65 1.65 0 0 0 -2.6 0a1.78 1.78 0 0 1 -3.1 -1.4v-7'
20
+
21
+ const animatedEdgeY = 18.85
22
+
23
+ function formatPoint(value: number): string {
24
+ return value.toFixed(3)
25
+ }
26
+
27
+ function smoothPath(points: Point[]): string {
28
+ let path = ''
29
+
30
+ for (let index = 0; index < points.length - 1; index += 1) {
31
+ const previous = points[index - 1] ?? points[index]
32
+ const current = points[index]
33
+ const next = points[index + 1]
34
+ const afterNext = points[index + 2] ?? next
35
+ const firstControl =
36
+ index === 0
37
+ ? { x: current.x, y: current.y + 0.4 }
38
+ : {
39
+ x: current.x + (next.x - previous.x) / 6,
40
+ y: current.y + (next.y - previous.y) / 6
41
+ }
42
+ const secondControl =
43
+ index === points.length - 2
44
+ ? { x: next.x, y: next.y + 0.4 }
45
+ : {
46
+ x: next.x - (afterNext.x - current.x) / 6,
47
+ y: next.y - (afterNext.y - current.y) / 6
48
+ }
49
+
50
+ path += `C${formatPoint(firstControl.x)} ${formatPoint(firstControl.y)} ${formatPoint(secondControl.x)} ${formatPoint(secondControl.y)} ${formatPoint(next.x)} ${formatPoint(next.y)}`
51
+ }
52
+
53
+ return path
54
+ }
55
+
56
+ function bodyPathAt(progress: number): string {
57
+ const phase = progress * Math.PI * 2
58
+ const verticalProgress = 1 - Math.abs(progress * 2 - 1)
59
+ const verticalOffset = verticalProgress * 1.55
60
+ const edgeY = animatedEdgeY + verticalOffset
61
+ const points = Array.from({ length: 13 }, (_, index): Point => {
62
+ const horizontalProgress = index / 12
63
+ const envelope = Math.sin(Math.PI * horizontalProgress) ** 0.35
64
+ const baseline = edgeY + 0.3 * envelope
65
+ const wave = 0.55 * envelope * Math.sin(5 * Math.PI * horizontalProgress - phase)
66
+
67
+ return {
68
+ x: 5 + 14 * horizontalProgress,
69
+ y: baseline + wave
70
+ }
71
+ })
72
+ const sideLength = edgeY - 11
73
+
74
+ return `M5 11a7 7 0 0 1 14 0v${formatPoint(sideLength)}${smoothPath(points.reverse())}v-${formatPoint(sideLength)}`
75
+ }
76
+
77
+ const animatedBodyPaths = Array.from({ length: 17 }, (_, index) => bodyPathAt(index / 16))
78
+
79
+ const IconGhost = forwardRef<SVGSVGElement, IconGhostProps>(function IconGhost(
80
+ {
81
+ animated = false,
82
+ color = 'currentColor',
83
+ size = 24,
84
+ stroke = 2,
85
+ title,
86
+ className,
87
+ children,
88
+ ...props
89
+ },
90
+ ref
91
+ ) {
92
+ const prefersReducedMotion = useReducedMotion()
93
+ const shouldAnimate = animated && !prefersReducedMotion
94
+
95
+ return (
96
+ <svg
97
+ ref={ref}
98
+ xmlns="http://www.w3.org/2000/svg"
99
+ width={size}
100
+ height={size}
101
+ viewBox="0 0 24 24"
102
+ fill="none"
103
+ stroke={color}
104
+ strokeWidth={stroke}
105
+ strokeLinecap="round"
106
+ strokeLinejoin="round"
107
+ className={cn('tabler-icon tabler-icon-ghost', className)}
108
+ {...props}
109
+ >
110
+ {title && <title>{title}</title>}
111
+ {shouldAnimate ? (
112
+ <motion.path
113
+ d={animatedBodyPaths[0]}
114
+ animate={{ d: animatedBodyPaths }}
115
+ transition={{ duration: 2, ease: 'linear', repeat: Infinity }}
116
+ />
117
+ ) : (
118
+ <path d={bodyPath} />
119
+ )}
120
+ <path d="M10 10l.01 0" />
121
+ <path d="M14 10l.01 0" />
122
+ <path d="M10 14a3.5 3.5 0 0 0 4 0" />
123
+ {children}
124
+ </svg>
125
+ )
126
+ })
127
+
128
+ IconGhost.displayName = TablerIconGhost.displayName
129
+
130
+ export { IconGhost }
@@ -216,7 +216,7 @@ function DropdownMenuSeparator({ className, ...props }: MenuPrimitive.Separator.
216
216
  return (
217
217
  <MenuPrimitive.Separator
218
218
  data-slot="dropdown-menu-separator"
219
- className={cn('-mx-1 my-1 h-px bg-border', className)}
219
+ className={cn('mx-2 my-1 h-px bg-border', className)}
220
220
  {...props}
221
221
  />
222
222
  )
@@ -0,0 +1,18 @@
1
+ import { IconLoader2 } from '@tabler/icons-react'
2
+
3
+ import { cn } from '@/client/lib/cn'
4
+
5
+ function Spinner({ className, ...props }: React.ComponentProps<typeof IconLoader2>) {
6
+ return (
7
+ <IconLoader2
8
+ data-slot="spinner"
9
+ role="status"
10
+ aria-label="Loading"
11
+ className={cn('size-4 animate-spin', className)}
12
+ stroke={1.75}
13
+ {...props}
14
+ />
15
+ )
16
+ }
17
+
18
+ export { Spinner }
@@ -0,0 +1,220 @@
1
+ import * as React from 'react'
2
+ import { Toast as ToastPrimitive } from '@base-ui/react/toast'
3
+
4
+ import { cn } from '@/client/lib/cn'
5
+ import { Button } from '@/client/components/ui/button'
6
+ import {
7
+ IconX,
8
+ IconCircleCheck,
9
+ IconInfoCircle,
10
+ IconAlertTriangle,
11
+ IconAlertOctagon,
12
+ IconLoader
13
+ } from '@tabler/icons-react'
14
+
15
+ const toast = ToastPrimitive.createToastManager()
16
+
17
+ function ToastProvider({ ...props }: ToastPrimitive.Provider.Props) {
18
+ return <ToastPrimitive.Provider {...props} />
19
+ }
20
+
21
+ function ToastPortal({ ...props }: ToastPrimitive.Portal.Props) {
22
+ return <ToastPrimitive.Portal data-slot="toast-portal" {...props} />
23
+ }
24
+
25
+ function ToastViewport({ className, ...props }: ToastPrimitive.Viewport.Props) {
26
+ return (
27
+ <ToastPrimitive.Viewport
28
+ data-slot="toast-viewport"
29
+ className={cn(
30
+ 'pointer-events-none fixed inset-x-4 bottom-4 z-50 mx-auto w-auto max-w-sm outline-none sm:right-4 sm:left-auto sm:mx-0 sm:w-full',
31
+ className
32
+ )}
33
+ {...props}
34
+ />
35
+ )
36
+ }
37
+
38
+ function Toast({ className, ...props }: ToastPrimitive.Root.Props) {
39
+ return (
40
+ <ToastPrimitive.Root
41
+ data-slot="toast"
42
+ className={cn(
43
+ 'group/toast pointer-events-auto absolute right-0 bottom-0 z-[calc(1000-var(--toast-index))] w-full origin-bottom rounded-2xl border bg-popover text-popover-foreground shadow-lg will-change-transform outline-none select-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50',
44
+ '[--gap:0.75rem] [--height:var(--toast-frontmost-height,var(--toast-height))] [--offset-y:calc(var(--toast-offset-y)*-1+calc(var(--toast-index)*var(--gap)*-1)+var(--toast-swipe-movement-y))] [--peek:0.75rem] [--scale:calc(max(0,1-(var(--toast-index)*0.1)))] [--shrink:calc(1-var(--scale))]',
45
+ 'h-(--height) [transform:translateX(var(--toast-swipe-movement-x))_translateY(calc(var(--toast-swipe-movement-y)-(var(--toast-index)*var(--peek))-(var(--shrink)*var(--height))))_scale(var(--scale))] [transition:transform_500ms_cubic-bezier(0.22,1,0.36,1),opacity_500ms,height_150ms]',
46
+ "after:absolute after:top-full after:left-0 after:h-[calc(var(--gap)+1px)] after:w-full after:content-['']",
47
+ 'data-expanded:h-(--toast-height) data-expanded:[transform:translateX(var(--toast-swipe-movement-x))_translateY(var(--offset-y))]',
48
+ 'data-limited:opacity-0 data-starting-style:[transform:translateY(150%)]',
49
+ '[&[data-ending-style]:not([data-limited]):not([data-swipe-direction])]:[transform:translateY(150%)]',
50
+ 'data-ending-style:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+150%))]',
51
+ 'data-ending-style:data-[swipe-direction=left]:[transform:translateX(calc(var(--toast-swipe-movement-x)-150%))_translateY(var(--offset-y))]',
52
+ 'data-ending-style:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+150%))_translateY(var(--offset-y))]',
53
+ 'data-ending-style:data-[swipe-direction=up]:[transform:translateY(calc(var(--toast-swipe-movement-y)-150%))]',
54
+ 'data-expanded:data-ending-style:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+150%))]',
55
+ 'data-expanded:data-ending-style:data-[swipe-direction=left]:[transform:translateX(calc(var(--toast-swipe-movement-x)-150%))_translateY(var(--offset-y))]',
56
+ 'data-expanded:data-ending-style:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+150%))_translateY(var(--offset-y))]',
57
+ 'data-expanded:data-ending-style:data-[swipe-direction=up]:[transform:translateY(calc(var(--toast-swipe-movement-y)-150%))]',
58
+ className
59
+ )}
60
+ {...props}
61
+ />
62
+ )
63
+ }
64
+
65
+ function ToastContent({ className, ...props }: ToastPrimitive.Content.Props) {
66
+ return (
67
+ <ToastPrimitive.Content
68
+ data-slot="toast-content"
69
+ className={cn(
70
+ 'flex h-full items-center gap-3 overflow-hidden p-4 transition-opacity duration-250 ease-[cubic-bezier(0.22,1,0.36,1)] data-behind:opacity-0 data-expanded:opacity-100',
71
+ className
72
+ )}
73
+ {...props}
74
+ />
75
+ )
76
+ }
77
+
78
+ function ToastTitle({ className, ...props }: ToastPrimitive.Title.Props) {
79
+ return (
80
+ <ToastPrimitive.Title
81
+ data-slot="toast-title"
82
+ className={cn('text-sm font-medium', className)}
83
+ {...props}
84
+ />
85
+ )
86
+ }
87
+
88
+ function ToastDescription({ className, ...props }: ToastPrimitive.Description.Props) {
89
+ return (
90
+ <ToastPrimitive.Description
91
+ data-slot="toast-description"
92
+ className={cn('text-sm text-muted-foreground', className)}
93
+ {...props}
94
+ />
95
+ )
96
+ }
97
+
98
+ function ToastAction({
99
+ className,
100
+ render = <Button variant="outline" size="sm" />,
101
+ ...props
102
+ }: ToastPrimitive.Action.Props) {
103
+ return (
104
+ <ToastPrimitive.Action
105
+ data-slot="toast-action"
106
+ render={render}
107
+ className={cn('shrink-0', className)}
108
+ {...props}
109
+ />
110
+ )
111
+ }
112
+
113
+ function ToastClose({
114
+ className,
115
+ children,
116
+ render = <Button variant="ghost" size="icon-sm" />,
117
+ ...props
118
+ }: ToastPrimitive.Close.Props) {
119
+ return (
120
+ <ToastPrimitive.Close
121
+ data-slot="toast-close"
122
+ aria-label="Close toast"
123
+ render={render}
124
+ className={cn(
125
+ "relative shrink-0 text-muted-foreground after:absolute after:-inset-2 after:content-[''] hover:text-foreground",
126
+ className
127
+ )}
128
+ {...props}
129
+ >
130
+ {children ?? <IconX aria-hidden="true" stroke={1.75} />}
131
+ </ToastPrimitive.Close>
132
+ )
133
+ }
134
+
135
+ function ToastIcon({ type }: { type: string | undefined }) {
136
+ let icon: React.ReactNode = null
137
+
138
+ if (type === 'success') {
139
+ icon = <IconCircleCheck aria-hidden="true" stroke={1.75} />
140
+ }
141
+
142
+ if (type === 'info') {
143
+ icon = <IconInfoCircle aria-hidden="true" stroke={1.75} />
144
+ }
145
+
146
+ if (type === 'warning') {
147
+ icon = <IconAlertTriangle aria-hidden="true" stroke={1.75} />
148
+ }
149
+
150
+ if (type === 'error') {
151
+ icon = <IconAlertOctagon className="text-destructive" aria-hidden="true" stroke={1.75} />
152
+ }
153
+
154
+ if (type === 'loading') {
155
+ icon = <IconLoader className="animate-spin" aria-hidden="true" stroke={1.75} />
156
+ }
157
+
158
+ if (!icon) {
159
+ return null
160
+ }
161
+
162
+ return (
163
+ <span
164
+ data-slot="toast-icon"
165
+ className="shrink-0 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4"
166
+ >
167
+ {icon}
168
+ </span>
169
+ )
170
+ }
171
+
172
+ function ToastList() {
173
+ const { toasts } = ToastPrimitive.useToastManager()
174
+
175
+ return toasts.map(toastItem => (
176
+ <Toast key={toastItem.id} toast={toastItem}>
177
+ <ToastContent>
178
+ <ToastIcon type={toastItem.type} />
179
+ <div className="flex min-w-0 flex-1 flex-col gap-1">
180
+ <ToastTitle />
181
+ <ToastDescription />
182
+ </div>
183
+ <ToastAction />
184
+ <ToastClose />
185
+ </ToastContent>
186
+ </Toast>
187
+ ))
188
+ }
189
+
190
+ function Toaster({ children, toastManager = toast, ...props }: ToastPrimitive.Provider.Props) {
191
+ return (
192
+ <ToastProvider toastManager={toastManager} {...props}>
193
+ {children}
194
+ <ToastPortal>
195
+ <ToastViewport>
196
+ <ToastList />
197
+ </ToastViewport>
198
+ </ToastPortal>
199
+ </ToastProvider>
200
+ )
201
+ }
202
+
203
+ const createToastManager = ToastPrimitive.createToastManager
204
+ const useToastManager = ToastPrimitive.useToastManager
205
+
206
+ export {
207
+ Toaster,
208
+ Toast,
209
+ ToastAction,
210
+ ToastClose,
211
+ ToastContent,
212
+ ToastDescription,
213
+ ToastPortal,
214
+ ToastProvider,
215
+ ToastTitle,
216
+ ToastViewport,
217
+ createToastManager,
218
+ toast,
219
+ useToastManager
220
+ }
@@ -28,22 +28,23 @@ type ChatComposerProps = {
28
28
  onSend: (text: string) => void
29
29
  onStop: () => void
30
30
  processing: boolean
31
+ sessionId: string | null
31
32
  unavailableReason: string | null | undefined
32
33
  }
33
34
 
34
35
  // Draft text is persisted per workspace, while attachments remain ephemeral and
35
- // follow the active chat. Both stores are subscribed here so a keystroke or
36
+ // follow the selected chat. Both stores are subscribed here so a keystroke or
36
37
  // upload re-renders only the composer.
37
38
  export function ChatComposer({
38
39
  composerRef,
39
40
  onSend,
40
41
  onStop,
41
42
  processing,
43
+ sessionId,
42
44
  unavailableReason
43
45
  }: ChatComposerProps) {
44
46
  const fileRef = useRef<HTMLInputElement>(null)
45
47
  const workspaceId = useWorkspaceId()
46
- const sessionId = useLive(s => s.activeByWorkspace[workspaceId] ?? null)
47
48
  const value = useUiStore(s => s.composerDrafts[workspaceId] ?? '')
48
49
  const attachments = useLive(s => s.attachments[attachmentKey(workspaceId, sessionId)] ?? EMPTY)
49
50
  const [dragOver, setDragOver] = useState(false)
@@ -28,8 +28,8 @@ type ChatPanelProps = {
28
28
  // into the transcript through the same groupTurns pipeline so a thinking-only
29
29
  // preview folds into the current tool group. See client/lib/preview-turn.ts.
30
30
  previewTurn?: Turn | null
31
- // Active thread id — used only as the scroll reset key (jump to bottom on
32
- // thread switch).
31
+ // Selected session id — used only as the scroll reset key (jump to bottom on
32
+ // session switch).
33
33
  sessionId?: string | null
34
34
  processing: boolean
35
35
  error?: string | null
@@ -38,7 +38,7 @@ type ChatPanelProps = {
38
38
  unavailableReason: string | null | undefined
39
39
  send: (text: string, options?: ChatSendOptions) => void
40
40
  stop: () => void
41
- onSwitchThread: (sessionId: string | null) => void
41
+ onSelectSession: (sessionId: string | null) => void
42
42
  // Floating popup: render a close (X) button that dismisses the popup.
43
43
  onClose?: () => void
44
44
  }
@@ -57,7 +57,7 @@ export function ChatPanel({
57
57
  unavailableReason,
58
58
  send,
59
59
  stop,
60
- onSwitchThread,
60
+ onSelectSession,
61
61
  onClose
62
62
  }: ChatPanelProps) {
63
63
  const workspaceId = useWorkspaceId()
@@ -90,7 +90,7 @@ export function ChatPanel({
90
90
  isWorkspacePendingAnalysis
91
91
  })
92
92
 
93
- // Stick to the bottom while pinned; respect scroll-up; jump on thread switch.
93
+ // Stick to the bottom while pinned; respect scroll-up; jump on session switch.
94
94
  const { atBottom, scrollToBottom, scrollToTop } = useStickToBottom(scrollRef, sessionId)
95
95
 
96
96
  useLayoutEffect(() => {
@@ -124,7 +124,7 @@ export function ChatPanel({
124
124
  return (
125
125
  <div className="flex min-h-0 flex-1 flex-col pt-2 pb-3">
126
126
  <header className="mx-auto flex w-full max-w-[calc(var(--chat-max-container)+40px)] items-center justify-between pr-2 pb-2 pl-2">
127
- <ChatSelector onSwitch={onSwitchThread} />
127
+ <ChatSelector selectedSessionId={sessionId ?? null} onSelectSession={onSelectSession} />
128
128
  {onClose && (
129
129
  <Button variant="ghost" size="icon" onClick={onClose} aria-label="Close chat">
130
130
  <IconX stroke={1.5} />
@@ -206,6 +206,7 @@ export function ChatPanel({
206
206
  onSend={handleSend}
207
207
  onStop={stop}
208
208
  processing={processing}
209
+ sessionId={sessionId ?? null}
209
210
  unavailableReason={unavailableReason}
210
211
  />
211
212
  </div>
@@ -2,19 +2,25 @@ import type { ReactNode } from 'react'
2
2
 
3
3
  import { motion } from 'motion/react'
4
4
 
5
- import { IconGhost } from '@tabler/icons-react'
6
-
5
+ import { IconGhost } from '@/client/components/shared/IconGhost'
7
6
  import { Button } from '@/client/components/ui/button'
8
7
  import { Popover, PopoverContent, PopoverTrigger } from '@/client/components/ui/popover'
9
8
 
10
9
  type ChatPopupProps = {
10
+ loading: boolean
11
11
  open: boolean
12
12
  onOpenChange: (open: boolean) => void
13
13
  onOpenChangeComplete: (open: boolean) => void
14
14
  children: (onClose: () => void) => ReactNode
15
15
  }
16
16
 
17
- export function ChatPopup({ open, onOpenChange, onOpenChangeComplete, children }: ChatPopupProps) {
17
+ export function ChatPopup({
18
+ loading,
19
+ open,
20
+ onOpenChange,
21
+ onOpenChangeComplete,
22
+ children
23
+ }: ChatPopupProps) {
18
24
  const onClose = () => onOpenChange(false)
19
25
 
20
26
  return (
@@ -40,7 +46,7 @@ export function ChatPopup({ open, onOpenChange, onOpenChangeComplete, children }
40
46
  className="bg-card shadow-md hover:shadow-lg"
41
47
  aria-label="Agent"
42
48
  >
43
- <IconGhost stroke={1.75} />
49
+ <IconGhost animated={loading} stroke={1.75} />
44
50
  </Button>
45
51
  </motion.div>
46
52
  </div>