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,504 @@
|
|
|
1
|
+
import { useNavigate, useParams } from "@solidjs/router"
|
|
2
|
+
import { createEffect, createMemo, For, Show, type Accessor, type JSX } from "solid-js"
|
|
3
|
+
import { createStore } from "solid-js/store"
|
|
4
|
+
import { createSortable } from "@thisbeyond/solid-dnd"
|
|
5
|
+
import { createMediaQuery } from "@solid-primitives/media"
|
|
6
|
+
import { base64Encode } from "@reign-labs/util/encode"
|
|
7
|
+
import { getFilename } from "@reign-labs/util/path"
|
|
8
|
+
import { Button } from "@reign-labs/ui/button"
|
|
9
|
+
import { Collapsible } from "@reign-labs/ui/collapsible"
|
|
10
|
+
import { DropdownMenu } from "@reign-labs/ui/dropdown-menu"
|
|
11
|
+
import { Icon } from "@reign-labs/ui/icon"
|
|
12
|
+
import { IconButton } from "@reign-labs/ui/icon-button"
|
|
13
|
+
import { Spinner } from "@reign-labs/ui/spinner"
|
|
14
|
+
import { Tooltip } from "@reign-labs/ui/tooltip"
|
|
15
|
+
import { type Session } from "@reign-labs/sdk/v2/client"
|
|
16
|
+
import { type LocalProject } from "@/context/layout"
|
|
17
|
+
import { useGlobalSync } from "@/context/global-sync"
|
|
18
|
+
import { useLanguage } from "@/context/language"
|
|
19
|
+
import { NewSessionItem, SessionItem, SessionSkeleton } from "./sidebar-items"
|
|
20
|
+
import { childMapByParent, sortedRootSessions, workspaceKey } from "./helpers"
|
|
21
|
+
|
|
22
|
+
type InlineEditorComponent = (props: {
|
|
23
|
+
id: string
|
|
24
|
+
value: Accessor<string>
|
|
25
|
+
onSave: (next: string) => void
|
|
26
|
+
class?: string
|
|
27
|
+
displayClass?: string
|
|
28
|
+
editing?: boolean
|
|
29
|
+
stopPropagation?: boolean
|
|
30
|
+
openOnDblClick?: boolean
|
|
31
|
+
}) => JSX.Element
|
|
32
|
+
|
|
33
|
+
export type WorkspaceSidebarContext = {
|
|
34
|
+
currentDir: Accessor<string>
|
|
35
|
+
navList: Accessor<Session[]>
|
|
36
|
+
sidebarExpanded: Accessor<boolean>
|
|
37
|
+
sidebarHovering: Accessor<boolean>
|
|
38
|
+
nav: Accessor<HTMLElement | undefined>
|
|
39
|
+
hoverSession: Accessor<string | undefined>
|
|
40
|
+
setHoverSession: (id: string | undefined) => void
|
|
41
|
+
clearHoverProjectSoon: () => void
|
|
42
|
+
prefetchSession: (session: Session, priority?: "high" | "low") => void
|
|
43
|
+
archiveSession: (session: Session) => Promise<void>
|
|
44
|
+
workspaceName: (directory: string, projectId?: string, branch?: string) => string | undefined
|
|
45
|
+
renameWorkspace: (directory: string, next: string, projectId?: string, branch?: string) => void
|
|
46
|
+
editorOpen: (id: string) => boolean
|
|
47
|
+
openEditor: (id: string, value: string) => void
|
|
48
|
+
closeEditor: () => void
|
|
49
|
+
setEditor: (key: "value", value: string) => void
|
|
50
|
+
InlineEditor: InlineEditorComponent
|
|
51
|
+
isBusy: (directory: string) => boolean
|
|
52
|
+
workspaceExpanded: (directory: string, local: boolean) => boolean
|
|
53
|
+
setWorkspaceExpanded: (directory: string, value: boolean) => void
|
|
54
|
+
showResetWorkspaceDialog: (root: string, directory: string) => void
|
|
55
|
+
showDeleteWorkspaceDialog: (root: string, directory: string) => void
|
|
56
|
+
setScrollContainerRef: (el: HTMLDivElement | undefined, mobile?: boolean) => void
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const WorkspaceDragOverlay = (props: {
|
|
60
|
+
sidebarProject: Accessor<LocalProject | undefined>
|
|
61
|
+
activeWorkspace: Accessor<string | undefined>
|
|
62
|
+
workspaceLabel: (directory: string, branch?: string, projectId?: string) => string
|
|
63
|
+
}): JSX.Element => {
|
|
64
|
+
const globalSync = useGlobalSync()
|
|
65
|
+
const language = useLanguage()
|
|
66
|
+
const label = createMemo(() => {
|
|
67
|
+
const project = props.sidebarProject()
|
|
68
|
+
if (!project) return
|
|
69
|
+
const directory = props.activeWorkspace()
|
|
70
|
+
if (!directory) return
|
|
71
|
+
|
|
72
|
+
const [workspaceStore] = globalSync.child(directory, { bootstrap: false })
|
|
73
|
+
const kind =
|
|
74
|
+
directory === project.worktree ? language.t("workspace.type.local") : language.t("workspace.type.sandbox")
|
|
75
|
+
const name = props.workspaceLabel(directory, workspaceStore.vcs?.branch, project.id)
|
|
76
|
+
return `${kind} : ${name}`
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<Show when={label()}>
|
|
81
|
+
{(value) => <div class="bg-background-base rounded-md px-2 py-1 text-14-medium text-text-strong">{value()}</div>}
|
|
82
|
+
</Show>
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const WorkspaceHeader = (props: {
|
|
87
|
+
local: Accessor<boolean>
|
|
88
|
+
busy: Accessor<boolean>
|
|
89
|
+
open: Accessor<boolean>
|
|
90
|
+
directory: string
|
|
91
|
+
language: ReturnType<typeof useLanguage>
|
|
92
|
+
branch: Accessor<string | undefined>
|
|
93
|
+
workspaceValue: Accessor<string>
|
|
94
|
+
workspaceEditActive: Accessor<boolean>
|
|
95
|
+
InlineEditor: WorkspaceSidebarContext["InlineEditor"]
|
|
96
|
+
renameWorkspace: WorkspaceSidebarContext["renameWorkspace"]
|
|
97
|
+
setEditor: WorkspaceSidebarContext["setEditor"]
|
|
98
|
+
projectId?: string
|
|
99
|
+
}): JSX.Element => (
|
|
100
|
+
<div class="flex items-center gap-1 min-w-0 flex-1">
|
|
101
|
+
<div class="flex items-center justify-center shrink-0 size-6">
|
|
102
|
+
<Show when={props.busy()} fallback={<Icon name="branch" size="small" />}>
|
|
103
|
+
<Spinner class="size-[15px]" />
|
|
104
|
+
</Show>
|
|
105
|
+
</div>
|
|
106
|
+
<span class="text-14-medium text-text-base shrink-0">
|
|
107
|
+
{props.local() ? props.language.t("workspace.type.local") : props.language.t("workspace.type.sandbox")} :
|
|
108
|
+
</span>
|
|
109
|
+
<Show
|
|
110
|
+
when={!props.local()}
|
|
111
|
+
fallback={
|
|
112
|
+
<span class="text-14-medium text-text-base min-w-0 truncate">
|
|
113
|
+
{props.branch() ?? getFilename(props.directory)}
|
|
114
|
+
</span>
|
|
115
|
+
}
|
|
116
|
+
>
|
|
117
|
+
<props.InlineEditor
|
|
118
|
+
id={`workspace:${props.directory}`}
|
|
119
|
+
value={props.workspaceValue}
|
|
120
|
+
onSave={(next) => {
|
|
121
|
+
const trimmed = next.trim()
|
|
122
|
+
if (!trimmed) return
|
|
123
|
+
props.renameWorkspace(props.directory, trimmed, props.projectId, props.branch())
|
|
124
|
+
props.setEditor("value", props.workspaceValue())
|
|
125
|
+
}}
|
|
126
|
+
class="text-14-medium text-text-base min-w-0 truncate"
|
|
127
|
+
displayClass="text-14-medium text-text-base min-w-0 truncate"
|
|
128
|
+
editing={props.workspaceEditActive()}
|
|
129
|
+
stopPropagation={false}
|
|
130
|
+
openOnDblClick={false}
|
|
131
|
+
/>
|
|
132
|
+
</Show>
|
|
133
|
+
<div class="flex items-center justify-center shrink-0 overflow-hidden w-0 opacity-0 transition-all duration-200 group-hover/workspace:w-3.5 group-hover/workspace:opacity-100 group-focus-within/workspace:w-3.5 group-focus-within/workspace:opacity-100">
|
|
134
|
+
<Icon name={props.open() ? "chevron-down" : "chevron-right"} size="small" class="text-icon-base" />
|
|
135
|
+
</div>
|
|
136
|
+
</div>
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
const WorkspaceActions = (props: {
|
|
140
|
+
directory: string
|
|
141
|
+
local: Accessor<boolean>
|
|
142
|
+
busy: Accessor<boolean>
|
|
143
|
+
menuOpen: Accessor<boolean>
|
|
144
|
+
pendingRename: Accessor<boolean>
|
|
145
|
+
setMenuOpen: (open: boolean) => void
|
|
146
|
+
setPendingRename: (value: boolean) => void
|
|
147
|
+
sidebarHovering: Accessor<boolean>
|
|
148
|
+
touch: Accessor<boolean>
|
|
149
|
+
language: ReturnType<typeof useLanguage>
|
|
150
|
+
workspaceValue: Accessor<string>
|
|
151
|
+
openEditor: WorkspaceSidebarContext["openEditor"]
|
|
152
|
+
showResetWorkspaceDialog: WorkspaceSidebarContext["showResetWorkspaceDialog"]
|
|
153
|
+
showDeleteWorkspaceDialog: WorkspaceSidebarContext["showDeleteWorkspaceDialog"]
|
|
154
|
+
root: string
|
|
155
|
+
setHoverSession: WorkspaceSidebarContext["setHoverSession"]
|
|
156
|
+
clearHoverProjectSoon: WorkspaceSidebarContext["clearHoverProjectSoon"]
|
|
157
|
+
navigateToNewSession: () => void
|
|
158
|
+
}): JSX.Element => (
|
|
159
|
+
<div
|
|
160
|
+
class="absolute right-1 top-1/2 -translate-y-1/2 flex items-center gap-0.5 transition-opacity"
|
|
161
|
+
classList={{
|
|
162
|
+
"opacity-100 pointer-events-auto": props.menuOpen(),
|
|
163
|
+
"opacity-0 pointer-events-none": !props.menuOpen(),
|
|
164
|
+
"group-hover/workspace:opacity-100 group-hover/workspace:pointer-events-auto": true,
|
|
165
|
+
"group-focus-within/workspace:opacity-100 group-focus-within/workspace:pointer-events-auto": true,
|
|
166
|
+
}}
|
|
167
|
+
>
|
|
168
|
+
<DropdownMenu
|
|
169
|
+
modal={!props.sidebarHovering()}
|
|
170
|
+
open={props.menuOpen()}
|
|
171
|
+
onOpenChange={(open) => props.setMenuOpen(open)}
|
|
172
|
+
>
|
|
173
|
+
<Tooltip value={props.language.t("common.moreOptions")} placement="top">
|
|
174
|
+
<DropdownMenu.Trigger
|
|
175
|
+
as={IconButton}
|
|
176
|
+
icon="dot-grid"
|
|
177
|
+
variant="ghost"
|
|
178
|
+
class="size-6 rounded-md"
|
|
179
|
+
data-action="workspace-menu"
|
|
180
|
+
data-workspace={base64Encode(props.directory)}
|
|
181
|
+
aria-label={props.language.t("common.moreOptions")}
|
|
182
|
+
/>
|
|
183
|
+
</Tooltip>
|
|
184
|
+
<DropdownMenu.Portal>
|
|
185
|
+
<DropdownMenu.Content
|
|
186
|
+
onCloseAutoFocus={(event) => {
|
|
187
|
+
if (!props.pendingRename()) return
|
|
188
|
+
event.preventDefault()
|
|
189
|
+
props.setPendingRename(false)
|
|
190
|
+
props.openEditor(`workspace:${props.directory}`, props.workspaceValue())
|
|
191
|
+
}}
|
|
192
|
+
>
|
|
193
|
+
<DropdownMenu.Item
|
|
194
|
+
disabled={props.local()}
|
|
195
|
+
onSelect={() => {
|
|
196
|
+
props.setPendingRename(true)
|
|
197
|
+
props.setMenuOpen(false)
|
|
198
|
+
}}
|
|
199
|
+
>
|
|
200
|
+
<DropdownMenu.ItemLabel>{props.language.t("common.rename")}</DropdownMenu.ItemLabel>
|
|
201
|
+
</DropdownMenu.Item>
|
|
202
|
+
<DropdownMenu.Item
|
|
203
|
+
disabled={props.local() || props.busy()}
|
|
204
|
+
onSelect={() => props.showResetWorkspaceDialog(props.root, props.directory)}
|
|
205
|
+
>
|
|
206
|
+
<DropdownMenu.ItemLabel>{props.language.t("common.reset")}</DropdownMenu.ItemLabel>
|
|
207
|
+
</DropdownMenu.Item>
|
|
208
|
+
<DropdownMenu.Item
|
|
209
|
+
disabled={props.local() || props.busy()}
|
|
210
|
+
onSelect={() => props.showDeleteWorkspaceDialog(props.root, props.directory)}
|
|
211
|
+
>
|
|
212
|
+
<DropdownMenu.ItemLabel>{props.language.t("common.delete")}</DropdownMenu.ItemLabel>
|
|
213
|
+
</DropdownMenu.Item>
|
|
214
|
+
</DropdownMenu.Content>
|
|
215
|
+
</DropdownMenu.Portal>
|
|
216
|
+
</DropdownMenu>
|
|
217
|
+
<Show when={!props.touch()}>
|
|
218
|
+
<Tooltip value={props.language.t("command.session.new")} placement="top">
|
|
219
|
+
<IconButton
|
|
220
|
+
icon="new-session"
|
|
221
|
+
variant="ghost"
|
|
222
|
+
class="size-6 rounded-md opacity-0 pointer-events-none group-hover/workspace:opacity-100 group-hover/workspace:pointer-events-auto group-focus-within/workspace:opacity-100 group-focus-within/workspace:pointer-events-auto"
|
|
223
|
+
data-action="workspace-new-session"
|
|
224
|
+
data-workspace={base64Encode(props.directory)}
|
|
225
|
+
aria-label={props.language.t("command.session.new")}
|
|
226
|
+
onClick={(event) => {
|
|
227
|
+
event.preventDefault()
|
|
228
|
+
event.stopPropagation()
|
|
229
|
+
props.setHoverSession(undefined)
|
|
230
|
+
props.clearHoverProjectSoon()
|
|
231
|
+
props.navigateToNewSession()
|
|
232
|
+
}}
|
|
233
|
+
/>
|
|
234
|
+
</Tooltip>
|
|
235
|
+
</Show>
|
|
236
|
+
</div>
|
|
237
|
+
)
|
|
238
|
+
|
|
239
|
+
const WorkspaceSessionList = (props: {
|
|
240
|
+
slug: Accessor<string>
|
|
241
|
+
mobile?: boolean
|
|
242
|
+
popover?: boolean
|
|
243
|
+
ctx: WorkspaceSidebarContext
|
|
244
|
+
showNew: Accessor<boolean>
|
|
245
|
+
loading: Accessor<boolean>
|
|
246
|
+
sessions: Accessor<Session[]>
|
|
247
|
+
children: Accessor<Map<string, string[]>>
|
|
248
|
+
hasMore: Accessor<boolean>
|
|
249
|
+
loadMore: () => Promise<void>
|
|
250
|
+
language: ReturnType<typeof useLanguage>
|
|
251
|
+
}): JSX.Element => (
|
|
252
|
+
<nav class="flex flex-col gap-1">
|
|
253
|
+
<Show when={props.showNew()}>
|
|
254
|
+
<NewSessionItem
|
|
255
|
+
slug={props.slug()}
|
|
256
|
+
mobile={props.mobile}
|
|
257
|
+
sidebarExpanded={props.ctx.sidebarExpanded}
|
|
258
|
+
clearHoverProjectSoon={props.ctx.clearHoverProjectSoon}
|
|
259
|
+
setHoverSession={props.ctx.setHoverSession}
|
|
260
|
+
/>
|
|
261
|
+
</Show>
|
|
262
|
+
<Show when={props.loading()}>
|
|
263
|
+
<SessionSkeleton />
|
|
264
|
+
</Show>
|
|
265
|
+
<For each={props.sessions()}>
|
|
266
|
+
{(session) => (
|
|
267
|
+
<SessionItem
|
|
268
|
+
session={session}
|
|
269
|
+
list={props.sessions()}
|
|
270
|
+
navList={props.ctx.navList}
|
|
271
|
+
slug={props.slug()}
|
|
272
|
+
mobile={props.mobile}
|
|
273
|
+
popover={props.popover}
|
|
274
|
+
children={props.children()}
|
|
275
|
+
sidebarExpanded={props.ctx.sidebarExpanded}
|
|
276
|
+
sidebarHovering={props.ctx.sidebarHovering}
|
|
277
|
+
nav={props.ctx.nav}
|
|
278
|
+
hoverSession={props.ctx.hoverSession}
|
|
279
|
+
setHoverSession={props.ctx.setHoverSession}
|
|
280
|
+
clearHoverProjectSoon={props.ctx.clearHoverProjectSoon}
|
|
281
|
+
prefetchSession={props.ctx.prefetchSession}
|
|
282
|
+
archiveSession={props.ctx.archiveSession}
|
|
283
|
+
/>
|
|
284
|
+
)}
|
|
285
|
+
</For>
|
|
286
|
+
<Show when={props.hasMore()}>
|
|
287
|
+
<div class="relative w-full py-1">
|
|
288
|
+
<Button
|
|
289
|
+
variant="ghost"
|
|
290
|
+
class="flex w-full text-left justify-start text-14-regular text-text-weak pl-9 pr-10"
|
|
291
|
+
size="large"
|
|
292
|
+
onClick={(e: MouseEvent) => {
|
|
293
|
+
props.loadMore()
|
|
294
|
+
;(e.currentTarget as HTMLButtonElement).blur()
|
|
295
|
+
}}
|
|
296
|
+
>
|
|
297
|
+
{props.language.t("common.loadMore")}
|
|
298
|
+
</Button>
|
|
299
|
+
</div>
|
|
300
|
+
</Show>
|
|
301
|
+
</nav>
|
|
302
|
+
)
|
|
303
|
+
|
|
304
|
+
export const SortableWorkspace = (props: {
|
|
305
|
+
ctx: WorkspaceSidebarContext
|
|
306
|
+
directory: string
|
|
307
|
+
project: LocalProject
|
|
308
|
+
sortNow: Accessor<number>
|
|
309
|
+
mobile?: boolean
|
|
310
|
+
popover?: boolean
|
|
311
|
+
}): JSX.Element => {
|
|
312
|
+
const navigate = useNavigate()
|
|
313
|
+
const params = useParams()
|
|
314
|
+
const globalSync = useGlobalSync()
|
|
315
|
+
const language = useLanguage()
|
|
316
|
+
const sortable = createSortable(props.directory)
|
|
317
|
+
const [workspaceStore, setWorkspaceStore] = globalSync.child(props.directory, { bootstrap: false })
|
|
318
|
+
const [menu, setMenu] = createStore({
|
|
319
|
+
open: false,
|
|
320
|
+
pendingRename: false,
|
|
321
|
+
})
|
|
322
|
+
const slug = createMemo(() => base64Encode(props.directory))
|
|
323
|
+
const sessions = createMemo(() => sortedRootSessions(workspaceStore, props.sortNow()))
|
|
324
|
+
const children = createMemo(() => childMapByParent(workspaceStore.session))
|
|
325
|
+
const local = createMemo(() => props.directory === props.project.worktree)
|
|
326
|
+
const active = createMemo(() => workspaceKey(props.ctx.currentDir()) === workspaceKey(props.directory))
|
|
327
|
+
const workspaceValue = createMemo(() => {
|
|
328
|
+
const branch = workspaceStore.vcs?.branch
|
|
329
|
+
const name = branch ?? getFilename(props.directory)
|
|
330
|
+
return props.ctx.workspaceName(props.directory, props.project.id, branch) ?? name
|
|
331
|
+
})
|
|
332
|
+
const open = createMemo(() => props.ctx.workspaceExpanded(props.directory, local()))
|
|
333
|
+
const boot = createMemo(() => open() || active())
|
|
334
|
+
const booted = createMemo((prev) => prev || workspaceStore.status === "complete", false)
|
|
335
|
+
const count = createMemo(() => sessions()?.length ?? 0)
|
|
336
|
+
const hasMore = createMemo(() => workspaceStore.sessionTotal > count())
|
|
337
|
+
const busy = createMemo(() => props.ctx.isBusy(props.directory))
|
|
338
|
+
const wasBusy = createMemo((prev) => prev || busy(), false)
|
|
339
|
+
const loading = createMemo(() => open() && !booted() && count() === 0 && !wasBusy())
|
|
340
|
+
const touch = createMediaQuery("(hover: none)")
|
|
341
|
+
const showNew = createMemo(() => !loading() && (touch() || count() === 0 || (active() && !params.id)))
|
|
342
|
+
const loadMore = async () => {
|
|
343
|
+
setWorkspaceStore("limit", (limit) => (limit ?? 0) + 5)
|
|
344
|
+
await globalSync.project.loadSessions(props.directory)
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
const workspaceEditActive = createMemo(() => props.ctx.editorOpen(`workspace:${props.directory}`))
|
|
348
|
+
const header = () => (
|
|
349
|
+
<WorkspaceHeader
|
|
350
|
+
local={local}
|
|
351
|
+
busy={busy}
|
|
352
|
+
open={open}
|
|
353
|
+
directory={props.directory}
|
|
354
|
+
language={language}
|
|
355
|
+
branch={() => workspaceStore.vcs?.branch}
|
|
356
|
+
workspaceValue={workspaceValue}
|
|
357
|
+
workspaceEditActive={workspaceEditActive}
|
|
358
|
+
InlineEditor={props.ctx.InlineEditor}
|
|
359
|
+
renameWorkspace={props.ctx.renameWorkspace}
|
|
360
|
+
setEditor={props.ctx.setEditor}
|
|
361
|
+
projectId={props.project.id}
|
|
362
|
+
/>
|
|
363
|
+
)
|
|
364
|
+
|
|
365
|
+
const openWrapper = (value: boolean) => {
|
|
366
|
+
props.ctx.setWorkspaceExpanded(props.directory, value)
|
|
367
|
+
if (value) return
|
|
368
|
+
if (props.ctx.editorOpen(`workspace:${props.directory}`)) props.ctx.closeEditor()
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
createEffect(() => {
|
|
372
|
+
if (!boot()) return
|
|
373
|
+
globalSync.child(props.directory, { bootstrap: true })
|
|
374
|
+
})
|
|
375
|
+
|
|
376
|
+
return (
|
|
377
|
+
<div
|
|
378
|
+
// @ts-ignore
|
|
379
|
+
use:sortable
|
|
380
|
+
classList={{
|
|
381
|
+
"opacity-30": sortable.isActiveDraggable,
|
|
382
|
+
"opacity-50 pointer-events-none": busy(),
|
|
383
|
+
}}
|
|
384
|
+
>
|
|
385
|
+
<Collapsible variant="ghost" open={open()} class="shrink-0" onOpenChange={openWrapper}>
|
|
386
|
+
<div class="py-1">
|
|
387
|
+
<div
|
|
388
|
+
class="group/workspace relative"
|
|
389
|
+
data-component="workspace-item"
|
|
390
|
+
data-workspace={base64Encode(props.directory)}
|
|
391
|
+
>
|
|
392
|
+
<div class="flex items-center gap-1">
|
|
393
|
+
<Show
|
|
394
|
+
when={workspaceEditActive()}
|
|
395
|
+
fallback={
|
|
396
|
+
<Collapsible.Trigger
|
|
397
|
+
class={`flex items-center justify-between w-full pl-2 py-1.5 rounded-md hover:bg-surface-raised-base-hover transition-[padding] duration-200 ${
|
|
398
|
+
menu.open ? "pr-16" : "pr-2"
|
|
399
|
+
} group-hover/workspace:pr-16 group-focus-within/workspace:pr-16`}
|
|
400
|
+
data-action="workspace-toggle"
|
|
401
|
+
data-workspace={base64Encode(props.directory)}
|
|
402
|
+
>
|
|
403
|
+
{header()}
|
|
404
|
+
</Collapsible.Trigger>
|
|
405
|
+
}
|
|
406
|
+
>
|
|
407
|
+
<div
|
|
408
|
+
class={`flex items-center justify-between w-full pl-2 py-1.5 rounded-md transition-[padding] duration-200 ${
|
|
409
|
+
menu.open ? "pr-16" : "pr-2"
|
|
410
|
+
} group-hover/workspace:pr-16 group-focus-within/workspace:pr-16`}
|
|
411
|
+
>
|
|
412
|
+
{header()}
|
|
413
|
+
</div>
|
|
414
|
+
</Show>
|
|
415
|
+
<WorkspaceActions
|
|
416
|
+
directory={props.directory}
|
|
417
|
+
local={local}
|
|
418
|
+
busy={busy}
|
|
419
|
+
menuOpen={() => menu.open}
|
|
420
|
+
pendingRename={() => menu.pendingRename}
|
|
421
|
+
setMenuOpen={(open) => setMenu("open", open)}
|
|
422
|
+
setPendingRename={(value) => setMenu("pendingRename", value)}
|
|
423
|
+
sidebarHovering={props.ctx.sidebarHovering}
|
|
424
|
+
touch={touch}
|
|
425
|
+
language={language}
|
|
426
|
+
workspaceValue={workspaceValue}
|
|
427
|
+
openEditor={props.ctx.openEditor}
|
|
428
|
+
showResetWorkspaceDialog={props.ctx.showResetWorkspaceDialog}
|
|
429
|
+
showDeleteWorkspaceDialog={props.ctx.showDeleteWorkspaceDialog}
|
|
430
|
+
root={props.project.worktree}
|
|
431
|
+
setHoverSession={props.ctx.setHoverSession}
|
|
432
|
+
clearHoverProjectSoon={props.ctx.clearHoverProjectSoon}
|
|
433
|
+
navigateToNewSession={() => navigate(`/${slug()}/session`)}
|
|
434
|
+
/>
|
|
435
|
+
</div>
|
|
436
|
+
</div>
|
|
437
|
+
</div>
|
|
438
|
+
|
|
439
|
+
<Collapsible.Content>
|
|
440
|
+
<WorkspaceSessionList
|
|
441
|
+
slug={slug}
|
|
442
|
+
mobile={props.mobile}
|
|
443
|
+
popover={props.popover}
|
|
444
|
+
ctx={props.ctx}
|
|
445
|
+
showNew={showNew}
|
|
446
|
+
loading={loading}
|
|
447
|
+
sessions={sessions}
|
|
448
|
+
children={children}
|
|
449
|
+
hasMore={hasMore}
|
|
450
|
+
loadMore={loadMore}
|
|
451
|
+
language={language}
|
|
452
|
+
/>
|
|
453
|
+
</Collapsible.Content>
|
|
454
|
+
</Collapsible>
|
|
455
|
+
</div>
|
|
456
|
+
)
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
export const LocalWorkspace = (props: {
|
|
460
|
+
ctx: WorkspaceSidebarContext
|
|
461
|
+
project: LocalProject
|
|
462
|
+
sortNow: Accessor<number>
|
|
463
|
+
mobile?: boolean
|
|
464
|
+
popover?: boolean
|
|
465
|
+
}): JSX.Element => {
|
|
466
|
+
const globalSync = useGlobalSync()
|
|
467
|
+
const language = useLanguage()
|
|
468
|
+
const workspace = createMemo(() => {
|
|
469
|
+
const [store, setStore] = globalSync.child(props.project.worktree)
|
|
470
|
+
return { store, setStore }
|
|
471
|
+
})
|
|
472
|
+
const slug = createMemo(() => base64Encode(props.project.worktree))
|
|
473
|
+
const sessions = createMemo(() => sortedRootSessions(workspace().store, props.sortNow()))
|
|
474
|
+
const children = createMemo(() => childMapByParent(workspace().store.session))
|
|
475
|
+
const booted = createMemo((prev) => prev || workspace().store.status === "complete", false)
|
|
476
|
+
const count = createMemo(() => sessions()?.length ?? 0)
|
|
477
|
+
const loading = createMemo(() => !booted() && count() === 0)
|
|
478
|
+
const hasMore = createMemo(() => workspace().store.sessionTotal > count())
|
|
479
|
+
const loadMore = async () => {
|
|
480
|
+
workspace().setStore("limit", (limit) => (limit ?? 0) + 5)
|
|
481
|
+
await globalSync.project.loadSessions(props.project.worktree)
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
return (
|
|
485
|
+
<div
|
|
486
|
+
ref={(el) => props.ctx.setScrollContainerRef(el, props.mobile)}
|
|
487
|
+
class="size-full flex flex-col py-2 overflow-y-auto no-scrollbar [overflow-anchor:none]"
|
|
488
|
+
>
|
|
489
|
+
<WorkspaceSessionList
|
|
490
|
+
slug={slug}
|
|
491
|
+
mobile={props.mobile}
|
|
492
|
+
popover={props.popover}
|
|
493
|
+
ctx={props.ctx}
|
|
494
|
+
showNew={() => false}
|
|
495
|
+
loading={loading}
|
|
496
|
+
sessions={sessions}
|
|
497
|
+
children={children}
|
|
498
|
+
hasMore={hasMore}
|
|
499
|
+
loadMore={loadMore}
|
|
500
|
+
language={language}
|
|
501
|
+
/>
|
|
502
|
+
</div>
|
|
503
|
+
)
|
|
504
|
+
}
|