@comergehq/studio 0.1.11 → 0.1.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comergehq/studio",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "Comerge studio",
5
5
  "main": "src/index.ts",
6
6
  "module": "dist/index.mjs",
@@ -42,6 +42,7 @@
42
42
  },
43
43
  "dependencies": {
44
44
  "axios": "^1.13.1",
45
+ "@comergehq/studio-control": "^0.1.5",
45
46
  "react-native-markdown-display": "^7.0.2",
46
47
  "react-native-logs": "^5.5.0"
47
48
  },
@@ -21,6 +21,8 @@ export type ComergeStudioProps = {
21
21
  appKey?: string;
22
22
  onNavigateHome?: () => void;
23
23
  style?: ViewStyle;
24
+ showFloatingButton?: boolean;
25
+ studioControlOptions?: import('@comergehq/studio-control').StudioControlOptions;
24
26
  };
25
27
 
26
28
  export function ComergeStudio({
@@ -29,6 +31,8 @@ export function ComergeStudio({
29
31
  appKey = 'MicroMain',
30
32
  onNavigateHome,
31
33
  style,
34
+ showFloatingButton = true,
35
+ studioControlOptions,
32
36
  }: ComergeStudioProps) {
33
37
  const [activeAppId, setActiveAppId] = React.useState(appId);
34
38
  const [runtimeAppId, setRuntimeAppId] = React.useState(appId);
@@ -61,6 +65,8 @@ export function ComergeStudio({
61
65
  onNavigateHome={onNavigateHome}
62
66
  captureTargetRef={captureTargetRef}
63
67
  style={style}
68
+ showFloatingButton={showFloatingButton}
69
+ studioControlOptions={studioControlOptions}
64
70
  />
65
71
  </LiquidGlassResetProvider>
66
72
  </BottomSheetModalProvider>
@@ -82,6 +88,8 @@ type InnerProps = {
82
88
  onNavigateHome?: () => void;
83
89
  captureTargetRef: React.RefObject<View | null>;
84
90
  style?: ViewStyle;
91
+ showFloatingButton: boolean;
92
+ studioControlOptions?: import('@comergehq/studio-control').StudioControlOptions;
85
93
  };
86
94
 
87
95
  function ComergeStudioInner({
@@ -97,6 +105,8 @@ function ComergeStudioInner({
97
105
  onNavigateHome,
98
106
  captureTargetRef,
99
107
  style,
108
+ showFloatingButton,
109
+ studioControlOptions,
100
110
  }: InnerProps) {
101
111
  const { app, loading: appLoading } = useApp(activeAppId);
102
112
  const { app: runtimeAppFromHook } = useApp(runtimeAppId, { enabled: runtimeAppId !== activeAppId });
@@ -266,6 +276,8 @@ function ComergeStudioInner({
266
276
  chatShowTypingIndicator={chatShowTypingIndicator}
267
277
  onSendChat={(text, attachments) => actions.sendEdit({ prompt: text, attachments })}
268
278
  onNavigateHome={onNavigateHome}
279
+ showFloatingButton={showFloatingButton}
280
+ studioControlOptions={studioControlOptions}
269
281
  />
270
282
  </View>
271
283
  </View>
@@ -15,6 +15,11 @@ import { ConfirmMergeFlow } from './ConfirmMergeFlow';
15
15
  import type { MergeRequestSummary } from '../../components/models/types';
16
16
  import { useTheme } from '../../theme';
17
17
  import { useOptimisticChatMessages } from '../hooks/useOptimisticChatMessages';
18
+ import {
19
+ publishComergeStudioUIState,
20
+ startStudioControlPolling,
21
+ type StudioControlOptions,
22
+ } from '@comergehq/studio-control';
18
23
 
19
24
  import { MergeIcon } from '../../components/icons/MergeIcon';
20
25
 
@@ -56,6 +61,8 @@ export type StudioOverlayProps = {
56
61
 
57
62
  // Navigation callbacks
58
63
  onNavigateHome?: () => void;
64
+ showFloatingButton: boolean;
65
+ studioControlOptions?: StudioControlOptions;
59
66
  };
60
67
 
61
68
  type SheetPage = 'preview' | 'chat';
@@ -87,11 +94,14 @@ export function StudioOverlay({
87
94
  chatShowTypingIndicator,
88
95
  onSendChat,
89
96
  onNavigateHome,
97
+ showFloatingButton,
98
+ studioControlOptions,
90
99
  }: StudioOverlayProps) {
91
100
  const theme = useTheme();
92
101
  const { width } = useWindowDimensions();
93
102
 
94
103
  const [sheetOpen, setSheetOpen] = React.useState(false);
104
+ const sheetOpenRef = React.useRef(sheetOpen);
95
105
  const [activePage, setActivePage] = React.useState<SheetPage>('preview');
96
106
 
97
107
  const [drawing, setDrawing] = React.useState(false);
@@ -186,6 +196,23 @@ export function StudioOverlay({
186
196
  [closeSheet, onTestMr]
187
197
  );
188
198
 
199
+ React.useEffect(() => {
200
+ sheetOpenRef.current = sheetOpen;
201
+ }, [sheetOpen]);
202
+
203
+ React.useEffect(() => {
204
+ const poller = startStudioControlPolling((action) => {
205
+ if (action === 'show' && !sheetOpenRef.current) openSheet();
206
+ if (action === 'hide' && sheetOpenRef.current) closeSheet();
207
+ if (action === 'toggle') toggleSheet();
208
+ }, studioControlOptions);
209
+ return () => poller.stop();
210
+ }, [closeSheet, openSheet, studioControlOptions, toggleSheet]);
211
+
212
+ React.useEffect(() => {
213
+ void publishComergeStudioUIState(sheetOpen, studioControlOptions);
214
+ }, [sheetOpen, studioControlOptions]);
215
+
189
216
  return (
190
217
  <>
191
218
  {/* Testing glow around runtime */}
@@ -243,17 +270,19 @@ export function StudioOverlay({
243
270
  />
244
271
  </StudioBottomSheet>
245
272
 
246
- <FloatingDraggableButton
247
- visible={!sheetOpen && !drawing}
248
- ariaLabel={sheetOpen ? 'Hide studio' : 'Show studio'}
249
- badgeCount={incomingMergeRequests.length}
250
- onPress={toggleSheet}
251
- isLoading={app?.status === 'editing'}
252
- >
253
- <View style={{ width: 28, height: 28, alignItems: 'center', justifyContent: 'center' }}>
254
- <MergeIcon width={24} height={24} color={theme.colors.floatingContent} />
255
- </View>
256
- </FloatingDraggableButton>
273
+ {showFloatingButton && (
274
+ <FloatingDraggableButton
275
+ visible={!sheetOpen && !drawing}
276
+ ariaLabel={sheetOpen ? 'Hide studio' : 'Show studio'}
277
+ badgeCount={incomingMergeRequests.length}
278
+ onPress={toggleSheet}
279
+ isLoading={app?.status === 'editing'}
280
+ >
281
+ <View style={{ width: 28, height: 28, alignItems: 'center', justifyContent: 'center' }}>
282
+ <MergeIcon width={24} height={24} color={theme.colors.floatingContent} />
283
+ </View>
284
+ </FloatingDraggableButton>
285
+ )}
257
286
 
258
287
  <DrawModeOverlay
259
288
  visible={drawing}