@agimon-ai/po-native 0.0.1-alpha.62 → 0.0.1-alpha.64

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": "@agimon-ai/po-native",
3
- "version": "0.0.1-alpha.62",
3
+ "version": "0.0.1-alpha.64",
4
4
  "description": "Po for iOS and Android",
5
5
  "homepage": "https://agimon.ai",
6
6
  "bugs": {
@@ -29,17 +29,17 @@
29
29
  "access": "public"
30
30
  },
31
31
  "dependencies": {
32
- "@agimon-ai/po-core": "0.0.0-alpha.182",
33
- "@agimon-ai/po-expo-signing": "0.0.1-alpha.62",
34
- "@agimon-ai/po-identity": "0.0.2-alpha.129",
35
- "@agimon-ai/po-native-components": "0.0.0-alpha.182",
36
- "@agimon-ai/po-native-dashboard": "0.0.0-alpha.54",
37
- "@agimon-ai/po-template-advanced": "0.0.0-alpha.182",
38
- "@agimon-ai/po-template-elegant": "0.0.0-alpha.182",
39
- "@agimon-ai/po-voice": "0.0.0-alpha.182",
40
- "@agimon-ai/po-web-components": "0.0.0-alpha.182",
41
- "@agimon-ai/po-web-dashboard": "0.0.0-alpha.182",
42
- "@agimon-ai/po-web-security": "0.0.0-alpha.182",
32
+ "@agimon-ai/po-core": "0.0.0-alpha.184",
33
+ "@agimon-ai/po-expo-signing": "0.0.1-alpha.64",
34
+ "@agimon-ai/po-identity": "0.0.2-alpha.131",
35
+ "@agimon-ai/po-native-components": "0.0.0-alpha.184",
36
+ "@agimon-ai/po-native-dashboard": "0.0.0-alpha.56",
37
+ "@agimon-ai/po-template-advanced": "0.0.0-alpha.184",
38
+ "@agimon-ai/po-template-elegant": "0.0.0-alpha.184",
39
+ "@agimon-ai/po-voice": "0.0.0-alpha.184",
40
+ "@agimon-ai/po-web-components": "0.0.0-alpha.184",
41
+ "@agimon-ai/po-web-dashboard": "0.0.0-alpha.184",
42
+ "@agimon-ai/po-web-security": "0.0.0-alpha.184",
43
43
  "@better-auth/expo": "1.7.12",
44
44
  "@config-plugins/react-native-webrtc": "15.0.2",
45
45
  "@earendil-works/chord": "1.5.2",
package/src/app/App.tsx CHANGED
@@ -1,3 +1,4 @@
1
+ import { WORKFLOW_STEP_SESSION_PROVENANCE } from '@agimon-ai/po-core/hubChannel';
1
2
  import type { NativeTemplateSessionsActions, NativeTemplateSessionsProps } from '@agimon-ai/po-core/native';
2
3
  import { NATIVE_PAIRING_LINK_PREFIX } from '@agimon-ai/po-core/remoteContract';
3
4
  import type {
@@ -687,7 +688,7 @@ function SessionRoute({
687
688
  nativeRealtime: NativeRealtimeHost;
688
689
  runNativeVoice: NonNullable<WebPluginSlotProps['runNativeVoice']>;
689
690
  onFocus: (sessionId: string | null) => void;
690
- onWake: (sessionId: string) => Promise<void>;
691
+ onWake: (sessionId: string, options?: { silent?: boolean }) => Promise<void>;
691
692
  searchFiles: (sessionId: string, query: string) => Promise<string[]>;
692
693
  offline?: React.ComponentProps<typeof SessionScreen>['offline'];
693
694
  onRetryActivity: (sessionId: string) => void;
@@ -695,6 +696,13 @@ function SessionRoute({
695
696
  }) {
696
697
  useRenderTrace('SessionRoute');
697
698
  const { sessionId: ownerSessionId } = route.params;
699
+ const focused = useIsFocused();
700
+ const [foreground, setForeground] = useState(AppState.currentState === 'active');
701
+ useEffect(() => {
702
+ const subscription = AppState.addEventListener('change', (state) => setForeground(state === 'active'));
703
+ return () => subscription.remove();
704
+ }, []);
705
+ const wakeAttempted = useRef<string | null>(null);
698
706
  const [selectedTabId, setSelectedTabId] = useState<string | null>(null);
699
707
  // The aside conversation sheet belongs to the tab that opened it, so switching tabs closes it.
700
708
  const [conversationOpen, setConversationOpen] = useState(false);
@@ -854,6 +862,42 @@ function SessionRoute({
854
862
  return () => onFocus(null);
855
863
  }, [sessionId, onFocus]),
856
864
  );
865
+ useEffect(() => {
866
+ if (!focused || selectedTabId !== null || activityOpen) {
867
+ wakeAttempted.current = null;
868
+ return;
869
+ }
870
+ if (
871
+ !foreground ||
872
+ wakeAttempted.current === sessionId ||
873
+ route.params.activity ||
874
+ offline ||
875
+ summary?.dormant !== true ||
876
+ entry?.attach === 'offline' ||
877
+ summary.sessionProvenance === WORKFLOW_STEP_SESSION_PROVENANCE ||
878
+ entry?.canInteract !== true
879
+ )
880
+ return;
881
+ wakeAttempted.current = sessionId;
882
+ setWaking(true);
883
+ setWakeError(undefined);
884
+ void onWake(sessionId, { silent: true })
885
+ .catch((error: unknown) => setWakeError(messageOf(error, 'Po could not wake this session.')))
886
+ .finally(() => setWaking(false));
887
+ }, [
888
+ focused,
889
+ foreground,
890
+ selectedTabId,
891
+ activityOpen,
892
+ route.params.activity,
893
+ offline,
894
+ summary?.dormant,
895
+ entry?.attach,
896
+ summary?.sessionProvenance,
897
+ entry?.canInteract,
898
+ sessionId,
899
+ onWake,
900
+ ]);
857
901
  const store = sessionStoreFor(sessionId);
858
902
  const statuses = useStore(store, (state) => state.statuses);
859
903
  const [, modesChanged] = useState(0);
@@ -3317,10 +3361,11 @@ export function App({ nativeHost }: { nativeHost?: (sessionId: string) => Native
3317
3361
  hosts.current?.forSession(sessionId)?.searchFiles(sessionId, query) ?? Promise.resolve([]),
3318
3362
  [],
3319
3363
  );
3320
- const wakeSession = useCallback(async (sessionId: string) => {
3364
+ const wakeSession = useCallback(async (sessionId: string, options?: { silent?: boolean }) => {
3321
3365
  const runtime = hosts.current?.forSession(sessionId);
3322
3366
  if (!runtime) throw new Error('Po on your computer is not connected.');
3323
- await runtime.wake(sessionId);
3367
+ if (options) await runtime.wake(sessionId, options);
3368
+ else await runtime.wake(sessionId);
3324
3369
  }, []);
3325
3370
 
3326
3371
  const forgetHost = useCallback((hostUUID: string) => {
@@ -12,6 +12,7 @@ import { Sheet, SheetBody, SheetContent, fontOf } from '@agimon-ai/po-native-com
12
12
  import { useFocusEffect, useIsFocused } from '@react-navigation/native';
13
13
  import { type ReactNode, useCallback, useEffect, useRef, useState } from 'react';
14
14
  import { AppState, ScrollView, Text } from 'react-native';
15
+ import { KeyboardAwareScrollView } from 'react-native-keyboard-controller';
15
16
  import { StyleSheet } from 'react-native-unistyles';
16
17
 
17
18
  import * as deviceKey from '../../modules/po-device-key';
@@ -58,11 +59,15 @@ export function AddHostRoute({ connect, onLeave }: { connect: ConnectCardProps;
58
59
  if (!focused) onLeave();
59
60
  }, [focused, onLeave]);
60
61
  return (
61
- <HostRoutePage>
62
+ <KeyboardAwareScrollView
63
+ enabled={focused}
64
+ keyboardShouldPersistTaps="handled"
65
+ contentContainerStyle={styles.content}
66
+ >
62
67
  <AddHostView>
63
68
  <ConnectCard {...connect} cameraEnabled={focused} />
64
69
  </AddHostView>
65
- </HostRoutePage>
70
+ </KeyboardAwareScrollView>
66
71
  );
67
72
  }
68
73
 
@@ -239,7 +239,7 @@ export interface LiveRuntime {
239
239
  /** Focuses one session (protocol attach, hub subscribe, session composition) or none. */
240
240
  open(sessionId: string | null): void;
241
241
  /** Starts a stopped session again, as the cockpit's "Wake session" does. */
242
- wake(sessionId: string): Promise<void>;
242
+ wake(sessionId: string, options?: { silent?: boolean }): Promise<void>;
243
243
  /** Workspace files matching an `@` query, from the same hub route the cockpit searches. */
244
244
  searchFiles(sessionId: string, query: string): Promise<string[]>;
245
245
  retryActivity(sessionId: string): void;
@@ -812,14 +812,19 @@ export function startLiveRuntime(
812
812
  void loadCompositions();
813
813
  applyFocus();
814
814
  },
815
- async wake(sessionId) {
815
+ async wake(sessionId, options) {
816
816
  const target = hostPath(sessionId, '/revive');
817
817
  // A Cloud-linked computer has no Face ID key to confirm with; its sign-in is what admits the wake.
818
- const response = cloudComputer
819
- ? await request({ method: 'POST', target })
820
- : await fetchWithStepUp({ method: 'POST', target }, undefined, undefined, host.id);
818
+ const response =
819
+ cloudComputer || options?.silent === true
820
+ ? await request({ method: 'POST', target })
821
+ : await fetchWithStepUp({ method: 'POST', target }, undefined, undefined, host.id);
821
822
  if (response.ok) return;
822
823
  const body: unknown = await response.json().catch(() => undefined);
824
+ if (options?.silent && response.status === 401 && isRecord(body) && typeof body.action === 'string') return;
825
+ // Another client may have revived the same dormant record before this request arrived.
826
+ const current = sessionsStore.state.byId[sessionId]?.summary;
827
+ if (options?.silent && response.status === 404 && current && current.dormant !== true) return;
823
828
  throw new Error(
824
829
  isRecord(body) && typeof body.error === 'string' ? body.error : 'Po could not wake this session.',
825
830
  );