@terreno/ui 57.0.0 → 57.1.0

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 (56) hide show
  1. package/dist/DateTimeField.js +6 -2
  2. package/dist/DateTimeField.js.map +1 -1
  3. package/dist/DraggableList.js +7 -4
  4. package/dist/DraggableList.js.map +1 -1
  5. package/dist/Filter.js +14 -9
  6. package/dist/Filter.js.map +1 -1
  7. package/dist/GPTChat.d.ts +7 -1
  8. package/dist/GPTChat.js +26 -16
  9. package/dist/GPTChat.js.map +1 -1
  10. package/dist/ModalSheet.js +1 -1
  11. package/dist/ModalSheet.js.map +1 -1
  12. package/dist/PortalHost.d.ts +24 -0
  13. package/dist/PortalHost.js +52 -0
  14. package/dist/PortalHost.js.map +1 -0
  15. package/dist/SidebarNavigation.native.js +2 -1
  16. package/dist/SidebarNavigation.native.js.map +1 -1
  17. package/dist/TerrenoProvider.js +1 -1
  18. package/dist/TerrenoProvider.js.map +1 -1
  19. package/dist/ToastNotifications.js +8 -5
  20. package/dist/ToastNotifications.js.map +1 -1
  21. package/dist/Tooltip.js +1 -1
  22. package/dist/Tooltip.js.map +1 -1
  23. package/dist/Utilities.d.ts +24 -0
  24. package/dist/Utilities.js +51 -0
  25. package/dist/Utilities.js.map +1 -1
  26. package/dist/WebDropdownMenu.js +11 -15
  27. package/dist/WebDropdownMenu.js.map +1 -1
  28. package/dist/index.d.ts +1 -0
  29. package/dist/index.js +1 -0
  30. package/dist/index.js.map +1 -1
  31. package/package.json +2 -2
  32. package/src/DateTimeField.tsx +6 -3
  33. package/src/DraggableList.tsx +7 -4
  34. package/src/Filter.test.tsx +154 -1
  35. package/src/Filter.tsx +16 -7
  36. package/src/GPTChat.tsx +89 -16
  37. package/src/ModalSheet.tsx +2 -1
  38. package/src/PortalHost.tsx +105 -0
  39. package/src/SidebarNavigation.native.tsx +1 -1
  40. package/src/TerrenoProvider.tsx +1 -1
  41. package/src/ToastNotifications.tsx +4 -5
  42. package/src/Tooltip.tsx +1 -1
  43. package/src/Utilities.test.tsx +47 -0
  44. package/src/Utilities.tsx +78 -0
  45. package/src/WebDropdownMenu.test.tsx +54 -0
  46. package/src/WebDropdownMenu.tsx +11 -10
  47. package/src/__snapshots__/AddressField.test.tsx.snap +1 -7
  48. package/src/__snapshots__/CustomSelectField.test.tsx.snap +7 -49
  49. package/src/__snapshots__/Field.test.tsx.snap +9 -51
  50. package/src/__snapshots__/SelectField.test.tsx.snap +6 -42
  51. package/src/__snapshots__/TerrenoProvider.test.tsx.snap +4 -4
  52. package/src/__snapshots__/TimezonePicker.test.tsx.snap +6 -42
  53. package/src/bunSetup.ts +2 -2
  54. package/src/index.tsx +1 -0
  55. package/src/shadowStyleProps.test.ts +30 -0
  56. package/src/table/__snapshots__/TableBadge.test.tsx.snap +1 -7
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAEA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAC5C,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,C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C;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,WAAW,CAAC;AAC1B,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC"}
package/package.json CHANGED
@@ -68,7 +68,6 @@
68
68
  "react-native-modalize": "^2.1.1",
69
69
  "react-native-permissions": "^5.4.4",
70
70
  "react-native-picker-select": "^9.1.3",
71
- "react-native-portalize": "^1.0.7",
72
71
  "react-native-reanimated": "4.5.1",
73
72
  "react-native-safe-area-context": "~5.7.0",
74
73
  "react-native-screens": "4.26.2",
@@ -145,9 +144,10 @@
145
144
  "lint:unsafefix": "biome check --write --unsafe .",
146
145
  "local": "tsc-watch --onSuccess \"cp -a dist/* ../flourish/node_modules/@terreno/ui/dist\"",
147
146
  "test": "TZ=America/New_York bun test --watch",
147
+ "test:agent": "AGENT=1 TZ=America/New_York bun test --only-failures",
148
148
  "test:ci": "TZ=America/New_York bun test",
149
149
  "test:coverage": "TZ=America/New_York bun run ../scripts/check-coverage.ts",
150
150
  "types": "bun typedoc"
151
151
  },
152
- "version": "57.0.0"
152
+ "version": "57.1.0"
153
153
  }
@@ -279,8 +279,11 @@ const DateRowWithIcon: FC<DateRowWithIconProps> = ({
279
279
 
280
280
  return (
281
281
  <View
282
- pointerEvents={isMobileDatetime ? "none" : "auto"}
283
- style={{alignItems: "center", flexDirection: "row"}}
282
+ style={{
283
+ alignItems: "center",
284
+ flexDirection: "row",
285
+ pointerEvents: isMobileDatetime ? "none" : "auto",
286
+ }}
284
287
  >
285
288
  <DateField {...segmentProps} type={type} />
286
289
  {isMobile && <Box flex="grow" />}
@@ -1011,7 +1014,7 @@ export const DateTimeField: FC<DateTimeFieldProps> = ({
1011
1014
  )}
1012
1015
 
1013
1016
  {isMobileDatetime && (
1014
- <View pointerEvents="none">
1017
+ <View style={{pointerEvents: "none"}}>
1015
1018
  <MobileTimeDisplay
1016
1019
  disabled={disabled}
1017
1020
  displayText={mobileTimeDisplayText}
@@ -158,6 +158,9 @@ export const DragItem: React.FC<DragItemProps> = (props) => {
158
158
  const offset = useSharedValue(0);
159
159
  const startY = useSharedValue(0);
160
160
  const top = useSharedValue(plainPosition * (itemHeight + itemsGap));
161
+ // Drives the alpha of the drag shadow. `boxShadow` takes a single string, so the
162
+ // opacity has to be animated separately and interpolated into that string.
163
+ const shadowAlpha = useSharedValue(0);
161
164
  const [moving, setMoving] = useState(false);
162
165
 
163
166
  // React to changes in positions when not actively moving
@@ -196,13 +199,11 @@ export const DragItem: React.FC<DragItemProps> = (props) => {
196
199
  zIndex: pressed.value ? 1 : 0,
197
200
  };
198
201
 
199
- // Enhanced styles with shadow for iOS
202
+ // Enhanced styles with shadow for iOS and web
200
203
  const animBetter = {
201
204
  backgroundColor: pressed.value ? backgroundOnHold : "transparent",
205
+ boxShadow: `0px 0px 5px rgba(0, 0, 0, ${shadowAlpha.value})`,
202
206
  height: itemHeight,
203
- shadowOffset: {height: 0, width: 0},
204
- shadowOpacity: isAndroid ? 0 : withSpring(pressed.value ? 0.2 : 0),
205
- shadowRadius: isAndroid ? 0 : 5,
206
207
  top: topOffset,
207
208
  zIndex: pressed.value ? 1 : 0,
208
209
  };
@@ -216,6 +217,7 @@ export const DragItem: React.FC<DragItemProps> = (props) => {
216
217
  .onBegin(() => {
217
218
  // When dragging starts
218
219
  pressed.value = true;
220
+ shadowAlpha.value = withSpring(isAndroid ? 0 : 0.2);
219
221
  runOnJS(setMoving)(true);
220
222
  if (passVibration) passVibration();
221
223
  startY.value = top.value;
@@ -247,6 +249,7 @@ export const DragItem: React.FC<DragItemProps> = (props) => {
247
249
  offset.value = 0;
248
250
  top.value = positions.value[item] * (itemHeight + itemsGap);
249
251
  pressed.value = false;
252
+ shadowAlpha.value = withSpring(0);
250
253
 
251
254
  // Notify about the new order
252
255
  onCallbackData(positions.value, callbackNewDataIds, prevArrayFromPositions);
@@ -1,5 +1,9 @@
1
- import {describe, expect, it, mock} from "bun:test";
1
+ import {afterEach, beforeEach, describe, expect, it, mock} from "bun:test";
2
2
  import {act, fireEvent, waitFor} from "@testing-library/react-native";
3
+ import {assert} from "chai";
4
+ // Filter.tsx reads `Platform.OS` through this ESM binding, so the web branch tests must mutate
5
+ // the same object the component observes.
6
+ import {Platform as ImportedPlatform} from "react-native";
3
7
 
4
8
  import {Filter} from "./Filter";
5
9
  import {Text} from "./Text";
@@ -91,4 +95,153 @@ describe("Filter", () => {
91
95
  });
92
96
  expect(queryByTestId("f.panel")).toBeNull();
93
97
  });
98
+
99
+ it("toggles the panel from the trigger when uncontrolled", async () => {
100
+ const onOpenChange = mock();
101
+ const {getByTestId, queryByTestId} = renderWithTheme(
102
+ <Filter onOpenChange={onOpenChange} testID="f">
103
+ <Text>Body</Text>
104
+ </Filter>
105
+ );
106
+
107
+ await act(async () => {
108
+ fireEvent.press(getByTestId("f.trigger"));
109
+ });
110
+ expect(queryByTestId("f.panel")).toBeTruthy();
111
+ expect(onOpenChange).toHaveBeenCalledWith(true);
112
+
113
+ await act(async () => {
114
+ fireEvent.press(getByTestId("f.trigger"));
115
+ });
116
+ expect(queryByTestId("f.panel")).toBeNull();
117
+ expect(onOpenChange).toHaveBeenCalledWith(false);
118
+ });
119
+
120
+ it("defers open state to the parent when controlled", async () => {
121
+ const onOpenChange = mock();
122
+ const {getByTestId, queryByTestId} = renderWithTheme(
123
+ <Filter isOpen onOpenChange={onOpenChange} testID="f">
124
+ <Text>Body</Text>
125
+ </Filter>
126
+ );
127
+
128
+ // A controlled Filter must stay open until the parent flips `isOpen`, even after a
129
+ // dismissal that would close an uncontrolled panel.
130
+ await act(async () => {
131
+ fireEvent.press(getByTestId("f.cancel"));
132
+ });
133
+ expect(onOpenChange).toHaveBeenCalledWith(false);
134
+ expect(queryByTestId("f.panel")).toBeTruthy();
135
+ });
136
+
137
+ it("renders only the requested footer buttons", () => {
138
+ const {queryByTestId, getByTestId} = renderWithTheme(
139
+ <Filter defaultOpen showApplyButton={false} showClearButton={false} testID="f">
140
+ <Text>Body</Text>
141
+ </Filter>
142
+ );
143
+ expect(queryByTestId("f.clear")).toBeNull();
144
+ expect(queryByTestId("f.apply")).toBeNull();
145
+ expect(getByTestId("f.cancel")).toBeTruthy();
146
+ });
147
+
148
+ it("hides the footer when every button is disabled", () => {
149
+ const {queryByTestId} = renderWithTheme(
150
+ <Filter
151
+ defaultOpen
152
+ showApplyButton={false}
153
+ showCancelButton={false}
154
+ showClearButton={false}
155
+ testID="f"
156
+ >
157
+ <Text>Body</Text>
158
+ </Filter>
159
+ );
160
+ expect(queryByTestId("f.clear")).toBeNull();
161
+ expect(queryByTestId("f.apply")).toBeNull();
162
+ expect(queryByTestId("f.cancel")).toBeNull();
163
+ });
164
+
165
+ it("uses custom footer button labels", () => {
166
+ const {getByText} = renderWithTheme(
167
+ <Filter
168
+ applyButtonText="Save"
169
+ cancelButtonText="Dismiss"
170
+ clearButtonText="Reset"
171
+ defaultOpen
172
+ testID="f"
173
+ >
174
+ <Text>Body</Text>
175
+ </Filter>
176
+ );
177
+ expect(getByText("Save")).toBeTruthy();
178
+ expect(getByText("Dismiss")).toBeTruthy();
179
+ expect(getByText("Reset")).toBeTruthy();
180
+ });
181
+
182
+ it("omits testIDs on the panel internals when no testID is provided", () => {
183
+ const {queryByTestId, getByText} = renderWithTheme(
184
+ <Filter defaultOpen>
185
+ <Text>Body</Text>
186
+ </Filter>
187
+ );
188
+ expect(getByText("Apply")).toBeTruthy();
189
+ expect(queryByTestId("f.panel")).toBeNull();
190
+ });
191
+ });
192
+
193
+ describe("Filter web platform", () => {
194
+ const globalScope = globalThis as {document?: unknown; HTMLElement?: unknown};
195
+ const originalDocument = globalScope.document;
196
+ const originalHTMLElement = globalScope.HTMLElement;
197
+ const originalPlatformOS = ImportedPlatform.OS;
198
+
199
+ // The web branch requires `Platform.OS === "web"`, a `document`, and an `HTMLElement`
200
+ // constructor (it checks `document.body instanceof HTMLElement` before portaling). The stub
201
+ // body is intentionally not an HTMLElement so the overlay renders inline in the test tree
202
+ // instead of going through a react-dom portal, which react-test-renderer cannot host.
203
+ beforeEach(() => {
204
+ (ImportedPlatform as {OS: string}).OS = "web";
205
+ globalScope.HTMLElement = class FakeHTMLElement {};
206
+ globalScope.document = {body: {}};
207
+ });
208
+
209
+ afterEach(() => {
210
+ (ImportedPlatform as {OS: string}).OS = originalPlatformOS;
211
+ globalScope.document = originalDocument;
212
+ globalScope.HTMLElement = originalHTMLElement;
213
+ });
214
+
215
+ it("renders the fixed-position overlay once the trigger is measured", async () => {
216
+ const {getByTestId, getByText} = renderWithTheme(
217
+ <Filter defaultOpen testID="f">
218
+ <Text>Body</Text>
219
+ </Filter>
220
+ );
221
+
222
+ await waitFor(() => {
223
+ expect(getByTestId("f.panel")).toBeTruthy();
224
+ });
225
+ const panelStyle = getByTestId("f.panel").props.style as {position?: string};
226
+ assert.strictEqual(panelStyle.position, "fixed");
227
+ expect(getByText("Body")).toBeTruthy();
228
+ });
229
+
230
+ it("closes from the web backdrop", async () => {
231
+ const onCancel = mock();
232
+ const {getByTestId, queryByTestId} = renderWithTheme(
233
+ <Filter defaultOpen onCancel={onCancel} testID="f">
234
+ <Text>Body</Text>
235
+ </Filter>
236
+ );
237
+
238
+ await waitFor(() => {
239
+ expect(getByTestId("f.backdrop")).toBeTruthy();
240
+ });
241
+ await act(async () => {
242
+ fireEvent.press(getByTestId("f.backdrop"));
243
+ });
244
+ expect(onCancel).toHaveBeenCalled();
245
+ expect(queryByTestId("f.panel")).toBeNull();
246
+ });
94
247
  });
package/src/Filter.tsx CHANGED
@@ -7,6 +7,7 @@ import {createWebPortal} from "./createWebPortal";
7
7
  import {Text} from "./Text";
8
8
  import {useTheme} from "./Theme";
9
9
  import {resolveTestID} from "./testing/resolveTestId";
10
+ import {createBoxShadow} from "./Utilities";
10
11
  import {useWebDropdownAnchor} from "./WebDropdownMenu";
11
12
 
12
13
  const DEFAULT_WIDTH = 320;
@@ -111,10 +112,12 @@ export const Filter: FC<FilterProps> = ({
111
112
  borderColor: theme.border.default,
112
113
  borderRadius: theme.radius.default,
113
114
  borderWidth: 1,
114
- shadowColor: theme.primitives.neutral900,
115
- shadowOffset: {height: 4, width: 0},
116
- shadowOpacity: 0.15,
117
- shadowRadius: 12,
115
+ boxShadow: createBoxShadow({
116
+ blurRadius: 12,
117
+ color: theme.primitives.neutral900,
118
+ offsetY: 4,
119
+ opacity: 0.15,
120
+ }),
118
121
  width,
119
122
  };
120
123
 
@@ -184,9 +187,15 @@ export const Filter: FC<FilterProps> = ({
184
187
  }
185
188
  const overlay = (
186
189
  <View
187
- // box-none lets clicks pass to the backdrop / panel but not the empty overlay.
188
- pointerEvents="box-none"
189
- style={{inset: 0, position: "fixed", zIndex: 9999} as unknown as ViewStyle}
190
+ style={
191
+ {
192
+ inset: 0,
193
+ // box-none lets clicks pass to the backdrop / panel but not the empty overlay.
194
+ pointerEvents: "box-none",
195
+ position: "fixed",
196
+ zIndex: 9999,
197
+ } as unknown as ViewStyle
198
+ }
190
199
  >
191
200
  <Pressable
192
201
  aria-role="button"
package/src/GPTChat.tsx CHANGED
@@ -1,5 +1,10 @@
1
1
  import React, {useCallback, useEffect, useRef, useState} from "react";
2
- import {Platform, Image as RNImage, type ScrollView as RNScrollView} from "react-native";
2
+ import {
3
+ Platform,
4
+ Image as RNImage,
5
+ type ScrollView as RNScrollView,
6
+ type TextInput as RNTextInput,
7
+ } from "react-native";
3
8
 
4
9
  import {AttachmentPreview} from "./AttachmentPreview";
5
10
  import {Box} from "./Box";
@@ -82,6 +87,11 @@ export interface MCPServerStatus {
82
87
  name: string;
83
88
  }
84
89
 
90
+ export interface MCPToolDetail {
91
+ name: string;
92
+ description?: string;
93
+ }
94
+
85
95
  export interface GPTChatProps {
86
96
  attachments?: SelectedFile[];
87
97
  availableModels?: Array<{label: string; value: string}>;
@@ -90,6 +100,8 @@ export interface GPTChatProps {
90
100
  geminiApiKey?: string;
91
101
  histories: GPTChatHistory[];
92
102
  isStreaming?: boolean;
103
+ /** Available MCP tools to display in the tools panel. */
104
+ mcpTools?: MCPToolDetail[];
93
105
  mcpServers?: MCPServerStatus[];
94
106
  onAttachFiles?: (files: SelectedFile[]) => void;
95
107
  onCreateHistory: () => void;
@@ -639,6 +651,44 @@ const AttachButton = ({
639
651
  );
640
652
  };
641
653
 
654
+ const ToolsModal = ({
655
+ isVisible,
656
+ mcpTools,
657
+ onDismiss,
658
+ }: {
659
+ isVisible: boolean;
660
+ mcpTools: MCPToolDetail[];
661
+ onDismiss: () => void;
662
+ }): React.ReactElement => {
663
+ return (
664
+ <Modal onDismiss={onDismiss} size="md" title="Available Tools" visible={isVisible}>
665
+ <Box gap={2} padding={3}>
666
+ {mcpTools.length === 0 ? (
667
+ <Text color="secondaryDark" size="sm">
668
+ No tools available.
669
+ </Text>
670
+ ) : (
671
+ mcpTools.map((tool) => (
672
+ <Box border="default" gap={1} key={tool.name} padding={3} rounding="md">
673
+ <Box alignItems="center" direction="row" gap={2}>
674
+ <Icon iconName="wrench" size="xs" />
675
+ <Text bold size="sm">
676
+ {tool.name}
677
+ </Text>
678
+ </Box>
679
+ {tool.description && (
680
+ <Text color="secondaryDark" size="sm">
681
+ {tool.description}
682
+ </Text>
683
+ )}
684
+ </Box>
685
+ ))
686
+ )}
687
+ </Box>
688
+ </Modal>
689
+ );
690
+ };
691
+
642
692
  const ApiKeyModal = ({
643
693
  apiKeyDraft,
644
694
  handleSaveApiKey,
@@ -694,6 +744,7 @@ export const GPTChat = ({
694
744
  geminiApiKey,
695
745
  histories,
696
746
  isStreaming = false,
747
+ mcpTools,
697
748
  mcpServers,
698
749
  onAttachFiles,
699
750
  onCreateHistory,
@@ -720,6 +771,7 @@ export const GPTChat = ({
720
771
  const scrollOffsetRef = useRef(0);
721
772
  const viewportHeightRef = useRef(0);
722
773
  const [isApiKeyModalVisible, setIsApiKeyModalVisible] = useState(false);
774
+ const [isToolsModalVisible, setIsToolsModalVisible] = useState(false);
723
775
  const [apiKeyDraft, setApiKeyDraft] = useState(geminiApiKey ?? "");
724
776
 
725
777
  const handleSubmit = useCallback(() => {
@@ -732,32 +784,40 @@ export const GPTChat = ({
732
784
  setInputValue("");
733
785
  }, [inputValue, isStreaming, onSubmit]);
734
786
 
735
- // On web: Enter sends, Cmd+Enter inserts a new line
787
+ // On web: Enter sends, Shift+Enter inserts a new line
736
788
  const handleSubmitRef = useRef(handleSubmit);
737
789
  handleSubmitRef.current = handleSubmit;
790
+ // Attach keydown listener directly to the textarea element for reliable Enter-to-send.
791
+ // Tracked in state (not a ref) so the effect re-runs when the textarea remounts.
792
+ const [inputElement, setInputElement] = useState<HTMLElement | null>(null);
793
+
794
+ // On React Native Web the TextInput ref is the underlying DOM element.
795
+ const handleInputRef = useCallback((ref: RNTextInput | null) => {
796
+ setInputElement(ref as unknown as HTMLElement | null);
797
+ }, []);
798
+
738
799
  useEffect(() => {
739
- if (Platform.OS !== "web" || typeof document === "undefined") {
800
+ if (Platform.OS !== "web") {
740
801
  return;
741
802
  }
742
- const handler = (e: KeyboardEvent) => {
743
- if (e.key !== "Enter") {
744
- return;
745
- }
746
- const target = e.target as HTMLElement | null;
747
- const testId = target?.getAttribute("data-testid");
748
- if (testId !== "gpt-input") {
803
+ const el = inputElement;
804
+ if (!el) {
805
+ return;
806
+ }
807
+ const handler = (e: Event) => {
808
+ const ke = e as KeyboardEvent;
809
+ if (ke.key !== "Enter") {
749
810
  return;
750
811
  }
751
- if (e.metaKey || e.shiftKey) {
752
- // Cmd+Enter or Shift+Enter: allow default (new line)
812
+ if (ke.shiftKey || ke.metaKey) {
753
813
  return;
754
814
  }
755
815
  e.preventDefault();
756
816
  handleSubmitRef.current();
757
817
  };
758
- document.addEventListener("keydown", handler);
759
- return () => document.removeEventListener("keydown", handler);
760
- }, []);
818
+ el.addEventListener("keydown", handler);
819
+ return () => el.removeEventListener("keydown", handler);
820
+ }, [inputElement]);
761
821
 
762
822
  const handleCopyMessage = useCallback(async (text: string) => {
763
823
  const Clipboard = await import("expo-clipboard");
@@ -1011,12 +1071,20 @@ export const GPTChat = ({
1011
1071
  isStreaming={isStreaming}
1012
1072
  onAttachFiles={onAttachFiles}
1013
1073
  />
1074
+ {mcpTools && mcpTools.length > 0 && (
1075
+ <IconButton
1076
+ accessibilityLabel="Show available tools"
1077
+ iconName="hammer"
1078
+ onClick={() => setIsToolsModalVisible(true)}
1079
+ testID="gpt-tools-button"
1080
+ />
1081
+ )}
1014
1082
  <Box flex="grow">
1015
1083
  <TextArea
1016
1084
  blurOnSubmit={false}
1017
1085
  disabled={isStreaming}
1086
+ inputRef={handleInputRef}
1018
1087
  onChange={setInputValue}
1019
- onEnter={handleSubmit}
1020
1088
  placeholder="Type a message..."
1021
1089
  testID="gpt-input"
1022
1090
  value={inputValue}
@@ -1040,6 +1108,11 @@ export const GPTChat = ({
1040
1108
  onGeminiApiKeyChange={onGeminiApiKeyChange}
1041
1109
  setApiKeyDraft={setApiKeyDraft}
1042
1110
  />
1111
+ <ToolsModal
1112
+ isVisible={isToolsModalVisible}
1113
+ mcpTools={mcpTools ?? []}
1114
+ onDismiss={() => setIsToolsModalVisible(false)}
1115
+ />
1043
1116
  </Box>
1044
1117
  );
1045
1118
  };
@@ -8,7 +8,8 @@ import {
8
8
  } from "react";
9
9
  import {Animated} from "react-native";
10
10
  import {Modalize} from "react-native-modalize";
11
- import {Portal} from "react-native-portalize";
11
+
12
+ import {Portal} from "./PortalHost";
12
13
 
13
14
  export const useCombinedRefs = <T,>(
14
15
  ...refs: Array<Ref<T> | undefined>
@@ -0,0 +1,105 @@
1
+ import type {FC, ReactNode} from "react";
2
+ import {
3
+ createContext,
4
+ useCallback,
5
+ useContext,
6
+ useEffect,
7
+ useId,
8
+ useMemo,
9
+ useRef,
10
+ useState,
11
+ } from "react";
12
+ import {type StyleProp, StyleSheet, View, type ViewStyle} from "react-native";
13
+
14
+ interface PortalManager {
15
+ mount: (key: string, children: ReactNode) => void;
16
+ update: (key: string, children: ReactNode) => void;
17
+ unmount: (key: string) => void;
18
+ }
19
+
20
+ interface PortalEntry {
21
+ children: ReactNode;
22
+ key: string;
23
+ }
24
+
25
+ export const PortalContext = createContext<PortalManager | null>(null);
26
+
27
+ /**
28
+ * Renders its children plus any content sent from a {@link Portal} on top of
29
+ * them. Mount once near the root of the app (TerrenoProvider does this).
30
+ */
31
+ export const Host: FC<{children?: ReactNode; style?: StyleProp<ViewStyle>}> = ({
32
+ children,
33
+ style,
34
+ }) => {
35
+ const [portals, setPortals] = useState<PortalEntry[]>([]);
36
+
37
+ const mount = useCallback((key: string, portalChildren: ReactNode): void => {
38
+ setPortals((prev) => [
39
+ ...prev.filter((entry) => entry.key !== key),
40
+ {children: portalChildren, key},
41
+ ]);
42
+ }, []);
43
+
44
+ const update = useCallback((key: string, portalChildren: ReactNode): void => {
45
+ setPortals((prev) =>
46
+ prev.map((entry) => (entry.key === key ? {...entry, children: portalChildren} : entry))
47
+ );
48
+ }, []);
49
+
50
+ const unmount = useCallback((key: string): void => {
51
+ setPortals((prev) => prev.filter((entry) => entry.key !== key));
52
+ }, []);
53
+
54
+ const manager = useMemo<PortalManager>(
55
+ () => ({mount, unmount, update}),
56
+ [mount, unmount, update]
57
+ );
58
+
59
+ return (
60
+ <PortalContext.Provider value={manager}>
61
+ <View collapsable={false} style={[{flex: 1, pointerEvents: "box-none"}, style]}>
62
+ {children}
63
+ </View>
64
+ {portals.map(({children: portalChildren, key}) => (
65
+ <View
66
+ collapsable={false}
67
+ key={key}
68
+ style={[StyleSheet.absoluteFill, {pointerEvents: "box-none"}]}
69
+ >
70
+ {portalChildren}
71
+ </View>
72
+ ))}
73
+ </PortalContext.Provider>
74
+ );
75
+ };
76
+
77
+ /**
78
+ * Teleports its children to the nearest {@link Host}, so overlays escape the
79
+ * clipping and stacking context of the component that renders them.
80
+ */
81
+ export const Portal: FC<{children?: ReactNode}> = ({children}) => {
82
+ const manager = useContext(PortalContext);
83
+ const key = useId();
84
+ const childrenRef = useRef(children);
85
+ childrenRef.current = children;
86
+
87
+ // Register with the host on mount and clean up the portal when unmounting.
88
+ useEffect(() => {
89
+ if (!manager) {
90
+ return;
91
+ }
92
+ manager.mount(key, childrenRef.current);
93
+ return () => manager.unmount(key);
94
+ }, [key, manager]);
95
+
96
+ // Push the latest children into the host whenever the portal content changes.
97
+ useEffect(() => {
98
+ if (!manager) {
99
+ return;
100
+ }
101
+ manager.update(key, children);
102
+ }, [children, key, manager]);
103
+
104
+ return null;
105
+ };
@@ -391,12 +391,12 @@ const SidebarHeader: FC<{onOpen: () => void}> = ({onOpen}) => {
391
391
  </View>
392
392
  {Boolean(title) && (
393
393
  <View
394
- pointerEvents="none"
395
394
  style={{
396
395
  alignItems: "center",
397
396
  bottom: 0,
398
397
  justifyContent: "center",
399
398
  left: 0,
399
+ pointerEvents: "none",
400
400
  position: "absolute",
401
401
  right: 0,
402
402
  top: 0,
@@ -1,10 +1,10 @@
1
1
  import type React from "react";
2
2
  import type {FC} from "react";
3
- import {Host} from "react-native-portalize";
4
3
 
5
4
  import type {IconRegistryMap} from "./Common";
6
5
  import {IconRegistryProvider} from "./IconRegistry";
7
6
  import {OpenAPIProvider} from "./OpenAPIContext";
7
+ import {Host} from "./PortalHost";
8
8
  import {ThemeProvider} from "./Theme";
9
9
  import {Toast} from "./Toast";
10
10
  import {ToastProvider} from "./ToastNotifications";