@agimon-ai/po-template-advanced 0.0.0-alpha.52 → 0.0.0-alpha.53
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/dist/extensions/native.mjs +194 -85
- package/dist/extensions/native.mjs.map +1 -1
- package/dist/extensions/web.mjs +6 -7
- package/dist/extensions/web.mjs.map +1 -1
- package/dist/webClient.cjs +5 -6
- package/dist/webClient.cjs.map +1 -1
- package/dist/webClient.mjs +6 -7
- package/dist/webClient.mjs.map +1 -1
- package/package.json +7 -7
|
@@ -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, Input, KebabIcon, Label, ListRow, LiveDuration, PlusIcon, Sheet, SheetBody, SheetContent, SheetHeader, SheetTitle, Spinner, TrashIcon, UsersIcon, fontOf } from "@agimon-ai/po-native-components";
|
|
7
|
-
import { useEffect, useMemo, useState } from "react";
|
|
6
|
+
import { ActivityIcon, AlertIcon, Badge, BranchIcon, Button, CheckIcon, EditIcon, EmptyState, FolderIcon, ForkIcon, HostFilter, HostTag, InfoStrip, Input, KebabIcon, Label, ListRow, LiveDuration, PlusIcon, Sheet, SheetBody, SheetContent, SheetHeader, SheetTitle, Spinner, TrashIcon, UsersIcon, fontOf } from "@agimon-ai/po-native-components";
|
|
7
|
+
import { useCallback, useEffect, useMemo, 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. */
|
|
@@ -905,6 +905,7 @@ const styles$1 = StyleSheet.create((theme) => {
|
|
|
905
905
|
});
|
|
906
906
|
//#endregion
|
|
907
907
|
//#region src/extensions/(frontend)/template/_components/AdvancedSessions.native.tsx
|
|
908
|
+
const NO_HOSTS = [];
|
|
908
909
|
/** The same reading of the status line as the cockpit card. */
|
|
909
910
|
function statusTone(status) {
|
|
910
911
|
if (status.startsWith("failed") || status.includes(" failed")) return "failed";
|
|
@@ -912,29 +913,33 @@ function statusTone(status) {
|
|
|
912
913
|
return "quiet";
|
|
913
914
|
}
|
|
914
915
|
/** A 44 point icon target, as the cockpit's ghost icon buttons. */
|
|
915
|
-
function IconButton({ label, onPress, children }) {
|
|
916
|
+
function IconButton({ label, onPress, children, disabled = false }) {
|
|
916
917
|
return /* @__PURE__ */ jsx(Pressable, {
|
|
917
918
|
accessibilityRole: "button",
|
|
918
919
|
accessibilityLabel: label,
|
|
920
|
+
accessibilityState: { disabled },
|
|
921
|
+
disabled,
|
|
919
922
|
hitSlop: 6,
|
|
920
923
|
onPress,
|
|
921
924
|
style: ({ pressed }) => [styles.iconButton, pressed && styles.iconPressed],
|
|
922
925
|
children
|
|
923
926
|
});
|
|
924
927
|
}
|
|
925
|
-
function SessionCard({ session, onOpen, onMenu, onSetupMenu }) {
|
|
926
|
-
const tone = statusTone(session.status);
|
|
928
|
+
function SessionCard({ session, onOpen, onMenu, onSetupMenu, hostLabel, stale = false, path }) {
|
|
929
|
+
const tone = stale ? "quiet" : statusTone(session.status);
|
|
927
930
|
const name = session.name || "Untitled";
|
|
928
931
|
const markColor = session.active ? "green" : "faint";
|
|
929
932
|
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Pressable, {
|
|
930
933
|
accessibilityRole: "button",
|
|
931
934
|
accessibilityLabel: `Open ${name}`,
|
|
935
|
+
disabled: stale,
|
|
936
|
+
accessibilityState: { disabled: stale },
|
|
932
937
|
onPress: () => onOpen(session.id),
|
|
933
938
|
style: ({ pressed }) => [
|
|
934
939
|
styles.card,
|
|
935
940
|
session.nested && styles.nested,
|
|
936
941
|
pressed && styles.cardPressed,
|
|
937
|
-
session.active && styles.cardActive
|
|
942
|
+
!stale && session.active && styles.cardActive
|
|
938
943
|
],
|
|
939
944
|
children: [
|
|
940
945
|
/* @__PURE__ */ jsxs(View, {
|
|
@@ -967,7 +972,7 @@ function SessionCard({ session, onOpen, onMenu, onSetupMenu }) {
|
|
|
967
972
|
})]
|
|
968
973
|
}), /* @__PURE__ */ jsxs(View, {
|
|
969
974
|
style: styles.statusRow,
|
|
970
|
-
children: [session.restarting ? /* @__PURE__ */ jsx(Spinner, {
|
|
975
|
+
children: [stale ? null : session.restarting ? /* @__PURE__ */ jsx(Spinner, {
|
|
971
976
|
size: "small",
|
|
972
977
|
color: "dim",
|
|
973
978
|
label: "Restarting"
|
|
@@ -981,27 +986,34 @@ function SessionCard({ session, onOpen, onMenu, onSetupMenu }) {
|
|
|
981
986
|
}) : tone === "failed" ? /* @__PURE__ */ jsx(AlertIcon, {
|
|
982
987
|
size: 12,
|
|
983
988
|
color: "red"
|
|
984
|
-
}) : null, session.clock ? /* @__PURE__ */ jsx(LiveDuration, {
|
|
989
|
+
}) : null, !stale && session.clock ? /* @__PURE__ */ jsx(LiveDuration, {
|
|
985
990
|
style: styles.status(tone),
|
|
986
991
|
label: session.clock.label,
|
|
987
992
|
since: session.clock.since
|
|
988
993
|
}) : /* @__PURE__ */ jsx(Text, {
|
|
989
994
|
style: styles.status(tone),
|
|
990
995
|
numberOfLines: 1,
|
|
991
|
-
children: session.status
|
|
996
|
+
children: stale ? "Last known" : session.status
|
|
992
997
|
})]
|
|
993
998
|
})]
|
|
994
999
|
}),
|
|
995
|
-
/* @__PURE__ */ jsx(IconButton, {
|
|
1000
|
+
!stale ? /* @__PURE__ */ jsx(IconButton, {
|
|
996
1001
|
label: `${name} actions`,
|
|
997
1002
|
onPress: () => onMenu(session),
|
|
998
1003
|
children: /* @__PURE__ */ jsx(KebabIcon, {
|
|
999
1004
|
size: 16,
|
|
1000
1005
|
color: "dim"
|
|
1001
1006
|
})
|
|
1002
|
-
})
|
|
1007
|
+
}) : null
|
|
1003
1008
|
]
|
|
1004
1009
|
}),
|
|
1010
|
+
hostLabel ? /* @__PURE__ */ jsx(HostTag, { label: hostLabel }) : null,
|
|
1011
|
+
path ? /* @__PURE__ */ jsx(Text, {
|
|
1012
|
+
style: styles.groupRoot,
|
|
1013
|
+
numberOfLines: 1,
|
|
1014
|
+
ellipsizeMode: "middle",
|
|
1015
|
+
children: path
|
|
1016
|
+
}) : null,
|
|
1005
1017
|
session.git ? /* @__PURE__ */ jsxs(View, {
|
|
1006
1018
|
style: [styles.branchRow, session.profile && styles.underAvatar],
|
|
1007
1019
|
children: [
|
|
@@ -1050,7 +1062,7 @@ function SessionCard({ session, onOpen, onMenu, onSetupMenu }) {
|
|
|
1050
1062
|
style: [styles.name, styles.setupName],
|
|
1051
1063
|
numberOfLines: 1,
|
|
1052
1064
|
children: setup.name
|
|
1053
|
-
}), onSetupMenu ? /* @__PURE__ */ jsx(IconButton, {
|
|
1065
|
+
}), !stale && onSetupMenu ? /* @__PURE__ */ jsx(IconButton, {
|
|
1054
1066
|
label: `${setup.name} setup actions`,
|
|
1055
1067
|
onPress: () => onSetupMenu(setup),
|
|
1056
1068
|
children: /* @__PURE__ */ jsx(KebabIcon, {
|
|
@@ -1071,7 +1083,7 @@ function SessionCard({ session, onOpen, onMenu, onSetupMenu }) {
|
|
|
1071
1083
|
]
|
|
1072
1084
|
}, setup.id))] });
|
|
1073
1085
|
}
|
|
1074
|
-
function WorkspaceHeader({ workspace, actions, onWorkspaceMenu }) {
|
|
1086
|
+
function WorkspaceHeader({ workspace, actions, onWorkspaceMenu, onCreate, merged = false, stale = false }) {
|
|
1075
1087
|
return /* @__PURE__ */ jsxs(View, {
|
|
1076
1088
|
style: styles.group,
|
|
1077
1089
|
children: [
|
|
@@ -1089,28 +1101,28 @@ function WorkspaceHeader({ workspace, actions, onWorkspaceMenu }) {
|
|
|
1089
1101
|
style: styles.groupName,
|
|
1090
1102
|
numberOfLines: 1,
|
|
1091
1103
|
children: workspace.name
|
|
1092
|
-
}), /* @__PURE__ */ jsx(Text, {
|
|
1104
|
+
}), !merged ? /* @__PURE__ */ jsx(Text, {
|
|
1093
1105
|
style: styles.groupRoot,
|
|
1094
1106
|
numberOfLines: 1,
|
|
1095
1107
|
ellipsizeMode: "middle",
|
|
1096
1108
|
children: workspace.root
|
|
1097
|
-
})]
|
|
1109
|
+
}) : null]
|
|
1098
1110
|
}),
|
|
1099
|
-
workspace.legacy ? null : /* @__PURE__ */ jsxs(Fragment, { children: [workspace.available ? /* @__PURE__ */ jsx(IconButton, {
|
|
1111
|
+
workspace.legacy ? null : /* @__PURE__ */ jsxs(Fragment, { children: [workspace.available && (!stale || merged) ? /* @__PURE__ */ jsx(IconButton, {
|
|
1100
1112
|
label: `New session in ${workspace.name}`,
|
|
1101
|
-
onPress: () => actions.createSession(workspace.id),
|
|
1113
|
+
onPress: onCreate ?? (() => actions.createSession(workspace.id)),
|
|
1102
1114
|
children: /* @__PURE__ */ jsx(PlusIcon, {
|
|
1103
1115
|
size: 18,
|
|
1104
1116
|
color: "dim"
|
|
1105
1117
|
})
|
|
1106
|
-
}) : null, /* @__PURE__ */ jsx(IconButton, {
|
|
1118
|
+
}) : null, !stale || merged ? /* @__PURE__ */ jsx(IconButton, {
|
|
1107
1119
|
label: `${workspace.name} actions`,
|
|
1108
1120
|
onPress: () => onWorkspaceMenu(workspace),
|
|
1109
1121
|
children: /* @__PURE__ */ jsx(KebabIcon, {
|
|
1110
1122
|
size: 16,
|
|
1111
1123
|
color: "dim"
|
|
1112
1124
|
})
|
|
1113
|
-
})] })
|
|
1125
|
+
}) : null] })
|
|
1114
1126
|
]
|
|
1115
1127
|
}),
|
|
1116
1128
|
!workspace.available ? /* @__PURE__ */ jsx(Text, {
|
|
@@ -1124,70 +1136,92 @@ function WorkspaceHeader({ workspace, actions, onWorkspaceMenu }) {
|
|
|
1124
1136
|
]
|
|
1125
1137
|
});
|
|
1126
1138
|
}
|
|
1127
|
-
/**
|
|
1128
|
-
function
|
|
1129
|
-
const
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
children: /* @__PURE__ */ jsxs(View, {
|
|
1135
|
-
style: styles.empty,
|
|
1136
|
-
children: [/* @__PURE__ */ jsx(Text, {
|
|
1137
|
-
style: styles.emptyText,
|
|
1138
|
-
children: "Add a folder to start working with Po."
|
|
1139
|
-
}), /* @__PURE__ */ jsxs(Button, {
|
|
1140
|
-
style: styles.emptyButton,
|
|
1141
|
-
onPress: () => setAdding(true),
|
|
1142
|
-
children: [/* @__PURE__ */ jsx(PlusIcon, { size: 14 }), "Add workspace"]
|
|
1143
|
-
})]
|
|
1144
|
-
})
|
|
1145
|
-
}), /* @__PURE__ */ jsx(AddWorkspaceSheet, {
|
|
1146
|
-
open: adding,
|
|
1147
|
-
actions,
|
|
1148
|
-
onClose: () => setAdding(false)
|
|
1149
|
-
})]
|
|
1139
|
+
/** Display grouping never rewrites workspace or session identity. */
|
|
1140
|
+
function sessionSections(workspaces, presentation, selectedHost = null) {
|
|
1141
|
+
const filter = presentation?.hosts.some(({ id }) => id === selectedHost) ? selectedHost : null;
|
|
1142
|
+
const visible = workspaces.filter((workspace) => {
|
|
1143
|
+
const owner = presentation?.hostForId[workspace.id];
|
|
1144
|
+
if (owner && !presentation?.hosts.some(({ id }) => id === owner)) return false;
|
|
1145
|
+
return filter === null || owner === filter;
|
|
1150
1146
|
});
|
|
1147
|
+
const sections = [];
|
|
1148
|
+
for (const workspace of visible) {
|
|
1149
|
+
const existing = presentation && presentation.hosts.length > 1 && !workspace.legacy ? sections.find((section) => !section.workspace.legacy && section.workspace.name === workspace.name) : void 0;
|
|
1150
|
+
if (existing) {
|
|
1151
|
+
existing.members.push(workspace);
|
|
1152
|
+
existing.data = [...existing.data, ...workspace.sessions];
|
|
1153
|
+
existing.workspace = {
|
|
1154
|
+
...existing.workspace,
|
|
1155
|
+
available: existing.workspace.available || workspace.available
|
|
1156
|
+
};
|
|
1157
|
+
} else sections.push({
|
|
1158
|
+
key: workspace.id,
|
|
1159
|
+
workspace,
|
|
1160
|
+
members: [workspace],
|
|
1161
|
+
data: workspace.sessions
|
|
1162
|
+
});
|
|
1163
|
+
}
|
|
1164
|
+
return sections;
|
|
1151
1165
|
}
|
|
1152
|
-
/** The
|
|
1153
|
-
function AdvancedSessions({ workspaces, openSession, actions, setHeaderAction }) {
|
|
1154
|
-
const
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1166
|
+
/** The cockpit's workspace groups, with computers as a display filter rather than separate rails. */
|
|
1167
|
+
function AdvancedSessions({ workspaces, openSession, actions, setHeaderAction, hostPresentation }) {
|
|
1168
|
+
const [selectedHost, setSelectedHost] = useState(hostPresentation?.initialHostId ?? null);
|
|
1169
|
+
const selected = hostPresentation?.hosts.some(({ id }) => id === selectedHost) ? selectedHost : null;
|
|
1170
|
+
if (selectedHost !== selected) setSelectedHost(selected);
|
|
1171
|
+
const sections = useMemo(() => sessionSections(workspaces, hostPresentation, selected), [
|
|
1172
|
+
workspaces,
|
|
1173
|
+
hostPresentation,
|
|
1174
|
+
selected
|
|
1175
|
+
]);
|
|
1176
|
+
const hosts = hostPresentation?.hosts ?? NO_HOSTS;
|
|
1177
|
+
const hostOf = (id) => hosts.find((host) => host.id === hostPresentation?.hostForId[id]);
|
|
1178
|
+
const stale = (id) => hostPresentation !== void 0 && hostOf(id)?.status !== "connected";
|
|
1179
|
+
const [choosing, setChoosing] = useState(null);
|
|
1180
|
+
const [chooseAction, setChooseAction] = useState("create");
|
|
1181
|
+
const [addHost, setAddHost] = useState(null);
|
|
1159
1182
|
const [sessionMenu, setSessionMenu] = useState(null);
|
|
1160
1183
|
const [workspaceMenu, setWorkspaceMenu] = useState(null);
|
|
1161
1184
|
const [groupsFor, setGroupsFor] = useState(null);
|
|
1162
1185
|
const [setupMenu, setSetupMenu] = useState(null);
|
|
1163
1186
|
const [adding, setAdding] = useState(false);
|
|
1164
1187
|
const { addWorkspace, searchDirectories, listDirectory } = actions;
|
|
1165
|
-
const addActions = addWorkspace && searchDirectories && listDirectory ? {
|
|
1188
|
+
const addActions = hosts.length > 0 ? hosts.find(({ id }) => id === addHost)?.addWorkspaceActions : addWorkspace && searchDirectories && listDirectory ? {
|
|
1166
1189
|
addWorkspace,
|
|
1167
1190
|
searchDirectories,
|
|
1168
1191
|
listDirectory
|
|
1169
1192
|
} : void 0;
|
|
1170
|
-
const
|
|
1193
|
+
const canAdd = hosts.length > 0 ? hosts.some((host) => host.addWorkspaceActions !== void 0) : addActions !== void 0;
|
|
1194
|
+
const beginAdd = useCallback(() => {
|
|
1195
|
+
if (hosts.length > 1) {
|
|
1196
|
+
setChoosing("add");
|
|
1197
|
+
return;
|
|
1198
|
+
}
|
|
1199
|
+
if (hosts.length === 1) {
|
|
1200
|
+
if (hosts[0].status !== "connected") return;
|
|
1201
|
+
setAddHost(hosts[0].id);
|
|
1202
|
+
}
|
|
1203
|
+
setAdding(true);
|
|
1204
|
+
}, [hosts]);
|
|
1205
|
+
const titleAdd = canAdd && setHeaderAction !== void 0;
|
|
1171
1206
|
useEffect(() => {
|
|
1172
1207
|
if (!titleAdd) return;
|
|
1173
1208
|
setHeaderAction(/* @__PURE__ */ jsx(IconButton, {
|
|
1174
1209
|
label: "Add workspace",
|
|
1175
|
-
onPress:
|
|
1210
|
+
onPress: beginAdd,
|
|
1211
|
+
disabled: hosts.length === 1 && hosts[0].status !== "connected",
|
|
1176
1212
|
children: /* @__PURE__ */ jsx(PlusIcon, {
|
|
1177
1213
|
size: 18,
|
|
1178
1214
|
color: "dim"
|
|
1179
1215
|
})
|
|
1180
1216
|
}));
|
|
1181
1217
|
return () => setHeaderAction(null);
|
|
1182
|
-
}, [
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
});
|
|
1190
|
-
const sessions = workspaces.flatMap((workspace) => workspace.sessions);
|
|
1218
|
+
}, [
|
|
1219
|
+
titleAdd,
|
|
1220
|
+
setHeaderAction,
|
|
1221
|
+
beginAdd,
|
|
1222
|
+
hosts
|
|
1223
|
+
]);
|
|
1224
|
+
const sessions = workspaces.flatMap((workspace) => workspace.sessions).filter((session) => !stale(session.id));
|
|
1191
1225
|
const { setSessionGroups, renameGroup, deleteGroup, removePendingSetup } = actions;
|
|
1192
1226
|
const groupActions = setSessionGroups && renameGroup && deleteGroup ? {
|
|
1193
1227
|
setSessionGroups,
|
|
@@ -1208,13 +1242,31 @@ function AdvancedSessions({ workspaces, openSession, actions, setHeaderAction })
|
|
|
1208
1242
|
renderSectionHeader: ({ section }) => /* @__PURE__ */ jsx(WorkspaceHeader, {
|
|
1209
1243
|
workspace: section.workspace,
|
|
1210
1244
|
actions,
|
|
1211
|
-
onWorkspaceMenu: (entry) =>
|
|
1245
|
+
onWorkspaceMenu: (entry) => {
|
|
1246
|
+
const members = workspaces.filter((workspace) => !workspace.legacy && workspace.name === entry.name);
|
|
1247
|
+
if (hosts.length > 1 && members.length > 1) {
|
|
1248
|
+
setChooseAction("menu");
|
|
1249
|
+
setChoosing(members);
|
|
1250
|
+
} else if (!stale(entry.id)) setWorkspaceMenu(entry.id);
|
|
1251
|
+
},
|
|
1252
|
+
stale: stale(section.workspace.id),
|
|
1253
|
+
merged: section.members.length > 1,
|
|
1254
|
+
onCreate: () => {
|
|
1255
|
+
const members = workspaces.filter((entry) => !entry.legacy && entry.name === section.workspace.name);
|
|
1256
|
+
if (hosts.length > 1 && members.length > 1) {
|
|
1257
|
+
setChooseAction("create");
|
|
1258
|
+
setChoosing(members);
|
|
1259
|
+
} else if (!stale(section.workspace.id)) actions.createSession(section.workspace.id);
|
|
1260
|
+
}
|
|
1212
1261
|
}),
|
|
1213
1262
|
renderSectionFooter: ({ section }) => /* @__PURE__ */ jsx(View, { style: section === sections[sections.length - 1] ? void 0 : styles.sectionGap }),
|
|
1214
1263
|
renderItem: ({ item: session }) => /* @__PURE__ */ jsx(View, {
|
|
1215
1264
|
style: styles.sessionRow,
|
|
1216
1265
|
children: /* @__PURE__ */ jsx(SessionCard, {
|
|
1217
1266
|
session,
|
|
1267
|
+
stale: stale(session.id),
|
|
1268
|
+
hostLabel: hosts.length > 1 && selected === null ? hostOf(session.id)?.label : void 0,
|
|
1269
|
+
path: sectionPath(session.id, workspaces, sections),
|
|
1218
1270
|
onOpen: openSession,
|
|
1219
1271
|
onMenu: (entry) => setSessionMenu(entry.id),
|
|
1220
1272
|
...removePendingSetup ? { onSetupMenu: (setup) => setSetupMenu({
|
|
@@ -1223,21 +1275,34 @@ function AdvancedSessions({ workspaces, openSession, actions, setHeaderAction })
|
|
|
1223
1275
|
}) } : {}
|
|
1224
1276
|
})
|
|
1225
1277
|
}),
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1278
|
+
ListEmptyComponent: /* @__PURE__ */ jsx(EmptyState, {
|
|
1279
|
+
title: selected ? "No sessions on this computer." : "No sessions yet.",
|
|
1280
|
+
description: "Add a workspace to start working with Po."
|
|
1281
|
+
}),
|
|
1282
|
+
ListHeaderComponent: /* @__PURE__ */ jsxs(View, {
|
|
1283
|
+
style: styles.listHeader,
|
|
1284
|
+
children: [
|
|
1285
|
+
hosts.length > 1 ? /* @__PURE__ */ jsx(HostFilter, {
|
|
1286
|
+
hosts,
|
|
1287
|
+
value: selected,
|
|
1288
|
+
onChange: setSelectedHost
|
|
1289
|
+
}) : null,
|
|
1290
|
+
hosts.filter((host) => host.status !== "connected" && (selected === null || selected === host.id)).map((host) => /* @__PURE__ */ jsx(InfoStrip, {
|
|
1291
|
+
message: host.status === "update_required" ? `${host.label} needs an app update. Sessions are read-only.` : `${host.label} is offline. Showing last known sessions.`,
|
|
1292
|
+
actionLabel: "Retry",
|
|
1293
|
+
onAction: host.onRetry
|
|
1294
|
+
}, host.id)),
|
|
1295
|
+
canAdd && !titleAdd ? /* @__PURE__ */ jsxs(Button, {
|
|
1296
|
+
variant: "ghost",
|
|
1297
|
+
onPress: beginAdd,
|
|
1298
|
+
disabled: hosts.length === 1 && hosts[0].status !== "connected",
|
|
1299
|
+
children: [/* @__PURE__ */ jsx(PlusIcon, {
|
|
1300
|
+
size: 18,
|
|
1301
|
+
color: "dim"
|
|
1302
|
+
}), "Add workspace"]
|
|
1303
|
+
}) : null
|
|
1304
|
+
]
|
|
1305
|
+
})
|
|
1241
1306
|
}),
|
|
1242
1307
|
/* @__PURE__ */ jsx(SessionMenuSheet, {
|
|
1243
1308
|
session: sessions.find((session) => session.id === sessionMenu) ?? null,
|
|
@@ -1246,7 +1311,7 @@ function AdvancedSessions({ workspaces, openSession, actions, setHeaderAction })
|
|
|
1246
1311
|
onClose: () => setSessionMenu(null)
|
|
1247
1312
|
}),
|
|
1248
1313
|
/* @__PURE__ */ jsx(WorkspaceMenuSheet, {
|
|
1249
|
-
workspace: workspaces.find((workspace) => workspace.id === workspaceMenu) ?? null,
|
|
1314
|
+
workspace: workspaces.find((workspace) => workspace.id === workspaceMenu && !stale(workspace.id)) ?? null,
|
|
1250
1315
|
actions,
|
|
1251
1316
|
onClose: () => setWorkspaceMenu(null)
|
|
1252
1317
|
}),
|
|
@@ -1261,13 +1326,51 @@ function AdvancedSessions({ workspaces, openSession, actions, setHeaderAction })
|
|
|
1261
1326
|
removePendingSetup,
|
|
1262
1327
|
onClose: () => setSetupMenu(null)
|
|
1263
1328
|
}) : null,
|
|
1264
|
-
addActions ? /* @__PURE__ */ jsx(AddWorkspaceSheet, {
|
|
1329
|
+
addActions && (hosts.length === 0 || hosts.find(({ id }) => id === addHost)?.status === "connected") ? /* @__PURE__ */ jsx(AddWorkspaceSheet, {
|
|
1265
1330
|
open: adding,
|
|
1266
1331
|
actions: addActions,
|
|
1267
|
-
onClose: () =>
|
|
1268
|
-
|
|
1332
|
+
onClose: () => {
|
|
1333
|
+
setAdding(false);
|
|
1334
|
+
setAddHost(null);
|
|
1335
|
+
}
|
|
1336
|
+
}) : null,
|
|
1337
|
+
/* @__PURE__ */ jsx(Sheet, {
|
|
1338
|
+
open: choosing !== null,
|
|
1339
|
+
onOpenChange: (open) => {
|
|
1340
|
+
if (!open) setChoosing(null);
|
|
1341
|
+
},
|
|
1342
|
+
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, {
|
|
1343
|
+
variant: "ghost",
|
|
1344
|
+
disabled: host.status !== "connected" || !host.addWorkspaceActions,
|
|
1345
|
+
onPress: () => {
|
|
1346
|
+
setAddHost(host.id);
|
|
1347
|
+
setChoosing(null);
|
|
1348
|
+
setAdding(true);
|
|
1349
|
+
},
|
|
1350
|
+
children: [host.label, host.status !== "connected" ? " · Unavailable" : ""]
|
|
1351
|
+
}, host.id)) : choosing?.map((workspace) => /* @__PURE__ */ jsxs(Button, {
|
|
1352
|
+
variant: "ghost",
|
|
1353
|
+
disabled: stale(workspace.id) || !workspace.available,
|
|
1354
|
+
onPress: () => {
|
|
1355
|
+
setChoosing(null);
|
|
1356
|
+
if (chooseAction === "menu") setWorkspaceMenu(workspace.id);
|
|
1357
|
+
else actions.createSession(workspace.id);
|
|
1358
|
+
},
|
|
1359
|
+
children: [
|
|
1360
|
+
hostOf(workspace.id)?.label ?? workspace.name,
|
|
1361
|
+
" · ",
|
|
1362
|
+
workspace.root,
|
|
1363
|
+
stale(workspace.id) ? " · Unavailable" : ""
|
|
1364
|
+
]
|
|
1365
|
+
}, workspace.id)) })] })
|
|
1366
|
+
})
|
|
1269
1367
|
] });
|
|
1270
1368
|
}
|
|
1369
|
+
function sectionPath(sessionId, workspaces, sections) {
|
|
1370
|
+
const section = sections.find((entry) => entry.data.some(({ id }) => id === sessionId));
|
|
1371
|
+
if (!section || new Set(section.members.map(({ root }) => root)).size < 2) return void 0;
|
|
1372
|
+
return workspaces.find((workspace) => workspace.sessions.some(({ id }) => id === sessionId))?.root;
|
|
1373
|
+
}
|
|
1271
1374
|
const styles = StyleSheet.create((theme) => {
|
|
1272
1375
|
const sans = fontOf(theme.fontFamily.sans);
|
|
1273
1376
|
const text = (size, color) => ({
|
|
@@ -1291,6 +1394,11 @@ const styles = StyleSheet.create((theme) => {
|
|
|
1291
1394
|
padding: theme.spacing(4),
|
|
1292
1395
|
uni__dependencies: [0]
|
|
1293
1396
|
},
|
|
1397
|
+
listHeader: {
|
|
1398
|
+
gap: theme.spacing(3),
|
|
1399
|
+
paddingBottom: theme.spacing(4),
|
|
1400
|
+
uni__dependencies: [0]
|
|
1401
|
+
},
|
|
1294
1402
|
sectionGap: {
|
|
1295
1403
|
height: theme.spacing(6),
|
|
1296
1404
|
uni__dependencies: [0]
|
|
@@ -1392,11 +1500,12 @@ const styles = StyleSheet.create((theme) => {
|
|
|
1392
1500
|
uni__dependencies: [0]
|
|
1393
1501
|
},
|
|
1394
1502
|
iconButton: {
|
|
1395
|
-
width:
|
|
1396
|
-
height:
|
|
1397
|
-
borderRadius:
|
|
1503
|
+
width: 44,
|
|
1504
|
+
height: 44,
|
|
1505
|
+
borderRadius: theme.borderRadius.lg,
|
|
1398
1506
|
alignItems: "center",
|
|
1399
|
-
justifyContent: "center"
|
|
1507
|
+
justifyContent: "center",
|
|
1508
|
+
uni__dependencies: [0]
|
|
1400
1509
|
},
|
|
1401
1510
|
iconPressed: {
|
|
1402
1511
|
backgroundColor: theme.colors.panel,
|