@opengeni/react 0.3.0 → 0.4.0
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/dist/index.d.ts +1035 -14
- package/dist/index.js +6867 -1884
- package/dist/index.js.map +1 -1
- package/package.json +65 -2
- package/src/client.ts +21 -0
- package/src/components/code-editor.tsx +398 -0
- package/src/components/desktop-viewer.tsx +647 -0
- package/src/components/diff-view.tsx +230 -0
- package/src/components/file-browser.tsx +838 -0
- package/src/components/message-timeline.tsx +70 -196
- package/src/components/pierre-diff.tsx +140 -0
- package/src/components/pierre-file.tsx +142 -0
- package/src/components/sandbox-files.tsx +509 -0
- package/src/components/sandbox-terminal.tsx +425 -0
- package/src/components/workspace-dock.tsx +247 -0
- package/src/hooks/use-desktop-stream.ts +214 -0
- package/src/hooks/use-sandbox-files.ts +670 -0
- package/src/hooks/use-sandbox-git.ts +105 -0
- package/src/hooks/use-sandbox-terminal.ts +226 -0
- package/src/hooks/use-session-capabilities.ts +415 -0
- package/src/hooks/use-terminal-stream.ts +207 -0
- package/src/index.ts +111 -2
- package/src/lib/cn.ts +20 -1
- package/src/lib/git-patch.ts +37 -0
- package/src/lib/use-theme-type.ts +40 -0
- package/src/lib/xterm-theme.ts +34 -0
- package/src/timeline/activity-rail.tsx +207 -0
- package/src/timeline/disclosure-context.tsx +34 -0
- package/src/timeline/index.ts +85 -0
- package/src/timeline/parsers.ts +248 -0
- package/src/{timeline.ts → timeline/projection.ts} +59 -134
- package/src/timeline/registry.ts +96 -0
- package/src/timeline/screenshot-lightbox.tsx +152 -0
- package/src/timeline/shared.tsx +481 -0
- package/src/timeline/tool-diff.tsx +91 -0
- package/src/timeline/tool-renderers.tsx +882 -0
- package/src/timeline/turn-summary.tsx +125 -0
- package/src/timeline/types.ts +131 -0
- package/src/types/external.d.ts +7 -0
- package/styles/index.css +72 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { GitFileDiff } from "@opengeni/sdk";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { cn } from "../lib/cn";
|
|
4
|
+
import { useThemeType } from "../lib/use-theme-type";
|
|
5
|
+
import { DiffView } from "../components/diff-view";
|
|
6
|
+
import { PierreDiff } from "../components/pierre-diff";
|
|
7
|
+
|
|
8
|
+
/* ----------------------------------------------------------------------------
|
|
9
|
+
Tool diff
|
|
10
|
+
|
|
11
|
+
Renders parsed `GitFileDiff[]` (from the V4A apply_patch parser) through the
|
|
12
|
+
EXACT same diff stack the Files tab uses: `DiffView` with `PierreDiff` wired
|
|
13
|
+
into its `fallback` seam, so a host with `@pierre/diffs` installed gets the
|
|
14
|
+
Shiki-highlighted Pierre renderer and everyone else gets the hand-rolled
|
|
15
|
+
one — a single data contract, zero divergence. A per-block Unified/Split
|
|
16
|
+
toggle sits in the header.
|
|
17
|
+
-------------------------------------------------------------------------- */
|
|
18
|
+
|
|
19
|
+
export function ToolDiff({ files }: { files: GitFileDiff[] }) {
|
|
20
|
+
const [layout, setLayout] = useState<"unified" | "split">("unified");
|
|
21
|
+
// Resolve the host theme (auto-detect via `data-og-theme`) with the SAME hook
|
|
22
|
+
// the Files tab uses, then thread it into Pierre. Without it Pierre falls back
|
|
23
|
+
// to its hard dark default and renders a github-dark slab inside a light page.
|
|
24
|
+
const themeType = useThemeType(undefined);
|
|
25
|
+
// The fallback chain reads top-down: try Pierre's Shiki renderer, and if it's
|
|
26
|
+
// not installed fall back to the built-in DiffView. The plain node is named
|
|
27
|
+
// once and reused, so the same props aren't threaded through three JSX nodes.
|
|
28
|
+
const plain = <DiffView diff={files} layout={layout} />;
|
|
29
|
+
return (
|
|
30
|
+
<div className="min-w-0">
|
|
31
|
+
<div className="mb-1.5 flex justify-end">
|
|
32
|
+
<LayoutToggle layout={layout} onChange={setLayout} />
|
|
33
|
+
</div>
|
|
34
|
+
<DiffView
|
|
35
|
+
diff={files}
|
|
36
|
+
layout={layout}
|
|
37
|
+
fallback={<PierreDiff diff={files} layout={layout} themeType={themeType} fallback={plain} />}
|
|
38
|
+
/>
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function LayoutToggle({ layout, onChange }: { layout: "unified" | "split"; onChange: (next: "unified" | "split") => void }) {
|
|
44
|
+
return (
|
|
45
|
+
<div className="inline-flex items-center gap-px rounded-og-xs border border-og-border p-px">
|
|
46
|
+
{(["unified", "split"] as const).map((value) => (
|
|
47
|
+
<button
|
|
48
|
+
key={value}
|
|
49
|
+
type="button"
|
|
50
|
+
onClick={() => onChange(value)}
|
|
51
|
+
className={cn(
|
|
52
|
+
"rounded-[5px] px-2 py-[3px] text-[11px] font-medium capitalize transition-colors",
|
|
53
|
+
layout === value ? "bg-og-surface-2 text-og-fg" : "text-og-fg-subtle hover:text-og-fg-muted",
|
|
54
|
+
)}
|
|
55
|
+
>
|
|
56
|
+
{value}
|
|
57
|
+
</button>
|
|
58
|
+
))}
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Raw-patch fallback for a V4A hunk string the parser could not structure. */
|
|
64
|
+
export function RawPatch({ diff }: { diff: string }) {
|
|
65
|
+
return (
|
|
66
|
+
<div className="min-w-0">
|
|
67
|
+
<p className="mb-1 text-og-xs font-medium uppercase tracking-[0.08em] text-og-fg-subtle">
|
|
68
|
+
raw patch (could not parse hunks)
|
|
69
|
+
</p>
|
|
70
|
+
<pre className="max-h-72 overflow-auto rounded-og-sm border border-og-border bg-og-bg/60 p-2.5 font-og-mono text-og-xs leading-5">
|
|
71
|
+
{diff.split("\n").map((line, index) => (
|
|
72
|
+
<span
|
|
73
|
+
key={index}
|
|
74
|
+
className={cn(
|
|
75
|
+
"block",
|
|
76
|
+
line.startsWith("@@")
|
|
77
|
+
? "text-og-accent"
|
|
78
|
+
: line.startsWith("+")
|
|
79
|
+
? "text-og-status-idle"
|
|
80
|
+
: line.startsWith("-")
|
|
81
|
+
? "text-og-status-failed"
|
|
82
|
+
: "text-og-fg-muted",
|
|
83
|
+
)}
|
|
84
|
+
>
|
|
85
|
+
{line || " "}
|
|
86
|
+
</span>
|
|
87
|
+
))}
|
|
88
|
+
</pre>
|
|
89
|
+
</div>
|
|
90
|
+
);
|
|
91
|
+
}
|