@neurocode-ai/session-ui 1.18.8
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/package.json +71 -0
- package/src/components/apply-patch-file.test.ts +43 -0
- package/src/components/apply-patch-file.ts +78 -0
- package/src/components/basic-tool.css +358 -0
- package/src/components/basic-tool.stories.tsx +133 -0
- package/src/components/basic-tool.tsx +343 -0
- package/src/components/dock-prompt.stories.tsx +62 -0
- package/src/components/dock-prompt.tsx +23 -0
- package/src/components/file-media.tsx +291 -0
- package/src/components/file-search.tsx +72 -0
- package/src/components/file-ssr.tsx +197 -0
- package/src/components/file.css +46 -0
- package/src/components/file.tsx +1202 -0
- package/src/components/line-comment-annotations.tsx +637 -0
- package/src/components/line-comment-styles.ts +292 -0
- package/src/components/line-comment.stories.tsx +115 -0
- package/src/components/line-comment.tsx +439 -0
- package/src/components/markdown-cache.tsx +78 -0
- package/src/components/markdown-code-state.test.ts +32 -0
- package/src/components/markdown-code-state.ts +22 -0
- package/src/components/markdown-inline-code-kind.test.ts +46 -0
- package/src/components/markdown-inline-code-kind.ts +1915 -0
- package/src/components/markdown-preload.test.ts +18 -0
- package/src/components/markdown-shiki.worker.ts +104 -0
- package/src/components/markdown-stream.test.ts +194 -0
- package/src/components/markdown-stream.ts +110 -0
- package/src/components/markdown-worker-protocol.test.ts +81 -0
- package/src/components/markdown-worker-protocol.ts +48 -0
- package/src/components/markdown-worker-queue.test.ts +49 -0
- package/src/components/markdown-worker-queue.ts +64 -0
- package/src/components/markdown-worker-transport.test.ts +56 -0
- package/src/components/markdown-worker-transport.ts +41 -0
- package/src/components/markdown-worker.ts +122 -0
- package/src/components/markdown.css +377 -0
- package/src/components/markdown.stories.tsx +53 -0
- package/src/components/markdown.tsx +678 -0
- package/src/components/message-file.test.ts +63 -0
- package/src/components/message-file.ts +34 -0
- package/src/components/message-nav.css +127 -0
- package/src/components/message-nav.stories.tsx +7 -0
- package/src/components/message-nav.tsx +102 -0
- package/src/components/message-part-text.ts +3 -0
- package/src/components/message-part.css +1569 -0
- package/src/components/message-part.stories.tsx +7 -0
- package/src/components/message-part.test.ts +28 -0
- package/src/components/message-part.tsx +2662 -0
- package/src/components/session-diff.test.ts +135 -0
- package/src/components/session-diff.ts +145 -0
- package/src/components/session-retry.tsx +74 -0
- package/src/components/session-review.css +247 -0
- package/src/components/session-review.stories.tsx +7 -0
- package/src/components/session-review.tsx +657 -0
- package/src/components/session-turn.css +241 -0
- package/src/components/session-turn.stories.tsx +7 -0
- package/src/components/session-turn.tsx +543 -0
- package/src/components/shell-submessage-motion.stories.tsx +346 -0
- package/src/components/shell-submessage.css +23 -0
- package/src/components/timeline-playground.stories.tsx +2090 -0
- package/src/components/tool-count-label.css +57 -0
- package/src/components/tool-count-label.tsx +58 -0
- package/src/components/tool-count-summary.css +102 -0
- package/src/components/tool-count-summary.stories.tsx +238 -0
- package/src/components/tool-count-summary.tsx +52 -0
- package/src/components/tool-error-card.css +91 -0
- package/src/components/tool-error-card.stories.tsx +92 -0
- package/src/components/tool-error-card.tsx +157 -0
- package/src/components/tool-status-title.css +89 -0
- package/src/components/tool-status-title.tsx +133 -0
- package/src/context/data.tsx +64 -0
- package/src/context/index.ts +1 -0
- package/src/pierre/comment-hover.ts +83 -0
- package/src/pierre/commented-lines.ts +91 -0
- package/src/pierre/diff-selection.ts +71 -0
- package/src/pierre/file-find.ts +485 -0
- package/src/pierre/file-runtime.ts +114 -0
- package/src/pierre/file-selection.ts +85 -0
- package/src/pierre/index.ts +186 -0
- package/src/pierre/media.ts +110 -0
- package/src/pierre/selection-bridge.ts +132 -0
- package/src/pierre/virtualizer.ts +100 -0
- package/src/pierre/worker.ts +52 -0
- package/src/styles/index.css +14 -0
- package/src/v2/components/attachment-card-v2.css +70 -0
- package/src/v2/components/attachment-card-v2.tsx +33 -0
- package/src/v2/components/basic-tool-v2.css +163 -0
- package/src/v2/components/basic-tool-v2.stories.tsx +137 -0
- package/src/v2/components/basic-tool-v2.tsx +139 -0
- package/src/v2/components/comment-card-v2.tsx +64 -0
- package/src/v2/components/line-comment-annotations-v2.tsx +220 -0
- package/src/v2/components/prompt-input/attachments.ts +266 -0
- package/src/v2/components/prompt-input/index.tsx +706 -0
- package/src/v2/components/prompt-input/interaction.ts +482 -0
- package/src/v2/components/prompt-input/machine.test.ts +164 -0
- package/src/v2/components/prompt-input/machine.ts +261 -0
- package/src/v2/components/prompt-input/prompt-input.stories.tsx +221 -0
- package/src/v2/components/prompt-input/store.test.ts +116 -0
- package/src/v2/components/prompt-input/store.ts +152 -0
- package/src/v2/components/prompt-input/types.ts +106 -0
- package/src/v2/components/session-file-panel-v2.tsx +43 -0
- package/src/v2/components/session-progress-indicator-v2.css +875 -0
- package/src/v2/components/session-progress-indicator-v2.stories.tsx +66 -0
- package/src/v2/components/session-progress-indicator-v2.tsx +32 -0
- package/src/v2/components/session-review-empty-changes-v2.tsx +17 -0
- package/src/v2/components/session-review-empty-no-git-v2.tsx +28 -0
- package/src/v2/components/session-review-file-preview-v2-virtualize.test.ts +13 -0
- package/src/v2/components/session-review-file-preview-v2-virtualize.ts +5 -0
- package/src/v2/components/session-review-file-preview-v2.tsx +290 -0
- package/src/v2/components/session-review-v2.css +458 -0
- package/src/v2/components/session-review-v2.tsx +340 -0
- package/src/v2/components/tool-error-card-v2.css +200 -0
- package/src/v2/components/tool-error-card-v2.stories.tsx +91 -0
- package/src/v2/components/tool-error-card-v2.tsx +166 -0
- package/sst-env.d.ts +10 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test"
|
|
2
|
+
import type { FilePart } from "@neurocode-ai/sdk/v2"
|
|
3
|
+
import { attached, inline, kind, typeLabel } from "./message-file"
|
|
4
|
+
|
|
5
|
+
function file(part: Partial<FilePart> = {}): FilePart {
|
|
6
|
+
return {
|
|
7
|
+
id: "part_1",
|
|
8
|
+
sessionID: "ses_1",
|
|
9
|
+
messageID: "msg_1",
|
|
10
|
+
type: "file",
|
|
11
|
+
mime: "text/plain",
|
|
12
|
+
url: "file:///repo/README.txt",
|
|
13
|
+
filename: "README.txt",
|
|
14
|
+
...part,
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
describe("message-file", () => {
|
|
19
|
+
test("treats data URLs as attachments", () => {
|
|
20
|
+
expect(attached(file({ url: "data:text/plain;base64,SGVsbG8=" }))).toBe(true)
|
|
21
|
+
expect(attached(file())).toBe(false)
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
test("keeps data-backed file mentions inline", () => {
|
|
25
|
+
expect(
|
|
26
|
+
inline(
|
|
27
|
+
file({
|
|
28
|
+
source: {
|
|
29
|
+
type: "file",
|
|
30
|
+
path: "/repo/README.txt",
|
|
31
|
+
text: { value: "@README.txt", start: 0, end: 11 },
|
|
32
|
+
},
|
|
33
|
+
}),
|
|
34
|
+
),
|
|
35
|
+
).toBe(true)
|
|
36
|
+
|
|
37
|
+
const mentioned = file({
|
|
38
|
+
url: "data:text/plain;base64,SGVsbG8=",
|
|
39
|
+
source: {
|
|
40
|
+
type: "file",
|
|
41
|
+
path: "/repo/README.txt",
|
|
42
|
+
text: { value: "@README.txt", start: 0, end: 11 },
|
|
43
|
+
},
|
|
44
|
+
})
|
|
45
|
+
expect(inline(mentioned)).toBe(true)
|
|
46
|
+
expect(attached(mentioned)).toBe(false)
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
test("separates image and file attachment kinds", () => {
|
|
50
|
+
expect(kind(file({ mime: "image/png" }))).toBe("image")
|
|
51
|
+
expect(kind(file({ mime: "application/pdf" }))).toBe("file")
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
test("labels attachment types from the basename extension", () => {
|
|
55
|
+
expect(typeLabel("list.md", "text/plain")).toBe("Markdown")
|
|
56
|
+
expect(typeLabel("/repo/src/main.ts", "text/plain")).toBe("TypeScript")
|
|
57
|
+
expect(typeLabel("/tmp/report.pdf", "application/pdf")).toBe("PDF")
|
|
58
|
+
expect(typeLabel("notes.xyz", "text/plain")).toBe("XYZ")
|
|
59
|
+
expect(typeLabel("/home/user/my.project/Makefile", "text/plain")).toBe("File")
|
|
60
|
+
expect(typeLabel(".gitignore", "text/plain")).toBe("File")
|
|
61
|
+
expect(typeLabel("/repo/.env", "text/plain")).toBe("File")
|
|
62
|
+
})
|
|
63
|
+
})
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { bundledLanguagesInfo } from "shiki"
|
|
2
|
+
import { getFilename } from "@neurocode-ai/core/util/path"
|
|
3
|
+
import type { FilePart } from "@neurocode-ai/sdk/v2"
|
|
4
|
+
|
|
5
|
+
export function attached(part: FilePart) {
|
|
6
|
+
return part.url.startsWith("data:") && !inline(part)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function inline(part: FilePart) {
|
|
10
|
+
return part.source?.text?.start !== undefined && part.source?.text?.end !== undefined
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function kind(part: FilePart) {
|
|
14
|
+
return part.mime.startsWith("image/") ? "image" : "file"
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// language metadata only; grammars stay behind shiki's lazy imports
|
|
18
|
+
const LANGUAGE_NAMES = new Map<string, string>(
|
|
19
|
+
bundledLanguagesInfo.flatMap((info) =>
|
|
20
|
+
[info.id, ...(info.aliases ?? [])].map((alias) => [alias, info.name] as [string, string]),
|
|
21
|
+
),
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
// attachments carry text/plain for all text files, so the label comes from the extension;
|
|
25
|
+
// filename may be an absolute path, so extract the basename before looking for one
|
|
26
|
+
export function typeLabel(filename: string, mime: string) {
|
|
27
|
+
if (mime === "application/pdf") return "PDF"
|
|
28
|
+
const base = getFilename(filename)
|
|
29
|
+
// idx 0 is a dotfile like .gitignore, not an extension
|
|
30
|
+
const idx = base.lastIndexOf(".")
|
|
31
|
+
const suffix = idx <= 0 ? "" : base.slice(idx + 1).toLowerCase()
|
|
32
|
+
if (!suffix) return "File"
|
|
33
|
+
return LANGUAGE_NAMES.get(suffix) ?? suffix.toUpperCase()
|
|
34
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
[data-component="message-nav"] {
|
|
2
|
+
flex-shrink: 0;
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
align-items: flex-start;
|
|
6
|
+
padding-left: 0;
|
|
7
|
+
list-style: none;
|
|
8
|
+
|
|
9
|
+
&[data-size="normal"] {
|
|
10
|
+
width: 200px;
|
|
11
|
+
gap: 4px;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
&[data-size="compact"] {
|
|
15
|
+
width: 24px;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
[data-slot="message-nav-item"] {
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
align-self: stretch;
|
|
23
|
+
justify-content: flex-end;
|
|
24
|
+
|
|
25
|
+
[data-component="message-nav"][data-size="normal"] & {
|
|
26
|
+
justify-content: flex-start;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
[data-slot="message-nav-tick-button"] {
|
|
31
|
+
display: flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
justify-content: flex-start;
|
|
34
|
+
height: 12px;
|
|
35
|
+
width: 24px;
|
|
36
|
+
border: none;
|
|
37
|
+
background: none;
|
|
38
|
+
padding: 0;
|
|
39
|
+
|
|
40
|
+
&[data-active] [data-slot="message-nav-tick-line"] {
|
|
41
|
+
background-color: var(--icon-strong-base);
|
|
42
|
+
height: 2px;
|
|
43
|
+
width: 100%;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
[data-slot="message-nav-tick-line"] {
|
|
48
|
+
height: 1px;
|
|
49
|
+
width: 16px;
|
|
50
|
+
background-color: var(--icon-base);
|
|
51
|
+
transition:
|
|
52
|
+
width 0.2s,
|
|
53
|
+
background-color 0.2s;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
[data-slot="message-nav-tick-button"]:hover [data-slot="message-nav-tick-line"] {
|
|
57
|
+
width: 100%;
|
|
58
|
+
background-color: var(--icon-strong-base);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
[data-slot="message-nav-message-button"] {
|
|
62
|
+
display: flex;
|
|
63
|
+
align-items: center;
|
|
64
|
+
align-self: stretch;
|
|
65
|
+
width: 100%;
|
|
66
|
+
column-gap: 10px;
|
|
67
|
+
cursor: default;
|
|
68
|
+
border: none;
|
|
69
|
+
background: none;
|
|
70
|
+
padding: 4px 10px;
|
|
71
|
+
border-radius: var(--radius-sm);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
[data-slot="message-nav-title-preview"] {
|
|
75
|
+
font-size: 14px; /* text-14-regular */
|
|
76
|
+
color: var(--text-base);
|
|
77
|
+
white-space: nowrap;
|
|
78
|
+
overflow: hidden;
|
|
79
|
+
text-overflow: ellipsis;
|
|
80
|
+
min-width: 0;
|
|
81
|
+
text-align: left;
|
|
82
|
+
|
|
83
|
+
&[data-active] {
|
|
84
|
+
color: var(--text-strong);
|
|
85
|
+
font-weight: 500;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
[data-slot="message-nav-item"]:has([data-slot="message-nav-title-preview"][data-active])
|
|
90
|
+
[data-slot="message-nav-message-button"] {
|
|
91
|
+
background-color: var(--surface-base-active);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
[data-slot="message-nav-item"]:hover [data-slot="message-nav-message-button"] {
|
|
95
|
+
background-color: var(--surface-base);
|
|
96
|
+
}
|
|
97
|
+
[data-slot="message-nav-item"]:active [data-slot="message-nav-message-button"] {
|
|
98
|
+
background-color: var(--surface-base-active);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
[data-slot="message-nav-item"]:active [data-slot="message-nav-title-preview"] {
|
|
102
|
+
color: var(--text-base);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
[data-slot="message-nav-hovercard-content"] {
|
|
106
|
+
z-index: 1000;
|
|
107
|
+
display: flex;
|
|
108
|
+
padding: 4px 4px 6px 4px;
|
|
109
|
+
justify-content: center;
|
|
110
|
+
align-items: start;
|
|
111
|
+
border-radius: var(--radius-md);
|
|
112
|
+
background: var(--surface-raised-stronger-non-alpha);
|
|
113
|
+
max-height: min(480px, calc(100vh - 6rem));
|
|
114
|
+
overflow-y: auto;
|
|
115
|
+
overflow-x: hidden;
|
|
116
|
+
|
|
117
|
+
/* border/shadow-xs/base */
|
|
118
|
+
box-shadow:
|
|
119
|
+
0 0 0 1px var(--border-weak-base, rgba(17, 0, 0, 0.12)),
|
|
120
|
+
0 1px 2px -1px rgba(19, 16, 16, 0.04),
|
|
121
|
+
0 1px 2px 0 rgba(19, 16, 16, 0.06),
|
|
122
|
+
0 1px 3px 0 rgba(19, 16, 16, 0.08);
|
|
123
|
+
|
|
124
|
+
* {
|
|
125
|
+
margin: 0 !important;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import * as mod from "./message-nav"
|
|
3
|
+
import { create } from "@neurocode-ai/ui/storybook/scaffold"
|
|
4
|
+
|
|
5
|
+
const story = create({ title: "UI/MessageNav", mod })
|
|
6
|
+
export default { title: "UI/MessageNav", id: "components-message-nav", component: story.meta.component }
|
|
7
|
+
export const Basic = story.Basic
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { UserMessage } from "@neurocode-ai/sdk/v2"
|
|
2
|
+
import { HoverCard } from "@kobalte/core/hover-card"
|
|
3
|
+
import { ComponentProps, For, Match, Show, createSignal, splitProps, Switch } from "solid-js"
|
|
4
|
+
import { DiffChanges } from "@neurocode-ai/ui/diff-changes"
|
|
5
|
+
import { useI18n } from "@neurocode-ai/ui/context/i18n"
|
|
6
|
+
|
|
7
|
+
export function MessageNav(
|
|
8
|
+
props: ComponentProps<"ul"> & {
|
|
9
|
+
messages: UserMessage[]
|
|
10
|
+
current?: UserMessage
|
|
11
|
+
size: "normal" | "compact"
|
|
12
|
+
onMessageSelect: (message: UserMessage) => void
|
|
13
|
+
getLabel?: (message: UserMessage) => string | undefined
|
|
14
|
+
},
|
|
15
|
+
) {
|
|
16
|
+
const i18n = useI18n()
|
|
17
|
+
const [local, others] = splitProps(props, ["messages", "current", "size", "onMessageSelect", "getLabel", "class"])
|
|
18
|
+
const [hovercardOpen, setHovercardOpen] = createSignal(false)
|
|
19
|
+
|
|
20
|
+
const selectMessage = (message: UserMessage) => {
|
|
21
|
+
setHovercardOpen(false)
|
|
22
|
+
local.onMessageSelect(message)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const content = (className?: string) => (
|
|
26
|
+
<ul role="list" data-component="message-nav" data-size={local.size} class={className} {...others}>
|
|
27
|
+
<For each={local.messages}>
|
|
28
|
+
{(message) => {
|
|
29
|
+
const handleClick = () => selectMessage(message)
|
|
30
|
+
|
|
31
|
+
const handleKeyPress = (event: KeyboardEvent) => {
|
|
32
|
+
if (event.key !== "Enter" && event.key !== " ") return
|
|
33
|
+
event.preventDefault()
|
|
34
|
+
selectMessage(message)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<li data-slot="message-nav-item">
|
|
39
|
+
<Switch>
|
|
40
|
+
<Match when={local.size === "compact"}>
|
|
41
|
+
<div
|
|
42
|
+
data-slot="message-nav-tick-button"
|
|
43
|
+
data-active={message.id === local.current?.id || undefined}
|
|
44
|
+
role="button"
|
|
45
|
+
tabindex={0}
|
|
46
|
+
onClick={handleClick}
|
|
47
|
+
onKeyDown={handleKeyPress}
|
|
48
|
+
>
|
|
49
|
+
<div data-slot="message-nav-tick-line" />
|
|
50
|
+
</div>
|
|
51
|
+
</Match>
|
|
52
|
+
<Match when={local.size === "normal"}>
|
|
53
|
+
<button data-slot="message-nav-message-button" onClick={handleClick} onKeyDown={handleKeyPress}>
|
|
54
|
+
<DiffChanges changes={message.summary?.diffs ?? []} variant="bars" />
|
|
55
|
+
<div
|
|
56
|
+
data-slot="message-nav-title-preview"
|
|
57
|
+
data-active={message.id === local.current?.id || undefined}
|
|
58
|
+
>
|
|
59
|
+
<Show
|
|
60
|
+
when={local.getLabel?.(message) ?? message.summary?.title}
|
|
61
|
+
fallback={i18n.t("ui.messageNav.newMessage")}
|
|
62
|
+
>
|
|
63
|
+
{local.getLabel?.(message) ?? message.summary?.title}
|
|
64
|
+
</Show>
|
|
65
|
+
</div>
|
|
66
|
+
</button>
|
|
67
|
+
</Match>
|
|
68
|
+
</Switch>
|
|
69
|
+
</li>
|
|
70
|
+
)
|
|
71
|
+
}}
|
|
72
|
+
</For>
|
|
73
|
+
</ul>
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<Switch>
|
|
78
|
+
<Match when={local.size === "compact"}>
|
|
79
|
+
<HoverCard
|
|
80
|
+
open={hovercardOpen()}
|
|
81
|
+
onOpenChange={setHovercardOpen}
|
|
82
|
+
openDelay={0}
|
|
83
|
+
closeDelay={120}
|
|
84
|
+
placement="right-start"
|
|
85
|
+
gutter={8}
|
|
86
|
+
overflowPadding={24}
|
|
87
|
+
fitViewport
|
|
88
|
+
>
|
|
89
|
+
<HoverCard.Trigger as="div" data-component="message-nav-hovercard" class={local.class}>
|
|
90
|
+
{content()}
|
|
91
|
+
</HoverCard.Trigger>
|
|
92
|
+
<HoverCard.Portal>
|
|
93
|
+
<HoverCard.Content data-slot="message-nav-hovercard-content">
|
|
94
|
+
<MessageNav {...props} size="normal" class="" onMessageSelect={selectMessage} />
|
|
95
|
+
</HoverCard.Content>
|
|
96
|
+
</HoverCard.Portal>
|
|
97
|
+
</HoverCard>
|
|
98
|
+
</Match>
|
|
99
|
+
<Match when={local.size === "normal"}>{content(local.class)}</Match>
|
|
100
|
+
</Switch>
|
|
101
|
+
)
|
|
102
|
+
}
|