@zyro-sec/session-ui 0.0.0-stage → 1.0.4
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 +25 -0
- package/bunfig.toml +2 -0
- package/component-tests/basic-tool.fixture.tsx +46 -0
- package/component-tests/basic-tool.spec.ts +63 -0
- package/component-tests/file-media.fixture.tsx +39 -0
- package/component-tests/file-media.spec.ts +13 -0
- package/component-tests/file-tool.spec.ts +62 -0
- package/component-tests/file-viewer.fixture.tsx +109 -0
- package/component-tests/file-viewer.spec.ts +134 -0
- package/component-tests/file.spec.ts +33 -0
- package/component-tests/line-comment-v2.spec.ts +15 -0
- package/component-tests/markdown-code-wrap.spec.ts +94 -0
- package/component-tests/markdown-readiness.spec.ts +95 -0
- package/component-tests/markdown.fixture.tsx +104 -0
- package/component-tests/markdown.spec.ts +1564 -0
- package/component-tests/mermaid-preview.spec.ts +43 -0
- package/component-tests/patch-group.spec.ts +79 -0
- package/component-tests/read-group.spec.ts +72 -0
- package/component-tests/read-image.fixture.tsx +66 -0
- package/component-tests/read-image.spec.ts +154 -0
- package/component-tests/session-compaction.spec.ts +254 -0
- package/component-tests/session-lifecycle.spec.ts +190 -0
- package/component-tests/session-message-projection.spec.ts +639 -0
- package/component-tests/session-notice-projection.spec.ts +20 -0
- package/component-tests/session-review-comments.spec.ts +179 -0
- package/component-tests/session-shell.spec.ts +93 -0
- package/component-tests/session-timeline-mobile.spec.ts +201 -0
- package/component-tests/session-timeline-notices.spec.ts +38 -0
- package/component-tests/session-timeline-reasoning.spec.ts +107 -0
- package/component-tests/session-timeline.spec.ts +157 -0
- package/component-tests/session-tool-projection.spec.ts +323 -0
- package/component-tests/text-lifecycle.fixture.tsx +26 -0
- package/component-tests/text-lifecycle.spec.ts +42 -0
- package/component-tests/timeline-subagent-rows.spec.ts +33 -0
- package/component-tests/tool-disclosure.spec.ts +48 -0
- package/component-tests/tool-group-sticky.spec.ts +37 -0
- package/component-tests/tool-group.spec.ts +290 -0
- package/component-tests/tool-status-title.fixture.tsx +22 -0
- package/component-tests/tool-status-title.spec.ts +30 -0
- package/component-tests/user-message-quotes.spec.ts +111 -0
- package/package.json +91 -4
- package/playwright.components.config.ts +4 -0
- package/playwright.local.config.ts +2 -0
- package/src/actions.ts +54 -0
- package/src/components/apply-patch-file.ts +122 -0
- package/src/components/basic-tool.css +487 -0
- package/src/components/basic-tool.tsx +258 -0
- package/src/components/copy-machine.ts +78 -0
- package/src/components/copy.ts +85 -0
- package/src/components/diagram-preview.tsx +28 -0
- package/src/components/disclosure-machine.ts +188 -0
- package/src/components/disclosure.ts +129 -0
- package/src/components/dock-prompt.stories.tsx +73 -0
- package/src/components/dock-prompt.tsx +29 -0
- package/src/components/file-comment-selection.tsx +146 -0
- package/src/components/file-media-machine.ts +165 -0
- package/src/components/file-media.stories.tsx +112 -0
- package/src/components/file-media.tsx +323 -0
- package/src/components/file-search.tsx +73 -0
- package/src/components/file.css +59 -0
- package/src/components/file.tsx +1300 -0
- package/src/components/image-preview.tsx +35 -0
- package/src/components/line-comment-annotations.tsx +580 -0
- package/src/components/line-comment-machine.ts +262 -0
- package/src/components/line-comment-styles.ts +293 -0
- package/src/components/line-comment.stories.tsx +152 -0
- package/src/components/line-comment.tsx +448 -0
- package/src/components/link-segments.ts +20 -0
- package/src/components/linked-text.tsx +21 -0
- package/src/components/markdown-cache-machine.ts +257 -0
- package/src/components/markdown-cache.tsx +556 -0
- package/src/components/markdown-clipboard.ts +101 -0
- package/src/components/markdown-code-machine.ts +200 -0
- package/src/components/markdown-code-state.ts +22 -0
- package/src/components/markdown-fragment-links.ts +74 -0
- package/src/components/markdown-github.svg +3 -0
- package/src/components/markdown-globe.svg +5 -0
- package/src/components/markdown-image-machine.ts +170 -0
- package/src/components/markdown-image.ts +156 -0
- package/src/components/markdown-inline-code-kind.ts +39 -0
- package/src/components/markdown-mermaid.ts +18 -0
- package/src/components/markdown-phase-machine.ts +102 -0
- package/src/components/markdown-projection.ts +13 -0
- package/src/components/markdown-session-links.ts +183 -0
- package/src/components/markdown-solid.test.tsx +92 -0
- package/src/components/markdown-solid.tsx +113 -0
- package/src/components/markdown-stream.ts +95 -0
- package/src/components/markdown-worker-machine.ts +516 -0
- package/src/components/markdown-worker-protocol.ts +73 -0
- package/src/components/markdown-worker.ts +250 -0
- package/src/components/markdown.css +672 -0
- package/src/components/markdown.stories.tsx +199 -0
- package/src/components/markdown.tsx +1612 -0
- package/src/components/markdown.worker.ts +188 -0
- package/src/components/message-file.ts +102 -0
- package/src/components/message-nav.css +134 -0
- package/src/components/message-nav.tsx +159 -0
- package/src/components/message-part.css +2109 -0
- package/src/components/message-part.tsx +3 -0
- package/src/components/question-prompt-experimental.css +576 -0
- package/src/components/question-prompt.css +527 -0
- package/src/components/quote-highlight.css +59 -0
- package/src/components/review-focus-driver.ts +142 -0
- package/src/components/review-focus-machine.ts +95 -0
- package/src/components/session-compaction.css +270 -0
- package/src/components/session-diff.ts +358 -0
- package/src/components/session-error.tsx +41 -0
- package/src/components/session-retry.tsx +92 -0
- package/src/components/session-review-machine.ts +241 -0
- package/src/components/session-review.css +264 -0
- package/src/components/session-review.stories.tsx +232 -0
- package/src/components/session-review.tsx +733 -0
- package/src/components/session-turn.css +282 -0
- package/src/components/shell-submessage.css +24 -0
- package/src/components/timeline-separator.tsx +69 -0
- package/src/components/tool-count-label.css +57 -0
- package/src/components/tool-count-label.tsx +76 -0
- package/src/components/tool-count-summary.css +102 -0
- package/src/components/tool-count-summary.stories.tsx +99 -0
- package/src/components/tool-count-summary.tsx +44 -0
- package/src/components/tool-error-card.css +178 -0
- package/src/components/tool-error-card.stories.tsx +113 -0
- package/src/components/tool-error-card.tsx +202 -0
- package/src/components/tool-status-title-machine.ts +128 -0
- package/src/components/tool-status-title.css +89 -0
- package/src/components/tool-status-title.tsx +163 -0
- package/src/context/data.tsx +107 -0
- package/src/context/index.ts +1 -0
- package/src/context/markdown.tsx +129 -0
- package/src/context/sources.tsx +34 -0
- package/src/document.ts +8 -0
- package/src/file-presentation.ts +34 -0
- package/src/message/action-machine.ts +72 -0
- package/src/message/agent-label.ts +3 -0
- package/src/message/attachment-card.css +119 -0
- package/src/message/attachment-card.tsx +40 -0
- package/src/message/attachment-media-machine.ts +213 -0
- package/src/message/comment-card.tsx +155 -0
- package/src/message/compaction-entrance-machine.ts +93 -0
- package/src/message/current-message.tsx +157 -0
- package/src/message/current-tool-state.ts +161 -0
- package/src/message/message-content.tsx +1391 -0
- package/src/message/paced-text-machine.ts +73 -0
- package/src/message/prompt-message.stories.tsx +149 -0
- package/src/message/relative-time.ts +45 -0
- package/src/message/user-message-quote-parts.ts +16 -0
- package/src/message/user-message-quotes.stories.tsx +797 -0
- package/src/message/user-message-quotes.tsx +135 -0
- package/src/pierre/comment-hover-machine.ts +53 -0
- package/src/pierre/comment-hover.ts +131 -0
- package/src/pierre/comment-selection-machine.ts +257 -0
- package/src/pierre/commented-lines.ts +106 -0
- package/src/pierre/diff-selection.ts +91 -0
- package/src/pierre/file-find-machine.ts +323 -0
- package/src/pierre/file-find.ts +537 -0
- package/src/pierre/file-runtime.ts +42 -0
- package/src/pierre/file-selection.ts +140 -0
- package/src/pierre/index.ts +344 -0
- package/src/pierre/media.ts +140 -0
- package/src/pierre/render-machine.ts +381 -0
- package/src/pierre/selection-bridge.ts +82 -0
- package/src/pierre/selection-machine.ts +198 -0
- package/src/pierre/virtualizer.ts +114 -0
- package/src/pierre/worker.ts +46 -0
- package/src/sources/experiment.ts +59 -0
- package/src/sources/site-icon.tsx +53 -0
- package/src/sources/sources-chip.tsx +57 -0
- package/src/sources/sources-expand-machine.ts +101 -0
- package/src/sources/sources-panel.tsx +249 -0
- package/src/sources/sources-title.tsx +21 -0
- package/src/sources/sources.css +266 -0
- package/src/sources/sources.ts +141 -0
- package/src/storybook/current-session-fixtures.ts +1492 -0
- package/src/storybook/current-session-scenarios.ts +76 -0
- package/src/storybook/current-session-story.tsx +154 -0
- package/src/storybook/index.ts +43 -0
- package/src/styles/index.css +19 -0
- package/src/timeline/__snapshots__/group-labels.test.ts.snap +110 -0
- package/src/timeline/__snapshots__/placement.test.ts.snap +1041 -0
- package/src/timeline/code-blocks.stories.tsx +105 -0
- package/src/timeline/commentary.stories.tsx +70 -0
- package/src/timeline/commentary.ts +38 -0
- package/src/timeline/detail.ts +111 -0
- package/src/timeline/error-card.stories.tsx +134 -0
- package/src/timeline/error-spacing.stories.tsx +71 -0
- package/src/timeline/facts.ts +493 -0
- package/src/timeline/file-changes.stories.tsx +436 -0
- package/src/timeline/group-label-fixtures.ts +97 -0
- package/src/timeline/mermaid.stories.tsx +131 -0
- package/src/timeline/place.ts +280 -0
- package/src/timeline/placement-fixtures.ts +365 -0
- package/src/timeline/placement-reactivity.ts +133 -0
- package/src/timeline/projection.ts +1261 -0
- package/src/timeline/research-and-agents.stories.tsx +461 -0
- package/src/timeline/session-timeline-row.tsx +1675 -0
- package/src/timeline/session-timeline.tsx +68 -0
- package/src/timeline/steer-arrival-machine.ts +134 -0
- package/src/timeline/terminal-work.stories.tsx +464 -0
- package/src/timeline/timeline-row.stories.tsx +1069 -0
- package/src/timeline/timeline-row.ts +238 -0
- package/src/timeline/turn-phase-machine.ts +112 -0
- package/src/timeline/user-message-fold.stories.tsx +194 -0
- package/src/timeline/user-runs.ts +87 -0
- package/src/timeline-next/__snapshots__/placement.test.ts.snap +990 -0
- package/src/timeline-next/compaction.tsx +236 -0
- package/src/timeline-next/errors.ts +101 -0
- package/src/timeline-next/event-row.tsx +168 -0
- package/src/timeline-next/events.ts +103 -0
- package/src/timeline-next/index.ts +10 -0
- package/src/timeline-next/nested-rail.ts +125 -0
- package/src/timeline-next/projection.ts +1028 -0
- package/src/timeline-next/row.tsx +1728 -0
- package/src/timeline-next/rules.ts +89 -0
- package/src/timeline-next/separator.tsx +73 -0
- package/src/timeline-next/spacing.ts +127 -0
- package/src/timeline-next/status-line.tsx +41 -0
- package/src/timeline-next/status.ts +33 -0
- package/src/timeline-next/stories/compare-renderer.stories.tsx +190 -0
- package/src/timeline-next/stories/compare-sessions/.gitignore +3 -0
- package/src/timeline-next/stories/compare.stories.tsx +486 -0
- package/src/timeline-next/stories/playground.stories.tsx +297 -0
- package/src/timeline-next/stories/session-replay.ts +1156 -0
- package/src/timeline-next/stories/session-timeline.tsx +50 -0
- package/src/timeline-next/stories/subagent-status.stories.tsx +132 -0
- package/src/timeline-next/timeline-next.css +649 -0
- package/src/timeline-next/tools/__snapshots__/activity-label.test.ts.snap +39 -0
- package/src/timeline-next/tools/activity-label.ts +166 -0
- package/src/timeline-next/tools/assistant-content.tsx +84 -0
- package/src/timeline-next/tools/context-group.tsx +619 -0
- package/src/timeline-next/tools/error-card.tsx +147 -0
- package/src/timeline-next/tools/explore.tsx +119 -0
- package/src/timeline-next/tools/file-group.tsx +128 -0
- package/src/timeline-next/tools/patch.tsx +174 -0
- package/src/timeline-next/tools/shell.tsx +186 -0
- package/src/timeline-next/tools/thought.tsx +87 -0
- package/src/timeline-next/tools/tool-display.tsx +119 -0
- package/src/tools/ansi.ts +8 -0
- package/src/tools/context-group-label.ts +123 -0
- package/src/tools/file-runs.ts +35 -0
- package/src/tools/project-path.ts +18 -0
- package/src/tools/read-group.stories.tsx +159 -0
- package/src/tools/run-machine.ts +185 -0
- package/src/tools/shell-output-machine.ts +233 -0
- package/src/tools/shell-output.ts +91 -0
- package/src/tools/subagent-row-variants.stories.tsx +129 -0
- package/src/tools/tool-group.stories.tsx +345 -0
- package/src/tools/tool-renderer.tsx +2876 -0
- package/src/v2/components/line-comment-annotations-v2.tsx +215 -0
- package/src/v2/components/session-file-panel-v2.tsx +149 -0
- package/src/v2/components/session-progress-indicator-v2.css +5 -0
- package/src/v2/components/session-progress-indicator-v2.stories.tsx +86 -0
- package/src/v2/components/session-progress-indicator-v2.tsx +16 -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.ts +5 -0
- package/src/v2/components/session-review-file-preview-v2.tsx +266 -0
- package/src/v2/components/session-review-v2.css +653 -0
- package/src/v2/components/session-review-v2.tsx +422 -0
- package/src/v2/components/sidebar-presence-machine.ts +69 -0
- package/tsconfig.json +20 -0
- package/README.md +0 -3
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export const TEXT_RENDER_PACE_MS = 24
|
|
2
|
+
|
|
3
|
+
/** A live backlog up to this many characters shows at once; a larger one reveals in paced slices. */
|
|
4
|
+
export const TEXT_RENDER_IMMEDIATE = 512
|
|
5
|
+
|
|
6
|
+
const TEXT_RENDER_SNAP = /[\s.,!?;:)\]]/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Streamed text reveal. `synced` shows the latest text. `pacing` shows a prefix of `target` that is more than
|
|
10
|
+
* `TEXT_RENDER_IMMEDIATE` characters behind it and waits one `TEXT_RENDER_PACE_MS` step, numbered `attempt`.
|
|
11
|
+
* This runs on every streamed delta, so an event that changes nothing returns the same state.
|
|
12
|
+
*/
|
|
13
|
+
export type PacedTextState =
|
|
14
|
+
| { readonly status: "synced"; readonly shown: string; readonly attempts: number }
|
|
15
|
+
| { readonly status: "pacing"; readonly shown: string; readonly target: string; readonly attempt: number }
|
|
16
|
+
| { readonly status: "disposed" }
|
|
17
|
+
|
|
18
|
+
export type PacedTextEvent =
|
|
19
|
+
| { readonly type: "sync"; readonly text: string; readonly live: boolean }
|
|
20
|
+
| { readonly type: "tick"; readonly attempt: number }
|
|
21
|
+
| { readonly type: "disposed" }
|
|
22
|
+
|
|
23
|
+
export const DISPOSED_PACED_TEXT_STATE: PacedTextState = Object.freeze({ status: "disposed" })
|
|
24
|
+
|
|
25
|
+
export const DISPOSED_PACED_TEXT_EVENT: PacedTextEvent = Object.freeze({ type: "disposed" })
|
|
26
|
+
|
|
27
|
+
export function createPacedTextState(text: string): PacedTextState {
|
|
28
|
+
return { status: "synced", shown: text, attempts: 0 }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function transitionPacedText(state: PacedTextState, event: PacedTextEvent): PacedTextState {
|
|
32
|
+
if (state.status === "disposed") return state
|
|
33
|
+
|
|
34
|
+
if (event.type === "disposed") return DISPOSED_PACED_TEXT_STATE
|
|
35
|
+
|
|
36
|
+
if (event.type === "tick") {
|
|
37
|
+
if (state.status !== "pacing" || event.attempt !== state.attempt) return state
|
|
38
|
+
|
|
39
|
+
if (state.target.length - state.shown.length <= TEXT_RENDER_IMMEDIATE)
|
|
40
|
+
return { status: "synced", shown: state.target, attempts: state.attempt }
|
|
41
|
+
const end = nextSliceEnd(state.target, state.shown.length)
|
|
42
|
+
|
|
43
|
+
if (end >= state.target.length) return { status: "synced", shown: state.target, attempts: state.attempt }
|
|
44
|
+
|
|
45
|
+
return { status: "pacing", shown: state.target.slice(0, end), target: state.target, attempt: state.attempt + 1 }
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const text = event.text
|
|
49
|
+
|
|
50
|
+
if (state.status === "synced" && text === state.shown) return state
|
|
51
|
+
|
|
52
|
+
if (state.status === "pacing" && event.live && text === state.target) return state
|
|
53
|
+
|
|
54
|
+
// The length check runs first, so an ordinary delta never scans the whole response for its prefix.
|
|
55
|
+
if (!event.live || text.length - state.shown.length <= TEXT_RENDER_IMMEDIATE || !text.startsWith(state.shown))
|
|
56
|
+
return { status: "synced", shown: text, attempts: state.status === "pacing" ? state.attempt : state.attempts }
|
|
57
|
+
|
|
58
|
+
// A delta during a step keeps its attempt, so a steady stream cannot postpone the next slice.
|
|
59
|
+
if (state.status === "pacing") return { status: "pacing", shown: state.shown, target: text, attempt: state.attempt }
|
|
60
|
+
|
|
61
|
+
return { status: "pacing", shown: state.shown, target: text, attempt: state.attempts + 1 }
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function nextSliceEnd(text: string, start: number) {
|
|
65
|
+
const end = Math.min(text.length, start + Math.min(256, Math.ceil((text.length - start) / 4)))
|
|
66
|
+
const max = Math.min(text.length, end + 8)
|
|
67
|
+
|
|
68
|
+
for (let i = end; i < max; i++) {
|
|
69
|
+
if (TEXT_RENDER_SNAP.test(text[i]!)) return i + 1
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return end
|
|
73
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { createEffect, createMemo, For, Show } from "solid-js"
|
|
2
|
+
import { createStore } from "solid-js/store"
|
|
3
|
+
import type { SessionMessageUser } from "@zyro-sec/client/promise"
|
|
4
|
+
import type { SessionUserActions } from "../actions"
|
|
5
|
+
import { CurrentUserMessageDisplay } from "./message-content"
|
|
6
|
+
import { CurrentSessionProviders } from "../storybook/current-session-story"
|
|
7
|
+
import { CURRENT_SESSION_ID, STORY_MODEL, STORY_TIME } from "../storybook/current-session-fixtures"
|
|
8
|
+
|
|
9
|
+
const statuses = ["delivered", "starting", "steering", "stranded", "queued", "sending"] as const
|
|
10
|
+
|
|
11
|
+
type Args = { status: (typeof statuses)[number]; voice: boolean; text: boolean; grouped: boolean; fails: boolean }
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
title: "OpenCode/Conversation/Prompt message",
|
|
15
|
+
id: "current-prompt-message",
|
|
16
|
+
parameters: { layout: "fullscreen" },
|
|
17
|
+
args: { status: "steering", voice: false, text: true, grouped: false, fails: false } satisfies Args,
|
|
18
|
+
argTypes: { status: { options: statuses } },
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const Pending = {
|
|
22
|
+
render: (args: Args) => {
|
|
23
|
+
const [state, setState] = createStore({ ...args, failures: 0 })
|
|
24
|
+
|
|
25
|
+
// Frame controls and host callbacks can still change the fixture after a panel edit.
|
|
26
|
+
for (const key of ["status", "voice", "text", "grouped", "fails"] as const) {
|
|
27
|
+
createEffect(() => setState({ [key]: args[key] }))
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// A failing host rejects, like a server error, and leaves the message as it was.
|
|
31
|
+
const attempt = async (apply: () => void) => {
|
|
32
|
+
if (!state.fails) return apply()
|
|
33
|
+
setState("failures", (count) => count + 1)
|
|
34
|
+
throw new Error("Request failed")
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const message = createMemo<SessionMessageUser>(() => ({
|
|
38
|
+
id: "msg_pending_prompt_story",
|
|
39
|
+
type: "user",
|
|
40
|
+
text: state.text ? "Keep the prompt styling consistent with the rest of the timeline." : "",
|
|
41
|
+
time: { created: STORY_TIME },
|
|
42
|
+
files: state.text
|
|
43
|
+
? []
|
|
44
|
+
: [{ name: "notes.json", mime: "application/json", data: "e30=", source: { type: "inline" } }],
|
|
45
|
+
}))
|
|
46
|
+
|
|
47
|
+
const document = createMemo(() => ({
|
|
48
|
+
sessionID: CURRENT_SESSION_ID,
|
|
49
|
+
messages: [message()],
|
|
50
|
+
status: { type: "idle" as const },
|
|
51
|
+
diffs: [],
|
|
52
|
+
}))
|
|
53
|
+
|
|
54
|
+
const actions = {
|
|
55
|
+
revert: () => attempt(() => {}),
|
|
56
|
+
fork: () => attempt(() => {}),
|
|
57
|
+
pending: {
|
|
58
|
+
status: () => (state.status === "delivered" ? undefined : state.status),
|
|
59
|
+
queue: () => attempt(() => setState("status", "queued")),
|
|
60
|
+
remove: () => attempt(() => setState("status", "delivered")),
|
|
61
|
+
},
|
|
62
|
+
} satisfies SessionUserActions
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<section class="mx-auto flex w-full max-w-[840px] flex-col gap-8 p-6">
|
|
66
|
+
<div class="flex flex-wrap items-center gap-4">
|
|
67
|
+
<label>
|
|
68
|
+
Delivery state{" "}
|
|
69
|
+
<select
|
|
70
|
+
aria-label="Delivery state"
|
|
71
|
+
value={state.status}
|
|
72
|
+
onChange={(event) => {
|
|
73
|
+
const status = statuses.find((status) => status === event.currentTarget.value)
|
|
74
|
+
|
|
75
|
+
if (status) setState("status", status)
|
|
76
|
+
}}
|
|
77
|
+
>
|
|
78
|
+
<For each={statuses}>
|
|
79
|
+
{(status) => <option value={status}>{status[0].toUpperCase() + status.slice(1)}</option>}
|
|
80
|
+
</For>
|
|
81
|
+
</select>
|
|
82
|
+
</label>
|
|
83
|
+
<label>
|
|
84
|
+
<input
|
|
85
|
+
type="checkbox"
|
|
86
|
+
checked={state.voice}
|
|
87
|
+
onChange={(event) => setState("voice", event.currentTarget.checked)}
|
|
88
|
+
/>{" "}
|
|
89
|
+
Voice message
|
|
90
|
+
</label>
|
|
91
|
+
<label>
|
|
92
|
+
<input
|
|
93
|
+
type="checkbox"
|
|
94
|
+
checked={state.text}
|
|
95
|
+
onChange={(event) => setState("text", event.currentTarget.checked)}
|
|
96
|
+
/>{" "}
|
|
97
|
+
Prompt text
|
|
98
|
+
</label>
|
|
99
|
+
<label>
|
|
100
|
+
<input
|
|
101
|
+
type="checkbox"
|
|
102
|
+
checked={state.grouped}
|
|
103
|
+
onChange={(event) => setState("grouped", event.currentTarget.checked)}
|
|
104
|
+
/>{" "}
|
|
105
|
+
Grouped prompts
|
|
106
|
+
</label>
|
|
107
|
+
<label>
|
|
108
|
+
<input
|
|
109
|
+
type="checkbox"
|
|
110
|
+
checked={state.fails}
|
|
111
|
+
onChange={(event) => setState("fails", event.currentTarget.checked)}
|
|
112
|
+
/>{" "}
|
|
113
|
+
Actions fail
|
|
114
|
+
</label>
|
|
115
|
+
<output aria-label="Failed actions">{state.failures}</output>
|
|
116
|
+
</div>
|
|
117
|
+
<CurrentSessionProviders document={document()}>
|
|
118
|
+
<Show when={state.grouped && state.text}>
|
|
119
|
+
<CurrentUserMessageDisplay
|
|
120
|
+
sessionID={CURRENT_SESSION_ID}
|
|
121
|
+
message={{ ...message(), id: "msg_pending_prompt_above" }}
|
|
122
|
+
text="Keep the earlier prompt in the same run."
|
|
123
|
+
agent="build"
|
|
124
|
+
model={STORY_MODEL}
|
|
125
|
+
actions={actions}
|
|
126
|
+
run={{ above: false, below: true }}
|
|
127
|
+
/>
|
|
128
|
+
</Show>
|
|
129
|
+
<CurrentUserMessageDisplay
|
|
130
|
+
sessionID={CURRENT_SESSION_ID}
|
|
131
|
+
message={message()}
|
|
132
|
+
text={message().text}
|
|
133
|
+
agent="build"
|
|
134
|
+
model={STORY_MODEL}
|
|
135
|
+
voice={state.voice}
|
|
136
|
+
actions={actions}
|
|
137
|
+
run={{ above: state.grouped && state.text, below: false }}
|
|
138
|
+
/>
|
|
139
|
+
</CurrentSessionProviders>
|
|
140
|
+
</section>
|
|
141
|
+
)
|
|
142
|
+
},
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export const SendingAttachment = { ...Pending, args: { status: "sending", text: false } }
|
|
146
|
+
|
|
147
|
+
export const DeliveredVoice = { ...Pending, args: { status: "delivered", voice: true } }
|
|
148
|
+
|
|
149
|
+
export const StrandedSteer = { ...Pending, args: { status: "stranded", grouped: true } }
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { createSignal, onCleanup } from "solid-js"
|
|
2
|
+
|
|
3
|
+
const MINUTE = 60_000
|
|
4
|
+
|
|
5
|
+
const HOUR = 60 * MINUTE
|
|
6
|
+
|
|
7
|
+
const DAY = 24 * HOUR
|
|
8
|
+
|
|
9
|
+
export function relativeTime(created: number, now: number) {
|
|
10
|
+
const elapsed = Math.max(0, now - created)
|
|
11
|
+
|
|
12
|
+
if (elapsed < MINUTE) return { unit: "now" } as const
|
|
13
|
+
|
|
14
|
+
if (elapsed < HOUR) return { unit: "minute", count: Math.floor(elapsed / MINUTE) } as const
|
|
15
|
+
|
|
16
|
+
if (elapsed < DAY) return { unit: "hour", count: Math.floor(elapsed / HOUR) } as const
|
|
17
|
+
|
|
18
|
+
if (elapsed < 7 * DAY) return { unit: "day", count: Math.floor(elapsed / DAY) } as const
|
|
19
|
+
|
|
20
|
+
return { unit: "date" } as const
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const [now, setNow] = createSignal(Date.now())
|
|
24
|
+
|
|
25
|
+
let subscribers = 0
|
|
26
|
+
|
|
27
|
+
let timer: ReturnType<typeof setInterval> | undefined
|
|
28
|
+
|
|
29
|
+
// One shared clock for every relative timestamp on screen; it only ticks while one is mounted.
|
|
30
|
+
export function useNow() {
|
|
31
|
+
subscribers++
|
|
32
|
+
|
|
33
|
+
if (subscribers === 1) {
|
|
34
|
+
setNow(Date.now())
|
|
35
|
+
timer = setInterval(() => setNow(Date.now()), 30_000)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
onCleanup(() => {
|
|
39
|
+
subscribers--
|
|
40
|
+
|
|
41
|
+
if (subscribers === 0) clearInterval(timer)
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
return now
|
|
45
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** A comment split into plain text and the `@path` mentions that travel with the prompt as attached files. */
|
|
2
|
+
export function commentSegments(text: string) {
|
|
3
|
+
return text
|
|
4
|
+
.split(/(@\S+)/)
|
|
5
|
+
.map((part, index) => ({ text: part, mention: index % 2 === 1 }))
|
|
6
|
+
.filter((part) => part.text !== "")
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** `:118-124` for a line range, `:42` for one line, nothing for a whole file. */
|
|
10
|
+
export function selectionLabel(selection: { startLine: number; endLine: number } | undefined) {
|
|
11
|
+
if (!selection) return ""
|
|
12
|
+
|
|
13
|
+
if (selection.startLine === selection.endLine) return `:${selection.startLine}`
|
|
14
|
+
|
|
15
|
+
return `:${selection.startLine}-${selection.endLine}`
|
|
16
|
+
}
|