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,99 @@
|
|
|
1
|
+
import { For, Show, createEffect, createMemo } from "solid-js"
|
|
2
|
+
import { createStore } from "solid-js/store"
|
|
3
|
+
import { Button } from "@reign-labs/ui/button"
|
|
4
|
+
import { DockTray } from "@reign-labs/ui/dock-surface"
|
|
5
|
+
import { IconButton } from "@reign-labs/ui/icon-button"
|
|
6
|
+
import { useLanguage } from "@/context/language"
|
|
7
|
+
|
|
8
|
+
export function SessionRevertDock(props: {
|
|
9
|
+
items: { id: string; text: string }[]
|
|
10
|
+
restoring?: string
|
|
11
|
+
disabled?: boolean
|
|
12
|
+
onRestore: (id: string) => void
|
|
13
|
+
}) {
|
|
14
|
+
const language = useLanguage()
|
|
15
|
+
const [store, setStore] = createStore({
|
|
16
|
+
collapsed: true,
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
createEffect(() => {
|
|
20
|
+
props.items.length
|
|
21
|
+
props.items[0]?.id
|
|
22
|
+
setStore("collapsed", true)
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
const toggle = () => setStore("collapsed", (value) => !value)
|
|
26
|
+
const total = createMemo(() => props.items.length)
|
|
27
|
+
const label = createMemo(() =>
|
|
28
|
+
language.t(total() === 1 ? "session.revertDock.summary.one" : "session.revertDock.summary.other", {
|
|
29
|
+
count: total(),
|
|
30
|
+
}),
|
|
31
|
+
)
|
|
32
|
+
const preview = createMemo(() => props.items[0]?.text ?? "")
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<DockTray data-component="session-revert-dock">
|
|
36
|
+
<div
|
|
37
|
+
class="pl-3 pr-2 py-2 flex items-center gap-2"
|
|
38
|
+
role="button"
|
|
39
|
+
tabIndex={0}
|
|
40
|
+
onClick={toggle}
|
|
41
|
+
onKeyDown={(event) => {
|
|
42
|
+
if (event.key !== "Enter" && event.key !== " ") return
|
|
43
|
+
event.preventDefault()
|
|
44
|
+
toggle()
|
|
45
|
+
}}
|
|
46
|
+
>
|
|
47
|
+
<span class="shrink-0 text-14-regular text-text-strong cursor-default">{label()}</span>
|
|
48
|
+
<Show when={store.collapsed && preview()}>
|
|
49
|
+
<span class="min-w-0 flex-1 truncate text-14-regular text-text-base cursor-default">{preview()}</span>
|
|
50
|
+
</Show>
|
|
51
|
+
<div class="ml-auto shrink-0">
|
|
52
|
+
<IconButton
|
|
53
|
+
data-collapsed={store.collapsed ? "true" : "false"}
|
|
54
|
+
icon="chevron-down"
|
|
55
|
+
size="normal"
|
|
56
|
+
variant="ghost"
|
|
57
|
+
style={{ transform: `rotate(${store.collapsed ? 180 : 0}deg)` }}
|
|
58
|
+
onMouseDown={(event) => {
|
|
59
|
+
event.preventDefault()
|
|
60
|
+
event.stopPropagation()
|
|
61
|
+
}}
|
|
62
|
+
onClick={(event) => {
|
|
63
|
+
event.stopPropagation()
|
|
64
|
+
toggle()
|
|
65
|
+
}}
|
|
66
|
+
aria-label={
|
|
67
|
+
store.collapsed ? language.t("session.revertDock.expand") : language.t("session.revertDock.collapse")
|
|
68
|
+
}
|
|
69
|
+
/>
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
|
|
73
|
+
<Show when={store.collapsed}>
|
|
74
|
+
<div class="h-5" aria-hidden="true" />
|
|
75
|
+
</Show>
|
|
76
|
+
|
|
77
|
+
<Show when={!store.collapsed}>
|
|
78
|
+
<div class="px-3 pb-7 flex flex-col gap-1.5 max-h-42 overflow-y-auto no-scrollbar">
|
|
79
|
+
<For each={props.items}>
|
|
80
|
+
{(item) => (
|
|
81
|
+
<div class="flex items-center gap-2 min-w-0 py-1">
|
|
82
|
+
<span class="min-w-0 flex-1 truncate text-13-regular text-text-strong">{item.text}</span>
|
|
83
|
+
<Button
|
|
84
|
+
size="small"
|
|
85
|
+
variant="secondary"
|
|
86
|
+
class="shrink-0"
|
|
87
|
+
disabled={props.disabled || !!props.restoring}
|
|
88
|
+
onClick={() => props.onRestore(item.id)}
|
|
89
|
+
>
|
|
90
|
+
{language.t("session.revertDock.restore")}
|
|
91
|
+
</Button>
|
|
92
|
+
</div>
|
|
93
|
+
)}
|
|
94
|
+
</For>
|
|
95
|
+
</div>
|
|
96
|
+
</Show>
|
|
97
|
+
</DockTray>
|
|
98
|
+
)
|
|
99
|
+
}
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import type { Todo } from "@reign-labs/sdk/v2"
|
|
2
|
+
import { AnimatedNumber } from "@reign-labs/ui/animated-number"
|
|
3
|
+
import { Checkbox } from "@reign-labs/ui/checkbox"
|
|
4
|
+
import { DockTray } from "@reign-labs/ui/dock-surface"
|
|
5
|
+
import { IconButton } from "@reign-labs/ui/icon-button"
|
|
6
|
+
import { useSpring } from "@reign-labs/ui/motion-spring"
|
|
7
|
+
import { TextReveal } from "@reign-labs/ui/text-reveal"
|
|
8
|
+
import { TextStrikethrough } from "@reign-labs/ui/text-strikethrough"
|
|
9
|
+
import { Index, createEffect, createMemo, on, onCleanup } from "solid-js"
|
|
10
|
+
import { createStore } from "solid-js/store"
|
|
11
|
+
import { composerEnabled, composerProbe } from "@/testing/session-composer"
|
|
12
|
+
import { useLanguage } from "@/context/language"
|
|
13
|
+
|
|
14
|
+
const doneToken = "\u0000done\u0000"
|
|
15
|
+
const totalToken = "\u0000total\u0000"
|
|
16
|
+
|
|
17
|
+
function dot(status: Todo["status"]) {
|
|
18
|
+
if (status !== "in_progress") return undefined
|
|
19
|
+
return (
|
|
20
|
+
<svg
|
|
21
|
+
viewBox="0 0 12 12"
|
|
22
|
+
width="12"
|
|
23
|
+
height="12"
|
|
24
|
+
fill="currentColor"
|
|
25
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
26
|
+
class="block"
|
|
27
|
+
>
|
|
28
|
+
<circle
|
|
29
|
+
cx="6"
|
|
30
|
+
cy="6"
|
|
31
|
+
r="3"
|
|
32
|
+
style={{
|
|
33
|
+
animation: "var(--animate-pulse-scale)",
|
|
34
|
+
"transform-origin": "center",
|
|
35
|
+
"transform-box": "fill-box",
|
|
36
|
+
}}
|
|
37
|
+
/>
|
|
38
|
+
</svg>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function SessionTodoDock(props: {
|
|
43
|
+
sessionID?: string
|
|
44
|
+
todos: Todo[]
|
|
45
|
+
collapseLabel: string
|
|
46
|
+
expandLabel: string
|
|
47
|
+
dockProgress: number
|
|
48
|
+
}) {
|
|
49
|
+
const language = useLanguage()
|
|
50
|
+
const [store, setStore] = createStore({
|
|
51
|
+
collapsed: false,
|
|
52
|
+
height: 320,
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
const toggle = () => setStore("collapsed", (value) => !value)
|
|
56
|
+
|
|
57
|
+
const total = createMemo(() => props.todos.length)
|
|
58
|
+
const done = createMemo(() => props.todos.filter((todo) => todo.status === "completed").length)
|
|
59
|
+
const label = createMemo(() => language.t("session.todo.progress", { done: done(), total: total() }))
|
|
60
|
+
const progress = createMemo(() =>
|
|
61
|
+
language
|
|
62
|
+
.t("session.todo.progress", { done: doneToken, total: totalToken })
|
|
63
|
+
.split(/(\u0000done\u0000|\u0000total\u0000)/),
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
const active = createMemo(
|
|
67
|
+
() =>
|
|
68
|
+
props.todos.find((todo) => todo.status === "in_progress") ??
|
|
69
|
+
props.todos.find((todo) => todo.status === "pending") ??
|
|
70
|
+
props.todos.filter((todo) => todo.status === "completed").at(-1) ??
|
|
71
|
+
props.todos[0],
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
const preview = createMemo(() => active()?.content ?? "")
|
|
75
|
+
const collapse = useSpring(() => (store.collapsed ? 1 : 0), { visualDuration: 0.3, bounce: 0 })
|
|
76
|
+
const dock = createMemo(() => Math.max(0, Math.min(1, props.dockProgress)))
|
|
77
|
+
const shut = createMemo(() => 1 - dock())
|
|
78
|
+
const value = createMemo(() => Math.max(0, Math.min(1, collapse())))
|
|
79
|
+
const hide = createMemo(() => Math.max(value(), shut()))
|
|
80
|
+
const off = createMemo(() => hide() > 0.98)
|
|
81
|
+
const turn = createMemo(() => Math.max(0, Math.min(1, value())))
|
|
82
|
+
const full = createMemo(() => Math.max(78, store.height))
|
|
83
|
+
const e2e = composerEnabled()
|
|
84
|
+
const probe = composerProbe(props.sessionID)
|
|
85
|
+
let contentRef: HTMLDivElement | undefined
|
|
86
|
+
|
|
87
|
+
createEffect(() => {
|
|
88
|
+
const el = contentRef
|
|
89
|
+
if (!el) return
|
|
90
|
+
const update = () => {
|
|
91
|
+
setStore("height", el.getBoundingClientRect().height)
|
|
92
|
+
}
|
|
93
|
+
update()
|
|
94
|
+
const observer = new ResizeObserver(update)
|
|
95
|
+
observer.observe(el)
|
|
96
|
+
onCleanup(() => observer.disconnect())
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
createEffect(() => {
|
|
100
|
+
if (!e2e) return
|
|
101
|
+
|
|
102
|
+
probe.set({
|
|
103
|
+
mounted: true,
|
|
104
|
+
collapsed: store.collapsed,
|
|
105
|
+
hidden: store.collapsed || off(),
|
|
106
|
+
count: props.todos.length,
|
|
107
|
+
states: props.todos.map((todo) => todo.status),
|
|
108
|
+
})
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
onCleanup(() => {
|
|
112
|
+
if (!e2e) return
|
|
113
|
+
probe.drop()
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
<DockTray
|
|
118
|
+
data-component="session-todo-dock"
|
|
119
|
+
style={{
|
|
120
|
+
"overflow-x": "visible",
|
|
121
|
+
"overflow-y": "hidden",
|
|
122
|
+
"max-height": `${Math.max(78, full() - value() * (full() - 78))}px`,
|
|
123
|
+
}}
|
|
124
|
+
>
|
|
125
|
+
<div ref={contentRef}>
|
|
126
|
+
<div
|
|
127
|
+
data-action="session-todo-toggle"
|
|
128
|
+
class="pl-3 pr-2 py-2 flex items-center gap-2 overflow-visible"
|
|
129
|
+
role="button"
|
|
130
|
+
tabIndex={0}
|
|
131
|
+
onClick={toggle}
|
|
132
|
+
onKeyDown={(event) => {
|
|
133
|
+
if (event.key !== "Enter" && event.key !== " ") return
|
|
134
|
+
event.preventDefault()
|
|
135
|
+
toggle()
|
|
136
|
+
}}
|
|
137
|
+
>
|
|
138
|
+
<span
|
|
139
|
+
class="text-14-regular text-text-strong cursor-default inline-flex items-baseline shrink-0 overflow-visible"
|
|
140
|
+
aria-label={label()}
|
|
141
|
+
style={{
|
|
142
|
+
"--tool-motion-odometer-ms": "600ms",
|
|
143
|
+
"--tool-motion-mask": "18%",
|
|
144
|
+
"--tool-motion-mask-height": "0px",
|
|
145
|
+
"--tool-motion-spring-ms": "560ms",
|
|
146
|
+
"white-space": "pre",
|
|
147
|
+
opacity: `${Math.max(0, Math.min(1, 1 - shut()))}`,
|
|
148
|
+
}}
|
|
149
|
+
>
|
|
150
|
+
<Index each={progress()}>
|
|
151
|
+
{(item) =>
|
|
152
|
+
item() === doneToken ? (
|
|
153
|
+
<AnimatedNumber value={done()} />
|
|
154
|
+
) : item() === totalToken ? (
|
|
155
|
+
<AnimatedNumber value={total()} />
|
|
156
|
+
) : (
|
|
157
|
+
<span>{item()}</span>
|
|
158
|
+
)
|
|
159
|
+
}
|
|
160
|
+
</Index>
|
|
161
|
+
</span>
|
|
162
|
+
<div
|
|
163
|
+
data-slot="session-todo-preview"
|
|
164
|
+
class="ml-1 min-w-0 overflow-hidden"
|
|
165
|
+
style={{
|
|
166
|
+
flex: "1 1 auto",
|
|
167
|
+
"max-width": "100%",
|
|
168
|
+
}}
|
|
169
|
+
>
|
|
170
|
+
<TextReveal
|
|
171
|
+
class="text-14-regular text-text-base cursor-default"
|
|
172
|
+
text={store.collapsed ? preview() : undefined}
|
|
173
|
+
duration={600}
|
|
174
|
+
travel={25}
|
|
175
|
+
edge={17}
|
|
176
|
+
spring="cubic-bezier(0.34, 1, 0.64, 1)"
|
|
177
|
+
springSoft="cubic-bezier(0.34, 1, 0.64, 1)"
|
|
178
|
+
growOnly
|
|
179
|
+
truncate
|
|
180
|
+
/>
|
|
181
|
+
</div>
|
|
182
|
+
<div class="ml-auto">
|
|
183
|
+
<IconButton
|
|
184
|
+
data-action="session-todo-toggle-button"
|
|
185
|
+
data-collapsed={store.collapsed ? "true" : "false"}
|
|
186
|
+
icon="chevron-down"
|
|
187
|
+
size="normal"
|
|
188
|
+
variant="ghost"
|
|
189
|
+
style={{ transform: `rotate(${turn() * 180}deg)` }}
|
|
190
|
+
onMouseDown={(event) => {
|
|
191
|
+
event.preventDefault()
|
|
192
|
+
event.stopPropagation()
|
|
193
|
+
}}
|
|
194
|
+
onClick={(event) => {
|
|
195
|
+
event.stopPropagation()
|
|
196
|
+
toggle()
|
|
197
|
+
}}
|
|
198
|
+
aria-label={store.collapsed ? props.expandLabel : props.collapseLabel}
|
|
199
|
+
/>
|
|
200
|
+
</div>
|
|
201
|
+
</div>
|
|
202
|
+
|
|
203
|
+
<div
|
|
204
|
+
data-slot="session-todo-list"
|
|
205
|
+
aria-hidden={store.collapsed || off()}
|
|
206
|
+
classList={{
|
|
207
|
+
"pointer-events-none": hide() > 0.1,
|
|
208
|
+
}}
|
|
209
|
+
style={{
|
|
210
|
+
visibility: off() ? "hidden" : "visible",
|
|
211
|
+
opacity: `${Math.max(0, Math.min(1, 1 - hide()))}`,
|
|
212
|
+
}}
|
|
213
|
+
>
|
|
214
|
+
<TodoList todos={props.todos} open={!store.collapsed} />
|
|
215
|
+
</div>
|
|
216
|
+
</div>
|
|
217
|
+
</DockTray>
|
|
218
|
+
)
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function TodoList(props: { todos: Todo[]; open: boolean }) {
|
|
222
|
+
const [store, setStore] = createStore({
|
|
223
|
+
stuck: false,
|
|
224
|
+
scrolling: false,
|
|
225
|
+
})
|
|
226
|
+
let scrollRef!: HTMLDivElement
|
|
227
|
+
let timer: number | undefined
|
|
228
|
+
|
|
229
|
+
const inProgress = createMemo(() => props.todos.findIndex((todo) => todo.status === "in_progress"))
|
|
230
|
+
|
|
231
|
+
const ensure = () => {
|
|
232
|
+
if (!props.open) return
|
|
233
|
+
if (store.scrolling) return
|
|
234
|
+
if (!scrollRef || scrollRef.offsetParent === null) return
|
|
235
|
+
|
|
236
|
+
const el = scrollRef.querySelector("[data-in-progress]")
|
|
237
|
+
if (!(el instanceof HTMLElement)) return
|
|
238
|
+
|
|
239
|
+
const topFade = 16
|
|
240
|
+
const bottomFade = 44
|
|
241
|
+
const container = scrollRef.getBoundingClientRect()
|
|
242
|
+
const rect = el.getBoundingClientRect()
|
|
243
|
+
const top = rect.top - container.top + scrollRef.scrollTop
|
|
244
|
+
const bottom = rect.bottom - container.top + scrollRef.scrollTop
|
|
245
|
+
const viewTop = scrollRef.scrollTop + topFade
|
|
246
|
+
const viewBottom = scrollRef.scrollTop + scrollRef.clientHeight - bottomFade
|
|
247
|
+
|
|
248
|
+
if (top < viewTop) {
|
|
249
|
+
scrollRef.scrollTop = Math.max(0, top - topFade)
|
|
250
|
+
} else if (bottom > viewBottom) {
|
|
251
|
+
scrollRef.scrollTop = bottom - (scrollRef.clientHeight - bottomFade)
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
setStore("stuck", scrollRef.scrollTop > 0)
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
createEffect(
|
|
258
|
+
on([() => props.open, inProgress], () => {
|
|
259
|
+
if (!props.open || inProgress() < 0) return
|
|
260
|
+
requestAnimationFrame(ensure)
|
|
261
|
+
}),
|
|
262
|
+
)
|
|
263
|
+
|
|
264
|
+
onCleanup(() => {
|
|
265
|
+
if (!timer) return
|
|
266
|
+
window.clearTimeout(timer)
|
|
267
|
+
})
|
|
268
|
+
|
|
269
|
+
return (
|
|
270
|
+
<div class="relative">
|
|
271
|
+
<div
|
|
272
|
+
class="px-3 pb-11 flex flex-col gap-1.5 max-h-42 overflow-y-auto no-scrollbar"
|
|
273
|
+
ref={scrollRef}
|
|
274
|
+
style={{ "overflow-anchor": "none" }}
|
|
275
|
+
onScroll={(e) => {
|
|
276
|
+
setStore("stuck", e.currentTarget.scrollTop > 0)
|
|
277
|
+
setStore("scrolling", true)
|
|
278
|
+
if (timer) window.clearTimeout(timer)
|
|
279
|
+
timer = window.setTimeout(() => {
|
|
280
|
+
setStore("scrolling", false)
|
|
281
|
+
if (inProgress() < 0) return
|
|
282
|
+
requestAnimationFrame(ensure)
|
|
283
|
+
}, 250)
|
|
284
|
+
}}
|
|
285
|
+
>
|
|
286
|
+
<Index each={props.todos}>
|
|
287
|
+
{(todo) => (
|
|
288
|
+
<Checkbox
|
|
289
|
+
readOnly
|
|
290
|
+
checked={todo().status === "completed"}
|
|
291
|
+
indeterminate={todo().status === "in_progress"}
|
|
292
|
+
data-in-progress={todo().status === "in_progress" ? "" : undefined}
|
|
293
|
+
data-state={todo().status}
|
|
294
|
+
icon={dot(todo().status)}
|
|
295
|
+
style={{
|
|
296
|
+
"--checkbox-align": "flex-start",
|
|
297
|
+
"--checkbox-offset": "1px",
|
|
298
|
+
transition: "opacity 220ms var(--tool-motion-ease, cubic-bezier(0.22, 1, 0.36, 1))",
|
|
299
|
+
opacity: todo().status === "pending" ? "0.94" : "1",
|
|
300
|
+
}}
|
|
301
|
+
>
|
|
302
|
+
<TextStrikethrough
|
|
303
|
+
active={todo().status === "completed" || todo().status === "cancelled"}
|
|
304
|
+
text={todo().content}
|
|
305
|
+
class="text-14-regular min-w-0 break-words"
|
|
306
|
+
style={{
|
|
307
|
+
"line-height": "var(--line-height-normal)",
|
|
308
|
+
transition:
|
|
309
|
+
"color 220ms var(--tool-motion-ease, cubic-bezier(0.22, 1, 0.36, 1)), opacity 220ms var(--tool-motion-ease, cubic-bezier(0.22, 1, 0.36, 1))",
|
|
310
|
+
color:
|
|
311
|
+
todo().status === "completed" || todo().status === "cancelled"
|
|
312
|
+
? "var(--text-weak)"
|
|
313
|
+
: "var(--text-strong)",
|
|
314
|
+
opacity: todo().status === "pending" ? "0.92" : "1",
|
|
315
|
+
}}
|
|
316
|
+
/>
|
|
317
|
+
</Checkbox>
|
|
318
|
+
)}
|
|
319
|
+
</Index>
|
|
320
|
+
</div>
|
|
321
|
+
<div
|
|
322
|
+
class="pointer-events-none absolute top-0 left-0 right-0 h-4 transition-opacity duration-150"
|
|
323
|
+
style={{
|
|
324
|
+
background: "linear-gradient(to bottom, var(--background-base), transparent)",
|
|
325
|
+
opacity: store.stuck ? 1 : 0,
|
|
326
|
+
}}
|
|
327
|
+
/>
|
|
328
|
+
</div>
|
|
329
|
+
)
|
|
330
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test"
|
|
2
|
+
import { nextTabListScrollLeft } from "./file-tab-scroll"
|
|
3
|
+
|
|
4
|
+
describe("nextTabListScrollLeft", () => {
|
|
5
|
+
test("does not scroll when width shrinks", () => {
|
|
6
|
+
const left = nextTabListScrollLeft({
|
|
7
|
+
prevScrollWidth: 500,
|
|
8
|
+
scrollWidth: 420,
|
|
9
|
+
clientWidth: 300,
|
|
10
|
+
prevContextOpen: false,
|
|
11
|
+
contextOpen: false,
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
expect(left).toBeUndefined()
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
test("scrolls to start when context tab opens", () => {
|
|
18
|
+
const left = nextTabListScrollLeft({
|
|
19
|
+
prevScrollWidth: 400,
|
|
20
|
+
scrollWidth: 500,
|
|
21
|
+
clientWidth: 320,
|
|
22
|
+
prevContextOpen: false,
|
|
23
|
+
contextOpen: true,
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
expect(left).toBe(0)
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
test("scrolls to right edge for new file tabs", () => {
|
|
30
|
+
const left = nextTabListScrollLeft({
|
|
31
|
+
prevScrollWidth: 500,
|
|
32
|
+
scrollWidth: 780,
|
|
33
|
+
clientWidth: 300,
|
|
34
|
+
prevContextOpen: true,
|
|
35
|
+
contextOpen: true,
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
expect(left).toBe(480)
|
|
39
|
+
})
|
|
40
|
+
})
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
type Input = {
|
|
2
|
+
prevScrollWidth: number
|
|
3
|
+
scrollWidth: number
|
|
4
|
+
clientWidth: number
|
|
5
|
+
prevContextOpen: boolean
|
|
6
|
+
contextOpen: boolean
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const nextTabListScrollLeft = (input: Input) => {
|
|
10
|
+
if (input.scrollWidth <= input.prevScrollWidth) return
|
|
11
|
+
if (!input.prevContextOpen && input.contextOpen) return 0
|
|
12
|
+
if (input.scrollWidth <= input.clientWidth) return
|
|
13
|
+
return input.scrollWidth - input.clientWidth
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const createFileTabListSync = (input: { el: HTMLDivElement; contextOpen: () => boolean }) => {
|
|
17
|
+
let frame: number | undefined
|
|
18
|
+
let prevScrollWidth = input.el.scrollWidth
|
|
19
|
+
let prevContextOpen = input.contextOpen()
|
|
20
|
+
|
|
21
|
+
const update = () => {
|
|
22
|
+
const scrollWidth = input.el.scrollWidth
|
|
23
|
+
const clientWidth = input.el.clientWidth
|
|
24
|
+
const contextOpen = input.contextOpen()
|
|
25
|
+
const left = nextTabListScrollLeft({
|
|
26
|
+
prevScrollWidth,
|
|
27
|
+
scrollWidth,
|
|
28
|
+
clientWidth,
|
|
29
|
+
prevContextOpen,
|
|
30
|
+
contextOpen,
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
if (left !== undefined) {
|
|
34
|
+
input.el.scrollTo({
|
|
35
|
+
left,
|
|
36
|
+
behavior: "smooth",
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
prevScrollWidth = scrollWidth
|
|
41
|
+
prevContextOpen = contextOpen
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const schedule = () => {
|
|
45
|
+
if (frame !== undefined) cancelAnimationFrame(frame)
|
|
46
|
+
frame = requestAnimationFrame(() => {
|
|
47
|
+
frame = undefined
|
|
48
|
+
update()
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const onWheel = (e: WheelEvent) => {
|
|
53
|
+
if (Math.abs(e.deltaY) <= Math.abs(e.deltaX)) return
|
|
54
|
+
input.el.scrollLeft += e.deltaY > 0 ? 50 : -50
|
|
55
|
+
e.preventDefault()
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
input.el.addEventListener("wheel", onWheel, { passive: false })
|
|
59
|
+
const observer = new MutationObserver(schedule)
|
|
60
|
+
observer.observe(input.el, { childList: true })
|
|
61
|
+
|
|
62
|
+
return () => {
|
|
63
|
+
input.el.removeEventListener("wheel", onWheel)
|
|
64
|
+
observer.disconnect()
|
|
65
|
+
if (frame !== undefined) cancelAnimationFrame(frame)
|
|
66
|
+
}
|
|
67
|
+
}
|