@agimon-ai/po-template-advanced 0.0.0-alpha.73 → 0.0.0-alpha.75

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.
@@ -3,8 +3,8 @@ import { View } from "react-native-unistyles/components/native/View";
3
3
  import { Text } from "react-native-unistyles/components/native/Text";
4
4
  import { SectionList } from "react-native-unistyles/components/native/SectionList";
5
5
  import { Pressable } from "react-native-unistyles/components/native/Pressable";
6
- import { ActivityIcon, AlertIcon, Badge, BranchIcon, Button, CheckIcon, EditIcon, EmptyState, FolderIcon, ForkIcon, HostTag, InfoStrip, Input, KebabIcon, Label, ListRow, LiveDuration, PlusIcon, Sheet, SheetBody, SheetContent, SheetHeader, SheetTitle, Spinner, Textarea, TrashIcon, UsersIcon, fontOf } from "@agimon-ai/po-native-components";
7
- import { useCallback, useEffect, useMemo, useState } from "react";
6
+ import { ActivityIcon, AlertIcon, Badge, BranchIcon, Button, CheckIcon, CountBadge, EditIcon, EmptyState, FolderIcon, ForkIcon, HostTag, InfoStrip, Input, KebabIcon, Label, ListRow, LiveDuration, PlusIcon, Sheet, SheetBody, SheetContent, SheetHeader, SheetTitle, Spinner, Textarea, TrashIcon, UsersIcon, fontOf } from "@agimon-ai/po-native-components";
7
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
8
8
  import { StyleSheet } from "react-native-unistyles";
9
9
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
10
  /** Every group some session uses, in rail order, with the other sessions in it. */
@@ -1128,9 +1128,10 @@ function SessionCard({ session, onOpen, onMenu, onSetupMenu, hostLabel, stale =
1128
1128
  const tone = stale ? "quiet" : statusTone(session.status);
1129
1129
  const name = session.name || "Untitled";
1130
1130
  const markColor = session.active ? "green" : "faint";
1131
+ const waiting = stale ? 0 : session.waitingCount ?? (session.awaitingInput ? 1 : 0);
1131
1132
  return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Pressable, {
1132
1133
  accessibilityRole: "button",
1133
- accessibilityLabel: `Open ${name}`,
1134
+ accessibilityLabel: waiting > 0 ? `Open ${name}, ${String(waiting)} waiting for you` : `Open ${name}`,
1134
1135
  disabled: stale,
1135
1136
  accessibilityState: { disabled: stale },
1136
1137
  onPress: () => onOpen(session.id),
@@ -1144,41 +1145,47 @@ function SessionCard({ session, onOpen, onMenu, onSetupMenu, hostLabel, stale =
1144
1145
  /* @__PURE__ */ jsxs(View, {
1145
1146
  style: styles.cardHead,
1146
1147
  children: [
1147
- session.profile ? /* @__PURE__ */ jsx(View, {
1148
+ session.profile ? /* @__PURE__ */ jsxs(View, {
1148
1149
  style: styles.avatar,
1149
1150
  accessibilityLabel: session.profile.label,
1150
- children: /* @__PURE__ */ jsx(Text, {
1151
+ children: [/* @__PURE__ */ jsx(Text, {
1151
1152
  style: styles.initials,
1152
1153
  children: session.profile.initials
1153
- })
1154
+ }), /* @__PURE__ */ jsx(CountBadge, {
1155
+ count: waiting,
1156
+ style: styles.avatarBadge
1157
+ })]
1154
1158
  }) : null,
1155
1159
  /* @__PURE__ */ jsxs(View, {
1156
1160
  style: styles.cardText,
1157
1161
  children: [/* @__PURE__ */ jsxs(View, {
1158
1162
  style: styles.nameRow,
1159
- children: [session.nested && session.provenance === "workflow-session" ? /* @__PURE__ */ jsx(ActivityIcon, {
1160
- size: 13,
1161
- color: markColor,
1162
- accessibilityLabel: "workflow session"
1163
- }) : session.nested && session.provenance ? /* @__PURE__ */ jsx(ForkIcon, {
1164
- size: 13,
1165
- color: markColor,
1166
- accessibilityLabel: session.provenance === "worktree" ? "automatic per-conversation worktree" : session.provenance
1167
- }) : null, /* @__PURE__ */ jsx(Text, {
1168
- style: styles.name,
1169
- numberOfLines: 2,
1170
- children: name
1171
- })]
1163
+ children: [
1164
+ session.nested && session.provenance === "workflow-session" ? /* @__PURE__ */ jsx(ActivityIcon, {
1165
+ size: 13,
1166
+ color: markColor,
1167
+ accessibilityLabel: "workflow session"
1168
+ }) : session.nested && session.provenance ? /* @__PURE__ */ jsx(ForkIcon, {
1169
+ size: 13,
1170
+ color: markColor,
1171
+ accessibilityLabel: session.provenance === "worktree" ? "automatic per-conversation worktree" : session.provenance
1172
+ }) : null,
1173
+ /* @__PURE__ */ jsx(Text, {
1174
+ style: styles.name,
1175
+ numberOfLines: 2,
1176
+ children: name
1177
+ }),
1178
+ session.profile ? null : /* @__PURE__ */ jsx(CountBadge, {
1179
+ count: waiting,
1180
+ style: styles.nameBadge
1181
+ })
1182
+ ]
1172
1183
  }), /* @__PURE__ */ jsxs(View, {
1173
1184
  style: styles.statusRow,
1174
1185
  children: [stale ? null : session.restarting ? /* @__PURE__ */ jsx(Spinner, {
1175
1186
  size: "small",
1176
1187
  color: "dim",
1177
1188
  label: "Restarting"
1178
- }) : session.awaitingInput ? /* @__PURE__ */ jsx(AlertIcon, {
1179
- size: 12,
1180
- color: "magenta",
1181
- accessibilityLabel: "Waiting for you"
1182
1189
  }) : tone === "running" ? /* @__PURE__ */ jsx(Spinner, {
1183
1190
  size: "small",
1184
1191
  color: "yellow"
@@ -1344,8 +1351,9 @@ function sessionSections(workspaces, presentation, selectedHost = null) {
1344
1351
  return filter === null || owner === filter;
1345
1352
  });
1346
1353
  const sections = [];
1347
- for (const workspace of visible) {
1348
- const existing = presentation && presentation.hosts.length > 1 && !workspace.legacy ? sections.find((section) => !section.workspace.legacy && section.workspace.name === workspace.name) : void 0;
1354
+ for (const workspace of [...visible.filter((item) => item.kind === "session"), ...visible.filter((item) => item.kind !== "session")]) {
1355
+ if (workspace.kind === "session" && workspace.sessions.length === 0) continue;
1356
+ const existing = workspace.kind === "session" ? sections.find((section) => section.workspace.kind === "session") : presentation && presentation.hosts.length > 1 && !workspace.legacy ? sections.find((section) => section.workspace.kind !== "session" && !section.workspace.legacy && section.workspace.name === workspace.name) : void 0;
1349
1357
  if (existing) {
1350
1358
  existing.members.push(workspace);
1351
1359
  existing.data = [...existing.data, ...workspace.sessions];
@@ -1401,13 +1409,25 @@ function AdvancedSessions({ workspaces, openSession, actions, setHeaderAction, h
1401
1409
  }
1402
1410
  setAdding(true);
1403
1411
  }, [hosts]);
1404
- const titleAdd = canAdd && setHeaderAction !== void 0;
1412
+ const generalAction = useRef(actions.createGeneralSession);
1413
+ useEffect(() => {
1414
+ generalAction.current = actions.createGeneralSession;
1415
+ }, [actions.createGeneralSession]);
1416
+ const canGeneral = hosts.length > 0 ? hosts.some((host) => host.createGeneralSession !== void 0) : actions.createGeneralSession !== void 0;
1417
+ const beginGeneral = useCallback(() => {
1418
+ const host = hosts.find((host) => host.id === selected) ?? (hosts.length === 1 ? hosts[0] : void 0);
1419
+ if (host) {
1420
+ if (host.status === "connected") host.createGeneralSession?.();
1421
+ } else if (hosts.length > 1) setChoosing("general");
1422
+ else generalAction.current?.();
1423
+ }, [hosts, selected]);
1424
+ const titleAdd = (canGeneral || canAdd) && setHeaderAction !== void 0;
1405
1425
  useEffect(() => {
1406
1426
  if (!titleAdd) return;
1407
1427
  setHeaderAction(/* @__PURE__ */ jsx(IconButton, {
1408
- label: "Add workspace",
1409
- onPress: beginAdd,
1410
- disabled: hosts.length === 1 && hosts[0].status !== "connected",
1428
+ label: canGeneral ? "New session" : "Add workspace",
1429
+ onPress: canGeneral ? beginGeneral : beginAdd,
1430
+ disabled: canGeneral && selected !== null ? hosts.find((host) => host.id === selected)?.status !== "connected" : hosts.length === 1 && hosts[0].status !== "connected",
1411
1431
  children: /* @__PURE__ */ jsx(PlusIcon, {
1412
1432
  size: 18,
1413
1433
  color: "dim"
@@ -1418,7 +1438,10 @@ function AdvancedSessions({ workspaces, openSession, actions, setHeaderAction, h
1418
1438
  titleAdd,
1419
1439
  setHeaderAction,
1420
1440
  beginAdd,
1421
- hosts
1441
+ beginGeneral,
1442
+ canGeneral,
1443
+ hosts,
1444
+ selected
1422
1445
  ]);
1423
1446
  const sessions = workspaces.flatMap((workspace) => workspace.sessions).filter((session) => !stale(session.id));
1424
1447
  const { setSessionGroups, renameGroup, deleteGroup, removePendingSetup } = actions;
@@ -1438,7 +1461,7 @@ function AdvancedSessions({ workspaces, openSession, actions, setHeaderAction, h
1438
1461
  initialNumToRender: 12,
1439
1462
  maxToRenderPerBatch: 12,
1440
1463
  windowSize: 5,
1441
- renderSectionHeader: ({ section }) => /* @__PURE__ */ jsx(WorkspaceHeader, {
1464
+ renderSectionHeader: ({ section }) => section.workspace.kind === "session" ? null : /* @__PURE__ */ jsx(WorkspaceHeader, {
1442
1465
  workspace: section.workspace,
1443
1466
  actions,
1444
1467
  onWorkspaceMenu: (entry) => {
@@ -1476,23 +1499,28 @@ function AdvancedSessions({ workspaces, openSession, actions, setHeaderAction, h
1476
1499
  }),
1477
1500
  ListEmptyComponent: /* @__PURE__ */ jsx(EmptyState, {
1478
1501
  title: selected ? "No sessions on this computer." : "No sessions yet.",
1479
- description: "Add a workspace to start working with Po."
1502
+ description: canGeneral ? "Start a session to work with Po. No workspace needed." : "Add a workspace to start working with Po."
1480
1503
  }),
1481
1504
  ListHeaderComponent: /* @__PURE__ */ jsxs(View, {
1482
1505
  style: styles.listHeader,
1483
- children: [hosts.filter((host) => host.status !== "connected" && (selected === null || selected === host.id)).map((host) => /* @__PURE__ */ jsx(InfoStrip, {
1484
- message: host.status === "update_required" ? `${host.label} needs an app update. Sessions are read-only.` : `${host.label} is offline. Showing last known sessions.`,
1485
- actionLabel: "Retry",
1486
- onAction: host.onRetry
1487
- }, host.id)), canAdd && !titleAdd ? /* @__PURE__ */ jsxs(Button, {
1488
- variant: "ghost",
1489
- onPress: beginAdd,
1490
- disabled: hosts.length === 1 && hosts[0].status !== "connected",
1491
- children: [/* @__PURE__ */ jsx(PlusIcon, {
1492
- size: 18,
1493
- color: "dim"
1494
- }), "Add workspace"]
1495
- }) : null]
1506
+ children: [
1507
+ hosts.filter((host) => host.status !== "connected" && (selected === null || selected === host.id)).map((host) => /* @__PURE__ */ jsx(InfoStrip, {
1508
+ message: host.status === "update_required" ? `${host.label} needs an app update. Sessions are read-only.` : `${host.label} is offline. Showing last known sessions.`,
1509
+ actionLabel: "Retry",
1510
+ onAction: host.onRetry
1511
+ }, host.id)),
1512
+ canGeneral && !titleAdd ? /* @__PURE__ */ jsx(Button, {
1513
+ variant: "ghost",
1514
+ onPress: beginGeneral,
1515
+ children: "New session"
1516
+ }) : null,
1517
+ canAdd && (canGeneral || !titleAdd) ? /* @__PURE__ */ jsx(Button, {
1518
+ variant: "ghost",
1519
+ onPress: beginAdd,
1520
+ disabled: hosts.length === 1 && hosts[0].status !== "connected",
1521
+ children: "Add workspace"
1522
+ }) : null
1523
+ ]
1496
1524
  })
1497
1525
  }),
1498
1526
  /* @__PURE__ */ jsx(SessionMenuSheet, {
@@ -1530,7 +1558,15 @@ function AdvancedSessions({ workspaces, openSession, actions, setHeaderAction, h
1530
1558
  onOpenChange: (open) => {
1531
1559
  if (!open) setChoosing(null);
1532
1560
  },
1533
- children: /* @__PURE__ */ jsxs(SheetContent, { children: [/* @__PURE__ */ jsx(SheetHeader, { children: /* @__PURE__ */ jsx(SheetTitle, { children: "Which computer?" }) }), /* @__PURE__ */ jsx(SheetBody, { children: choosing === "add" ? hosts.map((host) => /* @__PURE__ */ jsxs(Button, {
1561
+ children: /* @__PURE__ */ jsxs(SheetContent, { children: [/* @__PURE__ */ jsx(SheetHeader, { children: /* @__PURE__ */ jsx(SheetTitle, { children: "Which computer?" }) }), /* @__PURE__ */ jsx(SheetBody, { children: choosing === "general" ? hosts.map((host) => /* @__PURE__ */ jsxs(Button, {
1562
+ variant: "ghost",
1563
+ disabled: host.status !== "connected" || !host.createGeneralSession,
1564
+ onPress: () => {
1565
+ setChoosing(null);
1566
+ host.createGeneralSession?.();
1567
+ },
1568
+ children: [host.label, host.status !== "connected" ? " · Unavailable" : ""]
1569
+ }, host.id)) : choosing === "add" ? hosts.map((host) => /* @__PURE__ */ jsxs(Button, {
1534
1570
  variant: "ghost",
1535
1571
  disabled: host.status !== "connected" || !host.addWorkspaceActions,
1536
1572
  onPress: () => {
@@ -1559,7 +1595,7 @@ function AdvancedSessions({ workspaces, openSession, actions, setHeaderAction, h
1559
1595
  }
1560
1596
  function sectionPath(sessionId, workspaces, sections) {
1561
1597
  const section = sections.find((entry) => entry.data.some(({ id }) => id === sessionId));
1562
- if (!section || new Set(section.members.map(({ root }) => root)).size < 2) return void 0;
1598
+ if (!section || section.workspace.kind === "session" || new Set(section.members.map(({ root }) => root)).size < 2) return void 0;
1563
1599
  return workspaces.find((workspace) => workspace.sessions.some(({ id }) => id === sessionId))?.root;
1564
1600
  }
1565
1601
  const styles = StyleSheet.create((theme) => {
@@ -1722,6 +1758,17 @@ const styles = StyleSheet.create((theme) => {
1722
1758
  fontWeight: theme.fontWeight.semibold,
1723
1759
  uni__dependencies: [0]
1724
1760
  },
1761
+ avatarBadge: {
1762
+ position: "absolute",
1763
+ top: -4,
1764
+ right: -6,
1765
+ borderColor: theme.colors.bg,
1766
+ uni__dependencies: [0]
1767
+ },
1768
+ nameBadge: {
1769
+ borderColor: theme.colors.bg,
1770
+ uni__dependencies: [0]
1771
+ },
1725
1772
  cardText: {
1726
1773
  flex: 1,
1727
1774
  minWidth: 0,