@@ -897,6 +897,60 @@ describe("session store writer queue", () => {
|
897 | 897 | expect(merged.modelProvider).toBeUndefined(); |
898 | 898 | }); |
899 | 899 | |
| 900 | +it("rewrites generated sessionFile paths when session id changes", () => { |
| 901 | +const previousSessionId = "11111111-1111-4111-8111-111111111111"; |
| 902 | +const nextSessionId = "22222222-2222-4222-8222-222222222222"; |
| 903 | +const merged = mergeSessionEntry( |
| 904 | +{ |
| 905 | +sessionId: previousSessionId, |
| 906 | +updatedAt: 100, |
| 907 | +sessionFile: `/tmp/openclaw/sessions/${previousSessionId}.jsonl`, |
| 908 | +}, |
| 909 | +{ |
| 910 | +sessionId: nextSessionId, |
| 911 | +updatedAt: 200, |
| 912 | +}, |
| 913 | +); |
| 914 | + |
| 915 | +expect(merged.sessionFile).toBe(`/tmp/openclaw/sessions/${nextSessionId}.jsonl`); |
| 916 | +}); |
| 917 | + |
| 918 | +it("rewrites stale generated sessionFile patches during session rollover", () => { |
| 919 | +const previousSessionId = "11111111-1111-4111-8111-111111111111"; |
| 920 | +const nextSessionId = "22222222-2222-4222-8222-222222222222"; |
| 921 | +const previousSessionFile = `/tmp/openclaw/sessions/${previousSessionId}-topic-456.jsonl`; |
| 922 | +const merged = mergeSessionEntry( |
| 923 | +{ |
| 924 | +sessionId: previousSessionId, |
| 925 | +updatedAt: 100, |
| 926 | +sessionFile: previousSessionFile, |
| 927 | +}, |
| 928 | +{ |
| 929 | +sessionId: nextSessionId, |
| 930 | +updatedAt: 200, |
| 931 | +sessionFile: previousSessionFile, |
| 932 | +}, |
| 933 | +); |
| 934 | + |
| 935 | +expect(merged.sessionFile).toBe(`/tmp/openclaw/sessions/${nextSessionId}-topic-456.jsonl`); |
| 936 | +}); |
| 937 | + |
| 938 | +it("preserves custom sessionFile paths when session id changes", () => { |
| 939 | +const merged = mergeSessionEntry( |
| 940 | +{ |
| 941 | +sessionId: "previous-session", |
| 942 | +updatedAt: 100, |
| 943 | +sessionFile: "/tmp/openclaw/sessions/custom-transcript.jsonl", |
| 944 | +}, |
| 945 | +{ |
| 946 | +sessionId: "next-session", |
| 947 | +updatedAt: 200, |
| 948 | +}, |
| 949 | +); |
| 950 | + |
| 951 | +expect(merged.sessionFile).toBe("/tmp/openclaw/sessions/custom-transcript.jsonl"); |
| 952 | +}); |
| 953 | + |
900 | 954 | it("caps future updatedAt values at the session merge boundary", () => { |
901 | 955 | const now = 1_000; |
902 | 956 | const merged = mergeSessionEntryWithPolicy( |
|