@backmatter/studio 0.0.18 → 0.0.20

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 (41) hide show
  1. package/dist/chunks/{UiKitApp-DkuQBiQZ.js → UiKitApp-C269OA8v.js} +528 -481
  2. package/dist/chunks/{WorkspaceRoutes-DVvb3N-V.js → WorkspaceRoutes-B4B5jjje.js} +24376 -23915
  3. package/dist/chunks/{dashboard-B4FITg6c.js → dashboard-DeNgythd.js} +586 -565
  4. package/dist/chunks/{index-CegtXnEI.js → index-7-TtXaMq.js} +104 -104
  5. package/dist/dashboard.js +2 -2
  6. package/dist/index.js +166 -159
  7. package/dist/site-widget.css +25 -6
  8. package/dist/site-widget.js +6925 -6840
  9. package/dist/studio.css +171 -36
  10. package/package.json +2 -2
  11. package/src/api.ts +48 -1
  12. package/src/chat/ChatMessage.tsx +4 -4
  13. package/src/chat/ChatProvider.tsx +6 -0
  14. package/src/chat/chat-helpers.ts +54 -2
  15. package/src/chrome/CommandPalette.tsx +3 -3
  16. package/src/chrome/ContentExplorerSidebar.tsx +421 -74
  17. package/src/chrome/WorkspaceStatusBar.tsx +24 -24
  18. package/src/chrome/commit-error.ts +48 -60
  19. package/src/chrome/commit-failure.tsx +2 -2
  20. package/src/chrome/content-path-tree.ts +4 -0
  21. package/src/chrome/explorer-row-menu.ts +28 -0
  22. package/src/chrome/folder-create-context.ts +14 -0
  23. package/src/chrome/use-publish-check.ts +75 -0
  24. package/src/fields/FieldControl.tsx +173 -62
  25. package/src/pages/BlocksList.tsx +38 -3
  26. package/src/pages/DocEditorPage.tsx +47 -64
  27. package/src/pages/EmbedPublishPage.tsx +13 -5
  28. package/src/pages/GithubConnectPage.tsx +1 -1
  29. package/src/pages/LoginPage.tsx +67 -5
  30. package/src/pages/MediaFieldInput.tsx +155 -63
  31. package/src/pages/MediaGalleryPage.tsx +56 -3
  32. package/src/pages/PreviewAddress.tsx +30 -0
  33. package/src/pages/WorkspaceHomePage.tsx +1 -1
  34. package/src/pages/ui-kit/colors.tsx +2 -0
  35. package/src/pages/ui-kit/fields.tsx +60 -0
  36. package/src/styles/themes.ts +2 -0
  37. package/src/styles/tokens.stylex.ts +1 -0
  38. package/src/ui/Button.tsx +14 -0
  39. package/src/ui/Field.tsx +12 -1
  40. package/src/ui/Input.tsx +191 -97
  41. package/src/ui/popup.ts +13 -6
@@ -29,10 +29,28 @@ export function isWriteTool(name: string) {
29
29
  name === "renameDoc" ||
30
30
  name === "deleteDoc" ||
31
31
  name === "deleteFolder" ||
32
- name === "moveFolder"
32
+ name === "moveFolder" ||
33
+ name === "revertDoc" ||
34
+ name === "resolveConflict"
33
35
  );
34
36
  }
35
37
 
38
+ /** Branch and history tools that change what Studio shows. */
39
+ export function branchToolReloads(name: string, output: unknown): boolean {
40
+ if (name !== "switchBranch" && name !== "undoPublish" && name !== "createBranch") return false;
41
+ return Boolean(output && typeof output === "object" && (output as { ok?: unknown }).ok === true);
42
+ }
43
+
44
+ /**
45
+ * A tool failed when it says `ok: false` with a message. A check with problems
46
+ * still succeeded, and a shell command's non-zero exit is its output.
47
+ */
48
+ export function toolFailed(output: unknown): boolean {
49
+ if (!output || typeof output !== "object") return false;
50
+ const body = output as { ok?: unknown; message?: unknown };
51
+ return body.ok === false && typeof body.message === "string";
52
+ }
53
+
36
54
  /** One write tool may record several files, as a folder move or delete does. */
37
55
  export function changesInToolOutput(output: unknown): ChatChangeSummary[] {
38
56
  if (!output || typeof output !== "object") return [];
@@ -140,6 +158,40 @@ export function toolLabel(name: string, input: unknown, output: unknown, state:
140
158
  const to = (input as { to?: string } | undefined)?.to ?? "";
141
159
  return running ? `Moving ${from}…` : `Moved ${from} to ${to}`;
142
160
  }
161
+ case "listBranches":
162
+ return running ? "Listing branches…" : "Listed branches";
163
+ case "listCommits":
164
+ return running ? "Reading the history…" : "Read the history";
165
+ case "createBranch": {
166
+ const branch = (output as { branch?: string } | undefined)?.branch;
167
+ return running ? "Creating a branch…" : branch ? `Created ${branch}` : "Create branch failed";
168
+ }
169
+ case "switchBranch": {
170
+ const name = (input as { name?: string } | undefined)?.name ?? "";
171
+ return running ? `Switching to ${name}…` : `Switched to ${name}`;
172
+ }
173
+ case "undoPublish": {
174
+ const sha = ((input as { sha?: string } | undefined)?.sha ?? "").slice(0, 7);
175
+ return running ? `Undoing ${sha}…` : `Undid ${sha}`;
176
+ }
177
+ case "getStatus":
178
+ return running ? "Checking status…" : "Checked status";
179
+ case "checkChanges": {
180
+ if (running) return "Checking changes…";
181
+ const problems = (output as { problems?: Array<{ code?: string }> } | undefined)?.problems ?? [];
182
+ const blocking = problems.filter((problem) => problem.code !== "nothing_to_publish");
183
+ if (blocking.length > 0) {
184
+ return blocking.length === 1 ? "Found 1 problem" : `Found ${blocking.length} problems`;
185
+ }
186
+ return problems.length > 0 ? "Nothing to publish" : "Ready to publish";
187
+ }
188
+ case "revertDoc":
189
+ return running ? `Reverting ${doc}…` : `Reverted ${doc}`;
190
+ case "resolveConflict": {
191
+ const theirs = (input as { strategy?: string } | undefined)?.strategy === "theirs";
192
+ if (running) return `Resolving ${doc}…`;
193
+ return theirs ? `Took the branch's version of ${doc}` : `Kept your version of ${doc}`;
194
+ }
143
195
  case "commit": {
144
196
  if (running) return "Publishing…";
145
197
  const published = output as { ok?: boolean; files?: unknown[] } | undefined;
@@ -408,7 +460,7 @@ export function chatSuggestions(input: {
408
460
  const type = input.contentTypes[0];
409
461
  return [
410
462
  type ? `Write a new ${type}` : "What can you help with?",
411
- "What have I changed but not committed?",
463
+ "What's ready to publish?",
412
464
  "Find pages mentioning…",
413
465
  ];
414
466
  }
@@ -163,8 +163,8 @@ export function CommandPalette() {
163
163
  icon: "commit",
164
164
  label:
165
165
  conflicts > 0
166
- ? `Commit blocked: ${conflicts} ${conflicts === 1 ? "conflict" : "conflicts"}`
167
- : `Commit ${count} ${count === 1 ? "file" : "files"} to ${git.currentBranch}`,
166
+ ? `Publish blocked: ${conflicts} ${conflicts === 1 ? "conflict" : "conflicts"}`
167
+ : `Publish ${count} ${count === 1 ? "file" : "files"} to ${git.currentBranch}`,
168
168
  hint: conflicts > 0 ? "Resolve conflicts in the editor first" : "Uses the default message",
169
169
  run: () => {
170
170
  setOpen(false);
@@ -238,7 +238,7 @@ export function CommandPalette() {
238
238
  group: "Editing",
239
239
  icon: "revert",
240
240
  label: "Revert file",
241
- hint: "Drop my uncommitted changes to this document",
241
+ hint: "Drop my unpublished changes to this document",
242
242
  run: () => {
243
243
  setOpen(false);
244
244
  void revertDoc();