@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
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 {
@@ -585,6 +585,10 @@
585
585
  animation-timing-function: linear;
586
586
  }
587
587
 
588
+ .xjyslct {
589
+ appearance: none;
590
+ }
591
+
588
592
  .x1plog1 {
589
593
  aspect-ratio: 1;
590
594
  }
@@ -689,6 +693,10 @@
689
693
  background-color: #18181b47;
690
694
  }
691
695
 
696
+ .xz16w0k {
697
+ background-color: #18181bd9;
698
+ }
699
+
692
700
  .x1iprpvx {
693
701
  background-color: #ffffff17;
694
702
  }
@@ -721,6 +729,10 @@
721
729
  background-color: var(--x13g60fp);
722
730
  }
723
731
 
732
+ .x15a9b3o {
733
+ background-color: var(--x13vbpmf);
734
+ }
735
+
724
736
  .xplmcw3 {
725
737
  background-color: var(--x1bx3j4t);
726
738
  }
@@ -801,6 +813,10 @@
801
813
  border-collapse: collapse;
802
814
  }
803
815
 
816
+ .xbf8z7v {
817
+ box-shadow: 0 0 0 2px var(--x1dudhym),0 0 0 4px var(--x1nzi8h4);
818
+ }
819
+
804
820
  .x1s0jfod {
805
821
  box-shadow: 0 10px 28px #18181b29;
806
822
  }
@@ -817,14 +833,30 @@
817
833
  box-shadow: 0 16px 48px #18181b33;
818
834
  }
819
835
 
836
+ .x1hujrgp {
837
+ box-shadow: 0 18px 48px #0000006b, 0 2px 8px #0003;
838
+ }
839
+
820
840
  .x1dej7w9 {
821
841
  box-shadow: 0 1px 2px #00000014;
822
842
  }
823
843
 
844
+ .x600is {
845
+ box-shadow: 0 1px 2px #00000029;
846
+ }
847
+
848
+ .x7fwzwe {
849
+ box-shadow: 0 1px 2px #00000047;
850
+ }
851
+
824
852
  .xtpupu6 {
825
853
  box-shadow: 0 1px 2px #18181b33;
826
854
  }
827
855
 
856
+ .x17u0ql0 {
857
+ box-shadow: 0 24px 64px #00000059;
858
+ }
859
+
828
860
  .xzlluq {
829
861
  box-shadow: 0 28px 80px #18181b29, inset 0 0 0 1px #ffffff8c;
830
862
  }
@@ -1117,14 +1149,14 @@
1117
1149
  grid-template-columns: repeat(2, minmax(0, 1fr));
1118
1150
  }
1119
1151
 
1120
- .xbqmlv7 {
1121
- grid-template-columns: repeat(4, 48px);
1122
- }
1123
-
1124
1152
  .x1sipb5g {
1125
1153
  grid-template-columns: repeat(4, minmax(0, 1fr));
1126
1154
  }
1127
1155
 
1156
+ .x9v2mtg {
1157
+ grid-template-columns: repeat(auto-fill, 72px);
1158
+ }
1159
+
1128
1160
  .x10vl0y4 {
1129
1161
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
1130
1162
  }
@@ -1193,6 +1225,10 @@
1193
1225
  line-height: 1.3;
1194
1226
  }
1195
1227
 
1228
+ .x1xfvgam {
1229
+ line-height: 1.35;
1230
+ }
1231
+
1196
1232
  .x37zpob {
1197
1233
  line-height: 1.4;
1198
1234
  }
@@ -1287,6 +1323,10 @@
1287
1323
  opacity: 1;
1288
1324
  }
1289
1325
 
1326
+ .xj2npx7 {
1327
+ opacity: var(--remove-opacity, 0);
1328
+ }
1329
+
1290
1330
  .x1ljc5jn {
1291
1331
  outline-color: var(--x1nzi8h4);
1292
1332
  }
@@ -1295,10 +1335,18 @@
1295
1335
  outline-color: var(--xz3qvk5);
1296
1336
  }
1297
1337
 
1338
+ .x1hl8ikr {
1339
+ outline-offset: 2px;
1340
+ }
1341
+
1298
1342
  .x1ewu8gn {
1299
1343
  outline-offset: 3px;
1300
1344
  }
1301
1345
 
1346
+ .x107h2d7 {
1347
+ outline-style: dashed;
1348
+ }
1349
+
1302
1350
  .xaatb59 {
1303
1351
  outline-style: solid;
1304
1352
  }
@@ -1431,6 +1479,10 @@
1431
1479
  transform-origin: calc(100% - 60px) 100%;
1432
1480
  }
1433
1481
 
1482
+ .x1g0ag68 {
1483
+ transform-origin: center;
1484
+ }
1485
+
1434
1486
  .xctpfpq {
1435
1487
  transform-origin: var(--transform-origin);
1436
1488
  }
@@ -1531,6 +1583,10 @@
1531
1583
  transition-property: width;
1532
1584
  }
1533
1585
 
1586
+ .x1p0hc1o {
1587
+ transition-timing-function: cubic-bezier(.2, 0, 0, 1);
1588
+ }
1589
+
1534
1590
  .x1ys8gui {
1535
1591
  transition-timing-function: cubic-bezier(.215, .61, .355, 1);
1536
1592
  }
@@ -1556,6 +1612,10 @@
1556
1612
  vertical-align: bottom;
1557
1613
  }
1558
1614
 
1615
+ .xeaf4i8 {
1616
+ white-space: normal;
1617
+ }
1618
+
1559
1619
  .xuxw1ft {
1560
1620
  white-space: nowrap;
1561
1621
  }
@@ -1626,6 +1686,10 @@
1626
1686
  color: var(--x11n7hvk);
1627
1687
  }
1628
1688
 
1689
+ .x25t5g8:focus-visible {
1690
+ opacity: 1;
1691
+ }
1692
+
1629
1693
  .x1yxvn1h:focus-visible {
1630
1694
  outline-color: var(--x1nzi8h4);
1631
1695
  }
@@ -1746,6 +1810,10 @@
1746
1810
  outline-width: 2px;
1747
1811
  }
1748
1812
 
1813
+ .xch2mbi:active {
1814
+ cursor: grabbing;
1815
+ }
1816
+
1749
1817
  .xd3so5o:active {
1750
1818
  transform: scale(.97);
1751
1819
  }
@@ -1770,6 +1838,12 @@
1770
1838
  }
1771
1839
  }
1772
1840
 
1841
+ @media (hover: hover) {
1842
+ .x5zbl5r.x5zbl5r {
1843
+ color: var(--xw4dauw);
1844
+ }
1845
+ }
1846
+
1773
1847
  @media (width >= 1024px) {
1774
1848
  .x1wecdhn.x1wecdhn {
1775
1849
  cursor: col-resize;
@@ -1833,6 +1907,10 @@
1833
1907
  background-color: #e4e4e7;
1834
1908
  }
1835
1909
 
1910
+ .x9ezvp6.x9ezvp6:hover {
1911
+ background-color: #18181b;
1912
+ }
1913
+
1836
1914
  .x1h6wuyy.x1h6wuyy:hover {
1837
1915
  background-color: #0000;
1838
1916
  }
@@ -2026,6 +2104,10 @@
2026
2104
  height: 28px;
2027
2105
  }
2028
2106
 
2107
+ .x36qwtl {
2108
+ height: 2px;
2109
+ }
2110
+
2029
2111
  .xettwda {
2030
2112
  height: 2rem;
2031
2113
  }
@@ -2090,10 +2172,6 @@
2090
2172
  height: min(640px,calc(100vh - 68px - env(safe-area-inset-bottom, 0px)));
2091
2173
  }
2092
2174
 
2093
- .xpojsfq {
2094
- height: min(720px, 80vh);
2095
- }
2096
-
2097
2175
  .xu96u03 {
2098
2176
  left: 0;
2099
2177
  }
@@ -2106,6 +2184,10 @@
2106
2184
  left: 50%;
2107
2185
  }
2108
2186
 
2187
+ .xx8bi4a {
2188
+ left: 7px;
2189
+ }
2190
+
2109
2191
  .xe5jagu {
2110
2192
  left: var(--x1ft7ks7);
2111
2193
  }
@@ -2170,6 +2252,10 @@
2170
2252
  margin-top: 0;
2171
2253
  }
2172
2254
 
2255
+ .xr9ek0c {
2256
+ margin-top: 2px;
2257
+ }
2258
+
2173
2259
  .x1tfhste {
2174
2260
  margin-top: 40px;
2175
2261
  }
@@ -2274,6 +2360,10 @@
2274
2360
  max-width: 220px;
2275
2361
  }
2276
2362
 
2363
+ .xuv54rz {
2364
+ max-width: 22rem;
2365
+ }
2366
+
2277
2367
  .x16em4ew {
2278
2368
  max-width: 240px;
2279
2369
  }
@@ -2398,6 +2488,10 @@
2398
2488
  min-width: 10rem;
2399
2489
  }
2400
2490
 
2491
+ .xbq476d {
2492
+ min-width: 11.5rem;
2493
+ }
2494
+
2401
2495
  .xee1316 {
2402
2496
  min-width: 11rem;
2403
2497
  }
@@ -2526,6 +2620,10 @@
2526
2620
  padding-left: calc(var(--x1ft7ks7) + var(--x1uiwg42));
2527
2621
  }
2528
2622
 
2623
+ .x19qf7k3 {
2624
+ padding-left: calc(var(--x1uiwg42) + var(--x1lzhbes) + 14px + var(--x1o7ezzp));
2625
+ }
2626
+
2529
2627
  .x1g65kkx {
2530
2628
  padding-left: var(--x1ft7ks7);
2531
2629
  }
@@ -2542,6 +2640,10 @@
2542
2640
  padding-right: 8px;
2543
2641
  }
2544
2642
 
2643
+ .x2zv159 {
2644
+ padding-right: var(--x1ft7ks7);
2645
+ }
2646
+
2545
2647
  .xznc5xv {
2546
2648
  padding-right: var(--x1lzhbes);
2547
2649
  }
@@ -2578,6 +2680,10 @@
2578
2680
  right: 0;
2579
2681
  }
2580
2682
 
2683
+ .xlftelb {
2684
+ right: 12px;
2685
+ }
2686
+
2581
2687
  .xn5hqff {
2582
2688
  right: 16px;
2583
2689
  }
@@ -2586,6 +2692,10 @@
2586
2692
  right: 2px;
2587
2693
  }
2588
2694
 
2695
+ .x1d37e2g {
2696
+ right: 7px;
2697
+ }
2698
+
2589
2699
  .xjcl65e {
2590
2700
  right: var(--x1ft7ks7);
2591
2701
  }
@@ -2598,6 +2708,10 @@
2598
2708
  right: var(--x1o7ezzp);
2599
2709
  }
2600
2710
 
2711
+ .x118cjmx {
2712
+ right: var(--x1uiwg42);
2713
+ }
2714
+
2601
2715
  .x1swmuje {
2602
2716
  right: var(--xvc7yhn);
2603
2717
  }
@@ -2606,6 +2720,10 @@
2606
2720
  top: 0;
2607
2721
  }
2608
2722
 
2723
+ .x1tk7jg1 {
2724
+ top: 12px;
2725
+ }
2726
+
2609
2727
  .x1lrs4fz {
2610
2728
  top: 18vh;
2611
2729
  }
@@ -2626,14 +2744,14 @@
2626
2744
  top: 50%;
2627
2745
  }
2628
2746
 
2629
- .x1blgq8 {
2630
- top: 8vh;
2631
- }
2632
-
2633
2747
  .x87tjf4 {
2634
2748
  top: var(--x1ft7ks7);
2635
2749
  }
2636
2750
 
2751
+ .x9rb8gd {
2752
+ top: var(--x1uiwg42);
2753
+ }
2754
+
2637
2755
  .x1agl8dm {
2638
2756
  top: var(--x1y1rrep);
2639
2757
  }
@@ -2766,6 +2884,10 @@
2766
2884
  width: 6px;
2767
2885
  }
2768
2886
 
2887
+ .xni59qk {
2888
+ width: 72px;
2889
+ }
2890
+
2769
2891
  .x1l24a0r {
2770
2892
  width: 7rem;
2771
2893
  }
@@ -2782,12 +2904,12 @@
2782
2904
  width: auto;
2783
2905
  }
2784
2906
 
2785
- .x12pdk5b {
2786
- width: calc(min(360px, 38vw) - 48px);
2907
+ .x18f6uos {
2908
+ width: calc(100% - 14px);
2787
2909
  }
2788
2910
 
2789
- .xeq5yr9 {
2790
- width: fit-content;
2911
+ .x12pdk5b {
2912
+ width: calc(min(360px, 38vw) - 48px);
2791
2913
  }
2792
2914
 
2793
2915
  .x3bfboh {
@@ -2822,10 +2944,6 @@
2822
2944
  width: min(760px, 100%);
2823
2945
  }
2824
2946
 
2825
- .xuxp2mc {
2826
- width: min(960px, 100vw - 32px);
2827
- }
2828
-
2829
2947
  .x1hhjr3y {
2830
2948
  width: var(--anchor-width);
2831
2949
  }
@@ -2854,8 +2972,8 @@
2854
2972
  width: var(--xvc7yhn);
2855
2973
  }
2856
2974
 
2857
- .xo5mw66:focus-visible {
2858
- border-bottom-color: var(--xz3qvk5);
2975
+ .x1nthoga:focus-visible {
2976
+ border-bottom-color: var(--x1nzi8h4);
2859
2977
  }
2860
2978
 
2861
2979
  .x1t1lzn6:last-child {
@@ -2866,8 +2984,8 @@
2866
2984
  margin-bottom: 0;
2867
2985
  }
2868
2986
 
2869
- .xdq5akm:focus {
2870
- border-bottom-color: var(--xz3qvk5);
2987
+ .xqg1kb6:focus {
2988
+ border-bottom-color: var(--x1nzi8h4);
2871
2989
  }
2872
2990
 
2873
2991
  @media (width <= 800px) {
@@ -3093,6 +3211,7 @@
3093
3211
  --x1xbnvpt: #f4f4f5;
3094
3212
  --xbtbsdh: #ececef;
3095
3213
  --x1dudhym: #fff;
3214
+ --x13vbpmf: #fff;
3096
3215
  --xeg52a: #18181b0d;
3097
3216
  --xfamku2: #18181b14;
3098
3217
  --x1fg5qi: #fff;
@@ -3110,7 +3229,7 @@
3110
3229
  --x1nzi8h4: #18181b;
3111
3230
  }
3112
3231
 
3113
- .x145rjjm.x145rjjm, .x145rjjm.x145rjjm:root {
3232
+ .x1qwws05.x1qwws05, .x1qwws05.x1qwws05:root {
3114
3233
  --x11n7hvk: #18181b;
3115
3234
  --x1vnpaut: #3f3f46;
3116
3235
  --x1ljpve6: #f4f4f5;
@@ -3120,6 +3239,7 @@
3120
3239
  --x1fg5qi: #fff;
3121
3240
  --x1xbnvpt: #f4f4f5;
3122
3241
  --xbtbsdh: #ececef;
3242
+ --x13vbpmf: #fff;
3123
3243
  --xoa6ql4: #ececee;
3124
3244
  --x13g60fp: #f4f4f5;
3125
3245
  --x1dudhym: #fff;
@@ -3133,7 +3253,7 @@
3133
3253
  --xw4dauw: #71717a;
3134
3254
  }
3135
3255
 
3136
- .xohh2l7.xohh2l7, .xohh2l7.xohh2l7:root {
3256
+ .x1ht4xdt.x1ht4xdt, .x1ht4xdt.x1ht4xdt:root {
3137
3257
  --x11n7hvk: #fafafa;
3138
3258
  --x1vnpaut: #e4e4e7;
3139
3259
  --x1ljpve6: #ffffff1a;
@@ -3143,6 +3263,7 @@
3143
3263
  --x1fg5qi: #18181b;
3144
3264
  --x1xbnvpt: #131316;
3145
3265
  --xbtbsdh: #0f0f12;
3266
+ --x13vbpmf: #2c2c32;
3146
3267
  --xoa6ql4: #111113;
3147
3268
  --x13g60fp: #111113;
3148
3269
  --x1dudhym: #1f1f23;
@@ -3155,3 +3276,17 @@
3155
3276
  --xadaimi: #18181b;
3156
3277
  --xw4dauw: #a1a1aa;
3157
3278
  }
3279
+
3280
+ .xyim6s9 {
3281
+ --remove-opacity: 0;
3282
+ }
3283
+
3284
+ .x1f1teyk:focus-within, .x172mly1:hover {
3285
+ --remove-opacity: 1;
3286
+ }
3287
+
3288
+ @media (hover: none) {
3289
+ .x1ldwc8i.x1ldwc8i {
3290
+ --remove-opacity: 1;
3291
+ }
3292
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backmatter/studio",
3
- "version": "0.0.18",
3
+ "version": "0.0.20",
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.35",
59
+ "@backmatter/core": "^0.0.37",
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>;
@@ -364,11 +369,18 @@ export type SchemaField = {
364
369
  max?: number;
365
370
  step?: number;
366
371
  where?: Record<string, string | number | boolean>;
372
+ /** Guidance from the site developer: what goes here. */
373
+ description?: string;
367
374
  };
368
375
 
369
376
  export type BlockSnapshot = {
370
377
  name: string;
371
378
  fields: Record<string, SchemaField>;
379
+ /** Guidance from the site developer: when to use this block. */
380
+ description?: string;
381
+ group?: string;
382
+ placement?: "first" | "last" | "any";
383
+ maxPerPage?: number;
372
384
  };
373
385
 
374
386
  export type SchemaPayload = {
@@ -492,6 +504,13 @@ export function commitWorkspace(workspaceId: string, message?: string) {
492
504
  });
493
505
  }
494
506
 
507
+ /** Every problem a publish would hit. Nothing reaches git. */
508
+ export function checkWorkspaceChanges(workspaceId: string) {
509
+ return api<{ problems: Problem[]; checkId: string }>(`/workspaces/${workspaceId}/git/check`, {
510
+ method: "POST",
511
+ });
512
+ }
513
+
495
514
  export type CodeSessionEditList = {
496
515
  files: Array<{ path: string; deleted: boolean }>;
497
516
  skipped: Array<{ path: string; reason: string }>;
@@ -724,6 +743,34 @@ export function saveDoc(
724
743
  });
725
744
  }
726
745
 
746
+ /** Move a document to a new slug in my working tree. The old path is removed. */
747
+ export function renameDoc(
748
+ workspaceId: string,
749
+ type: string,
750
+ slug: string,
751
+ nextSlug: string,
752
+ ) {
753
+ return api<{
754
+ doc: {
755
+ type: string;
756
+ slug: string;
757
+ source: "tree";
758
+ status: DocStatus;
759
+ headSha: string | null;
760
+ };
761
+ }>(docApiPath(workspaceId, type, slug, "/rename"), {
762
+ method: "POST",
763
+ body: JSON.stringify({ slug: nextSlug }),
764
+ });
765
+ }
766
+
767
+ /** Remove a document from my working tree. */
768
+ export function deleteDoc(workspaceId: string, type: string, slug: string) {
769
+ return api<{ ok: true }>(docApiPath(workspaceId, type, slug), {
770
+ method: "DELETE",
771
+ });
772
+ }
773
+
727
774
  /** Drop my uncommitted copy; the doc reads from HEAD again. */
728
775
  export function revertDoc(
729
776
  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) : [];