@protobase/ui 0.1.6 → 0.2.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.
Files changed (57) hide show
  1. package/dist/action-card/action-card.d.ts +26 -0
  2. package/dist/action-card/action-card.js +93 -0
  3. package/dist/action-card/field-list.d.ts +9 -0
  4. package/dist/action-card/field-list.js +18 -0
  5. package/dist/action-card/index.d.ts +3 -0
  6. package/dist/app/app.d.ts +3 -1
  7. package/dist/app/app.js +20 -7
  8. package/dist/app/assistant-shell.js +39 -0
  9. package/dist/app-shell/global-search.d.ts +1 -1
  10. package/dist/assistant-dock/assistant-dock.d.ts +10 -10
  11. package/dist/assistant-dock/assistant-dock.js +39 -74
  12. package/dist/assistant-dock/index.d.ts +5 -0
  13. package/dist/assistant-dock/part-view.d.ts +8 -0
  14. package/dist/assistant-dock/part-view.js +47 -0
  15. package/dist/assistant-dock/use-assistant-client.d.ts +4 -0
  16. package/dist/assistant-dock/use-assistant-client.js +17 -0
  17. package/dist/assistant-dock/use-assistant.d.ts +11 -0
  18. package/dist/assistant-dock/use-assistant.js +27 -0
  19. package/dist/auth/use-api-token.d.ts +7 -0
  20. package/dist/auth/use-api-token.js +37 -0
  21. package/dist/chat/chat-message.d.ts +8 -0
  22. package/dist/chat/chat-message.js +11 -0
  23. package/dist/chat/chat-thread.d.ts +12 -0
  24. package/dist/chat/chat-thread.js +23 -0
  25. package/dist/chat/composer.d.ts +12 -0
  26. package/dist/{assistant-dock → chat}/composer.js +5 -4
  27. package/dist/chat/index.d.ts +4 -0
  28. package/dist/compact-table/compact-table.d.ts +13 -0
  29. package/dist/compact-table/compact-table.js +49 -0
  30. package/dist/compact-table/format-cell.js +9 -0
  31. package/dist/data/meta-data.d.ts +4 -0
  32. package/dist/data/use-meta.js +2 -1
  33. package/dist/diff-view/diff-view.d.ts +13 -0
  34. package/dist/diff-view/diff-view.js +62 -0
  35. package/dist/diff-view/diff.d.ts +13 -0
  36. package/dist/diff-view/diff.js +29 -0
  37. package/dist/index.d.ts +19 -2
  38. package/dist/index.js +16 -2
  39. package/dist/side-panel/index.d.ts +2 -0
  40. package/dist/side-panel/side-panel.d.ts +17 -0
  41. package/dist/side-panel/side-panel.js +40 -0
  42. package/dist/step-list/step-list.d.ts +12 -0
  43. package/dist/step-list/step-list.js +40 -0
  44. package/package.json +4 -4
  45. package/dist/assistant-dock/chat-message.js +0 -9
  46. package/dist/assistant-dock/dock-item.d.ts +0 -4
  47. package/dist/assistant-dock/dock-item.js +0 -37
  48. package/dist/assistant-dock/model.d.ts +0 -84
  49. package/dist/assistant-dock/model.js +0 -26
  50. package/dist/assistant-dock/plan-card.d.ts +0 -13
  51. package/dist/assistant-dock/plan-card.js +0 -133
  52. package/dist/assistant-dock/progress-card.js +0 -18
  53. package/dist/assistant-dock/query-card.js +0 -52
  54. package/dist/assistant-dock/queue-card.js +0 -31
  55. package/dist/assistant-dock/result-card.js +0 -77
  56. package/dist/assistant-panel/content.d.ts +0 -7
  57. package/dist/assistant-panel/step-list.js +0 -30
@@ -1,13 +0,0 @@
1
- import { Plan } from "./model.js";
2
- //#region src/assistant-dock/plan-card.d.ts
3
- export type PlanCardProps = {
4
- plan: Plan;
5
- balance: number;
6
- onApprove?: (taskId: string) => void;
7
- /** Asks for the next revision; the dock moves to the chat box for what should change. */
8
- onRequestChanges?: (taskId: string) => void;
9
- onCancel?: (taskId: string) => void;
10
- /** A free re-plan from the moved branch. */
11
- onUpdatePlan?: (taskId: string) => void;
12
- };
13
- //#endregion
@@ -1,133 +0,0 @@
1
- import { Badge } from "../primitives/badge.js";
2
- import { Button } from "../primitives/button.js";
3
- import { approval, approveLabel, formatCredits, waitingText } from "./model.js";
4
- import { jsx, jsxs } from "react/jsx-runtime";
5
- import { AlertTriangle, GitBranch, ListChecks } from "lucide-react";
6
- //#region src/assistant-dock/plan-card.tsx
7
- const statusNote = {
8
- awaiting: void 0,
9
- approved: "Approved. The credits are held until the change is live.",
10
- canceled: "Canceled. The 1-credit deposit was kept.",
11
- superseded: "Replaced by a newer plan.",
12
- dropped: "The repository changed, so this plan was dropped and the deposit refunded."
13
- };
14
- const PlanCard = ({ plan, balance, onApprove, onRequestChanges, onCancel, onUpdatePlan }) => {
15
- const approve = approval(plan, balance);
16
- const awaiting = plan.status === "awaiting";
17
- const waiting = awaiting ? waitingText(plan.waiting) : void 0;
18
- return /* @__PURE__ */ jsxs("section", {
19
- "aria-label": `Plan, revision ${plan.revision}`,
20
- className: "shrink-0 overflow-hidden rounded-lg border border-primary-border bg-background shadow-sm",
21
- children: [/* @__PURE__ */ jsxs("header", {
22
- className: "flex items-center gap-2 bg-primary-soft px-3 py-2",
23
- children: [
24
- /* @__PURE__ */ jsx(ListChecks, { className: "size-3.5 text-primary-text" }),
25
- /* @__PURE__ */ jsxs("h3", {
26
- className: "flex-1 text-[13px] font-semibold text-primary-text",
27
- children: ["Plan", plan.revision > 1 && `, revision ${plan.revision}`]
28
- }),
29
- /* @__PURE__ */ jsxs(Badge, {
30
- tone: "blue",
31
- dot: false,
32
- children: ["Size ", plan.size]
33
- }),
34
- /* @__PURE__ */ jsx("span", {
35
- className: "text-xs font-medium text-primary-text",
36
- children: formatCredits(plan.credits)
37
- })
38
- ]
39
- }), /* @__PURE__ */ jsxs("div", {
40
- className: "space-y-2.5 px-3 py-2.5",
41
- children: [
42
- /* @__PURE__ */ jsx("p", {
43
- className: "text-[13px]",
44
- children: plan.summary
45
- }),
46
- plan.steps.length > 0 && /* @__PURE__ */ jsx("ol", {
47
- className: "list-decimal space-y-1 pl-5 text-xs text-muted-foreground",
48
- children: plan.steps.map((step) => /* @__PURE__ */ jsx("li", { children: step.title }, step.title))
49
- }),
50
- plan.migrations.length > 0 && /* @__PURE__ */ jsxs("div", {
51
- className: "space-y-1",
52
- children: [/* @__PURE__ */ jsx("div", {
53
- className: "text-xs font-semibold",
54
- children: "Database changes"
55
- }), /* @__PURE__ */ jsx("ul", {
56
- className: "space-y-1",
57
- children: plan.migrations.map((migration) => /* @__PURE__ */ jsxs("li", {
58
- className: "flex items-start gap-2 text-xs",
59
- children: [/* @__PURE__ */ jsx("span", {
60
- className: "min-w-0 flex-1",
61
- children: migration.description
62
- }), migration.destructive && /* @__PURE__ */ jsx(Badge, {
63
- tone: "red",
64
- children: "Destructive"
65
- })]
66
- }, migration.description))
67
- })]
68
- }),
69
- plan.risks.length > 0 && /* @__PURE__ */ jsx("ul", {
70
- className: "space-y-1",
71
- children: plan.risks.map((risk) => /* @__PURE__ */ jsxs("li", {
72
- className: "flex items-start gap-2 text-xs text-warning-text",
73
- children: [/* @__PURE__ */ jsx(AlertTriangle, { className: "mt-0.5 size-3 shrink-0" }), risk]
74
- }, risk))
75
- }),
76
- awaiting && plan.outdated && /* @__PURE__ */ jsxs("p", {
77
- role: "status",
78
- className: "flex items-start gap-2 rounded-md bg-warning-soft px-2.5 py-2 text-xs text-warning-text",
79
- children: [/* @__PURE__ */ jsx(GitBranch, { className: "mt-0.5 size-3 shrink-0" }), "The branch moved on GitHub since this plan was made. Approving runs it on the new code."]
80
- }),
81
- waiting && /* @__PURE__ */ jsxs("p", {
82
- className: "text-xs text-muted-foreground",
83
- children: [waiting, " Cancel frees the queue."]
84
- }),
85
- statusNote[plan.status] && /* @__PURE__ */ jsx("p", {
86
- className: "text-xs text-muted-foreground",
87
- children: statusNote[plan.status]
88
- }),
89
- awaiting && /* @__PURE__ */ jsxs("div", {
90
- className: "space-y-2 pt-0.5",
91
- children: [
92
- /* @__PURE__ */ jsx(Button, {
93
- variant: "primary",
94
- className: "w-full",
95
- disabled: !approve.enabled,
96
- onClick: () => onApprove?.(plan.taskId),
97
- children: approveLabel(plan)
98
- }),
99
- approve.reason && /* @__PURE__ */ jsx("p", {
100
- className: "text-xs text-danger-text",
101
- children: approve.reason
102
- }),
103
- /* @__PURE__ */ jsxs("div", {
104
- className: "flex gap-2",
105
- children: [
106
- plan.outdated && /* @__PURE__ */ jsx(Button, {
107
- size: "sm",
108
- className: "flex-1",
109
- onClick: () => onUpdatePlan?.(plan.taskId),
110
- children: "Update plan"
111
- }),
112
- /* @__PURE__ */ jsx(Button, {
113
- size: "sm",
114
- className: "flex-1",
115
- onClick: () => onRequestChanges?.(plan.taskId),
116
- children: "Ask for changes"
117
- }),
118
- /* @__PURE__ */ jsx(Button, {
119
- size: "sm",
120
- variant: "ghost",
121
- onClick: () => onCancel?.(plan.taskId),
122
- children: "Cancel"
123
- })
124
- ]
125
- })
126
- ]
127
- })
128
- ]
129
- })]
130
- });
131
- };
132
- //#endregion
133
- export { PlanCard };
@@ -1,18 +0,0 @@
1
- import { StepList } from "../assistant-panel/step-list.js";
2
- import { jsx, jsxs } from "react/jsx-runtime";
3
- //#region src/assistant-dock/progress-card.tsx
4
- const titles = {
5
- planning: "Planning",
6
- running: "Making the change"
7
- };
8
- /** What the planning run or the job is doing, step by step. */
9
- const ProgressCard = ({ phase, steps }) => /* @__PURE__ */ jsxs("section", {
10
- "aria-label": titles[phase],
11
- className: "shrink-0 space-y-2 rounded-lg border border-border-strong bg-background px-3 py-2.5 shadow-sm",
12
- children: [/* @__PURE__ */ jsx("h3", {
13
- className: "text-xs font-semibold",
14
- children: titles[phase]
15
- }), /* @__PURE__ */ jsx(StepList, { steps })]
16
- });
17
- //#endregion
18
- export { ProgressCard };
@@ -1,52 +0,0 @@
1
- import { formatCell } from "./model.js";
2
- import { jsx, jsxs } from "react/jsx-runtime";
3
- import { Database } from "lucide-react";
4
- //#region src/assistant-dock/query-card.tsx
5
- /** A read-only query the chat ran, with its rows as a table. */
6
- const QueryCard = ({ query }) => /* @__PURE__ */ jsxs("section", {
7
- "aria-label": "Query result",
8
- className: "shrink-0 overflow-hidden rounded-lg border border-border-strong bg-background shadow-sm",
9
- children: [
10
- /* @__PURE__ */ jsxs("header", {
11
- className: "flex items-start gap-2 bg-surface px-3 py-2",
12
- children: [/* @__PURE__ */ jsx(Database, { className: "mt-0.5 size-3.5 shrink-0 text-muted-foreground" }), /* @__PURE__ */ jsx("code", {
13
- className: "min-w-0 flex-1 whitespace-pre-wrap break-words font-mono text-[11px] text-foreground",
14
- children: query.sql
15
- })]
16
- }),
17
- query.rows.length === 0 ? /* @__PURE__ */ jsx("p", {
18
- className: "px-3 py-2 text-xs text-muted-foreground",
19
- children: "No rows."
20
- }) : /* @__PURE__ */ jsx("div", {
21
- className: "max-h-64 overflow-auto",
22
- children: /* @__PURE__ */ jsxs("table", {
23
- className: "w-full border-collapse text-left text-[11px]",
24
- children: [/* @__PURE__ */ jsx("thead", {
25
- className: "sticky top-0 bg-background",
26
- children: /* @__PURE__ */ jsx("tr", { children: query.columns.map((column) => /* @__PURE__ */ jsx("th", {
27
- scope: "col",
28
- className: "border-b border-border px-2 py-1 font-semibold whitespace-nowrap",
29
- children: column
30
- }, column)) })
31
- }), /* @__PURE__ */ jsx("tbody", { children: query.rows.map((row, index) => /* @__PURE__ */ jsx("tr", {
32
- className: "border-b border-border last:border-b-0",
33
- children: row.map((value, column) => /* @__PURE__ */ jsx("td", {
34
- className: value === null ? "px-2 py-1 whitespace-nowrap text-faint-foreground" : "px-2 py-1 whitespace-nowrap",
35
- children: formatCell(value)
36
- }, column))
37
- }, index)) })]
38
- })
39
- }),
40
- /* @__PURE__ */ jsxs("footer", {
41
- className: "border-t border-border px-3 py-1.5 text-[11px] text-muted-foreground",
42
- children: [
43
- query.rows.length,
44
- " ",
45
- query.rows.length === 1 ? "row" : "rows",
46
- query.truncated && ", cut off at the limit"
47
- ]
48
- })
49
- ]
50
- });
51
- //#endregion
52
- export { QueryCard };
@@ -1,31 +0,0 @@
1
- import { Button } from "../primitives/button.js";
2
- import { queueText } from "./model.js";
3
- import { jsx, jsxs } from "react/jsx-runtime";
4
- import { Clock } from "lucide-react";
5
- //#region src/assistant-dock/queue-card.tsx
6
- /** A task waiting in the app's queue, with its deposit billed. */
7
- const QueueCard = ({ taskId, request, ahead, waitingOnPlan, onCancel }) => /* @__PURE__ */ jsxs("section", {
8
- "aria-label": "Queued change",
9
- className: "flex shrink-0 items-start gap-2.5 rounded-lg border border-border-strong bg-background px-3 py-2.5 shadow-sm",
10
- children: [
11
- /* @__PURE__ */ jsx(Clock, { className: "mt-0.5 size-3.5 shrink-0 text-muted-foreground" }),
12
- /* @__PURE__ */ jsxs("div", {
13
- className: "min-w-0 flex-1 space-y-0.5",
14
- children: [/* @__PURE__ */ jsx("div", {
15
- className: "truncate text-[13px] font-medium",
16
- children: request
17
- }), /* @__PURE__ */ jsx("div", {
18
- className: "text-xs text-muted-foreground",
19
- children: queueText(ahead, waitingOnPlan)
20
- })]
21
- }),
22
- /* @__PURE__ */ jsx(Button, {
23
- variant: "ghost",
24
- size: "sm",
25
- onClick: () => onCancel?.(taskId),
26
- children: "Cancel"
27
- })
28
- ]
29
- });
30
- //#endregion
31
- export { QueueCard };
@@ -1,77 +0,0 @@
1
- import { cn } from "../lib/cn.js";
2
- import { formatCredits } from "./model.js";
3
- import { jsx, jsxs } from "react/jsx-runtime";
4
- import { CircleCheck, CircleX, GitCommitHorizontal } from "lucide-react";
5
- //#region src/assistant-dock/result-card.tsx
6
- const headings = {
7
- live: "Live now",
8
- failed: "The change failed",
9
- capped: "The change hit its limit"
10
- };
11
- /** How a job ended: live with its commit, or failed or capped at no cost, with the database changes that stay live. */
12
- const ResultCard = ({ result }) => {
13
- const live = result.outcome === "live";
14
- const Icon = live ? CircleCheck : CircleX;
15
- return /* @__PURE__ */ jsxs("section", {
16
- "aria-label": headings[result.outcome],
17
- className: cn("shrink-0 overflow-hidden rounded-lg border bg-background shadow-sm", live ? "border-success/40" : "border-danger/40"),
18
- children: [/* @__PURE__ */ jsxs("header", {
19
- className: cn("flex items-center gap-2 px-3 py-2", live ? "bg-success-soft text-success-text" : "bg-danger-soft text-danger-text"),
20
- children: [
21
- /* @__PURE__ */ jsx(Icon, { className: "size-3.5" }),
22
- /* @__PURE__ */ jsx("h3", {
23
- className: "flex-1 text-[13px] font-semibold",
24
- children: headings[result.outcome]
25
- }),
26
- /* @__PURE__ */ jsx("span", {
27
- className: "text-xs font-medium",
28
- children: live ? formatCredits(result.credits) : "No charge"
29
- })
30
- ]
31
- }), /* @__PURE__ */ jsxs("div", {
32
- className: "space-y-2.5 px-3 py-2.5",
33
- children: [
34
- /* @__PURE__ */ jsx("p", {
35
- className: "text-[13px]",
36
- children: result.summary
37
- }),
38
- result.commit && /* @__PURE__ */ jsxs("div", {
39
- className: "flex items-center gap-2 text-xs text-muted-foreground",
40
- children: [/* @__PURE__ */ jsx(GitCommitHorizontal, { className: "size-3.5" }), result.commit.url ? /* @__PURE__ */ jsx("a", {
41
- className: "font-mono text-primary-text hover:underline",
42
- href: result.commit.url,
43
- target: "_blank",
44
- rel: "noreferrer",
45
- children: result.commit.sha.slice(0, 7)
46
- }) : /* @__PURE__ */ jsx("span", {
47
- className: "font-mono",
48
- children: result.commit.sha.slice(0, 7)
49
- })]
50
- }),
51
- result.keptOnBranch && /* @__PURE__ */ jsxs("p", {
52
- className: "text-xs text-muted-foreground",
53
- children: [
54
- "GitHub did not accept the push. The code is kept on the branch ",
55
- /* @__PURE__ */ jsx("code", {
56
- className: "font-mono",
57
- children: result.keptOnBranch
58
- }),
59
- "."
60
- ]
61
- }),
62
- result.dbChanges.length > 0 && /* @__PURE__ */ jsxs("div", {
63
- className: "space-y-1",
64
- children: [/* @__PURE__ */ jsx("div", {
65
- className: "text-xs font-semibold",
66
- children: live ? "Database changes" : "Database changes that stay live"
67
- }), /* @__PURE__ */ jsx("ul", {
68
- className: "space-y-0.5 font-mono text-[11px] text-muted-foreground",
69
- children: result.dbChanges.map((change) => /* @__PURE__ */ jsx("li", { children: change }, change))
70
- })]
71
- })
72
- ]
73
- })]
74
- });
75
- };
76
- //#endregion
77
- export { ResultCard };
@@ -1,7 +0,0 @@
1
- //#region src/assistant-panel/content.d.ts
2
- export type StepState = 'done' | 'running' | 'failed';
3
- export type Step = {
4
- label: string;
5
- state: StepState;
6
- };
7
- //#endregion
@@ -1,30 +0,0 @@
1
- import { cn } from "../lib/cn.js";
2
- import { Spinner } from "../primitives/spinner.js";
3
- import { jsx, jsxs } from "react/jsx-runtime";
4
- import { Check, X } from "lucide-react";
5
- //#region src/assistant-panel/step-list.tsx
6
- const StepList = ({ steps }) => /* @__PURE__ */ jsx("ul", {
7
- className: "shrink-0 space-y-2",
8
- children: steps.map((step) => /* @__PURE__ */ jsxs("li", {
9
- className: "flex items-start gap-2.5 text-[13px]",
10
- children: [/* @__PURE__ */ jsxs("span", {
11
- className: "mt-0.5 flex size-4 shrink-0 items-center justify-center",
12
- children: [
13
- step.state === "running" && /* @__PURE__ */ jsx(Spinner, { className: "size-3.5 text-primary" }),
14
- step.state === "done" && /* @__PURE__ */ jsx(Check, {
15
- className: "size-3.5 text-success",
16
- strokeWidth: 2.5
17
- }),
18
- step.state === "failed" && /* @__PURE__ */ jsx(X, {
19
- className: "size-3.5 text-danger",
20
- strokeWidth: 2.5
21
- })
22
- ]
23
- }), /* @__PURE__ */ jsx("span", {
24
- className: cn(step.state === "running" ? "text-foreground" : "text-muted-foreground", step.state === "failed" && "text-danger-text"),
25
- children: step.label
26
- })]
27
- }, step.label))
28
- });
29
- //#endregion
30
- export { StepList };