@ottocode/web-sdk 0.1.228 → 0.1.230

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 (46) hide show
  1. package/dist/components/chat/ChatInput.d.ts.map +1 -1
  2. package/dist/components/chat/ChatInputContainer.d.ts.map +1 -1
  3. package/dist/components/chat/ConfigModal.d.ts.map +1 -1
  4. package/dist/components/chat/ConfigSelector.d.ts.map +1 -1
  5. package/dist/components/index.js +2953 -2236
  6. package/dist/components/index.js.map +34 -32
  7. package/dist/components/messages/ActionToolBox.d.ts +8 -0
  8. package/dist/components/messages/ActionToolBox.d.ts.map +1 -0
  9. package/dist/components/messages/AssistantMessageGroup.d.ts.map +1 -1
  10. package/dist/components/messages/CompactActivityGroup.d.ts.map +1 -1
  11. package/dist/components/messages/MessageThread.d.ts.map +1 -1
  12. package/dist/components/messages/compactActivity.d.ts +1 -0
  13. package/dist/components/messages/compactActivity.d.ts.map +1 -1
  14. package/dist/components/research/ResearchSidebar.d.ts.map +1 -1
  15. package/dist/components/session-files/SessionFilesSidebar.d.ts.map +1 -1
  16. package/dist/components/sessions/SessionHeader.d.ts.map +1 -1
  17. package/dist/components/sessions/SessionItem.d.ts.map +1 -1
  18. package/dist/components/sessions/SessionListContainer.d.ts.map +1 -1
  19. package/dist/components/sessions/session-time.d.ts +9 -0
  20. package/dist/components/sessions/session-time.d.ts.map +1 -0
  21. package/dist/components/settings/SettingsSidebar.d.ts.map +1 -1
  22. package/dist/hooks/index.js +217 -50
  23. package/dist/hooks/index.js.map +10 -10
  24. package/dist/hooks/useConfig.d.ts +3 -0
  25. package/dist/hooks/useConfig.d.ts.map +1 -1
  26. package/dist/hooks/useMessages.d.ts +6 -1
  27. package/dist/hooks/useMessages.d.ts.map +1 -1
  28. package/dist/hooks/usePreferences.d.ts +1 -0
  29. package/dist/hooks/usePreferences.d.ts.map +1 -1
  30. package/dist/hooks/useProviderUsage.d.ts.map +1 -1
  31. package/dist/hooks/useResearch.d.ts +1 -1
  32. package/dist/hooks/useResearch.d.ts.map +1 -1
  33. package/dist/hooks/useSessionFiles.d.ts +1 -1
  34. package/dist/hooks/useSessionFiles.d.ts.map +1 -1
  35. package/dist/hooks/useSessionStream.d.ts +1 -1
  36. package/dist/hooks/useSessionStream.d.ts.map +1 -1
  37. package/dist/index.js +2964 -2247
  38. package/dist/index.js.map +34 -32
  39. package/dist/lib/api-client/config.d.ts +3 -0
  40. package/dist/lib/api-client/config.d.ts.map +1 -1
  41. package/dist/lib/api-client/index.d.ts +3 -0
  42. package/dist/lib/api-client/index.d.ts.map +1 -1
  43. package/dist/lib/index.js.map +2 -2
  44. package/dist/types/api.d.ts +2 -0
  45. package/dist/types/api.d.ts.map +1 -1
  46. package/package.json +3 -3
@@ -0,0 +1,8 @@
1
+ import type { MessagePart } from '../../types/api';
2
+ interface ActionToolBoxProps {
3
+ part: MessagePart;
4
+ showLine: boolean;
5
+ }
6
+ export declare function ActionToolBox({ part, showLine }: ActionToolBoxProps): import("react/jsx-runtime").JSX.Element;
7
+ export {};
8
+ //# sourceMappingURL=ActionToolBox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActionToolBox.d.ts","sourceRoot":"","sources":["../../../src/components/messages/ActionToolBox.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAmInD,UAAU,kBAAkB;IAC3B,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CAClB;AAED,wBAAgB,aAAa,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,kBAAkB,2CA4PnE"}
@@ -1 +1 @@
1
- {"version":3,"file":"AssistantMessageGroup.d.ts","sourceRoot":"","sources":["../../../src/components/messages/AssistantMessageGroup.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAe,MAAM,iBAAiB,CAAC;AAc5D,UAAU,0BAA0B;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,uBAAuB,EAAE,OAAO,CAAC;IACjC,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IACjD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,mBAAmB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAiCD,eAAO,MAAM,qBAAqB,kEAoejC,CAAC"}
1
+ {"version":3,"file":"AssistantMessageGroup.d.ts","sourceRoot":"","sources":["../../../src/components/messages/AssistantMessageGroup.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAe,MAAM,iBAAiB,CAAC;AAe5D,UAAU,0BAA0B;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,uBAAuB,EAAE,OAAO,CAAC;IACjC,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IACjD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,mBAAmB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAiCD,eAAO,MAAM,qBAAqB,kEAugBjC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"CompactActivityGroup.d.ts","sourceRoot":"","sources":["../../../src/components/messages/CompactActivityGroup.tsx"],"names":[],"mappings":"AAEA,OAAO,EACN,KAAK,oBAAoB,EAEzB,MAAM,mBAAmB,CAAC;AAS3B,UAAU,yBAAyB;IAClC,OAAO,EAAE,oBAAoB,EAAE,CAAC;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,oBAAoB,CAAC,EACpC,OAAO,EACP,aAAa,EACb,QAAQ,EACR,SAAS,GACT,EAAE,yBAAyB,2CAuP3B"}
1
+ {"version":3,"file":"CompactActivityGroup.d.ts","sourceRoot":"","sources":["../../../src/components/messages/CompactActivityGroup.tsx"],"names":[],"mappings":"AAEA,OAAO,EACN,KAAK,oBAAoB,EAEzB,MAAM,mBAAmB,CAAC;AAM3B,UAAU,yBAAyB;IAClC,OAAO,EAAE,oBAAoB,EAAE,CAAC;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,oBAAoB,CAAC,EACpC,OAAO,EACP,aAAa,EACb,QAAQ,EACR,SAAS,GACT,EAAE,yBAAyB,2CAiP3B"}
@@ -1 +1 @@
1
- {"version":3,"file":"MessageThread.d.ts","sourceRoot":"","sources":["../../../src/components/messages/MessageThread.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAUxD,UAAU,kBAAkB;IAC3B,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,eAAe,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9C;AAED,eAAO,MAAM,aAAa,0DA8WxB,CAAC"}
1
+ {"version":3,"file":"MessageThread.d.ts","sourceRoot":"","sources":["../../../src/components/messages/MessageThread.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAWxD,UAAU,kBAAkB;IAC3B,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,eAAe,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9C;AAED,eAAO,MAAM,aAAa,0DA+WxB,CAAC"}
@@ -6,6 +6,7 @@ interface CompactActivityEntry {
6
6
  path?: string;
7
7
  query?: string;
8
8
  url?: string;
9
+ fullText?: string;
9
10
  startedAt?: number | null;
10
11
  completedAt?: number | null;
11
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"compactActivity.d.ts","sourceRoot":"","sources":["../../../src/components/messages/compactActivity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAkBnD,UAAU,oBAAoB;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,UAAU,sBAAsB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,EAAE,CAAC;CAClB;AAoFD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAUhE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACtC,IAAI,EAAE,WAAW,GACf,oBAAoB,GAAG,IAAI,CAqG7B;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAC1C,KAAK,EAAE,WAAW,EAAE,GAClB,oBAAoB,EAAE,CA2BxB;AA2CD;;GAEG;AACH,wBAAgB,0BAA0B,CACzC,OAAO,EAAE,oBAAoB,EAAE,GAC7B,sBAAsB,CAoGxB;AAED,YAAY,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,CAAC"}
1
+ {"version":3,"file":"compactActivity.d.ts","sourceRoot":"","sources":["../../../src/components/messages/compactActivity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAkBnD,UAAU,oBAAoB;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,UAAU,sBAAsB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,EAAE,CAAC;CAClB;AAoFD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAUhE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACtC,IAAI,EAAE,WAAW,GACf,oBAAoB,GAAG,IAAI,CAqG7B;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAC1C,KAAK,EAAE,WAAW,EAAE,GAClB,oBAAoB,EAAE,CA2BxB;AA2CD;;GAEG;AACH,wBAAgB,0BAA0B,CACzC,OAAO,EAAE,oBAAoB,EAAE,GAC7B,sBAAsB,CAoGxB;AAED,YAAY,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ResearchSidebar.d.ts","sourceRoot":"","sources":["../../../src/components/research/ResearchSidebar.tsx"],"names":[],"mappings":"AA0CA,UAAU,oBAAoB;IAC7B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,mBAAmB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAClD;AAED,eAAO,MAAM,eAAe,4DAomB1B,CAAC"}
1
+ {"version":3,"file":"ResearchSidebar.d.ts","sourceRoot":"","sources":["../../../src/components/research/ResearchSidebar.tsx"],"names":[],"mappings":"AA0CA,UAAU,oBAAoB;IAC7B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,mBAAmB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAClD;AAED,eAAO,MAAM,eAAe,4DAsmB1B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"SessionFilesSidebar.d.ts","sourceRoot":"","sources":["../../../src/components/session-files/SessionFilesSidebar.tsx"],"names":[],"mappings":"AAqBA,UAAU,wBAAwB;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AA0GD,eAAO,MAAM,mBAAmB,gEA8F9B,CAAC"}
1
+ {"version":3,"file":"SessionFilesSidebar.d.ts","sourceRoot":"","sources":["../../../src/components/session-files/SessionFilesSidebar.tsx"],"names":[],"mappings":"AAqBA,UAAU,wBAAwB;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AA0GD,eAAO,MAAM,mBAAmB,gEAiG9B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"SessionHeader.d.ts","sourceRoot":"","sources":["../../../src/components/sessions/SessionHeader.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAgB/C,UAAU,kBAAkB;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,mBAAmB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAClD;AAED,wBAAgB,aAAa,CAAC,EAC7B,OAAO,EACP,mBAAmB,GACnB,EAAE,kBAAkB,2CA+KpB"}
1
+ {"version":3,"file":"SessionHeader.d.ts","sourceRoot":"","sources":["../../../src/components/sessions/SessionHeader.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAiB/C,UAAU,kBAAkB;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,mBAAmB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAClD;AAED,wBAAgB,aAAa,CAAC,EAC7B,OAAO,EACP,mBAAmB,GACnB,EAAE,kBAAkB,2CAkLpB"}
@@ -1 +1 @@
1
- {"version":3,"file":"SessionItem.d.ts","sourceRoot":"","sources":["../../../src/components/sessions/SessionItem.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE/C,UAAU,gBAAgB;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,IAAI,CAAC;CACpB;AAED,eAAO,MAAM,WAAW,wDAiEtB,CAAC"}
1
+ {"version":3,"file":"SessionItem.d.ts","sourceRoot":"","sources":["../../../src/components/sessions/SessionItem.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAG/C,UAAU,gBAAgB;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,IAAI,CAAC;CACpB;AAED,eAAO,MAAM,WAAW,wDAyCtB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"SessionListContainer.d.ts","sourceRoot":"","sources":["../../../src/components/sessions/SessionListContainer.tsx"],"names":[],"mappings":"AAMA,UAAU,yBAAyB;IAClC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7C;AAED,eAAO,MAAM,oBAAoB,iEA2I/B,CAAC"}
1
+ {"version":3,"file":"SessionListContainer.d.ts","sourceRoot":"","sources":["../../../src/components/sessions/SessionListContainer.tsx"],"names":[],"mappings":"AAOA,UAAU,yBAAyB;IAClC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7C;AAED,eAAO,MAAM,oBAAoB,iEAsL/B,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Formats a timestamp into a compact relative label for session metadata.
3
+ */
4
+ export declare function formatRelativeSessionTime(timestamp: number): string;
5
+ /**
6
+ * Returns a date bucket label for grouping recent sessions in the sidebar.
7
+ */
8
+ export declare function getSessionGroupLabel(timestamp: number): string;
9
+ //# sourceMappingURL=session-time.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-time.d.ts","sourceRoot":"","sources":["../../../src/components/sessions/session-time.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAqBnE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAc9D"}
@@ -1 +1 @@
1
- {"version":3,"file":"SettingsSidebar.d.ts","sourceRoot":"","sources":["../../../src/components/settings/SettingsSidebar.tsx"],"names":[],"mappings":"AAkLA,eAAO,MAAM,eAAe,8CAuO1B,CAAC"}
1
+ {"version":3,"file":"SettingsSidebar.d.ts","sourceRoot":"","sources":["../../../src/components/settings/SettingsSidebar.tsx"],"names":[],"mappings":"AAkLA,eAAO,MAAM,eAAe,8CAuQ1B,CAAC"}
@@ -934,7 +934,8 @@ import { useCallback, useMemo, useSyncExternalStore } from "react";
934
934
  var STORAGE_KEY = "otto-preferences";
935
935
  var DEFAULT_PREFERENCES = {
936
936
  vimMode: false,
937
- compactThread: true
937
+ compactThread: true,
938
+ fullWidthContent: false
938
939
  };
939
940
  function resolveInitialPreferences() {
940
941
  if (typeof window === "undefined") {
@@ -1633,7 +1634,8 @@ function useDeleteSession() {
1633
1634
  }
1634
1635
 
1635
1636
  // src/hooks/useMessages.ts
1636
- function useMessages(sessionId) {
1637
+ function useMessages(sessionId, options = {}) {
1638
+ const { enabled = true, staleTime = 15000 } = options;
1637
1639
  return useQuery4({
1638
1640
  queryKey: ["messages", sessionId],
1639
1641
  queryFn: () => {
@@ -1642,7 +1644,9 @@ function useMessages(sessionId) {
1642
1644
  }
1643
1645
  return apiClient.getMessages(sessionId);
1644
1646
  },
1645
- enabled: !!sessionId
1647
+ enabled: !!sessionId && enabled,
1648
+ staleTime,
1649
+ refetchOnWindowFocus: false
1646
1650
  });
1647
1651
  }
1648
1652
  function useSendMessage(sessionId) {
@@ -1787,11 +1791,10 @@ var useToolApprovalStore = create9((set) => ({
1787
1791
  }));
1788
1792
 
1789
1793
  // src/hooks/useSessionStream.ts
1790
- function useSessionStream(sessionId) {
1794
+ function useSessionStream(sessionId, enabled = true) {
1791
1795
  const queryClient = useQueryClient5();
1792
1796
  const clientRef = useRef(null);
1793
1797
  const assistantMessageIdRef = useRef(null);
1794
- const lastInvalidationRef = useRef(0);
1795
1798
  const {
1796
1799
  addPendingApproval,
1797
1800
  removePendingApproval,
@@ -1799,8 +1802,7 @@ function useSessionStream(sessionId) {
1799
1802
  setPendingApprovals
1800
1803
  } = useToolApprovalStore();
1801
1804
  useEffect(() => {
1802
- if (!sessionId) {
1803
- console.log("[useSessionStream] No sessionId, skipping");
1805
+ if (!sessionId || !enabled) {
1804
1806
  return;
1805
1807
  }
1806
1808
  assistantMessageIdRef.current = null;
@@ -1847,6 +1849,27 @@ function useSessionStream(sessionId) {
1847
1849
  }
1848
1850
  return "";
1849
1851
  };
1852
+ const getToolEventCallId = (payload) => {
1853
+ if (typeof payload?.callId === "string")
1854
+ return payload.callId;
1855
+ return typeof payload?.toolCallId === "string" ? payload.toolCallId : null;
1856
+ };
1857
+ const getToolEventName = (payload) => {
1858
+ if (typeof payload?.name === "string")
1859
+ return payload.name;
1860
+ return typeof payload?.toolName === "string" ? payload.toolName : null;
1861
+ };
1862
+ const getToolEventArgs = (payload) => payload?.args ?? payload?.input;
1863
+ const getToolInputDelta = (payload) => {
1864
+ if (typeof payload?.delta === "string")
1865
+ return payload.delta;
1866
+ return typeof payload?.inputTextDelta === "string" ? payload.inputTextDelta : null;
1867
+ };
1868
+ const getToolOutputDelta = (payload) => {
1869
+ if (typeof payload?.delta === "string")
1870
+ return payload.delta;
1871
+ return typeof payload?.outputTextDelta === "string" ? payload.outputTextDelta : null;
1872
+ };
1850
1873
  const getOptimisticPartIndex = (parts, stepIndex) => {
1851
1874
  if (typeof stepIndex !== "number") {
1852
1875
  return parts.length;
@@ -1979,8 +2002,8 @@ function useSessionStream(sessionId) {
1979
2002
  const upsertEphemeralToolCall = (payload) => {
1980
2003
  if (!payload)
1981
2004
  return;
1982
- const callId = typeof payload.callId === "string" ? payload.callId : null;
1983
- const name = typeof payload.name === "string" ? payload.name : null;
2005
+ const callId = getToolEventCallId(payload);
2006
+ const name = getToolEventName(payload);
1984
2007
  if (!name)
1985
2008
  return;
1986
2009
  queryClient.setQueryData(["messages", sessionId], (oldMessages) => {
@@ -2004,7 +2027,7 @@ function useSessionStream(sessionId) {
2004
2027
  if (partIndex === -1 && !callId) {
2005
2028
  partIndex = parts.findIndex((part) => part.ephemeral && part.toolName === name);
2006
2029
  }
2007
- const args = payload.args;
2030
+ const args = getToolEventArgs(payload);
2008
2031
  const stepIndex = typeof payload.stepIndex === "number" ? payload.stepIndex : null;
2009
2032
  const contentJsonBase = { name };
2010
2033
  if (callId)
@@ -2054,15 +2077,161 @@ function useSessionStream(sessionId) {
2054
2077
  return nextMessages;
2055
2078
  });
2056
2079
  };
2080
+ const accumulateToolInputDelta = (payload, delta) => {
2081
+ if (!payload)
2082
+ return;
2083
+ const callId = getToolEventCallId(payload);
2084
+ const name = getToolEventName(payload);
2085
+ if (!name)
2086
+ return;
2087
+ queryClient.setQueryData(["messages", sessionId], (oldMessages) => {
2088
+ if (!oldMessages)
2089
+ return oldMessages;
2090
+ const nextMessages = [...oldMessages];
2091
+ let targetIndex = resolveAssistantTargetIndex(nextMessages);
2092
+ if (typeof payload.messageId === "string") {
2093
+ const explicitIndex = nextMessages.findIndex((message) => message.id === payload.messageId);
2094
+ if (explicitIndex !== -1)
2095
+ targetIndex = explicitIndex;
2096
+ }
2097
+ if (targetIndex === -1)
2098
+ return oldMessages;
2099
+ const targetMessage = nextMessages[targetIndex];
2100
+ const parts = targetMessage.parts ? [...targetMessage.parts] : [];
2101
+ let partIndex = -1;
2102
+ if (callId) {
2103
+ partIndex = parts.findIndex((part) => part.toolCallId === callId && part.ephemeral);
2104
+ }
2105
+ if (partIndex === -1 && !callId) {
2106
+ partIndex = parts.findIndex((part) => part.ephemeral && part.toolName === name);
2107
+ }
2108
+ const stepIndex = typeof payload.stepIndex === "number" ? payload.stepIndex : null;
2109
+ if (partIndex === -1) {
2110
+ const contentJsonBase = {
2111
+ name,
2112
+ _streamedInput: delta
2113
+ };
2114
+ if (callId)
2115
+ contentJsonBase.callId = callId;
2116
+ const newPart = {
2117
+ id: callId ? `ephemeral-tool-call-${callId}` : `ephemeral-tool-call-${name}-${Date.now()}`,
2118
+ messageId: targetMessage.id,
2119
+ index: getOptimisticPartIndex(parts, stepIndex),
2120
+ stepIndex,
2121
+ type: "tool_call",
2122
+ content: JSON.stringify(contentJsonBase),
2123
+ contentJson: contentJsonBase,
2124
+ agent: targetMessage.agent,
2125
+ provider: targetMessage.provider,
2126
+ model: targetMessage.model,
2127
+ startedAt: Date.now(),
2128
+ completedAt: null,
2129
+ toolName: name,
2130
+ toolCallId: callId,
2131
+ toolDurationMs: null,
2132
+ ephemeral: true
2133
+ };
2134
+ parts.push(newPart);
2135
+ } else {
2136
+ const existing = parts[partIndex];
2137
+ const prev = typeof existing.contentJson?._streamedInput === "string" ? existing.contentJson._streamedInput : "";
2138
+ const nextContentJson = {
2139
+ ...typeof existing.contentJson === "object" && !Array.isArray(existing.contentJson) ? existing.contentJson : {},
2140
+ _streamedInput: prev + delta
2141
+ };
2142
+ parts[partIndex] = {
2143
+ ...existing,
2144
+ content: JSON.stringify(nextContentJson),
2145
+ contentJson: nextContentJson,
2146
+ stepIndex: stepIndex ?? existing.stepIndex ?? null
2147
+ };
2148
+ }
2149
+ nextMessages[targetIndex] = { ...targetMessage, parts };
2150
+ return nextMessages;
2151
+ });
2152
+ };
2153
+ const accumulateToolOutputDelta = (payload, delta) => {
2154
+ if (!payload)
2155
+ return;
2156
+ const callId = getToolEventCallId(payload);
2157
+ const name = getToolEventName(payload);
2158
+ if (!name)
2159
+ return;
2160
+ queryClient.setQueryData(["messages", sessionId], (oldMessages) => {
2161
+ if (!oldMessages)
2162
+ return oldMessages;
2163
+ const nextMessages = [...oldMessages];
2164
+ let targetIndex = resolveAssistantTargetIndex(nextMessages);
2165
+ if (typeof payload.messageId === "string") {
2166
+ const explicitIndex = nextMessages.findIndex((message) => message.id === payload.messageId);
2167
+ if (explicitIndex !== -1)
2168
+ targetIndex = explicitIndex;
2169
+ }
2170
+ if (targetIndex === -1)
2171
+ return oldMessages;
2172
+ const targetMessage = nextMessages[targetIndex];
2173
+ const parts = targetMessage.parts ? [...targetMessage.parts] : [];
2174
+ let partIndex = -1;
2175
+ if (callId) {
2176
+ partIndex = parts.findIndex((part) => part.toolCallId === callId && part.ephemeral);
2177
+ }
2178
+ if (partIndex === -1 && !callId) {
2179
+ partIndex = parts.findIndex((part) => part.ephemeral && part.toolName === name);
2180
+ }
2181
+ const stepIndex = typeof payload.stepIndex === "number" ? payload.stepIndex : null;
2182
+ if (partIndex === -1) {
2183
+ const contentJsonBase = {
2184
+ name,
2185
+ _streamedOutput: delta
2186
+ };
2187
+ if (callId)
2188
+ contentJsonBase.callId = callId;
2189
+ const newPart = {
2190
+ id: callId ? `ephemeral-tool-call-${callId}` : `ephemeral-tool-call-${name}-${Date.now()}`,
2191
+ messageId: targetMessage.id,
2192
+ index: getOptimisticPartIndex(parts, stepIndex),
2193
+ stepIndex,
2194
+ type: "tool_call",
2195
+ content: JSON.stringify(contentJsonBase),
2196
+ contentJson: contentJsonBase,
2197
+ agent: targetMessage.agent,
2198
+ provider: targetMessage.provider,
2199
+ model: targetMessage.model,
2200
+ startedAt: Date.now(),
2201
+ completedAt: null,
2202
+ toolName: name,
2203
+ toolCallId: callId,
2204
+ toolDurationMs: null,
2205
+ ephemeral: true
2206
+ };
2207
+ parts.push(newPart);
2208
+ } else {
2209
+ const existing = parts[partIndex];
2210
+ const prev = typeof existing.contentJson?._streamedOutput === "string" ? existing.contentJson._streamedOutput : "";
2211
+ const nextContentJson = {
2212
+ ...typeof existing.contentJson === "object" && !Array.isArray(existing.contentJson) ? existing.contentJson : {},
2213
+ _streamedOutput: prev + delta
2214
+ };
2215
+ parts[partIndex] = {
2216
+ ...existing,
2217
+ content: JSON.stringify(nextContentJson),
2218
+ contentJson: nextContentJson,
2219
+ stepIndex: stepIndex ?? existing.stepIndex ?? null
2220
+ };
2221
+ }
2222
+ nextMessages[targetIndex] = { ...targetMessage, parts };
2223
+ return nextMessages;
2224
+ });
2225
+ };
2057
2226
  const resolveEphemeralToolCall = (payload) => {
2058
- const callId = typeof payload?.callId === "string" ? payload.callId : null;
2227
+ const callId = getToolEventCallId(payload);
2059
2228
  if (!callId)
2060
2229
  return;
2061
- const payloadName = typeof payload?.name === "string" ? payload.name : null;
2230
+ const payloadName = getToolEventName(payload);
2062
2231
  const payloadStepIndex = typeof payload?.stepIndex === "number" ? payload.stepIndex : null;
2063
2232
  const payloadResult = payload?.result;
2064
2233
  const payloadArtifact = payload?.artifact;
2065
- const payloadArgs = payload?.args;
2234
+ const payloadArgs = getToolEventArgs(payload);
2066
2235
  queryClient.setQueryData(["messages", sessionId], (oldMessages) => {
2067
2236
  if (!oldMessages)
2068
2237
  return oldMessages;
@@ -2110,7 +2279,7 @@ function useSessionStream(sessionId) {
2110
2279
  });
2111
2280
  };
2112
2281
  const removeEphemeralToolCall = (payload) => {
2113
- const callId = typeof payload?.callId === "string" ? payload.callId : null;
2282
+ const callId = getToolEventCallId(payload);
2114
2283
  if (!callId)
2115
2284
  return;
2116
2285
  queryClient.setQueryData(["messages", sessionId], (oldMessages) => {
@@ -2169,20 +2338,6 @@ function useSessionStream(sessionId) {
2169
2338
  return nextMessages;
2170
2339
  });
2171
2340
  };
2172
- const throttledInvalidate = () => {
2173
- const now = Date.now();
2174
- if (now - lastInvalidationRef.current < 500) {
2175
- return;
2176
- }
2177
- lastInvalidationRef.current = now;
2178
- queryClient.invalidateQueries({ queryKey: ["messages", sessionId] });
2179
- };
2180
- const invalidatingEvents = new Set([
2181
- "message.completed",
2182
- "message.updated",
2183
- "finish-step",
2184
- "error"
2185
- ]);
2186
2341
  const unsubscribe = client2.on("*", (event) => {
2187
2342
  const payload = event.payload;
2188
2343
  switch (event.type) {
@@ -2222,7 +2377,6 @@ function useSessionStream(sessionId) {
2222
2377
  next.sort((a, b) => a.createdAt - b.createdAt);
2223
2378
  return next;
2224
2379
  });
2225
- throttledInvalidate();
2226
2380
  }
2227
2381
  break;
2228
2382
  }
@@ -2241,13 +2395,21 @@ function useSessionStream(sessionId) {
2241
2395
  }
2242
2396
  markMessageCompleted(payload);
2243
2397
  clearEphemeralForMessage(id);
2398
+ queryClient.invalidateQueries({ queryKey: ["messages", sessionId] });
2244
2399
  queryClient.invalidateQueries({ queryKey: sessionsQueryKey });
2245
2400
  break;
2246
2401
  }
2247
2402
  case "tool.delta": {
2248
2403
  const channel = typeof payload?.channel === "string" ? payload.channel : null;
2249
- if (channel === "input") {
2250
- upsertEphemeralToolCall(payload);
2404
+ const delta = channel === "output" ? getToolOutputDelta(payload) : getToolInputDelta(payload);
2405
+ if (channel === "input" || channel == null && delta) {
2406
+ if (delta) {
2407
+ accumulateToolInputDelta(payload, delta);
2408
+ } else {
2409
+ upsertEphemeralToolCall(payload);
2410
+ }
2411
+ } else if (channel === "output" && delta) {
2412
+ accumulateToolOutputDelta(payload, delta);
2251
2413
  }
2252
2414
  break;
2253
2415
  }
@@ -2296,6 +2458,7 @@ function useSessionStream(sessionId) {
2296
2458
  if (messageId) {
2297
2459
  clearEphemeralForMessage(messageId);
2298
2460
  }
2461
+ queryClient.invalidateQueries({ queryKey: ["messages", sessionId] });
2299
2462
  break;
2300
2463
  }
2301
2464
  case "message.updated": {
@@ -2330,9 +2493,6 @@ function useSessionStream(sessionId) {
2330
2493
  default:
2331
2494
  break;
2332
2495
  }
2333
- if (invalidatingEvents.has(event.type)) {
2334
- throttledInvalidate();
2335
- }
2336
2496
  if (event.type === "finish-step") {
2337
2497
  const now = Date.now();
2338
2498
  if (now - lastSessionInvalidation >= 2000) {
@@ -2350,6 +2510,7 @@ function useSessionStream(sessionId) {
2350
2510
  queryClient,
2351
2511
  addPendingApproval,
2352
2512
  removePendingApproval,
2513
+ enabled,
2353
2514
  setPendingApprovals,
2354
2515
  updatePendingApproval
2355
2516
  ]);
@@ -3240,13 +3401,13 @@ function useFileUpload(options = {}) {
3240
3401
  }
3241
3402
  // src/hooks/useSessionFiles.ts
3242
3403
  import { useQuery as useQuery5 } from "@tanstack/react-query";
3243
- function useSessionFiles(sessionId) {
3404
+ function useSessionFiles(sessionId, enabled = true) {
3244
3405
  const isExpanded = useSessionFilesStore((state) => state.isExpanded);
3245
3406
  return useQuery5({
3246
3407
  queryKey: ["session", sessionId, "files"],
3247
3408
  queryFn: () => sessionId ? apiClient.getSessionFiles(sessionId) : null,
3248
- enabled: !!sessionId,
3249
- refetchInterval: isExpanded ? 5000 : false,
3409
+ enabled: !!sessionId && enabled,
3410
+ refetchInterval: isExpanded && enabled ? 5000 : false,
3250
3411
  retry: 1,
3251
3412
  staleTime: 3000
3252
3413
  });
@@ -3438,11 +3599,11 @@ class ResearchApiClient {
3438
3599
  }
3439
3600
  }
3440
3601
  var researchApi = new ResearchApiClient;
3441
- function useResearchSessions(parentSessionId) {
3602
+ function useResearchSessions(parentSessionId, enabled = true) {
3442
3603
  return useQuery8({
3443
3604
  queryKey: ["research", "sessions", parentSessionId],
3444
3605
  queryFn: () => researchApi.listResearchSessions(parentSessionId),
3445
- enabled: !!parentSessionId,
3606
+ enabled: !!parentSessionId && enabled,
3446
3607
  staleTime: 30000
3447
3608
  });
3448
3609
  }
@@ -4395,7 +4556,7 @@ function useTunnelStream() {
4395
4556
  return { connect };
4396
4557
  }
4397
4558
  // src/hooks/useProviderUsage.ts
4398
- import { useEffect as useEffect13, useCallback as useCallback10 } from "react";
4559
+ import { useEffect as useEffect13, useCallback as useCallback10, useRef as useRef6 } from "react";
4399
4560
 
4400
4561
  // src/stores/usageStore.ts
4401
4562
  import { create as create18 } from "zustand";
@@ -4415,16 +4576,22 @@ var useUsageStore = create18((set) => ({
4415
4576
  // src/hooks/useProviderUsage.ts
4416
4577
  var POLL_INTERVAL = 60000;
4417
4578
  var STALE_THRESHOLD = 30000;
4579
+ var inflight = new Set;
4418
4580
  function useProviderUsage(provider, authType) {
4419
4581
  const setUsage = useUsageStore((s) => s.setUsage);
4420
4582
  const setLoading = useUsageStore((s) => s.setLoading);
4421
4583
  const setLastFetched = useUsageStore((s) => s.setLastFetched);
4422
4584
  const usage = useUsageStore((s) => provider ? s.usage[provider] : undefined);
4423
- const lastFetched = useUsageStore((s) => provider ? s.lastFetched[provider] : 0);
4424
4585
  const isOAuthProvider = authType === "oauth" && (provider === "anthropic" || provider === "openai");
4425
4586
  const fetchUsage = useCallback10(async () => {
4426
4587
  if (!provider || !isOAuthProvider)
4427
4588
  return;
4589
+ if (inflight.has(provider))
4590
+ return;
4591
+ const last = useUsageStore.getState().lastFetched[provider] ?? 0;
4592
+ if (last && Date.now() - last < STALE_THRESHOLD)
4593
+ return;
4594
+ inflight.add(provider);
4428
4595
  setLoading(provider, true);
4429
4596
  try {
4430
4597
  const data = await apiClient.getProviderUsage(provider);
@@ -4432,18 +4599,18 @@ function useProviderUsage(provider, authType) {
4432
4599
  setLastFetched(provider, Date.now());
4433
4600
  } catch {} finally {
4434
4601
  setLoading(provider, false);
4602
+ inflight.delete(provider);
4435
4603
  }
4436
4604
  }, [provider, isOAuthProvider, setUsage, setLoading, setLastFetched]);
4605
+ const fetchRef = useRef6(fetchUsage);
4606
+ fetchRef.current = fetchUsage;
4437
4607
  useEffect13(() => {
4438
4608
  if (!isOAuthProvider)
4439
4609
  return;
4440
- const isStale = !lastFetched || Date.now() - lastFetched > STALE_THRESHOLD;
4441
- if (isStale) {
4442
- fetchUsage();
4443
- }
4444
- const interval = setInterval(fetchUsage, POLL_INTERVAL);
4610
+ fetchRef.current();
4611
+ const interval = setInterval(() => fetchRef.current(), POLL_INTERVAL);
4445
4612
  return () => clearInterval(interval);
4446
- }, [isOAuthProvider, fetchUsage, lastFetched]);
4613
+ }, [isOAuthProvider, provider]);
4447
4614
  return {
4448
4615
  usage,
4449
4616
  fetchUsage,
@@ -4481,7 +4648,7 @@ function useGitDiffFullFile(file, staged = false, enabled = false) {
4481
4648
  }
4482
4649
  // src/hooks/useMCP.ts
4483
4650
  import { useQuery as useQuery12, useMutation as useMutation8, useQueryClient as useQueryClient10 } from "@tanstack/react-query";
4484
- import { useEffect as useEffect14, useRef as useRef6, useCallback as useCallback11 } from "react";
4651
+ import { useEffect as useEffect14, useRef as useRef7, useCallback as useCallback11 } from "react";
4485
4652
  import {
4486
4653
  listMcpServers,
4487
4654
  startMcpServer,
@@ -4647,7 +4814,7 @@ function useCopilotDevicePoller() {
4647
4814
  const setCopilotDevice = useMCPStore((s) => s.setCopilotDevice);
4648
4815
  const setLoading = useMCPStore((s) => s.setLoading);
4649
4816
  const queryClient = useQueryClient10();
4650
- const timerRef = useRef6(null);
4817
+ const timerRef = useRef7(null);
4651
4818
  const stopPolling = useCallback11(() => {
4652
4819
  if (timerRef.current) {
4653
4820
  clearInterval(timerRef.current);
@@ -4818,4 +4985,4 @@ export {
4818
4985
  sessionsQueryKey
4819
4986
  };
4820
4987
 
4821
- //# debugId=381FB663C2D4B88E64756E2164756E21
4988
+ //# debugId=8BD673F5FE928A9E64756E2164756E21