@nightkatana/kronosys-app 1.0.0-beta.16 → 1.0.0-beta.18

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/app/page.tsx CHANGED
@@ -233,6 +233,16 @@ function DashboardHome() {
233
233
  const [tourOpen, setTourOpen] = useState(false);
234
234
  const [newSessionModalOpen, setNewSessionModalOpen] = useState(false);
235
235
  const pendingNewSessionFocusRef = useRef(false);
236
+ const pendingNewSessionAfterEndRef = useRef<{
237
+ sessionScope: unknown;
238
+ sessionStartAtIso: string | null;
239
+ } | null>(null);
240
+ const createNewSessionAndFocusRef = useRef<
241
+ (args: {
242
+ sessionScope: unknown;
243
+ sessionStartAtIso: string | null;
244
+ }) => Promise<void>
245
+ >(async () => {});
236
246
  const [gitBannerDismissed, setGitBannerDismissed] = useState(false);
237
247
  const [gitIdentitySetupModalOpen, setGitIdentitySetupModalOpen] =
238
248
  useState(false);
@@ -798,6 +808,7 @@ function DashboardHome() {
798
808
  setEndSessionReasonKind("");
799
809
  setEndSessionReasonNote("");
800
810
  setEndSessionTaskHandling("keep");
811
+ pendingNewSessionAfterEndRef.current = null;
801
812
  }, []);
802
813
 
803
814
  const confirmEndLiveSession = useCallback(async () => {
@@ -828,6 +839,11 @@ function DashboardHome() {
828
839
  ...(note.length > 0 ? { sessionEndReasonNote: note } : {}),
829
840
  ...(handling !== "keep" ? { taskHandling: handling } : {}),
830
841
  });
842
+ const pend = pendingNewSessionAfterEndRef.current;
843
+ pendingNewSessionAfterEndRef.current = null;
844
+ if (pend) {
845
+ await createNewSessionAndFocusRef.current(pend);
846
+ }
831
847
  }, [
832
848
  history,
833
849
  live?.sessionId,
@@ -1250,10 +1266,30 @@ function DashboardHome() {
1250
1266
  }, [focusTaskLauncherInput, live?.sessionId]);
1251
1267
 
1252
1268
  const createNewSessionAndFocus = useCallback(
1253
- async (sessionScope: unknown) => {
1269
+ async (args: {
1270
+ sessionScope: unknown;
1271
+ sessionStartAtIso: string | null;
1272
+ }) => {
1254
1273
  setNewSessionModalOpen(false);
1274
+ const res = await post({
1275
+ type: "newSession",
1276
+ sessionScope: args.sessionScope,
1277
+ ...(args.sessionStartAtIso
1278
+ ? { sessionStartAt: args.sessionStartAtIso }
1279
+ : {}),
1280
+ });
1281
+ const hid =
1282
+ typeof res.result?.newHistorySessionId === "string"
1283
+ ? res.result.newHistorySessionId.trim()
1284
+ : "";
1285
+ if (hid !== "") {
1286
+ pendingNewSessionFocusRef.current = false;
1287
+ await handleSelectSession(hid);
1288
+ scrollToSessionInList(hid);
1289
+ focusTaskLauncherInput();
1290
+ return;
1291
+ }
1255
1292
  pendingNewSessionFocusRef.current = true;
1256
- await post({ type: "newSession", sessionScope });
1257
1293
  if (sessionQueryMode) {
1258
1294
  router.replace(
1259
1295
  pathnameWithUpdatedSessionQuery(
@@ -1267,14 +1303,18 @@ function DashboardHome() {
1267
1303
  },
1268
1304
  [
1269
1305
  focusTaskLauncherInput,
1306
+ handleSelectSession,
1270
1307
  pathname,
1271
1308
  post,
1272
1309
  router,
1310
+ scrollToSessionInList,
1273
1311
  searchParams,
1274
1312
  sessionQueryMode,
1275
1313
  ],
1276
1314
  );
1277
1315
 
1316
+ createNewSessionAndFocusRef.current = createNewSessionAndFocus;
1317
+
1278
1318
  const openSessionInNewTab = useCallback(
1279
1319
  (sessionId: string) => {
1280
1320
  const url = `${
@@ -1813,8 +1853,23 @@ function DashboardHome() {
1813
1853
  lang={lang}
1814
1854
  t={dt}
1815
1855
  onCancel={() => setNewSessionModalOpen(false)}
1816
- onConfirm={(sessionScope) => {
1817
- void createNewSessionAndFocus(sessionScope);
1856
+ onConfirm={(payload) => {
1857
+ const liveSid =
1858
+ typeof live?.sessionId === "string" ? live.sessionId.trim() : "";
1859
+ const hasActiveLive = liveSid !== "" && live?.archived !== true;
1860
+ if (!payload.sessionStartAtIso && hasActiveLive) {
1861
+ pendingNewSessionAfterEndRef.current = {
1862
+ sessionScope: payload.scope,
1863
+ sessionStartAtIso: null,
1864
+ };
1865
+ setNewSessionModalOpen(false);
1866
+ handleRequestEndLiveSession();
1867
+ return;
1868
+ }
1869
+ void createNewSessionAndFocus({
1870
+ sessionScope: payload.scope,
1871
+ sessionStartAtIso: payload.sessionStartAtIso,
1872
+ });
1818
1873
  }}
1819
1874
  />
1820
1875
  <GlobalPauseConfirmModal