reigncode-app 1.3.2
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/AGENTS.md +30 -0
- package/Dockerfile +21 -0
- package/README.md +51 -0
- package/bunfig.toml +3 -0
- package/create-effect-simplification-spec.md +515 -0
- package/e2e/AGENTS.md +226 -0
- package/e2e/actions.ts +1018 -0
- package/e2e/app/home.spec.ts +24 -0
- package/e2e/app/navigation.spec.ts +10 -0
- package/e2e/app/palette.spec.ts +20 -0
- package/e2e/app/server-default.spec.ts +58 -0
- package/e2e/app/session.spec.ts +16 -0
- package/e2e/app/titlebar-history.spec.ts +120 -0
- package/e2e/commands/input-focus.spec.ts +15 -0
- package/e2e/commands/panels.spec.ts +33 -0
- package/e2e/commands/tab-close.spec.ts +32 -0
- package/e2e/files/file-open.spec.ts +31 -0
- package/e2e/files/file-tree.spec.ts +56 -0
- package/e2e/files/file-viewer.spec.ts +156 -0
- package/e2e/fixtures.ts +154 -0
- package/e2e/models/model-picker.spec.ts +48 -0
- package/e2e/models/models-visibility.spec.ts +61 -0
- package/e2e/projects/project-edit.spec.ts +43 -0
- package/e2e/projects/projects-close.spec.ts +54 -0
- package/e2e/projects/projects-switch.spec.ts +116 -0
- package/e2e/projects/workspace-new-session.spec.ts +94 -0
- package/e2e/projects/workspaces.spec.ts +375 -0
- package/e2e/prompt/context.spec.ts +95 -0
- package/e2e/prompt/prompt-async.spec.ts +76 -0
- package/e2e/prompt/prompt-drop-file-uri.spec.ts +22 -0
- package/e2e/prompt/prompt-drop-file.spec.ts +30 -0
- package/e2e/prompt/prompt-history.spec.ts +184 -0
- package/e2e/prompt/prompt-mention.spec.ts +26 -0
- package/e2e/prompt/prompt-multiline.spec.ts +24 -0
- package/e2e/prompt/prompt-shell.spec.ts +62 -0
- package/e2e/prompt/prompt-slash-open.spec.ts +22 -0
- package/e2e/prompt/prompt-slash-share.spec.ts +64 -0
- package/e2e/prompt/prompt-slash-terminal.spec.ts +18 -0
- package/e2e/prompt/prompt.spec.ts +55 -0
- package/e2e/selectors.ts +75 -0
- package/e2e/session/session-child-navigation.spec.ts +37 -0
- package/e2e/session/session-composer-dock.spec.ts +530 -0
- package/e2e/session/session-model-persistence.spec.ts +359 -0
- package/e2e/session/session-review.spec.ts +426 -0
- package/e2e/session/session-undo-redo.spec.ts +233 -0
- package/e2e/session/session.spec.ts +174 -0
- package/e2e/settings/settings-keybinds.spec.ts +389 -0
- package/e2e/settings/settings-models.spec.ts +122 -0
- package/e2e/settings/settings-providers.spec.ts +136 -0
- package/e2e/settings/settings.spec.ts +519 -0
- package/e2e/sidebar/sidebar-popover-actions.spec.ts +118 -0
- package/e2e/sidebar/sidebar-session-links.spec.ts +30 -0
- package/e2e/sidebar/sidebar.spec.ts +40 -0
- package/e2e/status/status-popover.spec.ts +94 -0
- package/e2e/terminal/terminal-init.spec.ts +28 -0
- package/e2e/terminal/terminal-reconnect.spec.ts +46 -0
- package/e2e/terminal/terminal-tabs.spec.ts +168 -0
- package/e2e/terminal/terminal.spec.ts +18 -0
- package/e2e/thinking-level.spec.ts +25 -0
- package/e2e/tsconfig.json +9 -0
- package/e2e/utils.ts +63 -0
- package/happydom.ts +75 -0
- package/index.html +23 -0
- package/package.json +77 -0
- package/playwright.config.ts +45 -0
- package/public/_headers +17 -0
- package/public/oc-theme-preload.js +35 -0
- package/script/e2e-local.ts +180 -0
- package/src/addons/serialize.test.ts +319 -0
- package/src/addons/serialize.ts +634 -0
- package/src/app.tsx +308 -0
- package/src/components/debug-bar.tsx +443 -0
- package/src/components/dialog-connect-provider.tsx +617 -0
- package/src/components/dialog-custom-provider-form.ts +158 -0
- package/src/components/dialog-custom-provider.test.ts +80 -0
- package/src/components/dialog-custom-provider.tsx +329 -0
- package/src/components/dialog-edit-project.tsx +255 -0
- package/src/components/dialog-fork.tsx +108 -0
- package/src/components/dialog-manage-models.tsx +101 -0
- package/src/components/dialog-release-notes.tsx +144 -0
- package/src/components/dialog-select-directory.tsx +392 -0
- package/src/components/dialog-select-file.tsx +466 -0
- package/src/components/dialog-select-mcp.tsx +107 -0
- package/src/components/dialog-select-model-unpaid.tsx +137 -0
- package/src/components/dialog-select-model.tsx +220 -0
- package/src/components/dialog-select-provider.tsx +86 -0
- package/src/components/dialog-select-server.tsx +649 -0
- package/src/components/dialog-settings.tsx +73 -0
- package/src/components/file-tree.test.ts +78 -0
- package/src/components/file-tree.tsx +507 -0
- package/src/components/link.tsx +26 -0
- package/src/components/model-tooltip.tsx +91 -0
- package/src/components/prompt-input/attachments.test.ts +44 -0
- package/src/components/prompt-input/attachments.ts +201 -0
- package/src/components/prompt-input/build-request-parts.test.ts +312 -0
- package/src/components/prompt-input/build-request-parts.ts +175 -0
- package/src/components/prompt-input/context-items.tsx +88 -0
- package/src/components/prompt-input/drag-overlay.tsx +25 -0
- package/src/components/prompt-input/editor-dom.test.ts +99 -0
- package/src/components/prompt-input/editor-dom.ts +148 -0
- package/src/components/prompt-input/files.ts +66 -0
- package/src/components/prompt-input/history.test.ts +153 -0
- package/src/components/prompt-input/history.ts +256 -0
- package/src/components/prompt-input/image-attachments.tsx +58 -0
- package/src/components/prompt-input/paste.ts +24 -0
- package/src/components/prompt-input/placeholder.test.ts +48 -0
- package/src/components/prompt-input/placeholder.ts +15 -0
- package/src/components/prompt-input/slash-popover.tsx +141 -0
- package/src/components/prompt-input/submit.test.ts +346 -0
- package/src/components/prompt-input/submit.ts +579 -0
- package/src/components/prompt-input.tsx +1595 -0
- package/src/components/server/server-row.tsx +130 -0
- package/src/components/session/index.ts +5 -0
- package/src/components/session/session-context-breakdown.test.ts +61 -0
- package/src/components/session/session-context-breakdown.ts +132 -0
- package/src/components/session/session-context-format.ts +20 -0
- package/src/components/session/session-context-metrics.test.ts +101 -0
- package/src/components/session/session-context-metrics.ts +82 -0
- package/src/components/session/session-context-tab.tsx +339 -0
- package/src/components/session/session-header.tsx +486 -0
- package/src/components/session/session-new-view.tsx +91 -0
- package/src/components/session/session-sortable-tab.tsx +70 -0
- package/src/components/session/session-sortable-terminal-tab.tsx +193 -0
- package/src/components/session-context-usage.tsx +122 -0
- package/src/components/settings-general.tsx +585 -0
- package/src/components/settings-keybinds.tsx +453 -0
- package/src/components/settings-list.tsx +5 -0
- package/src/components/settings-models.tsx +137 -0
- package/src/components/settings-providers.tsx +251 -0
- package/src/components/status-popover.tsx +419 -0
- package/src/components/terminal.tsx +653 -0
- package/src/components/titlebar-history.test.ts +63 -0
- package/src/components/titlebar-history.ts +57 -0
- package/src/components/titlebar.tsx +312 -0
- package/src/constants/file-picker.ts +89 -0
- package/src/context/command-keybind.test.ts +69 -0
- package/src/context/command.test.ts +25 -0
- package/src/context/command.tsx +437 -0
- package/src/context/comments.test.ts +186 -0
- package/src/context/comments.tsx +243 -0
- package/src/context/file/content-cache.ts +88 -0
- package/src/context/file/path.test.ts +360 -0
- package/src/context/file/path.ts +151 -0
- package/src/context/file/tree-store.ts +170 -0
- package/src/context/file/types.ts +41 -0
- package/src/context/file/view-cache.ts +146 -0
- package/src/context/file/watcher.test.ts +149 -0
- package/src/context/file/watcher.ts +53 -0
- package/src/context/file-content-eviction-accounting.test.ts +65 -0
- package/src/context/file.tsx +280 -0
- package/src/context/global-sdk.tsx +232 -0
- package/src/context/global-sync/bootstrap.ts +206 -0
- package/src/context/global-sync/child-store.test.ts +38 -0
- package/src/context/global-sync/child-store.ts +281 -0
- package/src/context/global-sync/event-reducer.test.ts +552 -0
- package/src/context/global-sync/event-reducer.ts +359 -0
- package/src/context/global-sync/eviction.ts +28 -0
- package/src/context/global-sync/queue.ts +83 -0
- package/src/context/global-sync/session-cache.test.ts +102 -0
- package/src/context/global-sync/session-cache.ts +62 -0
- package/src/context/global-sync/session-load.ts +25 -0
- package/src/context/global-sync/session-prefetch.test.ts +96 -0
- package/src/context/global-sync/session-prefetch.ts +100 -0
- package/src/context/global-sync/session-trim.test.ts +59 -0
- package/src/context/global-sync/session-trim.ts +56 -0
- package/src/context/global-sync/types.ts +133 -0
- package/src/context/global-sync/utils.ts +25 -0
- package/src/context/global-sync.test.ts +122 -0
- package/src/context/global-sync.tsx +408 -0
- package/src/context/highlights.tsx +233 -0
- package/src/context/language.tsx +248 -0
- package/src/context/layout-scroll.test.ts +64 -0
- package/src/context/layout-scroll.ts +126 -0
- package/src/context/layout.test.ts +69 -0
- package/src/context/layout.tsx +937 -0
- package/src/context/local.tsx +422 -0
- package/src/context/model-variant.test.ts +86 -0
- package/src/context/model-variant.ts +52 -0
- package/src/context/models.tsx +163 -0
- package/src/context/notification.tsx +373 -0
- package/src/context/permission-auto-respond.test.ts +102 -0
- package/src/context/permission-auto-respond.ts +51 -0
- package/src/context/permission.tsx +277 -0
- package/src/context/platform.tsx +99 -0
- package/src/context/prompt.tsx +297 -0
- package/src/context/sdk.tsx +49 -0
- package/src/context/server.tsx +295 -0
- package/src/context/settings.tsx +241 -0
- package/src/context/sync-optimistic.test.ts +123 -0
- package/src/context/sync.tsx +618 -0
- package/src/context/terminal-title.ts +51 -0
- package/src/context/terminal.test.ts +82 -0
- package/src/context/terminal.tsx +437 -0
- package/src/entry.tsx +144 -0
- package/src/env.d.ts +18 -0
- package/src/hooks/use-providers.ts +44 -0
- package/src/i18n/ar.ts +855 -0
- package/src/i18n/br.ts +867 -0
- package/src/i18n/bs.ts +943 -0
- package/src/i18n/da.ts +937 -0
- package/src/i18n/de.ts +879 -0
- package/src/i18n/en.ts +948 -0
- package/src/i18n/es.ts +950 -0
- package/src/i18n/fr.ts +878 -0
- package/src/i18n/ja.ts +861 -0
- package/src/i18n/ko.ts +860 -0
- package/src/i18n/no.ts +944 -0
- package/src/i18n/parity.test.ts +32 -0
- package/src/i18n/pl.ts +865 -0
- package/src/i18n/ru.ts +946 -0
- package/src/i18n/th.ts +933 -0
- package/src/i18n/tr.ts +952 -0
- package/src/i18n/zh.ts +930 -0
- package/src/i18n/zht.ts +925 -0
- package/src/index.css +29 -0
- package/src/index.ts +6 -0
- package/src/pages/directory-layout.tsx +88 -0
- package/src/pages/error.tsx +327 -0
- package/src/pages/home.tsx +131 -0
- package/src/pages/layout/deep-links.ts +50 -0
- package/src/pages/layout/helpers.test.ts +211 -0
- package/src/pages/layout/helpers.ts +98 -0
- package/src/pages/layout/inline-editor.tsx +126 -0
- package/src/pages/layout/sidebar-items.tsx +437 -0
- package/src/pages/layout/sidebar-project.tsx +384 -0
- package/src/pages/layout/sidebar-shell.tsx +125 -0
- package/src/pages/layout/sidebar-workspace.tsx +504 -0
- package/src/pages/layout.tsx +2509 -0
- package/src/pages/session/composer/index.ts +2 -0
- package/src/pages/session/composer/session-composer-region.tsx +255 -0
- package/src/pages/session/composer/session-composer-state.test.ts +128 -0
- package/src/pages/session/composer/session-composer-state.ts +249 -0
- package/src/pages/session/composer/session-followup-dock.tsx +109 -0
- package/src/pages/session/composer/session-permission-dock.tsx +74 -0
- package/src/pages/session/composer/session-question-dock.tsx +449 -0
- package/src/pages/session/composer/session-request-tree.ts +52 -0
- package/src/pages/session/composer/session-revert-dock.tsx +99 -0
- package/src/pages/session/composer/session-todo-dock.tsx +330 -0
- package/src/pages/session/file-tab-scroll.test.ts +40 -0
- package/src/pages/session/file-tab-scroll.ts +67 -0
- package/src/pages/session/file-tabs.tsx +456 -0
- package/src/pages/session/handoff.ts +36 -0
- package/src/pages/session/helpers.test.ts +181 -0
- package/src/pages/session/helpers.ts +198 -0
- package/src/pages/session/message-gesture.test.ts +62 -0
- package/src/pages/session/message-gesture.ts +21 -0
- package/src/pages/session/message-id-from-hash.ts +6 -0
- package/src/pages/session/message-timeline.tsx +1013 -0
- package/src/pages/session/review-tab.tsx +170 -0
- package/src/pages/session/session-layout.ts +20 -0
- package/src/pages/session/session-model-helpers.test.ts +51 -0
- package/src/pages/session/session-model-helpers.ts +16 -0
- package/src/pages/session/session-side-panel.tsx +453 -0
- package/src/pages/session/terminal-label.ts +16 -0
- package/src/pages/session/terminal-panel.test.ts +25 -0
- package/src/pages/session/terminal-panel.tsx +326 -0
- package/src/pages/session/use-session-commands.tsx +495 -0
- package/src/pages/session/use-session-hash-scroll.test.ts +16 -0
- package/src/pages/session/use-session-hash-scroll.ts +197 -0
- package/src/pages/session.tsx +1841 -0
- package/src/sst-env.d.ts +12 -0
- package/src/testing/model-selection.ts +80 -0
- package/src/testing/prompt.ts +56 -0
- package/src/testing/session-composer.ts +84 -0
- package/src/testing/terminal.ts +118 -0
- package/src/theme-preload.test.ts +46 -0
- package/src/utils/agent.ts +23 -0
- package/src/utils/aim.ts +138 -0
- package/src/utils/base64.ts +10 -0
- package/src/utils/comment-note.ts +88 -0
- package/src/utils/id.ts +99 -0
- package/src/utils/notification-click.test.ts +27 -0
- package/src/utils/notification-click.ts +13 -0
- package/src/utils/persist.test.ts +115 -0
- package/src/utils/persist.ts +476 -0
- package/src/utils/prompt.test.ts +44 -0
- package/src/utils/prompt.ts +203 -0
- package/src/utils/runtime-adapters.test.ts +62 -0
- package/src/utils/runtime-adapters.ts +39 -0
- package/src/utils/same.ts +6 -0
- package/src/utils/scoped-cache.test.ts +69 -0
- package/src/utils/scoped-cache.ts +104 -0
- package/src/utils/server-errors.test.ts +131 -0
- package/src/utils/server-errors.ts +80 -0
- package/src/utils/server-health.test.ts +123 -0
- package/src/utils/server-health.ts +91 -0
- package/src/utils/server.ts +22 -0
- package/src/utils/solid-dnd.tsx +49 -0
- package/src/utils/sound.ts +117 -0
- package/src/utils/terminal-writer.test.ts +64 -0
- package/src/utils/terminal-writer.ts +65 -0
- package/src/utils/time.ts +22 -0
- package/src/utils/uuid.test.ts +78 -0
- package/src/utils/uuid.ts +12 -0
- package/src/utils/worktree.test.ts +46 -0
- package/src/utils/worktree.ts +73 -0
- package/sst-env.d.ts +10 -0
- package/tsconfig.json +26 -0
- package/vite.config.ts +15 -0
- package/vite.js +26 -0
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
import type { Message, Session, TextPart, UserMessage } from "@reign-labs/sdk/v2/client"
|
|
2
|
+
import { Avatar } from "@reign-labs/ui/avatar"
|
|
3
|
+
import { HoverCard } from "@reign-labs/ui/hover-card"
|
|
4
|
+
import { Icon } from "@reign-labs/ui/icon"
|
|
5
|
+
import { IconButton } from "@reign-labs/ui/icon-button"
|
|
6
|
+
import { MessageNav } from "@reign-labs/ui/message-nav"
|
|
7
|
+
import { Spinner } from "@reign-labs/ui/spinner"
|
|
8
|
+
import { Tooltip } from "@reign-labs/ui/tooltip"
|
|
9
|
+
import { base64Encode } from "@reign-labs/util/encode"
|
|
10
|
+
import { getFilename } from "@reign-labs/util/path"
|
|
11
|
+
import { A, useNavigate, useParams } from "@solidjs/router"
|
|
12
|
+
import { type Accessor, createMemo, For, type JSX, Match, onCleanup, Show, Switch } from "solid-js"
|
|
13
|
+
import { useGlobalSync } from "@/context/global-sync"
|
|
14
|
+
import { useLanguage } from "@/context/language"
|
|
15
|
+
import { getAvatarColors, type LocalProject, useLayout } from "@/context/layout"
|
|
16
|
+
import { useNotification } from "@/context/notification"
|
|
17
|
+
import { usePermission } from "@/context/permission"
|
|
18
|
+
import { messageAgentColor } from "@/utils/agent"
|
|
19
|
+
import { sessionPermissionRequest } from "../session/composer/session-request-tree"
|
|
20
|
+
import { hasProjectPermissions } from "./helpers"
|
|
21
|
+
|
|
22
|
+
const REIGNCODE_PROJECT_ID = "4b0ea68d7af9a6031a7ffda7ad66e0cb83315750"
|
|
23
|
+
|
|
24
|
+
export const ProjectIcon = (props: { project: LocalProject; class?: string; notify?: boolean }): JSX.Element => {
|
|
25
|
+
const globalSync = useGlobalSync()
|
|
26
|
+
const notification = useNotification()
|
|
27
|
+
const permission = usePermission()
|
|
28
|
+
const dirs = createMemo(() => [props.project.worktree, ...(props.project.sandboxes ?? [])])
|
|
29
|
+
const unseenCount = createMemo(() =>
|
|
30
|
+
dirs().reduce((total, directory) => total + notification.project.unseenCount(directory), 0),
|
|
31
|
+
)
|
|
32
|
+
const hasError = createMemo(() => dirs().some((directory) => notification.project.unseenHasError(directory)))
|
|
33
|
+
const hasPermissions = createMemo(() =>
|
|
34
|
+
dirs().some((directory) => {
|
|
35
|
+
const [store] = globalSync.child(directory, { bootstrap: false })
|
|
36
|
+
return hasProjectPermissions(store.permission, (item) => !permission.autoResponds(item, directory))
|
|
37
|
+
}),
|
|
38
|
+
)
|
|
39
|
+
const notify = createMemo(() => props.notify && (hasPermissions() || unseenCount() > 0))
|
|
40
|
+
const name = createMemo(() => props.project.name || getFilename(props.project.worktree))
|
|
41
|
+
return (
|
|
42
|
+
<div class={`relative size-8 shrink-0 rounded ${props.class ?? ""}`}>
|
|
43
|
+
<div class="size-full rounded overflow-clip">
|
|
44
|
+
<Avatar
|
|
45
|
+
fallback={name()}
|
|
46
|
+
src={
|
|
47
|
+
props.project.id === REIGNCODE_PROJECT_ID ? "https://code.reign-labs.com/favicon.svg" : props.project.icon?.override
|
|
48
|
+
}
|
|
49
|
+
{...getAvatarColors(props.project.icon?.color)}
|
|
50
|
+
class="size-full rounded"
|
|
51
|
+
classList={{ "badge-mask": notify() }}
|
|
52
|
+
/>
|
|
53
|
+
</div>
|
|
54
|
+
<Show when={notify()}>
|
|
55
|
+
<div
|
|
56
|
+
classList={{
|
|
57
|
+
"absolute top-px right-px size-1.5 rounded-full z-10": true,
|
|
58
|
+
"bg-surface-warning-strong": hasPermissions(),
|
|
59
|
+
"bg-icon-critical-base": !hasPermissions() && hasError(),
|
|
60
|
+
"bg-text-interactive-base": !hasPermissions() && !hasError(),
|
|
61
|
+
}}
|
|
62
|
+
/>
|
|
63
|
+
</Show>
|
|
64
|
+
</div>
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export type SessionItemProps = {
|
|
69
|
+
session: Session
|
|
70
|
+
list: Session[]
|
|
71
|
+
navList?: Accessor<Session[]>
|
|
72
|
+
slug: string
|
|
73
|
+
mobile?: boolean
|
|
74
|
+
dense?: boolean
|
|
75
|
+
popover?: boolean
|
|
76
|
+
children: Map<string, string[]>
|
|
77
|
+
sidebarExpanded: Accessor<boolean>
|
|
78
|
+
sidebarHovering: Accessor<boolean>
|
|
79
|
+
nav: Accessor<HTMLElement | undefined>
|
|
80
|
+
hoverSession: Accessor<string | undefined>
|
|
81
|
+
setHoverSession: (id: string | undefined) => void
|
|
82
|
+
clearHoverProjectSoon: () => void
|
|
83
|
+
prefetchSession: (session: Session, priority?: "high" | "low") => void
|
|
84
|
+
archiveSession: (session: Session) => Promise<void>
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const SessionRow = (props: {
|
|
88
|
+
session: Session
|
|
89
|
+
slug: string
|
|
90
|
+
mobile?: boolean
|
|
91
|
+
dense?: boolean
|
|
92
|
+
tint: Accessor<string | undefined>
|
|
93
|
+
isWorking: Accessor<boolean>
|
|
94
|
+
hasPermissions: Accessor<boolean>
|
|
95
|
+
hasError: Accessor<boolean>
|
|
96
|
+
unseenCount: Accessor<number>
|
|
97
|
+
setHoverSession: (id: string | undefined) => void
|
|
98
|
+
clearHoverProjectSoon: () => void
|
|
99
|
+
sidebarOpened: Accessor<boolean>
|
|
100
|
+
warmHover: () => void
|
|
101
|
+
warmPress: () => void
|
|
102
|
+
warmFocus: () => void
|
|
103
|
+
cancelHoverPrefetch: () => void
|
|
104
|
+
}): JSX.Element => (
|
|
105
|
+
<A
|
|
106
|
+
href={`/${props.slug}/session/${props.session.id}`}
|
|
107
|
+
class={`flex items-center gap-1 min-w-0 w-full text-left focus:outline-none ${props.dense ? "py-0.5" : "py-1"}`}
|
|
108
|
+
onPointerDown={props.warmPress}
|
|
109
|
+
onPointerEnter={props.warmHover}
|
|
110
|
+
onPointerLeave={props.cancelHoverPrefetch}
|
|
111
|
+
onFocus={props.warmFocus}
|
|
112
|
+
onClick={() => {
|
|
113
|
+
props.setHoverSession(undefined)
|
|
114
|
+
if (props.sidebarOpened()) return
|
|
115
|
+
props.clearHoverProjectSoon()
|
|
116
|
+
}}
|
|
117
|
+
>
|
|
118
|
+
<div
|
|
119
|
+
class="shrink-0 size-6 flex items-center justify-center"
|
|
120
|
+
style={{ color: props.tint() ?? "var(--icon-interactive-base)" }}
|
|
121
|
+
>
|
|
122
|
+
<Switch fallback={<Icon name="dash" size="small" class="text-icon-weak" />}>
|
|
123
|
+
<Match when={props.isWorking()}>
|
|
124
|
+
<Spinner class="size-[15px]" />
|
|
125
|
+
</Match>
|
|
126
|
+
<Match when={props.hasPermissions()}>
|
|
127
|
+
<div class="size-1.5 rounded-full bg-surface-warning-strong" />
|
|
128
|
+
</Match>
|
|
129
|
+
<Match when={props.hasError()}>
|
|
130
|
+
<div class="size-1.5 rounded-full bg-text-diff-delete-base" />
|
|
131
|
+
</Match>
|
|
132
|
+
<Match when={props.unseenCount() > 0}>
|
|
133
|
+
<div class="size-1.5 rounded-full bg-text-interactive-base" />
|
|
134
|
+
</Match>
|
|
135
|
+
</Switch>
|
|
136
|
+
</div>
|
|
137
|
+
<span class="text-14-regular text-text-strong min-w-0 flex-1 truncate">{props.session.title}</span>
|
|
138
|
+
</A>
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
const SessionHoverPreview = (props: {
|
|
142
|
+
mobile?: boolean
|
|
143
|
+
nav: Accessor<HTMLElement | undefined>
|
|
144
|
+
hoverSession: Accessor<string | undefined>
|
|
145
|
+
session: Session
|
|
146
|
+
sidebarHovering: Accessor<boolean>
|
|
147
|
+
hoverReady: Accessor<boolean>
|
|
148
|
+
hoverMessages: Accessor<UserMessage[] | undefined>
|
|
149
|
+
language: ReturnType<typeof useLanguage>
|
|
150
|
+
isActive: Accessor<boolean>
|
|
151
|
+
slug: string
|
|
152
|
+
setHoverSession: (id: string | undefined) => void
|
|
153
|
+
messageLabel: (message: Message) => string | undefined
|
|
154
|
+
onMessageSelect: (message: Message) => void
|
|
155
|
+
trigger: JSX.Element
|
|
156
|
+
}): JSX.Element => {
|
|
157
|
+
let ref: HTMLDivElement | undefined
|
|
158
|
+
|
|
159
|
+
return (
|
|
160
|
+
<HoverCard
|
|
161
|
+
openDelay={1000}
|
|
162
|
+
closeDelay={props.sidebarHovering() ? 600 : 0}
|
|
163
|
+
placement="right-start"
|
|
164
|
+
gutter={16}
|
|
165
|
+
shift={-2}
|
|
166
|
+
trigger={
|
|
167
|
+
<div ref={ref} class="min-w-0 w-full">
|
|
168
|
+
{props.trigger}
|
|
169
|
+
</div>
|
|
170
|
+
}
|
|
171
|
+
open={props.hoverSession() === props.session.id}
|
|
172
|
+
onOpenChange={(open) => {
|
|
173
|
+
if (!open) {
|
|
174
|
+
props.setHoverSession(undefined)
|
|
175
|
+
return
|
|
176
|
+
}
|
|
177
|
+
if (!ref?.matches(":hover")) return
|
|
178
|
+
props.setHoverSession(props.session.id)
|
|
179
|
+
}}
|
|
180
|
+
>
|
|
181
|
+
<Show
|
|
182
|
+
when={props.hoverReady()}
|
|
183
|
+
fallback={<div class="text-12-regular text-text-weak">{props.language.t("session.messages.loading")}</div>}
|
|
184
|
+
>
|
|
185
|
+
<div class="overflow-y-auto overflow-x-hidden max-h-72 h-full">
|
|
186
|
+
<MessageNav
|
|
187
|
+
messages={props.hoverMessages() ?? []}
|
|
188
|
+
current={undefined}
|
|
189
|
+
getLabel={props.messageLabel}
|
|
190
|
+
onMessageSelect={props.onMessageSelect}
|
|
191
|
+
size="normal"
|
|
192
|
+
class="w-60"
|
|
193
|
+
/>
|
|
194
|
+
</div>
|
|
195
|
+
</Show>
|
|
196
|
+
</HoverCard>
|
|
197
|
+
)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export const SessionItem = (props: SessionItemProps): JSX.Element => {
|
|
201
|
+
const params = useParams()
|
|
202
|
+
const navigate = useNavigate()
|
|
203
|
+
const layout = useLayout()
|
|
204
|
+
const language = useLanguage()
|
|
205
|
+
const notification = useNotification()
|
|
206
|
+
const permission = usePermission()
|
|
207
|
+
const globalSync = useGlobalSync()
|
|
208
|
+
const unseenCount = createMemo(() => notification.session.unseenCount(props.session.id))
|
|
209
|
+
const hasError = createMemo(() => notification.session.unseenHasError(props.session.id))
|
|
210
|
+
const [sessionStore] = globalSync.child(props.session.directory)
|
|
211
|
+
const hasPermissions = createMemo(() => {
|
|
212
|
+
return !!sessionPermissionRequest(sessionStore.session, sessionStore.permission, props.session.id, (item) => {
|
|
213
|
+
return !permission.autoResponds(item, props.session.directory)
|
|
214
|
+
})
|
|
215
|
+
})
|
|
216
|
+
const isWorking = createMemo(() => {
|
|
217
|
+
if (hasPermissions()) return false
|
|
218
|
+
const pending = (sessionStore.message[props.session.id] ?? []).findLast(
|
|
219
|
+
(message) =>
|
|
220
|
+
message.role === "assistant" &&
|
|
221
|
+
typeof (message as { time?: { completed?: unknown } }).time?.completed !== "number",
|
|
222
|
+
)
|
|
223
|
+
const status = sessionStore.session_status[props.session.id]
|
|
224
|
+
return (
|
|
225
|
+
pending !== undefined ||
|
|
226
|
+
status?.type === "busy" ||
|
|
227
|
+
status?.type === "retry" ||
|
|
228
|
+
(status !== undefined && status.type !== "idle")
|
|
229
|
+
)
|
|
230
|
+
})
|
|
231
|
+
|
|
232
|
+
const tint = createMemo(() => {
|
|
233
|
+
return messageAgentColor(sessionStore.message[props.session.id], sessionStore.agent)
|
|
234
|
+
})
|
|
235
|
+
|
|
236
|
+
const hoverMessages = createMemo(() =>
|
|
237
|
+
sessionStore.message[props.session.id]?.filter((message): message is UserMessage => message.role === "user"),
|
|
238
|
+
)
|
|
239
|
+
const hoverReady = createMemo(() => hoverMessages() !== undefined)
|
|
240
|
+
const hoverAllowed = createMemo(() => !props.mobile && props.sidebarExpanded())
|
|
241
|
+
const hoverEnabled = createMemo(() => (props.popover ?? true) && hoverAllowed())
|
|
242
|
+
const isActive = createMemo(() => props.session.id === params.id)
|
|
243
|
+
|
|
244
|
+
const warm = (span: number, priority: "high" | "low") => {
|
|
245
|
+
const nav = props.navList?.()
|
|
246
|
+
const list = nav?.some((item) => item.id === props.session.id && item.directory === props.session.directory)
|
|
247
|
+
? nav
|
|
248
|
+
: props.list
|
|
249
|
+
|
|
250
|
+
props.prefetchSession(props.session, priority)
|
|
251
|
+
|
|
252
|
+
const idx = list.findIndex((item) => item.id === props.session.id && item.directory === props.session.directory)
|
|
253
|
+
if (idx === -1) return
|
|
254
|
+
|
|
255
|
+
for (let step = 1; step <= span; step++) {
|
|
256
|
+
const next = list[idx + step]
|
|
257
|
+
if (next) props.prefetchSession(next, step === 1 ? "high" : priority)
|
|
258
|
+
|
|
259
|
+
const prev = list[idx - step]
|
|
260
|
+
if (prev) props.prefetchSession(prev, step === 1 ? "high" : priority)
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const hoverPrefetch = {
|
|
265
|
+
current: undefined as ReturnType<typeof setTimeout> | undefined,
|
|
266
|
+
}
|
|
267
|
+
const cancelHoverPrefetch = () => {
|
|
268
|
+
if (hoverPrefetch.current === undefined) return
|
|
269
|
+
clearTimeout(hoverPrefetch.current)
|
|
270
|
+
hoverPrefetch.current = undefined
|
|
271
|
+
}
|
|
272
|
+
const scheduleHoverPrefetch = () => {
|
|
273
|
+
warm(1, "high")
|
|
274
|
+
if (hoverPrefetch.current !== undefined) return
|
|
275
|
+
hoverPrefetch.current = setTimeout(() => {
|
|
276
|
+
hoverPrefetch.current = undefined
|
|
277
|
+
warm(2, "low")
|
|
278
|
+
}, 80)
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
onCleanup(cancelHoverPrefetch)
|
|
282
|
+
|
|
283
|
+
const messageLabel = (message: Message) => {
|
|
284
|
+
const parts = sessionStore.part[message.id] ?? []
|
|
285
|
+
const text = parts.find((part): part is TextPart => part?.type === "text" && !part.synthetic && !part.ignored)
|
|
286
|
+
return text?.text
|
|
287
|
+
}
|
|
288
|
+
const item = (
|
|
289
|
+
<SessionRow
|
|
290
|
+
session={props.session}
|
|
291
|
+
slug={props.slug}
|
|
292
|
+
mobile={props.mobile}
|
|
293
|
+
dense={props.dense}
|
|
294
|
+
tint={tint}
|
|
295
|
+
isWorking={isWorking}
|
|
296
|
+
hasPermissions={hasPermissions}
|
|
297
|
+
hasError={hasError}
|
|
298
|
+
unseenCount={unseenCount}
|
|
299
|
+
setHoverSession={props.setHoverSession}
|
|
300
|
+
clearHoverProjectSoon={props.clearHoverProjectSoon}
|
|
301
|
+
sidebarOpened={layout.sidebar.opened}
|
|
302
|
+
warmHover={scheduleHoverPrefetch}
|
|
303
|
+
warmPress={() => warm(2, "high")}
|
|
304
|
+
warmFocus={() => warm(2, "high")}
|
|
305
|
+
cancelHoverPrefetch={cancelHoverPrefetch}
|
|
306
|
+
/>
|
|
307
|
+
)
|
|
308
|
+
|
|
309
|
+
return (
|
|
310
|
+
<div
|
|
311
|
+
data-session-id={props.session.id}
|
|
312
|
+
class="group/session relative w-full min-w-0 rounded-md cursor-default pl-2 pr-3 transition-colors
|
|
313
|
+
hover:bg-surface-raised-base-hover [&:has(:focus-visible)]:bg-surface-raised-base-hover has-[[data-expanded]]:bg-surface-raised-base-hover has-[.active]:bg-surface-base-active"
|
|
314
|
+
>
|
|
315
|
+
<div class="flex min-w-0 items-center gap-1">
|
|
316
|
+
<div class="min-w-0 flex-1">
|
|
317
|
+
<Show
|
|
318
|
+
when={hoverEnabled()}
|
|
319
|
+
fallback={
|
|
320
|
+
<Tooltip
|
|
321
|
+
placement={props.mobile ? "bottom" : "right"}
|
|
322
|
+
value={props.session.title}
|
|
323
|
+
gutter={10}
|
|
324
|
+
class="min-w-0 w-full"
|
|
325
|
+
>
|
|
326
|
+
{item}
|
|
327
|
+
</Tooltip>
|
|
328
|
+
}
|
|
329
|
+
>
|
|
330
|
+
<SessionHoverPreview
|
|
331
|
+
mobile={props.mobile}
|
|
332
|
+
nav={props.nav}
|
|
333
|
+
hoverSession={props.hoverSession}
|
|
334
|
+
session={props.session}
|
|
335
|
+
sidebarHovering={props.sidebarHovering}
|
|
336
|
+
hoverReady={hoverReady}
|
|
337
|
+
hoverMessages={hoverMessages}
|
|
338
|
+
language={language}
|
|
339
|
+
isActive={isActive}
|
|
340
|
+
slug={props.slug}
|
|
341
|
+
setHoverSession={props.setHoverSession}
|
|
342
|
+
messageLabel={messageLabel}
|
|
343
|
+
onMessageSelect={(message) => {
|
|
344
|
+
if (!isActive())
|
|
345
|
+
layout.pendingMessage.set(`${base64Encode(props.session.directory)}/${props.session.id}`, message.id)
|
|
346
|
+
|
|
347
|
+
navigate(`${props.slug}/session/${props.session.id}#message-${message.id}`)
|
|
348
|
+
}}
|
|
349
|
+
trigger={item}
|
|
350
|
+
/>
|
|
351
|
+
</Show>
|
|
352
|
+
</div>
|
|
353
|
+
|
|
354
|
+
<div
|
|
355
|
+
class="shrink-0 overflow-hidden transition-[width,opacity]"
|
|
356
|
+
classList={{
|
|
357
|
+
"w-6 opacity-100 pointer-events-auto": !!props.mobile,
|
|
358
|
+
"w-0 opacity-0 pointer-events-none": !props.mobile,
|
|
359
|
+
"group-hover/session:w-6 group-hover/session:opacity-100 group-hover/session:pointer-events-auto": true,
|
|
360
|
+
"group-focus-within/session:w-6 group-focus-within/session:opacity-100 group-focus-within/session:pointer-events-auto": true,
|
|
361
|
+
}}
|
|
362
|
+
>
|
|
363
|
+
<Tooltip value={language.t("common.archive")} placement="top">
|
|
364
|
+
<IconButton
|
|
365
|
+
icon="archive"
|
|
366
|
+
variant="ghost"
|
|
367
|
+
class="size-6 rounded-md"
|
|
368
|
+
aria-label={language.t("common.archive")}
|
|
369
|
+
onClick={(event) => {
|
|
370
|
+
event.preventDefault()
|
|
371
|
+
event.stopPropagation()
|
|
372
|
+
void props.archiveSession(props.session)
|
|
373
|
+
}}
|
|
374
|
+
/>
|
|
375
|
+
</Tooltip>
|
|
376
|
+
</div>
|
|
377
|
+
</div>
|
|
378
|
+
</div>
|
|
379
|
+
)
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
export const NewSessionItem = (props: {
|
|
383
|
+
slug: string
|
|
384
|
+
mobile?: boolean
|
|
385
|
+
dense?: boolean
|
|
386
|
+
sidebarExpanded: Accessor<boolean>
|
|
387
|
+
clearHoverProjectSoon: () => void
|
|
388
|
+
setHoverSession: (id: string | undefined) => void
|
|
389
|
+
}): JSX.Element => {
|
|
390
|
+
const layout = useLayout()
|
|
391
|
+
const language = useLanguage()
|
|
392
|
+
const label = language.t("command.session.new")
|
|
393
|
+
const tooltip = () => props.mobile || !props.sidebarExpanded()
|
|
394
|
+
const item = (
|
|
395
|
+
<A
|
|
396
|
+
href={`/${props.slug}/session`}
|
|
397
|
+
end
|
|
398
|
+
class={`flex items-center gap-1 min-w-0 w-full text-left focus:outline-none ${props.dense ? "py-0.5" : "py-1"}`}
|
|
399
|
+
onClick={() => {
|
|
400
|
+
props.setHoverSession(undefined)
|
|
401
|
+
if (layout.sidebar.opened()) return
|
|
402
|
+
props.clearHoverProjectSoon()
|
|
403
|
+
}}
|
|
404
|
+
>
|
|
405
|
+
<div class="shrink-0 size-6 flex items-center justify-center">
|
|
406
|
+
<Icon name="new-session" size="small" class="text-icon-weak" />
|
|
407
|
+
</div>
|
|
408
|
+
<span class="text-14-regular text-text-strong min-w-0 flex-1 truncate">{label}</span>
|
|
409
|
+
</A>
|
|
410
|
+
)
|
|
411
|
+
|
|
412
|
+
return (
|
|
413
|
+
<div class="group/session relative w-full min-w-0 rounded-md cursor-default transition-colors pl-2 pr-3 hover:bg-surface-raised-base-hover [&:has(:focus-visible)]:bg-surface-raised-base-hover has-[.active]:bg-surface-base-active">
|
|
414
|
+
<Show
|
|
415
|
+
when={!tooltip()}
|
|
416
|
+
fallback={
|
|
417
|
+
<Tooltip placement={props.mobile ? "bottom" : "right"} value={label} gutter={10} class="min-w-0 w-full">
|
|
418
|
+
{item}
|
|
419
|
+
</Tooltip>
|
|
420
|
+
}
|
|
421
|
+
>
|
|
422
|
+
{item}
|
|
423
|
+
</Show>
|
|
424
|
+
</div>
|
|
425
|
+
)
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
export const SessionSkeleton = (props: { count?: number }): JSX.Element => {
|
|
429
|
+
const items = Array.from({ length: props.count ?? 4 }, (_, index) => index)
|
|
430
|
+
return (
|
|
431
|
+
<div class="flex flex-col gap-1">
|
|
432
|
+
<For each={items}>
|
|
433
|
+
{() => <div class="h-8 w-full rounded-md bg-surface-raised-base opacity-60 animate-pulse" />}
|
|
434
|
+
</For>
|
|
435
|
+
</div>
|
|
436
|
+
)
|
|
437
|
+
}
|