@get-bb/plugin-sdk 0.6.33 → 0.6.37
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/bundled-types/bb-plugin-sdk-app.d.ts +608 -82
- package/bundled-types/bb-plugin-sdk-internal-composer-handle.d.ts +4 -0
- package/bundled-types/bb-plugin-sdk-internal-host-policy.d.ts +10 -0
- package/bundled-types/bb-plugin-sdk-internal-plugin-app-collector.d.ts +2 -1
- package/bundled-types/bb-plugin-sdk-provider-bridge-testing.d.ts +12 -0
- package/bundled-types/bb-plugin-sdk-provider-bridge.d.ts +16 -0
- package/bundled-types/bb-plugin-sdk-testing-app.d.ts +33 -18
- package/bundled-types/bb-plugin-sdk.d.ts +610 -84
- package/dist/app.js +33 -0
- package/dist/index.js +9 -0
- package/dist/internal/composer-handle.js +1 -0
- package/dist/internal/host-policy.js +11 -0
- package/dist/internal/plugin-app-collector.js +25 -0
- package/dist/provider-bridge-acp.js +5 -0
- package/dist/provider-bridge-testing.js +5 -0
- package/dist/provider-bridge.js +5 -0
- package/dist/testing/app.js +248 -2
- package/dist/testing/index.js +12 -0
- package/package.json +1 -1
package/dist/app.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
// src/thread-action-groups.ts
|
|
2
|
+
var experimental_THREAD_ACTION_GROUPS = {
|
|
3
|
+
open: "1_open",
|
|
4
|
+
organize: "2_organize",
|
|
5
|
+
settings: "3_settings",
|
|
6
|
+
lifecycle: "4_lifecycle"
|
|
7
|
+
};
|
|
8
|
+
|
|
1
9
|
// src/app.ts
|
|
2
10
|
function runtimeHost() {
|
|
3
11
|
return globalThis.__bbPluginRuntime;
|
|
@@ -101,6 +109,21 @@ var experimental_useSidebarThreads = runtimeFunction(
|
|
|
101
109
|
var experimental_useSidebarThreadActions = runtimeFunction(
|
|
102
110
|
"experimental_useSidebarThreadActions"
|
|
103
111
|
);
|
|
112
|
+
var experimental_useThreadActions = runtimeFunction(
|
|
113
|
+
"experimental_useThreadActions"
|
|
114
|
+
);
|
|
115
|
+
var experimental_useArchiveEnvironmentThreads = runtimeFunction(
|
|
116
|
+
"experimental_useArchiveEnvironmentThreads"
|
|
117
|
+
);
|
|
118
|
+
var experimental_useThreadActionRegistrations = runtimeFunction(
|
|
119
|
+
"experimental_useThreadActionRegistrations"
|
|
120
|
+
);
|
|
121
|
+
var experimental_ThreadActionsMenu = runtimeComponent(
|
|
122
|
+
"experimental_ThreadActionsMenu"
|
|
123
|
+
);
|
|
124
|
+
var experimental_ThreadActionsContextMenu = runtimeComponent(
|
|
125
|
+
"experimental_ThreadActionsContextMenu"
|
|
126
|
+
);
|
|
104
127
|
var experimental_useSidebarThreadPullRequest = runtimeFunction(
|
|
105
128
|
"experimental_useSidebarThreadPullRequest"
|
|
106
129
|
);
|
|
@@ -122,6 +145,9 @@ var useSidebarThreadShortcut = runtimeFunction(
|
|
|
122
145
|
"useSidebarThreadShortcut"
|
|
123
146
|
);
|
|
124
147
|
var ThreadTitle = runtimeComponent("ThreadTitle");
|
|
148
|
+
var experimental_ThreadStatusGlyph = runtimeComponent(
|
|
149
|
+
"experimental_ThreadStatusGlyph"
|
|
150
|
+
);
|
|
125
151
|
var useEnvironmentProviders = runtimeFunction(
|
|
126
152
|
"useEnvironmentProviders"
|
|
127
153
|
);
|
|
@@ -150,9 +176,14 @@ export {
|
|
|
150
176
|
experimental_ProviderIcon,
|
|
151
177
|
experimental_ProviderModelPicker,
|
|
152
178
|
experimental_SourceCode,
|
|
179
|
+
experimental_THREAD_ACTION_GROUPS,
|
|
180
|
+
experimental_ThreadActionsContextMenu,
|
|
181
|
+
experimental_ThreadActionsMenu,
|
|
182
|
+
experimental_ThreadStatusGlyph,
|
|
153
183
|
experimental_VoiceInputTextarea,
|
|
154
184
|
experimental_copyToClipboard,
|
|
155
185
|
experimental_useAppPanel,
|
|
186
|
+
experimental_useArchiveEnvironmentThreads,
|
|
156
187
|
experimental_useBranches,
|
|
157
188
|
experimental_useCheckoutState,
|
|
158
189
|
experimental_useCodeTheme,
|
|
@@ -164,6 +195,8 @@ export {
|
|
|
164
195
|
experimental_useSidebarThreadPullRequest,
|
|
165
196
|
experimental_useSidebarThreadSplit,
|
|
166
197
|
experimental_useSidebarThreads,
|
|
198
|
+
experimental_useThreadActionRegistrations,
|
|
199
|
+
experimental_useThreadActions,
|
|
167
200
|
useBbContext,
|
|
168
201
|
useBbNavigate,
|
|
169
202
|
useComposer,
|
package/dist/index.js
CHANGED
|
@@ -812,11 +812,20 @@ function experimental_defineHostEntry(args) {
|
|
|
812
812
|
function defineRpcContract(contract) {
|
|
813
813
|
return contract;
|
|
814
814
|
}
|
|
815
|
+
|
|
816
|
+
// src/thread-action-groups.ts
|
|
817
|
+
var experimental_THREAD_ACTION_GROUPS = {
|
|
818
|
+
open: "1_open",
|
|
819
|
+
organize: "2_organize",
|
|
820
|
+
settings: "3_settings",
|
|
821
|
+
lifecycle: "4_lifecycle"
|
|
822
|
+
};
|
|
815
823
|
export {
|
|
816
824
|
PLUGIN_CLI_OUTPUT_MAX_BYTES,
|
|
817
825
|
PluginCliError,
|
|
818
826
|
cliCommand,
|
|
819
827
|
defineCli,
|
|
820
828
|
defineRpcContract,
|
|
829
|
+
experimental_THREAD_ACTION_GROUPS,
|
|
821
830
|
experimental_defineHostEntry
|
|
822
831
|
};
|
|
@@ -86,6 +86,7 @@ var mentionSchema = z.discriminatedUnion("kind", [
|
|
|
86
86
|
origin: z.enum(["builtin", "project", "user"]),
|
|
87
87
|
argumentHint: z.string().nullable()
|
|
88
88
|
}),
|
|
89
|
+
z.object({ ...range, kind: z.literal("attachment"), path: z.string() }),
|
|
89
90
|
z.object({
|
|
90
91
|
...range,
|
|
91
92
|
kind: z.literal("plugin"),
|
|
@@ -400,6 +400,7 @@ var settingDescriptorSchema = z5.discriminatedUnion("type", [
|
|
|
400
400
|
type: z5.literal("select"),
|
|
401
401
|
...settingsBaseFields,
|
|
402
402
|
options: z5.array(z5.string().min(1)).min(1),
|
|
403
|
+
experimental_optionLabels: z5.record(z5.string().min(1), z5.string().min(1)).optional(),
|
|
403
404
|
experimental_schema: stringSettingSchemaSchema.optional(),
|
|
404
405
|
default: z5.string().optional()
|
|
405
406
|
}).strict(),
|
|
@@ -435,6 +436,16 @@ function registerSettingDescriptors(target, added) {
|
|
|
435
436
|
`default for setting "${key}" must be one of its options`
|
|
436
437
|
);
|
|
437
438
|
}
|
|
439
|
+
if (descriptor.type === "select") {
|
|
440
|
+
const unknownLabel = Object.keys(
|
|
441
|
+
descriptor.experimental_optionLabels ?? {}
|
|
442
|
+
).find((option) => !descriptor.options.includes(option));
|
|
443
|
+
if (unknownLabel !== void 0) {
|
|
444
|
+
throw new Error(
|
|
445
|
+
`label for setting "${key}" names "${unknownLabel}", which is not one of its options`
|
|
446
|
+
);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
438
449
|
if (descriptor.default !== void 0) {
|
|
439
450
|
const errors = validateSettingsUpdate(
|
|
440
451
|
{ [key]: descriptor },
|
|
@@ -471,6 +471,7 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
|
|
|
471
471
|
experimentalSidebarFooterItems: [],
|
|
472
472
|
threadLists: [],
|
|
473
473
|
threadHeaderActions: [],
|
|
474
|
+
threadActions: [],
|
|
474
475
|
browserToolbarActions: [],
|
|
475
476
|
fileOpeners: [],
|
|
476
477
|
sourceCodeRenderers: [],
|
|
@@ -499,6 +500,7 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
|
|
|
499
500
|
sidebarFooterItem: /* @__PURE__ */ new Set(),
|
|
500
501
|
threadList: /* @__PURE__ */ new Set(),
|
|
501
502
|
threadHeaderAction: /* @__PURE__ */ new Set(),
|
|
503
|
+
threadAction: /* @__PURE__ */ new Set(),
|
|
502
504
|
browserToolbarAction: /* @__PURE__ */ new Set(),
|
|
503
505
|
fileOpener: /* @__PURE__ */ new Set(),
|
|
504
506
|
sourceCodeRenderer: /* @__PURE__ */ new Set(),
|
|
@@ -735,6 +737,29 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
|
|
|
735
737
|
component: requireComponent(kind, registration.component)
|
|
736
738
|
});
|
|
737
739
|
},
|
|
740
|
+
experimental_threadAction(registration) {
|
|
741
|
+
const kind = "slots.experimental_threadAction";
|
|
742
|
+
const id = requireSlotId(kind, registration?.id);
|
|
743
|
+
requireUniqueId(kind, seenIds.threadAction, id);
|
|
744
|
+
if (typeof registration.item !== "function") {
|
|
745
|
+
throw new Error(`${kind}: "item" must be a function`);
|
|
746
|
+
}
|
|
747
|
+
if (registration.useData !== void 0 && typeof registration.useData !== "function") {
|
|
748
|
+
throw new Error(`${kind}: "useData" must be a function`);
|
|
749
|
+
}
|
|
750
|
+
if (registration.order !== void 0 && !Number.isFinite(registration.order)) {
|
|
751
|
+
throw new Error(`${kind}: "order" must be a finite number`);
|
|
752
|
+
}
|
|
753
|
+
collected.threadActions.push({
|
|
754
|
+
id,
|
|
755
|
+
title: requireNonEmptyString(kind, "title", registration.title),
|
|
756
|
+
icon: requireNonEmptyString(kind, "icon", registration.icon),
|
|
757
|
+
group: requireNonEmptyString(kind, "group", registration.group),
|
|
758
|
+
...registration.order !== void 0 ? { order: registration.order } : {},
|
|
759
|
+
...registration.useData !== void 0 ? { useData: registration.useData } : {},
|
|
760
|
+
item: registration.item
|
|
761
|
+
});
|
|
762
|
+
},
|
|
738
763
|
experimental_browserToolbarAction(registration) {
|
|
739
764
|
const kind = "slots.experimental_browserToolbarAction";
|
|
740
765
|
const id = requireSlotId(kind, registration?.id);
|
|
@@ -706,6 +706,11 @@ var canonicalPromptMentionResourceSchema = z3.discriminatedUnion("kind", [
|
|
|
706
706
|
icon: z3.string().nullable().optional(),
|
|
707
707
|
itemId: z3.string(),
|
|
708
708
|
label: z3.string()
|
|
709
|
+
}),
|
|
710
|
+
z3.object({
|
|
711
|
+
kind: z3.literal("attachment"),
|
|
712
|
+
path: z3.string(),
|
|
713
|
+
label: z3.string()
|
|
709
714
|
})
|
|
710
715
|
]);
|
|
711
716
|
function normalizeLegacyPromptMentionResource(value) {
|
|
@@ -141,6 +141,11 @@ var canonicalPromptMentionResourceSchema = z3.discriminatedUnion("kind", [
|
|
|
141
141
|
icon: z3.string().nullable().optional(),
|
|
142
142
|
itemId: z3.string(),
|
|
143
143
|
label: z3.string()
|
|
144
|
+
}),
|
|
145
|
+
z3.object({
|
|
146
|
+
kind: z3.literal("attachment"),
|
|
147
|
+
path: z3.string(),
|
|
148
|
+
label: z3.string()
|
|
144
149
|
})
|
|
145
150
|
]);
|
|
146
151
|
function normalizeLegacyPromptMentionResource(value) {
|
package/dist/provider-bridge.js
CHANGED
|
@@ -1199,6 +1199,11 @@ var canonicalPromptMentionResourceSchema = z5.discriminatedUnion("kind", [
|
|
|
1199
1199
|
icon: z5.string().nullable().optional(),
|
|
1200
1200
|
itemId: z5.string(),
|
|
1201
1201
|
label: z5.string()
|
|
1202
|
+
}),
|
|
1203
|
+
z5.object({
|
|
1204
|
+
kind: z5.literal("attachment"),
|
|
1205
|
+
path: z5.string(),
|
|
1206
|
+
label: z5.string()
|
|
1202
1207
|
})
|
|
1203
1208
|
]);
|
|
1204
1209
|
function normalizeLegacyPromptMentionResource(value) {
|
package/dist/testing/app.js
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import {
|
|
4
4
|
createContext,
|
|
5
|
+
useCallback,
|
|
5
6
|
useContext,
|
|
7
|
+
useLayoutEffect,
|
|
6
8
|
useEffect,
|
|
7
9
|
useMemo,
|
|
8
10
|
useRef,
|
|
@@ -104,6 +106,7 @@ var mentionSchema = z.discriminatedUnion("kind", [
|
|
|
104
106
|
origin: z.enum(["builtin", "project", "user"]),
|
|
105
107
|
argumentHint: z.string().nullable()
|
|
106
108
|
}),
|
|
109
|
+
z.object({ ...range, kind: z.literal("attachment"), path: z.string() }),
|
|
107
110
|
z.object({
|
|
108
111
|
...range,
|
|
109
112
|
kind: z.literal("plugin"),
|
|
@@ -954,6 +957,14 @@ function normalizeExperimentalFileOpenOptions(value) {
|
|
|
954
957
|
return { target, location };
|
|
955
958
|
}
|
|
956
959
|
|
|
960
|
+
// src/thread-action-groups.ts
|
|
961
|
+
var experimental_THREAD_ACTION_GROUPS = {
|
|
962
|
+
open: "1_open",
|
|
963
|
+
organize: "2_organize",
|
|
964
|
+
settings: "3_settings",
|
|
965
|
+
lifecycle: "4_lifecycle"
|
|
966
|
+
};
|
|
967
|
+
|
|
957
968
|
// src/internal/plugin-app-collector.ts
|
|
958
969
|
import { z as z2 } from "zod";
|
|
959
970
|
var sidebarFooterCommandSequence = 0;
|
|
@@ -1176,6 +1187,7 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
|
|
|
1176
1187
|
experimentalSidebarFooterItems: [],
|
|
1177
1188
|
threadLists: [],
|
|
1178
1189
|
threadHeaderActions: [],
|
|
1190
|
+
threadActions: [],
|
|
1179
1191
|
browserToolbarActions: [],
|
|
1180
1192
|
fileOpeners: [],
|
|
1181
1193
|
sourceCodeRenderers: [],
|
|
@@ -1204,6 +1216,7 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
|
|
|
1204
1216
|
sidebarFooterItem: /* @__PURE__ */ new Set(),
|
|
1205
1217
|
threadList: /* @__PURE__ */ new Set(),
|
|
1206
1218
|
threadHeaderAction: /* @__PURE__ */ new Set(),
|
|
1219
|
+
threadAction: /* @__PURE__ */ new Set(),
|
|
1207
1220
|
browserToolbarAction: /* @__PURE__ */ new Set(),
|
|
1208
1221
|
fileOpener: /* @__PURE__ */ new Set(),
|
|
1209
1222
|
sourceCodeRenderer: /* @__PURE__ */ new Set(),
|
|
@@ -1440,6 +1453,29 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
|
|
|
1440
1453
|
component: requireComponent(kind, registration.component)
|
|
1441
1454
|
});
|
|
1442
1455
|
},
|
|
1456
|
+
experimental_threadAction(registration) {
|
|
1457
|
+
const kind = "slots.experimental_threadAction";
|
|
1458
|
+
const id = requireSlotId(kind, registration?.id);
|
|
1459
|
+
requireUniqueId(kind, seenIds.threadAction, id);
|
|
1460
|
+
if (typeof registration.item !== "function") {
|
|
1461
|
+
throw new Error(`${kind}: "item" must be a function`);
|
|
1462
|
+
}
|
|
1463
|
+
if (registration.useData !== void 0 && typeof registration.useData !== "function") {
|
|
1464
|
+
throw new Error(`${kind}: "useData" must be a function`);
|
|
1465
|
+
}
|
|
1466
|
+
if (registration.order !== void 0 && !Number.isFinite(registration.order)) {
|
|
1467
|
+
throw new Error(`${kind}: "order" must be a finite number`);
|
|
1468
|
+
}
|
|
1469
|
+
collected.threadActions.push({
|
|
1470
|
+
id,
|
|
1471
|
+
title: requireNonEmptyString(kind, "title", registration.title),
|
|
1472
|
+
icon: requireNonEmptyString(kind, "icon", registration.icon),
|
|
1473
|
+
group: requireNonEmptyString(kind, "group", registration.group),
|
|
1474
|
+
...registration.order !== void 0 ? { order: registration.order } : {},
|
|
1475
|
+
...registration.useData !== void 0 ? { useData: registration.useData } : {},
|
|
1476
|
+
item: registration.item
|
|
1477
|
+
});
|
|
1478
|
+
},
|
|
1443
1479
|
experimental_browserToolbarAction(registration) {
|
|
1444
1480
|
const kind = "slots.experimental_browserToolbarAction";
|
|
1445
1481
|
const id = requireSlotId(kind, registration?.id);
|
|
@@ -1654,6 +1690,7 @@ function testComposerMentionText(mention) {
|
|
|
1654
1690
|
case "command":
|
|
1655
1691
|
return `${mention.trigger}${mention.name}`;
|
|
1656
1692
|
case "plugin":
|
|
1693
|
+
case "attachment":
|
|
1657
1694
|
return `@${mention.label}`;
|
|
1658
1695
|
case "path": {
|
|
1659
1696
|
const path = mention.source === "thread-storage" ? `thread-storage:${mention.path}` : mention.path;
|
|
@@ -1694,6 +1731,25 @@ function TestThreadTitle({ threadId }) {
|
|
|
1694
1731
|
if (thread === void 0) return null;
|
|
1695
1732
|
return /* @__PURE__ */ jsx("span", { "data-thread-title": threadId, children: thread.displayTitle });
|
|
1696
1733
|
}
|
|
1734
|
+
function TestThreadStatusGlyph({
|
|
1735
|
+
indicator,
|
|
1736
|
+
archived = false,
|
|
1737
|
+
rowStatus = null,
|
|
1738
|
+
hideIdleDraftLabel = false,
|
|
1739
|
+
size = "default"
|
|
1740
|
+
}) {
|
|
1741
|
+
if (!archived && indicator === "none" && rowStatus === null) return null;
|
|
1742
|
+
return /* @__PURE__ */ jsx(
|
|
1743
|
+
"span",
|
|
1744
|
+
{
|
|
1745
|
+
"data-thread-status-glyph": archived ? "archived" : indicator,
|
|
1746
|
+
"data-row-status": rowStatus?.label,
|
|
1747
|
+
"data-row-status-tone": rowStatus?.tone,
|
|
1748
|
+
"data-hide-idle-draft-label": hideIdleDraftLabel ? "" : void 0,
|
|
1749
|
+
"data-size": size
|
|
1750
|
+
}
|
|
1751
|
+
);
|
|
1752
|
+
}
|
|
1697
1753
|
function SlotLifecycleGuard({
|
|
1698
1754
|
children,
|
|
1699
1755
|
onUnmount
|
|
@@ -1702,6 +1758,161 @@ function SlotLifecycleGuard({
|
|
|
1702
1758
|
return children;
|
|
1703
1759
|
}
|
|
1704
1760
|
var SlotEnvContext = createContext(null);
|
|
1761
|
+
var NO_THREAD_ACTIONS = () => [];
|
|
1762
|
+
var NO_THREAD_ACTION_REGISTRATIONS = [];
|
|
1763
|
+
function noRenameEditor() {
|
|
1764
|
+
}
|
|
1765
|
+
function useTestThreadActions(hook, thread, options) {
|
|
1766
|
+
const entries = useSlotEnv(hook).threadActions(thread, {
|
|
1767
|
+
requestRename: options?.requestRename ?? noRenameEditor
|
|
1768
|
+
});
|
|
1769
|
+
const keys = options?.keys;
|
|
1770
|
+
if (keys === void 0) return entries;
|
|
1771
|
+
return keys.flatMap((key) => {
|
|
1772
|
+
const entry = entries.find((candidate) => candidate.key === key);
|
|
1773
|
+
return entry === void 0 ? [] : [entry];
|
|
1774
|
+
});
|
|
1775
|
+
}
|
|
1776
|
+
function TestThreadActionsMenuItems({
|
|
1777
|
+
hook,
|
|
1778
|
+
thread,
|
|
1779
|
+
inline = [],
|
|
1780
|
+
requestRename,
|
|
1781
|
+
onClose
|
|
1782
|
+
}) {
|
|
1783
|
+
const rename = requestRename ?? noRenameEditor;
|
|
1784
|
+
const entries = useTestThreadActions(hook, thread, { requestRename: rename });
|
|
1785
|
+
const rows = [
|
|
1786
|
+
...entries.map((entry) => ({
|
|
1787
|
+
key: entry.key,
|
|
1788
|
+
action: entry.action,
|
|
1789
|
+
run: () => entry.action.run()
|
|
1790
|
+
})),
|
|
1791
|
+
...inline.map((item) => ({
|
|
1792
|
+
key: item.key,
|
|
1793
|
+
action: item.action,
|
|
1794
|
+
run: () => item.action.run({ requestRename: rename })
|
|
1795
|
+
}))
|
|
1796
|
+
];
|
|
1797
|
+
return /* @__PURE__ */ jsx("div", { role: "menu", "aria-label": "Thread actions", children: rows.map((row) => /* @__PURE__ */ jsx(
|
|
1798
|
+
"button",
|
|
1799
|
+
{
|
|
1800
|
+
type: "button",
|
|
1801
|
+
role: "menuitem",
|
|
1802
|
+
"data-thread-action": row.key,
|
|
1803
|
+
disabled: row.action.disabled,
|
|
1804
|
+
onClick: () => {
|
|
1805
|
+
void row.run();
|
|
1806
|
+
onClose();
|
|
1807
|
+
},
|
|
1808
|
+
children: row.action.label
|
|
1809
|
+
},
|
|
1810
|
+
row.key
|
|
1811
|
+
)) });
|
|
1812
|
+
}
|
|
1813
|
+
function useTestMenuOpenState({
|
|
1814
|
+
onOpenChange,
|
|
1815
|
+
onCloseAutoFocus
|
|
1816
|
+
}) {
|
|
1817
|
+
const [open, setOpen] = useState(false);
|
|
1818
|
+
return {
|
|
1819
|
+
open,
|
|
1820
|
+
show: () => {
|
|
1821
|
+
setOpen(true);
|
|
1822
|
+
onOpenChange?.(true);
|
|
1823
|
+
},
|
|
1824
|
+
close: () => {
|
|
1825
|
+
setOpen(false);
|
|
1826
|
+
onOpenChange?.(false);
|
|
1827
|
+
onCloseAutoFocus?.(new Event("focus", { cancelable: true }));
|
|
1828
|
+
}
|
|
1829
|
+
};
|
|
1830
|
+
}
|
|
1831
|
+
var TEST_TRIGGER_HOST_CLASS = "bb-test-thread-actions-trigger";
|
|
1832
|
+
function TestThreadActionsMenu({
|
|
1833
|
+
thread,
|
|
1834
|
+
trigger,
|
|
1835
|
+
inline,
|
|
1836
|
+
requestRename,
|
|
1837
|
+
onOpenChange,
|
|
1838
|
+
onCloseAutoFocus
|
|
1839
|
+
}) {
|
|
1840
|
+
const menu = useTestMenuOpenState({ onOpenChange, onCloseAutoFocus });
|
|
1841
|
+
const triggerElement = useRef(null);
|
|
1842
|
+
useLayoutEffect(() => {
|
|
1843
|
+
const element = triggerElement.current;
|
|
1844
|
+
if (element?.getAttribute("aria-haspopup") !== "menu") {
|
|
1845
|
+
throw new Error(
|
|
1846
|
+
"experimental_ThreadActionsMenu: `trigger` must spread the props and ref it receives onto the button it renders, or the menu never opens"
|
|
1847
|
+
);
|
|
1848
|
+
}
|
|
1849
|
+
if (!element.classList.contains(TEST_TRIGGER_HOST_CLASS)) {
|
|
1850
|
+
throw new Error(
|
|
1851
|
+
"experimental_ThreadActionsMenu: `trigger` replaced the host's className; merge props.className into its own"
|
|
1852
|
+
);
|
|
1853
|
+
}
|
|
1854
|
+
});
|
|
1855
|
+
return /* @__PURE__ */ jsxs("span", { "data-testid": "bb-thread-actions-menu", "data-thread-id": thread.id, children: [
|
|
1856
|
+
trigger({
|
|
1857
|
+
ref: triggerElement,
|
|
1858
|
+
type: "button",
|
|
1859
|
+
className: TEST_TRIGGER_HOST_CLASS,
|
|
1860
|
+
"aria-haspopup": "menu",
|
|
1861
|
+
"aria-expanded": menu.open,
|
|
1862
|
+
onClick: menu.show
|
|
1863
|
+
}),
|
|
1864
|
+
menu.open ? /* @__PURE__ */ jsx(
|
|
1865
|
+
TestThreadActionsMenuItems,
|
|
1866
|
+
{
|
|
1867
|
+
hook: "experimental_ThreadActionsMenu",
|
|
1868
|
+
thread,
|
|
1869
|
+
inline,
|
|
1870
|
+
requestRename,
|
|
1871
|
+
onClose: menu.close
|
|
1872
|
+
}
|
|
1873
|
+
) : null
|
|
1874
|
+
] });
|
|
1875
|
+
}
|
|
1876
|
+
function TestThreadActionsContextMenu({
|
|
1877
|
+
thread,
|
|
1878
|
+
children,
|
|
1879
|
+
inline,
|
|
1880
|
+
requestRename,
|
|
1881
|
+
onOpenChange,
|
|
1882
|
+
onCloseAutoFocus,
|
|
1883
|
+
disabled,
|
|
1884
|
+
dragging
|
|
1885
|
+
}) {
|
|
1886
|
+
const menu = useTestMenuOpenState({ onOpenChange, onCloseAutoFocus });
|
|
1887
|
+
return /* @__PURE__ */ jsxs(
|
|
1888
|
+
"div",
|
|
1889
|
+
{
|
|
1890
|
+
"data-testid": "bb-thread-actions-context-menu",
|
|
1891
|
+
"data-thread-id": thread.id,
|
|
1892
|
+
"data-disabled": disabled === true ? "true" : "false",
|
|
1893
|
+
"data-dragging": dragging === true ? "true" : "false",
|
|
1894
|
+
className: "contents",
|
|
1895
|
+
onContextMenu: (event) => {
|
|
1896
|
+
if (disabled === true || dragging === true) return;
|
|
1897
|
+
event.preventDefault();
|
|
1898
|
+
menu.show();
|
|
1899
|
+
},
|
|
1900
|
+
children: [
|
|
1901
|
+
children,
|
|
1902
|
+
menu.open ? /* @__PURE__ */ jsx(
|
|
1903
|
+
TestThreadActionsMenuItems,
|
|
1904
|
+
{
|
|
1905
|
+
hook: "experimental_ThreadActionsContextMenu",
|
|
1906
|
+
thread,
|
|
1907
|
+
inline,
|
|
1908
|
+
requestRename,
|
|
1909
|
+
onClose: menu.close
|
|
1910
|
+
}
|
|
1911
|
+
) : null
|
|
1912
|
+
]
|
|
1913
|
+
}
|
|
1914
|
+
);
|
|
1915
|
+
}
|
|
1705
1916
|
function useSlotEnv(hook) {
|
|
1706
1917
|
const env = useContext(SlotEnvContext);
|
|
1707
1918
|
if (!env) {
|
|
@@ -2277,6 +2488,30 @@ var testPluginSdkApp = {
|
|
|
2277
2488
|
experimental_useSidebarThreadActions() {
|
|
2278
2489
|
return useSlotEnv("experimental_useSidebarThreadActions").sidebarActions;
|
|
2279
2490
|
},
|
|
2491
|
+
experimental_useThreadActions(thread, options) {
|
|
2492
|
+
return useTestThreadActions(
|
|
2493
|
+
"experimental_useThreadActions",
|
|
2494
|
+
thread,
|
|
2495
|
+
options
|
|
2496
|
+
);
|
|
2497
|
+
},
|
|
2498
|
+
experimental_useArchiveEnvironmentThreads() {
|
|
2499
|
+
const calls = useSlotEnv(
|
|
2500
|
+
"experimental_useArchiveEnvironmentThreads"
|
|
2501
|
+
).environmentArchiveCalls;
|
|
2502
|
+
return useCallback(
|
|
2503
|
+
async (environmentId) => {
|
|
2504
|
+
calls.push(environmentId);
|
|
2505
|
+
},
|
|
2506
|
+
[calls]
|
|
2507
|
+
);
|
|
2508
|
+
},
|
|
2509
|
+
experimental_useThreadActionRegistrations() {
|
|
2510
|
+
return useSlotEnv("experimental_useThreadActionRegistrations").threadActionRegistrations;
|
|
2511
|
+
},
|
|
2512
|
+
experimental_ThreadActionsMenu: TestThreadActionsMenu,
|
|
2513
|
+
experimental_ThreadActionsContextMenu: TestThreadActionsContextMenu,
|
|
2514
|
+
experimental_THREAD_ACTION_GROUPS,
|
|
2280
2515
|
experimental_useSidebarThreadSplit(threadId) {
|
|
2281
2516
|
const env = useSlotEnv("experimental_useSidebarThreadSplit");
|
|
2282
2517
|
return useMemo(
|
|
@@ -2317,6 +2552,7 @@ var testPluginSdkApp = {
|
|
|
2317
2552
|
return env.sidebarShortcuts.get(threadId) ?? null;
|
|
2318
2553
|
},
|
|
2319
2554
|
ThreadTitle: TestThreadTitle,
|
|
2555
|
+
experimental_ThreadStatusGlyph: TestThreadStatusGlyph,
|
|
2320
2556
|
useEnvironmentProviders() {
|
|
2321
2557
|
return useSlotEnv("useEnvironmentProviders").environmentProviders;
|
|
2322
2558
|
},
|
|
@@ -2609,6 +2845,7 @@ function renderSlot(registration, props, options = {}) {
|
|
|
2609
2845
|
}
|
|
2610
2846
|
};
|
|
2611
2847
|
const sidebarActionCalls = [];
|
|
2848
|
+
const environmentArchiveCalls = [];
|
|
2612
2849
|
const sidebarPullRequests = new Map(
|
|
2613
2850
|
Object.entries(options.sidebarPullRequests ?? {})
|
|
2614
2851
|
);
|
|
@@ -2684,8 +2921,12 @@ function renderSlot(registration, props, options = {}) {
|
|
|
2684
2921
|
}
|
|
2685
2922
|
};
|
|
2686
2923
|
const navigate = {
|
|
2687
|
-
toThread(threadId2) {
|
|
2688
|
-
navigateCalls.push({
|
|
2924
|
+
toThread(threadId2, threadOptions) {
|
|
2925
|
+
navigateCalls.push({
|
|
2926
|
+
method: "toThread",
|
|
2927
|
+
threadId: threadId2,
|
|
2928
|
+
...threadOptions !== void 0 ? { options: threadOptions } : {}
|
|
2929
|
+
});
|
|
2689
2930
|
},
|
|
2690
2931
|
toProject(projectId2) {
|
|
2691
2932
|
navigateCalls.push({ method: "toProject", projectId: projectId2 });
|
|
@@ -2989,6 +3230,9 @@ ${block}
|
|
|
2989
3230
|
sidebarThreads,
|
|
2990
3231
|
sidebarActions,
|
|
2991
3232
|
sidebarActionCalls,
|
|
3233
|
+
environmentArchiveCalls,
|
|
3234
|
+
threadActions: options.threadActions ?? NO_THREAD_ACTIONS,
|
|
3235
|
+
threadActionRegistrations: options.threadActionRegistrations ?? NO_THREAD_ACTION_REGISTRATIONS,
|
|
2992
3236
|
sidebarPullRequests,
|
|
2993
3237
|
sidebarDraftThreadIds,
|
|
2994
3238
|
sidebarRowStatuses,
|
|
@@ -3065,6 +3309,7 @@ ${block}
|
|
|
3065
3309
|
navigateCalls,
|
|
3066
3310
|
experimental_fixedTabOpenCalls,
|
|
3067
3311
|
sidebarActionCalls,
|
|
3312
|
+
experimental_environmentArchiveCalls: environmentArchiveCalls,
|
|
3068
3313
|
sdkCalls,
|
|
3069
3314
|
experimental_clipboardWrites,
|
|
3070
3315
|
composer: composerLog,
|
|
@@ -3079,6 +3324,7 @@ ${block}
|
|
|
3079
3324
|
navigateCalls,
|
|
3080
3325
|
experimental_fixedTabOpenCalls,
|
|
3081
3326
|
sidebarActionCalls,
|
|
3327
|
+
experimental_environmentArchiveCalls: environmentArchiveCalls,
|
|
3082
3328
|
sdkCalls,
|
|
3083
3329
|
experimental_clipboardWrites,
|
|
3084
3330
|
composer: composerLog
|
package/dist/testing/index.js
CHANGED
|
@@ -445,6 +445,7 @@ var settingDescriptorSchema = z5.discriminatedUnion("type", [
|
|
|
445
445
|
type: z5.literal("select"),
|
|
446
446
|
...settingsBaseFields,
|
|
447
447
|
options: z5.array(z5.string().min(1)).min(1),
|
|
448
|
+
experimental_optionLabels: z5.record(z5.string().min(1), z5.string().min(1)).optional(),
|
|
448
449
|
experimental_schema: stringSettingSchemaSchema.optional(),
|
|
449
450
|
default: z5.string().optional()
|
|
450
451
|
}).strict(),
|
|
@@ -480,6 +481,16 @@ function registerSettingDescriptors(target, added) {
|
|
|
480
481
|
`default for setting "${key}" must be one of its options`
|
|
481
482
|
);
|
|
482
483
|
}
|
|
484
|
+
if (descriptor.type === "select") {
|
|
485
|
+
const unknownLabel = Object.keys(
|
|
486
|
+
descriptor.experimental_optionLabels ?? {}
|
|
487
|
+
).find((option) => !descriptor.options.includes(option));
|
|
488
|
+
if (unknownLabel !== void 0) {
|
|
489
|
+
throw new Error(
|
|
490
|
+
`label for setting "${key}" names "${unknownLabel}", which is not one of its options`
|
|
491
|
+
);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
483
494
|
if (descriptor.default !== void 0) {
|
|
484
495
|
const errors = validateSettingsUpdate(
|
|
485
496
|
{ [key]: descriptor },
|
|
@@ -2823,6 +2834,7 @@ function normalizeCallArgs(pluginId, path, args) {
|
|
|
2823
2834
|
case "threads.fork":
|
|
2824
2835
|
return withThreadAttribution(pluginId, args);
|
|
2825
2836
|
case "threads.getPluginMetadata":
|
|
2837
|
+
case "threads.experimental_listPluginMetadata":
|
|
2826
2838
|
return withPluginMetadataTarget(pluginId, args, false);
|
|
2827
2839
|
case "threads.updatePluginMetadata":
|
|
2828
2840
|
return withPluginMetadataTarget(pluginId, args, true);
|