@backmatter/studio 0.0.17 → 0.0.19

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 (48) hide show
  1. package/dist/chunks/{UiKitApp-D7vllRQE.js → UiKitApp-B1ANqCac.js} +528 -481
  2. package/dist/chunks/{WorkspaceRoutes-DH1LD-2Q.js → WorkspaceRoutes-BHNGrf-j.js} +24955 -24119
  3. package/dist/chunks/{dashboard-Dsaeud2x.js → dashboard-b-W6dGm5.js} +586 -565
  4. package/dist/chunks/{index-CGMqw2NH.js → index-HYioDjux.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 -42
  10. package/package.json +2 -2
  11. package/src/api.ts +44 -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/{pages/code-session-routes.ts → content-routes.ts} +6 -6
  25. package/src/fields/FieldControl.tsx +198 -64
  26. package/src/fields/LinkFieldInput.tsx +315 -0
  27. package/src/fields/choose-field-input.ts +5 -0
  28. package/src/fields/link-targets.ts +60 -0
  29. package/src/host-path.ts +13 -0
  30. package/src/pages/CodeSessionPage.tsx +6 -241
  31. package/src/pages/DocEditorPage.tsx +121 -178
  32. package/src/pages/EmbedPublishPage.tsx +13 -5
  33. package/src/pages/GithubConnectPage.tsx +1 -1
  34. package/src/pages/LoginPage.tsx +67 -5
  35. package/src/pages/MediaFieldInput.tsx +712 -37
  36. package/src/pages/MediaGalleryPage.tsx +69 -5
  37. package/src/pages/PreviewAddress.tsx +293 -0
  38. package/src/pages/WorkspaceHomePage.tsx +1 -1
  39. package/src/pages/code-session-boot.ts +0 -12
  40. package/src/pages/media-selection.ts +79 -0
  41. package/src/pages/ui-kit/colors.tsx +2 -0
  42. package/src/pages/ui-kit/fields.tsx +60 -0
  43. package/src/styles/themes.ts +2 -0
  44. package/src/styles/tokens.stylex.ts +1 -0
  45. package/src/ui/Button.tsx +14 -0
  46. package/src/ui/Field.tsx +12 -1
  47. package/src/ui/Input.tsx +191 -97
  48. package/src/ui/popup.ts +13 -6
package/dist/studio.css CHANGED
@@ -11,6 +11,10 @@
11
11
  inset: 0;
12
12
  }
13
13
 
14
+ .x485pll {
15
+ inset: clamp(12px, 3vw, 32px);
16
+ }
17
+
14
18
  .x184nht {
15
19
  inset: var(--x1o7ezzp);
16
20
  }
@@ -69,6 +73,10 @@
69
73
  border-color: #ffffff1a;
70
74
  }
71
75
 
76
+ .x16s2x7e {
77
+ border-color: #fff9;
78
+ }
79
+
72
80
  .xe0g8ez {
73
81
  border-color: #ffffffb8;
74
82
  }
@@ -411,10 +419,6 @@
411
419
  border-color: var(--x1nzi8h4);
412
420
  }
413
421
 
414
- .xqvbft6:focus-visible {
415
- border-color: var(--xz3qvk5);
416
- }
417
-
418
422
  .xowh0s7:focus-visible {
419
423
  border-radius: var(--x16ewcrl);
420
424
  }
@@ -439,10 +443,6 @@
439
443
  border-color: var(--xw4dauw);
440
444
  }
441
445
 
442
- .xlsk2y3:focus {
443
- border-color: var(--xz3qvk5);
444
- }
445
-
446
446
  .x1uvtmcs:focus {
447
447
  outline: none;
448
448
  }
@@ -489,8 +489,8 @@
489
489
  -webkit-text-fill-color: transparent;
490
490
  }
491
491
 
492
- .x1h22klu {
493
- accent-color: var(--x5y0tk9);
492
+ .x1kb3qnp {
493
+ accent-color: #fafafa;
494
494
  }
495
495
 
496
496
  .x1pha0wt {
@@ -537,10 +537,6 @@
537
537
  animation-duration: .2s;
538
538
  }
539
539
 
540
- .xof6966 {
541
- animation-duration: .7s;
542
- }
543
-
544
540
  .xemfg65 {
545
541
  animation-duration: .8s;
546
542
  }
@@ -561,10 +557,6 @@
561
557
  animation-name: x18re5ia-B;
562
558
  }
563
559
 
564
- .xpedhrg {
565
- animation-name: x1fy8ia8-B;
566
- }
567
-
568
560
  .x1bzz7ut {
569
561
  animation-name: x1tbvpe3-B;
570
562
  }
@@ -593,6 +585,10 @@
593
585
  animation-timing-function: linear;
594
586
  }
595
587
 
588
+ .xjyslct {
589
+ appearance: none;
590
+ }
591
+
596
592
  .x1plog1 {
597
593
  aspect-ratio: 1;
598
594
  }
@@ -697,6 +693,10 @@
697
693
  background-color: #18181b47;
698
694
  }
699
695
 
696
+ .xz16w0k {
697
+ background-color: #18181bd9;
698
+ }
699
+
700
700
  .x1iprpvx {
701
701
  background-color: #ffffff17;
702
702
  }
@@ -729,6 +729,10 @@
729
729
  background-color: var(--x13g60fp);
730
730
  }
731
731
 
732
+ .x15a9b3o {
733
+ background-color: var(--x13vbpmf);
734
+ }
735
+
732
736
  .xplmcw3 {
733
737
  background-color: var(--x1bx3j4t);
734
738
  }
@@ -809,6 +813,10 @@
809
813
  border-collapse: collapse;
810
814
  }
811
815
 
816
+ .xbf8z7v {
817
+ box-shadow: 0 0 0 2px var(--x1dudhym),0 0 0 4px var(--x1nzi8h4);
818
+ }
819
+
812
820
  .x1s0jfod {
813
821
  box-shadow: 0 10px 28px #18181b29;
814
822
  }
@@ -825,14 +833,30 @@
825
833
  box-shadow: 0 16px 48px #18181b33;
826
834
  }
827
835
 
836
+ .x1hujrgp {
837
+ box-shadow: 0 18px 48px #0000006b, 0 2px 8px #0003;
838
+ }
839
+
828
840
  .x1dej7w9 {
829
841
  box-shadow: 0 1px 2px #00000014;
830
842
  }
831
843
 
844
+ .x600is {
845
+ box-shadow: 0 1px 2px #00000029;
846
+ }
847
+
848
+ .x7fwzwe {
849
+ box-shadow: 0 1px 2px #00000047;
850
+ }
851
+
832
852
  .xtpupu6 {
833
853
  box-shadow: 0 1px 2px #18181b33;
834
854
  }
835
855
 
856
+ .x17u0ql0 {
857
+ box-shadow: 0 24px 64px #00000059;
858
+ }
859
+
836
860
  .xzlluq {
837
861
  box-shadow: 0 28px 80px #18181b29, inset 0 0 0 1px #ffffff8c;
838
862
  }
@@ -1129,6 +1153,10 @@
1129
1153
  grid-template-columns: repeat(4, minmax(0, 1fr));
1130
1154
  }
1131
1155
 
1156
+ .x9v2mtg {
1157
+ grid-template-columns: repeat(auto-fill, 72px);
1158
+ }
1159
+
1132
1160
  .x10vl0y4 {
1133
1161
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
1134
1162
  }
@@ -1291,6 +1319,10 @@
1291
1319
  opacity: 1;
1292
1320
  }
1293
1321
 
1322
+ .xj2npx7 {
1323
+ opacity: var(--remove-opacity, 0);
1324
+ }
1325
+
1294
1326
  .x1ljc5jn {
1295
1327
  outline-color: var(--x1nzi8h4);
1296
1328
  }
@@ -1299,10 +1331,18 @@
1299
1331
  outline-color: var(--xz3qvk5);
1300
1332
  }
1301
1333
 
1334
+ .x1hl8ikr {
1335
+ outline-offset: 2px;
1336
+ }
1337
+
1302
1338
  .x1ewu8gn {
1303
1339
  outline-offset: 3px;
1304
1340
  }
1305
1341
 
1342
+ .x107h2d7 {
1343
+ outline-style: dashed;
1344
+ }
1345
+
1306
1346
  .xaatb59 {
1307
1347
  outline-style: solid;
1308
1348
  }
@@ -1435,6 +1475,10 @@
1435
1475
  transform-origin: calc(100% - 60px) 100%;
1436
1476
  }
1437
1477
 
1478
+ .x1g0ag68 {
1479
+ transform-origin: center;
1480
+ }
1481
+
1438
1482
  .xctpfpq {
1439
1483
  transform-origin: var(--transform-origin);
1440
1484
  }
@@ -1535,6 +1579,10 @@
1535
1579
  transition-property: width;
1536
1580
  }
1537
1581
 
1582
+ .x1p0hc1o {
1583
+ transition-timing-function: cubic-bezier(.2, 0, 0, 1);
1584
+ }
1585
+
1538
1586
  .x1ys8gui {
1539
1587
  transition-timing-function: cubic-bezier(.215, .61, .355, 1);
1540
1588
  }
@@ -1630,6 +1678,10 @@
1630
1678
  color: var(--x11n7hvk);
1631
1679
  }
1632
1680
 
1681
+ .x25t5g8:focus-visible {
1682
+ opacity: 1;
1683
+ }
1684
+
1633
1685
  .x1yxvn1h:focus-visible {
1634
1686
  outline-color: var(--x1nzi8h4);
1635
1687
  }
@@ -1750,6 +1802,10 @@
1750
1802
  outline-width: 2px;
1751
1803
  }
1752
1804
 
1805
+ .xch2mbi:active {
1806
+ cursor: grabbing;
1807
+ }
1808
+
1753
1809
  .xd3so5o:active {
1754
1810
  transform: scale(.97);
1755
1811
  }
@@ -1774,6 +1830,12 @@
1774
1830
  }
1775
1831
  }
1776
1832
 
1833
+ @media (hover: hover) {
1834
+ .x5zbl5r.x5zbl5r {
1835
+ color: var(--xw4dauw);
1836
+ }
1837
+ }
1838
+
1777
1839
  @media (width >= 1024px) {
1778
1840
  .x1wecdhn.x1wecdhn {
1779
1841
  cursor: col-resize;
@@ -1837,6 +1899,10 @@
1837
1899
  background-color: #e4e4e7;
1838
1900
  }
1839
1901
 
1902
+ .x9ezvp6.x9ezvp6:hover {
1903
+ background-color: #18181b;
1904
+ }
1905
+
1840
1906
  .x1h6wuyy.x1h6wuyy:hover {
1841
1907
  background-color: #0000;
1842
1908
  }
@@ -1974,6 +2040,10 @@
1974
2040
  bottom: var(--xvc7yhn);
1975
2041
  }
1976
2042
 
2043
+ .xmll18r {
2044
+ height: 1.25rem;
2045
+ }
2046
+
1977
2047
  .x5yr21d {
1978
2048
  height: 100%;
1979
2049
  }
@@ -2026,6 +2096,10 @@
2026
2096
  height: 28px;
2027
2097
  }
2028
2098
 
2099
+ .x36qwtl {
2100
+ height: 2px;
2101
+ }
2102
+
2029
2103
  .xettwda {
2030
2104
  height: 2rem;
2031
2105
  }
@@ -2090,10 +2164,6 @@
2090
2164
  height: min(640px,calc(100vh - 68px - env(safe-area-inset-bottom, 0px)));
2091
2165
  }
2092
2166
 
2093
- .xpojsfq {
2094
- height: min(720px, 80vh);
2095
- }
2096
-
2097
2167
  .xu96u03 {
2098
2168
  left: 0;
2099
2169
  }
@@ -2106,6 +2176,10 @@
2106
2176
  left: 50%;
2107
2177
  }
2108
2178
 
2179
+ .xx8bi4a {
2180
+ left: 7px;
2181
+ }
2182
+
2109
2183
  .xe5jagu {
2110
2184
  left: var(--x1ft7ks7);
2111
2185
  }
@@ -2170,6 +2244,10 @@
2170
2244
  margin-top: 0;
2171
2245
  }
2172
2246
 
2247
+ .xr9ek0c {
2248
+ margin-top: 2px;
2249
+ }
2250
+
2173
2251
  .x1tfhste {
2174
2252
  margin-top: 40px;
2175
2253
  }
@@ -2398,6 +2476,10 @@
2398
2476
  min-width: 10rem;
2399
2477
  }
2400
2478
 
2479
+ .xbq476d {
2480
+ min-width: 11.5rem;
2481
+ }
2482
+
2401
2483
  .xee1316 {
2402
2484
  min-width: 11rem;
2403
2485
  }
@@ -2526,6 +2608,10 @@
2526
2608
  padding-left: calc(var(--x1ft7ks7) + var(--x1uiwg42));
2527
2609
  }
2528
2610
 
2611
+ .x19qf7k3 {
2612
+ padding-left: calc(var(--x1uiwg42) + var(--x1lzhbes) + 14px + var(--x1o7ezzp));
2613
+ }
2614
+
2529
2615
  .x1g65kkx {
2530
2616
  padding-left: var(--x1ft7ks7);
2531
2617
  }
@@ -2542,6 +2628,10 @@
2542
2628
  padding-right: 8px;
2543
2629
  }
2544
2630
 
2631
+ .x2zv159 {
2632
+ padding-right: var(--x1ft7ks7);
2633
+ }
2634
+
2545
2635
  .xznc5xv {
2546
2636
  padding-right: var(--x1lzhbes);
2547
2637
  }
@@ -2578,6 +2668,10 @@
2578
2668
  right: 0;
2579
2669
  }
2580
2670
 
2671
+ .xlftelb {
2672
+ right: 12px;
2673
+ }
2674
+
2581
2675
  .xn5hqff {
2582
2676
  right: 16px;
2583
2677
  }
@@ -2586,6 +2680,10 @@
2586
2680
  right: 2px;
2587
2681
  }
2588
2682
 
2683
+ .x1d37e2g {
2684
+ right: 7px;
2685
+ }
2686
+
2589
2687
  .xjcl65e {
2590
2688
  right: var(--x1ft7ks7);
2591
2689
  }
@@ -2598,6 +2696,10 @@
2598
2696
  right: var(--x1o7ezzp);
2599
2697
  }
2600
2698
 
2699
+ .x118cjmx {
2700
+ right: var(--x1uiwg42);
2701
+ }
2702
+
2601
2703
  .x1swmuje {
2602
2704
  right: var(--xvc7yhn);
2603
2705
  }
@@ -2606,6 +2708,10 @@
2606
2708
  top: 0;
2607
2709
  }
2608
2710
 
2711
+ .x1tk7jg1 {
2712
+ top: 12px;
2713
+ }
2714
+
2609
2715
  .x1lrs4fz {
2610
2716
  top: 18vh;
2611
2717
  }
@@ -2626,18 +2732,22 @@
2626
2732
  top: 50%;
2627
2733
  }
2628
2734
 
2629
- .x1blgq8 {
2630
- top: 8vh;
2631
- }
2632
-
2633
2735
  .x87tjf4 {
2634
2736
  top: var(--x1ft7ks7);
2635
2737
  }
2636
2738
 
2739
+ .x9rb8gd {
2740
+ top: var(--x1uiwg42);
2741
+ }
2742
+
2637
2743
  .x1agl8dm {
2638
2744
  top: var(--x1y1rrep);
2639
2745
  }
2640
2746
 
2747
+ .xwqq7k2 {
2748
+ width: 1.25rem;
2749
+ }
2750
+
2641
2751
  .xh8yej3 {
2642
2752
  width: 100%;
2643
2753
  }
@@ -2738,6 +2848,10 @@
2738
2848
  width: 4.5rem;
2739
2849
  }
2740
2850
 
2851
+ .x100vrsf {
2852
+ width: 40px;
2853
+ }
2854
+
2741
2855
  .x187nhsf {
2742
2856
  width: 44px;
2743
2857
  }
@@ -2758,6 +2872,10 @@
2758
2872
  width: 6px;
2759
2873
  }
2760
2874
 
2875
+ .xni59qk {
2876
+ width: 72px;
2877
+ }
2878
+
2761
2879
  .x1l24a0r {
2762
2880
  width: 7rem;
2763
2881
  }
@@ -2774,6 +2892,10 @@
2774
2892
  width: auto;
2775
2893
  }
2776
2894
 
2895
+ .x18f6uos {
2896
+ width: calc(100% - 14px);
2897
+ }
2898
+
2777
2899
  .x12pdk5b {
2778
2900
  width: calc(min(360px, 38vw) - 48px);
2779
2901
  }
@@ -2810,10 +2932,6 @@
2810
2932
  width: min(760px, 100%);
2811
2933
  }
2812
2934
 
2813
- .xuxp2mc {
2814
- width: min(960px, 100vw - 32px);
2815
- }
2816
-
2817
2935
  .x1hhjr3y {
2818
2936
  width: var(--anchor-width);
2819
2937
  }
@@ -2842,8 +2960,8 @@
2842
2960
  width: var(--xvc7yhn);
2843
2961
  }
2844
2962
 
2845
- .xo5mw66:focus-visible {
2846
- border-bottom-color: var(--xz3qvk5);
2963
+ .x1nthoga:focus-visible {
2964
+ border-bottom-color: var(--x1nzi8h4);
2847
2965
  }
2848
2966
 
2849
2967
  .x1t1lzn6:last-child {
@@ -2854,8 +2972,8 @@
2854
2972
  margin-bottom: 0;
2855
2973
  }
2856
2974
 
2857
- .xdq5akm:focus {
2858
- border-bottom-color: var(--xz3qvk5);
2975
+ .xqg1kb6:focus {
2976
+ border-bottom-color: var(--x1nzi8h4);
2859
2977
  }
2860
2978
 
2861
2979
  @media (width <= 800px) {
@@ -3022,12 +3140,6 @@
3022
3140
  }
3023
3141
  }
3024
3142
 
3025
- @keyframes x1fy8ia8-B {
3026
- to {
3027
- transform: rotate(360deg);
3028
- }
3029
- }
3030
-
3031
3143
  @keyframes x1wc8ddo-B {
3032
3144
  from {
3033
3145
  transform: rotate(0);
@@ -3087,6 +3199,7 @@
3087
3199
  --x1xbnvpt: #f4f4f5;
3088
3200
  --xbtbsdh: #ececef;
3089
3201
  --x1dudhym: #fff;
3202
+ --x13vbpmf: #fff;
3090
3203
  --xeg52a: #18181b0d;
3091
3204
  --xfamku2: #18181b14;
3092
3205
  --x1fg5qi: #fff;
@@ -3104,7 +3217,7 @@
3104
3217
  --x1nzi8h4: #18181b;
3105
3218
  }
3106
3219
 
3107
- .x145rjjm.x145rjjm, .x145rjjm.x145rjjm:root {
3220
+ .x1qwws05.x1qwws05, .x1qwws05.x1qwws05:root {
3108
3221
  --x11n7hvk: #18181b;
3109
3222
  --x1vnpaut: #3f3f46;
3110
3223
  --x1ljpve6: #f4f4f5;
@@ -3114,6 +3227,7 @@
3114
3227
  --x1fg5qi: #fff;
3115
3228
  --x1xbnvpt: #f4f4f5;
3116
3229
  --xbtbsdh: #ececef;
3230
+ --x13vbpmf: #fff;
3117
3231
  --xoa6ql4: #ececee;
3118
3232
  --x13g60fp: #f4f4f5;
3119
3233
  --x1dudhym: #fff;
@@ -3127,7 +3241,7 @@
3127
3241
  --xw4dauw: #71717a;
3128
3242
  }
3129
3243
 
3130
- .xohh2l7.xohh2l7, .xohh2l7.xohh2l7:root {
3244
+ .x1ht4xdt.x1ht4xdt, .x1ht4xdt.x1ht4xdt:root {
3131
3245
  --x11n7hvk: #fafafa;
3132
3246
  --x1vnpaut: #e4e4e7;
3133
3247
  --x1ljpve6: #ffffff1a;
@@ -3137,6 +3251,7 @@
3137
3251
  --x1fg5qi: #18181b;
3138
3252
  --x1xbnvpt: #131316;
3139
3253
  --xbtbsdh: #0f0f12;
3254
+ --x13vbpmf: #2c2c32;
3140
3255
  --xoa6ql4: #111113;
3141
3256
  --x13g60fp: #111113;
3142
3257
  --x1dudhym: #1f1f23;
@@ -3149,3 +3264,17 @@
3149
3264
  --xadaimi: #18181b;
3150
3265
  --xw4dauw: #a1a1aa;
3151
3266
  }
3267
+
3268
+ .xyim6s9 {
3269
+ --remove-opacity: 0;
3270
+ }
3271
+
3272
+ .x1f1teyk:focus-within, .x172mly1:hover {
3273
+ --remove-opacity: 1;
3274
+ }
3275
+
3276
+ @media (hover: none) {
3277
+ .x1ldwc8i.x1ldwc8i {
3278
+ --remove-opacity: 1;
3279
+ }
3280
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backmatter/studio",
3
- "version": "0.0.17",
3
+ "version": "0.0.19",
4
4
  "description": "The Backmatter editing surface: document editor, AI chat, publish. Mounted on your site or hosted on the dashboard.",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -56,7 +56,7 @@
56
56
  },
57
57
  "dependencies": {
58
58
  "@ai-sdk/react": "^4.0.100",
59
- "@backmatter/core": "^0.0.34",
59
+ "@backmatter/core": "^0.0.36",
60
60
  "@base-ui/react": "^1.6.0",
61
61
  "@central-icons-react/round-outlined-radius-2-stroke-1.5": "1.2.15",
62
62
  "@dnd-kit/abstract": "^0.5.0",
package/src/api.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  // packages/studio/src/api.ts
2
+ import type { Problem } from "@backmatter/core";
2
3
  import { replicaQuery, type ReplicaCache } from "./replica/cache";
3
4
  import type { ReplicaBody } from "./replica/types";
4
5
  import { apiCredentials, apiHeaders, apiUrl, reportUnauthorized } from "./studio-config";
@@ -7,6 +8,7 @@ export type ApiError = Error & {
7
8
  status: number;
8
9
  code?: string;
9
10
  details?: string[];
11
+ problems?: Problem[];
10
12
  };
11
13
 
12
14
  async function api<T>(path: string, init?: RequestInit): Promise<T> {
@@ -24,6 +26,7 @@ async function api<T>(path: string, init?: RequestInit): Promise<T> {
24
26
  error?: string;
25
27
  details?: string[];
26
28
  paths?: string[];
29
+ problems?: Problem[];
27
30
  };
28
31
  if (res.status === 401 || res.status === 426) reportUnauthorized(res.status, body.error);
29
32
  const code = body.error ?? `request failed: ${res.status}`;
@@ -31,10 +34,12 @@ async function api<T>(path: string, init?: RequestInit): Promise<T> {
31
34
  Array.isArray(body.details) && body.details.length > 0
32
35
  ? `: ${body.details.join(", ")}`
33
36
  : "";
34
- const err = new Error(`${code}${detailSuffix}`) as ApiError;
37
+ const problems = Array.isArray(body.problems) ? body.problems : undefined;
38
+ const err = new Error(problems?.[0]?.message ?? `${code}${detailSuffix}`) as ApiError;
35
39
  err.status = res.status;
36
40
  err.code = body.error;
37
41
  err.details = body.details ?? body.paths;
42
+ err.problems = problems;
38
43
  throw err;
39
44
  }
40
45
  return res.json() as Promise<T>;
@@ -350,8 +355,11 @@ export function unbindGithub(workspaceId: string) {
350
355
 
351
356
  export type SchemaField = {
352
357
  kind: string;
358
+ multiple?: boolean;
353
359
  required?: boolean;
354
360
  relationTo?: string;
361
+ to?: "internal" | "external";
362
+ models?: string[];
355
363
  object?: string;
356
364
  fields?: Record<string, SchemaField>;
357
365
  /** Studio input name from `field.text({ input })`; see `defineStudio`. */
@@ -489,6 +497,13 @@ export function commitWorkspace(workspaceId: string, message?: string) {
489
497
  });
490
498
  }
491
499
 
500
+ /** Every problem a publish would hit. Nothing reaches git. */
501
+ export function checkWorkspaceChanges(workspaceId: string) {
502
+ return api<{ problems: Problem[]; checkId: string }>(`/workspaces/${workspaceId}/git/check`, {
503
+ method: "POST",
504
+ });
505
+ }
506
+
492
507
  export type CodeSessionEditList = {
493
508
  files: Array<{ path: string; deleted: boolean }>;
494
509
  skipped: Array<{ path: string; reason: string }>;
@@ -721,6 +736,34 @@ export function saveDoc(
721
736
  });
722
737
  }
723
738
 
739
+ /** Move a document to a new slug in my working tree. The old path is removed. */
740
+ export function renameDoc(
741
+ workspaceId: string,
742
+ type: string,
743
+ slug: string,
744
+ nextSlug: string,
745
+ ) {
746
+ return api<{
747
+ doc: {
748
+ type: string;
749
+ slug: string;
750
+ source: "tree";
751
+ status: DocStatus;
752
+ headSha: string | null;
753
+ };
754
+ }>(docApiPath(workspaceId, type, slug, "/rename"), {
755
+ method: "POST",
756
+ body: JSON.stringify({ slug: nextSlug }),
757
+ });
758
+ }
759
+
760
+ /** Remove a document from my working tree. */
761
+ export function deleteDoc(workspaceId: string, type: string, slug: string) {
762
+ return api<{ ok: true }>(docApiPath(workspaceId, type, slug), {
763
+ method: "DELETE",
764
+ });
765
+ }
766
+
724
767
  /** Drop my uncommitted copy; the doc reads from HEAD again. */
725
768
  export function revertDoc(
726
769
  workspaceId: string,
@@ -11,7 +11,7 @@ import { useChatSession, useChatUI } from "./ChatProvider";
11
11
  import {
12
12
  assistantShowsRow,
13
13
  bindDocsPlaceholders,
14
- isCommitTool,
14
+ toolFailed,
15
15
  isWriteTool,
16
16
  presentedChangeStatus,
17
17
  replaceEchoedDocList,
@@ -74,6 +74,8 @@ function docListFromTool(
74
74
 
75
75
  function ToolIcon({ name }: { name: string }) {
76
76
  if (name === "commit") return <CheckIcon size={12} />;
77
+ if (name === "revertDoc" || name === "resolveConflict") return <UndoIcon size={12} />;
78
+ if (name === "getStatus" || name === "checkChanges") return <EyeIcon size={12} />;
77
79
  if (name === "searchDocs") return <SearchIcon size={12} />;
78
80
  if (name === "readDoc" || name === "listDocs") return <EyeIcon size={12} />;
79
81
  return <FileIcon size={12} />;
@@ -301,10 +303,8 @@ export function ChatMessage({
301
303
  tp.state,
302
304
  );
303
305
  const write = isWriteTool(name);
304
- const commit = isCommitTool(name);
305
306
  const out = tp.state === "output-available" ? (tp.output as WriteToolOutput) : null;
306
- const failed =
307
- tp.state === "output-error" || (out !== null && (write || commit) && !out.ok);
307
+ const failed = tp.state === "output-error" || toolFailed(out);
308
308
  const error = failed
309
309
  ? (tp.state === "output-error"
310
310
  ? tp.errorText
@@ -28,6 +28,7 @@ import {
28
28
  keepAllChanges,
29
29
  keepChange,
30
30
  notifyHeadChanged,
31
+ notifyWorkspaceChanged,
31
32
  notifyTreeChanged,
32
33
  undoAllChanges,
33
34
  undoChange,
@@ -62,6 +63,7 @@ import {
62
63
  changesInToolOutput,
63
64
  detailForTreePatch,
64
65
  treeStatusPatches,
66
+ branchToolReloads,
65
67
  type TreeStatusPatch,
66
68
  } from "./chat-helpers";
67
69
  import {
@@ -734,6 +736,10 @@ function LiveSession({
734
736
  if (part.state === "output-available" && !seen.has(part.toolCallId)) {
735
737
  seen.add(part.toolCallId);
736
738
  if (checkoutWriteReloads(name, part.output)) onCheckoutWrite?.();
739
+ if (branchToolReloads(name, part.output)) {
740
+ notifyWorkspaceChanged();
741
+ notifyHeadChanged();
742
+ }
737
743
  const patches = treeStatusPatches(part.output);
738
744
  if (patches.length > 0) publishTreePatches(workspaceId, patches);
739
745
  const found = write ? changesInToolOutput(part.output) : [];