@get-bb/plugin-sdk 0.6.144 → 0.6.146

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.
@@ -1220,6 +1220,7 @@ interface ExperimentalFakeHostRpcCall {
1220
1220
  input: unknown;
1221
1221
  hostId: string;
1222
1222
  signal?: AbortSignal;
1223
+ timeoutMs?: number;
1223
1224
  }
1224
1225
  /** Everything the plugin registered, exposed raw for assertions. */
1225
1226
  interface FakePluginRegistrations {
@@ -80,7 +80,7 @@ var experimental_PluginRpcRefusal = class extends Error {
80
80
  };
81
81
 
82
82
  // src/internal/rpc-query-host.ts
83
- import { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2 } from "react";
83
+ import { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
84
84
  import { useIsFetching } from "@tanstack/react-query";
85
85
 
86
86
  // ../query-tags/src/index.ts
@@ -2378,6 +2378,17 @@ var tagsOf = (data) => [
2378
2378
  ...data.tags,
2379
2379
  ...Object.values(data.keyTags).flat()
2380
2380
  ];
2381
+ function useParsedRpcInput(input) {
2382
+ const identity = JSON.stringify(input ?? null);
2383
+ const [parsed, setParsed] = useState2(() => ({
2384
+ identity,
2385
+ value: jsonValueSchema.parse(input ?? null)
2386
+ }));
2387
+ if (parsed.identity === identity) return parsed.value;
2388
+ const next = { identity, value: jsonValueSchema.parse(input ?? null) };
2389
+ setParsed(next);
2390
+ return next.value;
2391
+ }
2381
2392
  var owners = /* @__PURE__ */ new WeakMap();
2382
2393
  function createRpcQueryHooks(useHost) {
2383
2394
  function useSubscription(host, pluginId, enabled) {
@@ -2389,8 +2400,11 @@ function createRpcQueryHooks(useHost) {
2389
2400
  const experimental_useRpcQuery = (options) => {
2390
2401
  const host = useHost();
2391
2402
  const pluginId = resolvePluginId(host, options.pluginId);
2392
- const input = jsonValueSchema.parse(options.input ?? null);
2393
- const queryKey = rpcQueryKey(pluginId, options.method, input);
2403
+ const input = useParsedRpcInput(options.input);
2404
+ const queryKey = useMemo2(
2405
+ () => rpcQueryKey(pluginId, options.method, input),
2406
+ [input, options.method, pluginId]
2407
+ );
2394
2408
  useSubscription(host, pluginId, options.enabled ?? true);
2395
2409
  const watchIdentity = canonicalPluginReadInput(input);
2396
2410
  useEffect2(() => {
@@ -2415,18 +2429,24 @@ function createRpcQueryHooks(useHost) {
2415
2429
  },
2416
2430
  host.queryClient
2417
2431
  );
2418
- return {
2419
- data: query.data?.result,
2420
- error: query.error === null ? null : experimental_PluginRpcCallError.from(
2421
- query.error,
2432
+ const { refetch: refetchQuery, error: queryError } = query;
2433
+ const refetch = useCallback2(async () => {
2434
+ await refetchQuery();
2435
+ }, [refetchQuery]);
2436
+ const error = useMemo2(
2437
+ () => queryError === null ? null : experimental_PluginRpcCallError.from(
2438
+ queryError,
2422
2439
  "invalid_response"
2423
2440
  ),
2424
- isLoading: (options.enabled ?? true) && query.isLoading,
2425
- isFetching: query.isFetching,
2426
- refetch: async () => {
2427
- await query.refetch();
2428
- }
2429
- };
2441
+ [queryError]
2442
+ );
2443
+ const data = query.data?.result;
2444
+ const isLoading = (options.enabled ?? true) && query.isLoading;
2445
+ const isFetching = query.isFetching;
2446
+ return useMemo2(
2447
+ () => ({ data, error, isLoading, isFetching, refetch }),
2448
+ [data, error, isFetching, isLoading, refetch]
2449
+ );
2430
2450
  };
2431
2451
  function experimental_useRpcKeyedQuery(options) {
2432
2452
  const host = useHost();
@@ -2532,11 +2552,14 @@ function createRpcQueryHooks(useHost) {
2532
2552
  },
2533
2553
  [current, keys]
2534
2554
  );
2535
- return {
2536
- ...query,
2537
- refetch,
2538
- refetchKeys
2539
- };
2555
+ return useMemo2(
2556
+ () => ({
2557
+ ...query,
2558
+ refetch,
2559
+ refetchKeys
2560
+ }),
2561
+ [query, refetch, refetchKeys]
2562
+ );
2540
2563
  }
2541
2564
  function experimental_useRpcMutation(options) {
2542
2565
  const host = useHost();
@@ -1278,7 +1278,7 @@ function useQuerySelection(subscribe, getSnapshot, select) {
1278
1278
  import { QueryClient } from "@tanstack/react-query";
1279
1279
 
1280
1280
  // src/internal/rpc-query-host.ts
1281
- import { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2 } from "react";
1281
+ import { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
1282
1282
  import { useIsFetching } from "@tanstack/react-query";
1283
1283
 
1284
1284
  // ../domain/src/shared-types.ts
@@ -2381,6 +2381,17 @@ var tagsOf = (data) => [
2381
2381
  ...data.tags,
2382
2382
  ...Object.values(data.keyTags).flat()
2383
2383
  ];
2384
+ function useParsedRpcInput(input) {
2385
+ const identity = JSON.stringify(input ?? null);
2386
+ const [parsed, setParsed] = useState2(() => ({
2387
+ identity,
2388
+ value: jsonValueSchema.parse(input ?? null)
2389
+ }));
2390
+ if (parsed.identity === identity) return parsed.value;
2391
+ const next = { identity, value: jsonValueSchema.parse(input ?? null) };
2392
+ setParsed(next);
2393
+ return next.value;
2394
+ }
2384
2395
  var owners = /* @__PURE__ */ new WeakMap();
2385
2396
  function createRpcQueryHooks(useHost) {
2386
2397
  function useSubscription(host, pluginId, enabled) {
@@ -2392,8 +2403,11 @@ function createRpcQueryHooks(useHost) {
2392
2403
  const experimental_useRpcQuery = (options) => {
2393
2404
  const host = useHost();
2394
2405
  const pluginId = resolvePluginId(host, options.pluginId);
2395
- const input = jsonValueSchema.parse(options.input ?? null);
2396
- const queryKey = rpcQueryKey(pluginId, options.method, input);
2406
+ const input = useParsedRpcInput(options.input);
2407
+ const queryKey = useMemo2(
2408
+ () => rpcQueryKey(pluginId, options.method, input),
2409
+ [input, options.method, pluginId]
2410
+ );
2397
2411
  useSubscription(host, pluginId, options.enabled ?? true);
2398
2412
  const watchIdentity = canonicalPluginReadInput(input);
2399
2413
  useEffect2(() => {
@@ -2418,18 +2432,24 @@ function createRpcQueryHooks(useHost) {
2418
2432
  },
2419
2433
  host.queryClient
2420
2434
  );
2421
- return {
2422
- data: query.data?.result,
2423
- error: query.error === null ? null : experimental_PluginRpcCallError.from(
2424
- query.error,
2435
+ const { refetch: refetchQuery, error: queryError } = query;
2436
+ const refetch = useCallback2(async () => {
2437
+ await refetchQuery();
2438
+ }, [refetchQuery]);
2439
+ const error = useMemo2(
2440
+ () => queryError === null ? null : experimental_PluginRpcCallError.from(
2441
+ queryError,
2425
2442
  "invalid_response"
2426
2443
  ),
2427
- isLoading: (options.enabled ?? true) && query.isLoading,
2428
- isFetching: query.isFetching,
2429
- refetch: async () => {
2430
- await query.refetch();
2431
- }
2432
- };
2444
+ [queryError]
2445
+ );
2446
+ const data = query.data?.result;
2447
+ const isLoading = (options.enabled ?? true) && query.isLoading;
2448
+ const isFetching = query.isFetching;
2449
+ return useMemo2(
2450
+ () => ({ data, error, isLoading, isFetching, refetch }),
2451
+ [data, error, isFetching, isLoading, refetch]
2452
+ );
2433
2453
  };
2434
2454
  function experimental_useRpcKeyedQuery(options) {
2435
2455
  const host = useHost();
@@ -2535,11 +2555,14 @@ function createRpcQueryHooks(useHost) {
2535
2555
  },
2536
2556
  [current, keys]
2537
2557
  );
2538
- return {
2539
- ...query,
2540
- refetch,
2541
- refetchKeys
2542
- };
2558
+ return useMemo2(
2559
+ () => ({
2560
+ ...query,
2561
+ refetch,
2562
+ refetchKeys
2563
+ }),
2564
+ [query, refetch, refetchKeys]
2565
+ );
2543
2566
  }
2544
2567
  function experimental_useRpcMutation(options) {
2545
2568
  const host = useHost();
@@ -2621,7 +2644,7 @@ import {
2621
2644
  useEffect as useEffect3,
2622
2645
  useMemo as useMemo3,
2623
2646
  useRef as useRef3,
2624
- useState as useState2,
2647
+ useState as useState3,
2625
2648
  useSyncExternalStore as useSyncExternalStore2
2626
2649
  } from "react";
2627
2650
  import { act, render } from "@testing-library/react";
@@ -4969,7 +4992,7 @@ function useTestMenuOpenState({
4969
4992
  onOpenChange,
4970
4993
  onCloseAutoFocus
4971
4994
  }) {
4972
- const [open, setOpen] = useState2(false);
4995
+ const [open, setOpen] = useState3(false);
4973
4996
  return {
4974
4997
  open,
4975
4998
  show: () => {
@@ -5237,7 +5260,7 @@ function TestNewThreadComposer({
5237
5260
  draftKey,
5238
5261
  onSubmit
5239
5262
  }) {
5240
- const [text, setText] = useState2(initialPrompt ?? "");
5263
+ const [text, setText] = useState3(initialPrompt ?? "");
5241
5264
  return /* @__PURE__ */ jsxs(
5242
5265
  "div",
5243
5266
  {
@@ -5297,7 +5320,7 @@ function TestProviderModelPicker({
5297
5320
  disabled,
5298
5321
  className
5299
5322
  }) {
5300
- const [draft, setDraft] = useState2(value);
5323
+ const [draft, setDraft] = useState3(value);
5301
5324
  const { providerId, model, reasoningLevel, serviceTier } = value;
5302
5325
  useEffect3(
5303
5326
  () => setDraft({
@@ -5574,7 +5597,10 @@ function TestVoiceInputTextarea({
5574
5597
  }
5575
5598
  );
5576
5599
  }
5577
- function TestFilePreview({ target, renderPreview }) {
5600
+ function TestFilePreview({
5601
+ target,
5602
+ renderPreview
5603
+ }) {
5578
5604
  const file = useSlotEnv("experimental_FilePreview").filePreview(target);
5579
5605
  return /* @__PURE__ */ jsx("div", { "data-testid": "bb-file-preview", "data-path": target.path, children: file === null ? null : renderPreview(file) });
5580
5606
  }
@@ -5991,18 +6017,23 @@ var testPluginSdkApp = {
5991
6017
  experimental_SidebarNavigationIcon: TestSidebarNavigationIcon,
5992
6018
  experimental_useSidebarThreadSplit(threadId) {
5993
6019
  const env = useSlotEnv("experimental_useSidebarThreadSplit");
5994
- return useMemo3(
5995
- () => ({
6020
+ return useMemo3(() => {
6021
+ const panes = env.sidebarSplitLayout?.panes.map((pane) => ({
6022
+ paneId: pane.paneId,
6023
+ rect: pane.rect,
6024
+ isMe: pane.threadId === threadId,
6025
+ isFocused: pane.isFocused
6026
+ })) ?? [];
6027
+ return {
5996
6028
  splitProps: {
5997
6029
  onPointerDown: () => {
5998
6030
  env.sidebarActionCalls.push({ method: "open", threadId });
5999
6031
  }
6000
6032
  },
6001
6033
  isAvailable: true,
6002
- layout: null
6003
- }),
6004
- [env, threadId]
6005
- );
6034
+ layout: panes.some((pane) => pane.isMe) ? { panes } : null
6035
+ };
6036
+ }, [env, threadId]);
6006
6037
  },
6007
6038
  useSidebarThreadDraft(threadId) {
6008
6039
  const env = useSlotEnv("useSidebarThreadDraft");
@@ -3641,7 +3641,8 @@ function createFakePluginHostInternal(options, sharedState) {
3641
3641
  method: String(method),
3642
3642
  input: validatedInput,
3643
3643
  hostId: callOptions.hostId,
3644
- ...callOptions.signal === void 0 ? {} : { signal: callOptions.signal }
3644
+ ...callOptions.signal === void 0 ? {} : { signal: callOptions.signal },
3645
+ ...callOptions.timeoutMs === void 0 ? {} : { timeoutMs: callOptions.timeoutMs }
3645
3646
  };
3646
3647
  hostRpcCalls.push(call);
3647
3648
  if (options.experimental_callHostRpc === void 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@get-bb/plugin-sdk",
3
- "version": "0.6.144",
3
+ "version": "0.6.146",
4
4
  "homepage": "https://github.com/get-bb/bb#readme",
5
5
  "bugs": {
6
6
  "url": "https://github.com/get-bb/bb/issues"