@code-fixer-23/pi-session-manager 1.0.2 → 1.0.4

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/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ ## 1.0.4 (2026-07-04)
2
+
3
+ ### 🩹 Fixes
4
+
5
+ - **pi-session-manager:** do proper session restoration ([271d67d](https://github.com/louiss0/pi-packages/commit/271d67d))
6
+
7
+ ### ❤️ Thank You
8
+
9
+ - louiss0 @louiss0
10
+
11
+ ## 1.0.3 (2026-07-03)
12
+
13
+ ### 🩹 Fixes
14
+
15
+ - **pi-session-manager:** persist session series without returns ([6d12cc0](https://github.com/louiss0/pi-packages/commit/6d12cc0))
16
+
17
+ ### ❤️ Thank You
18
+
19
+ - louiss0 @louiss0
20
+
1
21
  ## 1.0.2 (2026-07-03)
2
22
 
3
23
  ### 🩹 Fixes
@@ -13,6 +13,8 @@ import {
13
13
  handleSessionSeries,
14
14
  getSessionSeriesDataTempPath,
15
15
  persistSessionSeriesData,
16
+ consumePersistedSessionSeriesData,
17
+ applyPersistedSessionSeriesData,
16
18
  $TimestampCalculator,
17
19
  type $SessionFilter,
18
20
  type DurationRecord,
@@ -271,6 +273,9 @@ describe("persisted session series data", () => {
271
273
  },
272
274
  };
273
275
 
276
+ expect(applyPersistedSessionSeriesData(pi as never, ctx as never)).toBe(
277
+ true,
278
+ );
274
279
  expect(pi.setSessionName).toHaveBeenCalledWith(sessionData.sessionName);
275
280
  expect(pi.appendEntry).toHaveBeenCalledWith(sessionData.entry.customType, {
276
281
  series: sessionData.entry.series,
@@ -770,7 +775,7 @@ describe("handleSessionSeries", () => {
770
775
  "appendSessionSeriesBasedOnCwd",
771
776
  );
772
777
 
773
- const sessionData = await handleSessionSeries(
778
+ await handleSessionSeries(
774
779
  "new",
775
780
  {
776
781
  sessionManagerConfigurator,
@@ -818,7 +823,9 @@ describe("handleSessionSeries", () => {
818
823
  });
819
824
 
820
825
  const sessionSeriesAndTitle = `${context.ui.select.mock.settledResults[0]?.value}${SESION_TITLE_SEPARATOR}${context.ui.input.mock.settledResults[0]?.value}`;
821
- expect(sessionData).toMatchObject({ sessionName: sessionSeriesAndTitle });
826
+ expect(consumePersistedSessionSeriesData()).toMatchObject({
827
+ sessionName: sessionSeriesAndTitle,
828
+ });
822
829
 
823
830
  expect(sessionCtx.ui.notify).toHaveBeenCalledWith(
824
831
  expect.stringContaining(
@@ -969,7 +976,7 @@ describe("handleSessionSeries", () => {
969
976
  "appendSessionSeriesBasedOnCwd",
970
977
  );
971
978
 
972
- const sessionData = await handleSessionSeries(
979
+ await handleSessionSeries(
973
980
  "continue",
974
981
  {
975
982
  sessionFilter: new MockSessionFilter(
@@ -1026,7 +1033,9 @@ describe("handleSessionSeries", () => {
1026
1033
  });
1027
1034
 
1028
1035
  const sessionSeriesAndTitle = `${entry.data.series}${SESION_TITLE_SEPARATOR}${context.ui.input.mock.settledResults[1]?.value?.trim()}`;
1029
- expect(sessionData).toMatchObject({ sessionName: sessionSeriesAndTitle });
1036
+ expect(consumePersistedSessionSeriesData()).toMatchObject({
1037
+ sessionName: sessionSeriesAndTitle,
1038
+ });
1030
1039
  expect(appendSessionSeriesBasedOnCwdSpy).toHaveBeenCalledWith(
1031
1040
  sessionCtx.cwd,
1032
1041
  entry.data.series,
@@ -45,20 +45,17 @@ export default function (pi: ExtensionAPI) {
45
45
 
46
46
  pi.on("session_start", async (event, ctx) => {
47
47
  sessionManagerConfigurator = new SessionManagerConfigurator();
48
+
49
+ if (event.reason !== "fork" && event.reason !== "reload") {
50
+ applyPersistedSessionSeriesData(pi, ctx);
51
+ }
52
+
48
53
  const eventIsNotReloadOrStartUp =
49
54
  event.reason !== "reload" && event.reason !== "startup";
50
55
  if (eventIsNotReloadOrStartUp) {
51
56
  return;
52
57
  }
53
58
 
54
- const sessionData = consumePersistedSessionSeriesData();
55
-
56
- if (sessionData) {
57
- pi.setSessionName(sessionData.sessionName);
58
- const { customType, ...data } = sessionData.entry;
59
- pi.appendEntry(customType, data);
60
- }
61
-
62
59
  const dayLimitResult =
63
60
  sessionManagerConfigurator.getSessionDeletionDayLimit();
64
61
 
@@ -694,6 +691,24 @@ export function consumePersistedSessionSeriesData(
694
691
  }
695
692
  }
696
693
 
694
+ export function applyPersistedSessionSeriesData(
695
+ pi: Pick<ExtensionAPI, "setSessionName" | "appendEntry">,
696
+ ctx: Pick<ExtensionCommandContext, "ui">,
697
+ tempPath = getSessionSeriesDataTempPath(),
698
+ ) {
699
+ const sessionData = consumePersistedSessionSeriesData(tempPath);
700
+
701
+ if (!sessionData) {
702
+ return false;
703
+ }
704
+
705
+ pi.setSessionName(sessionData.sessionName);
706
+ const { customType, ...data } = sessionData.entry;
707
+ pi.appendEntry(customType, data);
708
+ ctx.ui.notify("Setting necessary session data");
709
+ return true;
710
+ }
711
+
697
712
  function promptForUniqueTrimmedInput(
698
713
  ctx: ExtensionCommandContext,
699
714
  prompt: string,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@code-fixer-23/pi-session-manager",
3
3
  "type": "module",
4
- "version": "1.0.2",
4
+ "version": "1.0.4",
5
5
  "keywords": [
6
6
  "pi-package"
7
7
  ],