@kabmo-labs/kabmo 0.53.2 → 0.54.0
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/client/index.html +1 -1
- package/dist/client/index.js +529 -518
- package/dist/client/static/js/{Body-vaa10tcd.js → Body-x5grdps8.js} +1 -1
- package/dist/client/static/js/{CsvGrid-wabx4e6w.js → CsvGrid-248v9yzf.js} +1 -1
- package/dist/client/static/js/{DocxView-22b3mhh5.js → DocxView-5we92k2h.js} +1 -1
- package/dist/client/static/js/{DrawioView-e02qhkp2.js → DrawioView-c6xmw4qq.js} +1 -1
- package/dist/client/static/js/{HtmlPreview-q7hwcf4s.js → HtmlPreview-r3qxgqg6.js} +1 -1
- package/dist/client/static/js/{ImageView-fxb60ge7.js → ImageView-cr4fea18.js} +1 -1
- package/dist/client/static/js/{LayoutWrapper-cey5agsf.js → LayoutWrapper-j12z0djx.js} +2 -2
- package/dist/client/static/js/MergeDiffView-y0we0194.js +1 -0
- package/dist/client/static/js/{Modal-e4yq7p5f.js → Modal-cqceypcn.js} +11 -11
- package/dist/client/static/js/{PdfView-pf3angsq.js → PdfView-xdgn31cm.js} +1 -1
- package/dist/client/static/js/{SessionsView-mcvhpx0b.js → SessionsView-ms6z44e2.js} +1 -1
- package/dist/client/static/js/{SheetView-5ha5vvsr.js → SheetView-peqm9vft.js} +1 -1
- package/dist/client/static/js/{SvgPreview-45wqjw0b.js → SvgPreview-rdf4wbzr.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-gnf6krbs.js → abnfDiagram-O67JEVCF-48z2x5vg.js} +1 -1
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-00fd0wsg.js → architectureDiagram-NJMV4G6O-n1pr5s6j.js} +1 -1
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-9c2sm96a.js → blockDiagram-BEXU5L5S-p19shaft.js} +1 -1
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-pemygn0s.js → c4Diagram-YGBWAQC7-qcd46ts2.js} +1 -1
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-h7r3sx3s.js → classDiagram-v2-NBCMYWYE-scyhe133.js} +1 -1
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-krx9crwv.js → cose-bilkent-JH36ORCC-srnnj3f7.js} +1 -1
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-5rp2btew.js → cynefinDiagram-VND7K2PF-1zfrnyay.js} +1 -1
- package/dist/client/static/js/{dagre-6A5THRUB-q57cnz52.js → dagre-6A5THRUB-hepk25pz.js} +1 -1
- package/dist/client/static/js/{diagram-22UHCM2B-0bptn06k.js → diagram-22UHCM2B-wy2y0323.js} +1 -1
- package/dist/client/static/js/{diagram-3UASUU5V-60snxawz.js → diagram-3UASUU5V-j904f93p.js} +1 -1
- package/dist/client/static/js/{diagram-ATOU4E4O-bb0kewfp.js → diagram-ATOU4E4O-2mmxccm2.js} +2 -2
- package/dist/client/static/js/{diagram-CDSNMT55-3cdkns0z.js → diagram-CDSNMT55-cfhk73ty.js} +3 -3
- package/dist/client/static/js/{diagram-MLGK6HIB-03mbhzeq.js → diagram-MLGK6HIB-ryf8j6hf.js} +1 -1
- package/dist/client/static/js/{diagram-MPIPVDR6-bcvzqqf4.js → diagram-MPIPVDR6-8k5e36sd.js} +2 -2
- package/dist/client/static/js/{dockerfile-7kqkk4tz.js → dockerfile-1e7deann.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-sg6kwnbx.js → ebnfDiagram-ZINNZB2B-5kkbbbhv.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-5b8v0sdv.js → elk-276RUBZZ-jqc4mzvc.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-xbs156j5.js → erDiagram-OPXOYQCR-kx15t6f0.js} +1 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-dpjz82p8.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-4p7pfk6c.js → ganttDiagram-FUAMR5RP-3hv8pej4.js} +1 -1
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-3xqwr9pf.js → gitGraphDiagram-X574FWY7-a4mq8vwz.js} +2 -2
- package/dist/client/static/js/{index-1regq9wd.js → index-01rdknec.js} +1 -1
- package/dist/client/static/js/{index-e2esj214.js → index-0j5ng1qc.js} +1 -1
- package/dist/client/static/js/{index-yf5a6t3p.js → index-0z7kerp1.js} +1 -1
- package/dist/client/static/js/{index-p75b7phb.js → index-1ye834yz.js} +1 -1
- package/dist/client/static/js/{index-1d8ff4t7.js → index-317v49ey.js} +2 -2
- package/dist/client/static/js/{index-x0y2c61e.js → index-3kenmzbe.js} +1 -1
- package/dist/client/static/js/{index-26a4afcr.js → index-40fdtqvw.js} +1 -1
- package/dist/client/static/js/{index-cj8v7b50.js → index-40ydm28n.js} +1 -1
- package/dist/client/static/js/{index-3bmn5cc5.js → index-51wzt3ma.js} +1 -1
- package/dist/client/static/js/{index-trrmbq0h.js → index-8hnem33f.js} +1 -1
- package/dist/client/static/js/{index-pak6t03c.js → index-937bn0d2.js} +1 -1
- package/dist/client/static/js/{index-nnhs52db.js → index-9cr6p86f.js} +1 -1
- package/dist/client/static/js/{index-rtpg4t84.js → index-9gddw5qy.js} +1 -1
- package/dist/client/static/js/{index-ryww3xxj.js → index-bf54x0w8.js} +1 -1
- package/dist/client/static/js/{index-hwq7zgqd.js → index-br27jz2t.js} +1 -1
- package/dist/client/static/js/{index-ayx3q8t9.js → index-demg0p74.js} +1 -1
- package/dist/client/static/js/{index-0btbxkxf.js → index-e2y4hkps.js} +1 -1
- package/dist/client/static/js/{index-vwxt5ss9.js → index-eb43hnd3.js} +1 -1
- package/dist/client/static/js/{index-mtjbp5ga.js → index-exyg9sna.js} +1 -1
- package/dist/client/static/js/{index-xqkcx4az.js → index-fanhvjk8.js} +1 -1
- package/dist/client/static/js/{index-ng3e6k6x.js → index-g3x4w48f.js} +1 -1
- package/dist/client/static/js/{index-c8ta3k4g.js → index-jvn2xfpt.js} +135 -135
- package/dist/client/static/js/{index-5qtnmn76.js → index-k4kwrze2.js} +1 -1
- package/dist/client/static/js/{index-cysdvwqw.js → index-kevqayd9.js} +1 -1
- package/dist/client/static/js/{index-hp3s5r3g.js → index-kvker1ps.js} +1 -1
- package/dist/client/static/js/{index-nmhwjwmt.js → index-kz5d00m5.js} +1 -1
- package/dist/client/static/js/{index-pdkt3r4r.js → index-m85c740p.js} +1 -1
- package/dist/client/static/js/{index-z7gd7nvb.js → index-n3cts2j1.js} +1 -1
- package/dist/client/static/js/{index-jf8zcg99.js → index-n4pm0hrh.js} +4 -4
- package/dist/client/static/js/{index-3amzzsdk.js → index-n5194pe6.js} +11 -11
- package/dist/client/static/js/{index-qj9tcz44.js → index-p8bta9ae.js} +1 -1
- package/dist/client/static/js/{index-45vcpqp9.js → index-pszsxhjr.js} +1 -1
- package/dist/client/static/js/{index-mgs5nscx.js → index-rtfw07hy.js} +1 -1
- package/dist/client/static/js/{index-cy6ceab8.js → index-v90zd3sq.js} +1 -1
- package/dist/client/static/js/{index-zc3snsr9.js → index-vxe4e903.js} +1 -1
- package/dist/client/static/js/{index-gzz6snng.js → index-w4dep7k6.js} +1 -1
- package/dist/client/static/js/{index-j9t5xc3y.js → index-x5c5yxhj.js} +1 -1
- package/dist/client/static/js/{index-jg6ecfc7.js → index-xhcbaaga.js} +2 -2
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-c362sv3t.js → infoDiagram-VRGFBTTK-wtnqb06v.js} +1 -1
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-yc8ts8wj.js → ishikawaDiagram-OU5B5YK6-eta0jnvr.js} +1 -1
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-178c75fy.js → journeyDiagram-ZHPQQLJL-4e572kkp.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-w6g3n001.js → kanban-definition-PNTS6WVX-yrtnn4zy.js} +1 -1
- package/dist/client/static/js/{mermaid.core-vcdgn378.js → mermaid.core-195b0fb6.js} +3 -3
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-t9e8arca.js → mindmap-definition-NLK3R4M7-pphjnkvt.js} +1 -1
- package/dist/client/static/js/one-dark-pro-asy2qj2p.js +1 -0
- package/dist/client/static/js/one-light-fya1pbbx.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-nehn0x9n.js → pegDiagram-GJSIUBJH-kgffb9p3.js} +1 -1
- package/dist/client/static/js/{pieDiagram-5QR66LMP-p1t3ctd4.js → pieDiagram-5QR66LMP-efech3mm.js} +2 -2
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-614rtbfe.js → quadrantDiagram-O4NWA36T-khf9cv3t.js} +1 -1
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-2vpr6pw8.js → railroadDiagram-XR7U4H2S-ye68kdx2.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-b91s5q3p.js → requirementDiagram-PLB6GJNP-3s4smnme.js} +1 -1
- package/dist/client/static/js/{rust-jj206pb7.js → rust-tdrnaxp3.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-4101kt9r.js → sankeyDiagram-IPEJSGJF-9pqd25mc.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-yq0cxg8c.js → sequenceDiagram-PO4LG4MO-rka8ct43.js} +1 -1
- package/dist/client/static/js/{sizeCapture-INFHLROL-jkvq39vz.js → sizeCapture-INFHLROL-g5wkzry8.js} +1 -1
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-y0h7w5rw.js → stateDiagram-v2-GCMORJYK-gy1zab2j.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-1y073wzx.js → swimlanes-2SLR337P-kr35nmd2.js} +1 -1
- package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-8ahz3c68.js → swimlanesDiagram-TC7HE7FX-qnhxxmjr.js} +1 -1
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-yjb0g0ys.js → timeline-definition-EJHVYXUP-sg151mkc.js} +1 -1
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-8xjkxrkv.js → usecaseDiagram-POWQR4AR-f91g61p3.js} +1 -1
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-18wjbwtg.js → vennDiagram-UO4OBE2U-zbhr4eqf.js} +2 -2
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-xqrfsrwp.js → wardleyDiagram-VNRHLVJA-6302414n.js} +2 -2
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-azygghkz.js → xychartDiagram-PMCCYNJV-0a47th65.js} +2 -2
- package/package.json +1 -1
- package/src/client/App.tsx +4 -0
- package/src/client/bootstrap.d.ts +11 -0
- package/src/client/data/settings/omp-schema.json +11 -1
- package/src/client/hooks/shell/last-opened-session.test.ts +166 -0
- package/src/client/hooks/shell/last-opened-session.ts +74 -0
- package/src/client/lib/router/open-session.test.ts +8 -0
- package/src/client/lib/router/open-session.ts +9 -4
- package/src/client/main.tsx +7 -0
- package/src/server/lib/db/schema.ts +10 -0
- package/src/server/lib/sessions/last-opened-client.server.ts +86 -0
- package/src/server/lib/sessions/last-opened-client.test.ts +91 -0
- package/src/server/lib/sessions/last-opened.server.test.ts +127 -0
- package/src/server/lib/sessions/last-opened.server.ts +129 -0
- package/src/server/plugins/ssr.ts +40 -17
- package/src/server/routes/sessions/index.ts +14 -0
- package/src/server/routes/sessions/last-opened.test.ts +139 -0
- package/src/server/routes/sessions/last-opened.ts +66 -0
- package/src/shared/lib/omp/config/schema-releases.test.ts +15 -0
- package/dist/client/static/js/MergeDiffView-1z9mwf73.js +0 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-sasgvf55.js +0 -1
- package/dist/client/static/js/one-dark-pro-17hh3q12.js +0 -1
- package/dist/client/static/js/one-light-cntgvscy.js +0 -1
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The last-opened route pair's request contract.
|
|
8
|
+
*
|
|
9
|
+
* The read is what the SSR bootstrap and any late caller trust, and the write is
|
|
10
|
+
* what a shell's next launch depends on — so the cases here pin the refusals
|
|
11
|
+
* that would otherwise be silent: a wrong verb must not be read as "nothing
|
|
12
|
+
* recorded", a blank or path-shaped id must not reach the store, a pending
|
|
13
|
+
* placeholder must answer `recorded: false`, and one client's write must not
|
|
14
|
+
* become another client's restore.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test } from 'bun:test';
|
|
18
|
+
import { getDb } from '@/server/db.server';
|
|
19
|
+
import type { DbClient } from '@kabmo-labs/kabmo-db/client';
|
|
20
|
+
import type { ActionFunctionArgs, LoaderFunctionArgs } from '@kabmo-labs/kabmo-http';
|
|
21
|
+
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
22
|
+
import { getLastOpenedSession, markSessionOpened } from '@/server/routes/sessions/last-opened';
|
|
23
|
+
import { readLastOpenedSessionId } from '@/server/lib/sessions/last-opened.server';
|
|
24
|
+
import { CLIENT_COOKIE } from '@/server/lib/sessions/last-opened-client.server';
|
|
25
|
+
|
|
26
|
+
const SESSION_ID = '43';
|
|
27
|
+
const CLIENT = '11111111-2222-4333-8444-555555555555';
|
|
28
|
+
const OTHER_CLIENT = '99999999-8888-4777-8666-555555555555';
|
|
29
|
+
let db: DbClient;
|
|
30
|
+
let priorMock: string | undefined;
|
|
31
|
+
|
|
32
|
+
beforeAll(() => {
|
|
33
|
+
priorMock = Bun.env.MOCK;
|
|
34
|
+
Bun.env.MOCK = 'true';
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
beforeEach(async () => {
|
|
38
|
+
await isolateDb();
|
|
39
|
+
db = await getDb();
|
|
40
|
+
await db.run("INSERT OR IGNORE INTO workspace_folders (id, name) VALUES (8, 'test')");
|
|
41
|
+
await db.run('INSERT INTO sessions (id, folder_id, title) VALUES (?, 8, ?)', [SESSION_ID, 'Probe']);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
afterEach(async () => {
|
|
45
|
+
await releaseDb();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
afterAll(() => {
|
|
49
|
+
if (priorMock === undefined) delete Bun.env.MOCK;
|
|
50
|
+
else Bun.env.MOCK = priorMock;
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
function request(method: string, clientId?: string): Request {
|
|
54
|
+
return new Request('http://localhost/api/x', {
|
|
55
|
+
method,
|
|
56
|
+
headers: clientId ? { cookie: `${CLIENT_COOKIE}=${clientId}` } : {},
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function actionArgs(method: string, sessionId?: string, clientId?: string): ActionFunctionArgs {
|
|
61
|
+
return {
|
|
62
|
+
request: request(method, clientId),
|
|
63
|
+
params: sessionId === undefined ? {} : { sessionId },
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function loaderArgs(clientId?: string): LoaderFunctionArgs {
|
|
68
|
+
return { request: request('GET', clientId), params: {} };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function readBody(response: unknown): Promise<Record<string, unknown>> {
|
|
72
|
+
return (await (response as Response).json()) as Record<string, unknown>;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
describe('getLastOpenedSession', () => {
|
|
76
|
+
test('answers no-store, because the value moves with every open', async () => {
|
|
77
|
+
const response = (await getLastOpenedSession(loaderArgs(CLIENT))) as Response;
|
|
78
|
+
expect(response.status).toBe(200);
|
|
79
|
+
expect(response.headers.get('cache-control')).toBe('no-store');
|
|
80
|
+
expect(await readBody(response)).toEqual({ sessionId: null });
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('a request with no client cookie has no pointer', async () => {
|
|
84
|
+
expect(await readBody(await getLastOpenedSession(loaderArgs()))).toEqual({ sessionId: null });
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
describe('markSessionOpened', () => {
|
|
89
|
+
test('records a real session, and the read answers it for that client', async () => {
|
|
90
|
+
const posted = await markSessionOpened(actionArgs('POST', SESSION_ID, CLIENT));
|
|
91
|
+
expect(await readBody(posted)).toEqual({ success: true, recorded: true });
|
|
92
|
+
expect(await readBody(await getLastOpenedSession(loaderArgs(CLIENT)))).toEqual({
|
|
93
|
+
sessionId: SESSION_ID,
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test("one client's write is not another client's restore", async () => {
|
|
98
|
+
await markSessionOpened(actionArgs('POST', SESSION_ID, CLIENT));
|
|
99
|
+
expect(await readBody(await getLastOpenedSession(loaderArgs(OTHER_CLIENT)))).toEqual({
|
|
100
|
+
sessionId: null,
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test('a request without a cookie gets one, and it is what gets recorded', async () => {
|
|
105
|
+
const posted = (await markSessionOpened(actionArgs('POST', SESSION_ID))) as Response;
|
|
106
|
+
const cookie = posted.headers.get('set-cookie');
|
|
107
|
+
expect(cookie).toContain(CLIENT_COOKIE);
|
|
108
|
+
expect(await readBody(posted)).toEqual({ success: true, recorded: true });
|
|
109
|
+
|
|
110
|
+
const clientId = cookie?.match(new RegExp(`${CLIENT_COOKIE}=([^;]+)`))?.[1] ?? '';
|
|
111
|
+
expect(await readBody(await getLastOpenedSession(loaderArgs(decodeURIComponent(clientId))))).toEqual({
|
|
112
|
+
sessionId: SESSION_ID,
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test('a pending placeholder is refused without failing the request', async () => {
|
|
117
|
+
const posted = await markSessionOpened(actionArgs('POST', 'new-1761000000000', CLIENT));
|
|
118
|
+
expect((posted as Response).status).toBe(200);
|
|
119
|
+
expect(await readBody(posted)).toEqual({ success: true, recorded: false });
|
|
120
|
+
expect(await readLastOpenedSessionId(CLIENT)).toBeNull();
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test('a wrong verb is a 405', async () => {
|
|
124
|
+
const response = (await markSessionOpened(actionArgs('GET', SESSION_ID, CLIENT))) as Response;
|
|
125
|
+
expect(response.status).toBe(405);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test('a missing id is a 400', async () => {
|
|
129
|
+
const response = (await markSessionOpened(actionArgs('POST'))) as Response;
|
|
130
|
+
expect(response.status).toBe(400);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test('a path-shaped id is a 404 before the store sees it', async () => {
|
|
134
|
+
for (const id of ['.', '..', 'a/b', 'a\\b']) {
|
|
135
|
+
const response = (await markSessionOpened(actionArgs('POST', id, CLIENT))) as Response;
|
|
136
|
+
expect(response.status).toBe(404);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The last-opened session: what a native shell restores on a cold start, and
|
|
8
|
+
* the write every open makes.
|
|
9
|
+
*
|
|
10
|
+
* The record is keyed by the `kabmo_client` cookie, so a phone and a desktop
|
|
11
|
+
* pointed at the same console keep separate pointers. Both routes resolve that
|
|
12
|
+
* identity here rather than trusting a client-supplied id: a value the page can
|
|
13
|
+
* choose would let one shell read or rewrite another's row.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { json, NO_STORE_HEADERS } from '@kabmo-labs/kabmo-http';
|
|
17
|
+
import type { ActionFunctionArgs, LoaderFunctionArgs } from '@kabmo-labs/kabmo-http';
|
|
18
|
+
import { isSinglePathSegment } from '@kabmo-labs/kabmo-paths/path-segment';
|
|
19
|
+
import { methodNotAllowed } from '@/server/lib/route-adapter';
|
|
20
|
+
import {
|
|
21
|
+
lastOpenedSession,
|
|
22
|
+
recordLastOpenedSession,
|
|
23
|
+
} from '@/server/lib/sessions/last-opened.server';
|
|
24
|
+
import {
|
|
25
|
+
readClientId,
|
|
26
|
+
resolveClientIdentity,
|
|
27
|
+
} from '@/server/lib/sessions/last-opened-client.server';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* GET /api/sessions/last-opened — this client's validated id, or null.
|
|
31
|
+
*
|
|
32
|
+
* Never cached: the answer moves with every session the user opens, and a
|
|
33
|
+
* shell's first request after a relaunch must not receive a previous response.
|
|
34
|
+
*/
|
|
35
|
+
export async function getLastOpenedSession({ request }: LoaderFunctionArgs) {
|
|
36
|
+
const clientId = readClientId(request);
|
|
37
|
+
const sessionId = clientId ? await lastOpenedSession(clientId) : null;
|
|
38
|
+
return json({ sessionId }, { headers: NO_STORE_HEADERS });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* POST /api/sessions/:sessionId/opened — remember this session as the target
|
|
43
|
+
* THIS client opens next time.
|
|
44
|
+
*
|
|
45
|
+
* A pending id is a refusal, not an error: the caller's URL may still name
|
|
46
|
+
* `new-…`, and the record must wait for the spawn's real id. `recorded: false`
|
|
47
|
+
* says which happened without turning a placeholder into a failed request.
|
|
48
|
+
*
|
|
49
|
+
* A request with no client cookie gets one, so a caller that reached this
|
|
50
|
+
* endpoint without the document still lands on a row of its own.
|
|
51
|
+
*/
|
|
52
|
+
export async function markSessionOpened({ request, params }: ActionFunctionArgs) {
|
|
53
|
+
if (request.method !== 'POST') {
|
|
54
|
+
return methodNotAllowed({ request, params });
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const sessionId = params.sessionId;
|
|
58
|
+
if (!sessionId) return json({ error: 'Missing session id' }, { status: 400 });
|
|
59
|
+
if (!isSinglePathSegment(sessionId)) return json({ error: 'Session not found' }, { status: 404 });
|
|
60
|
+
|
|
61
|
+
const identity = resolveClientIdentity(request);
|
|
62
|
+
const recorded = await recordLastOpenedSession(identity.clientId, sessionId);
|
|
63
|
+
const headers: Record<string, string> = {};
|
|
64
|
+
if (identity.setCookie) headers['set-cookie'] = identity.setCookie;
|
|
65
|
+
return json({ success: true, recorded }, { headers });
|
|
66
|
+
}
|
|
@@ -304,4 +304,19 @@ describe('OMP_SCHEMA release rows', () => {
|
|
|
304
304
|
// panel's own dropdown.
|
|
305
305
|
expect(OMP_SCHEMA.entries['prewalk.auto']?.values).toContain('escalate');
|
|
306
306
|
});
|
|
307
|
+
|
|
308
|
+
test("19.2.1's background-reaping row is offered", () => {
|
|
309
|
+
// One net row. The reminder and session-end reaping are off under RPC (the
|
|
310
|
+
// description says so), so nothing in Kabmo reads it — but the panel is the
|
|
311
|
+
// only place an omp setting is reachable, and a schema regenerated without
|
|
312
|
+
// the row removes it entirely.
|
|
313
|
+
const entry = OMP_SCHEMA.entries['bash.reapBackground'];
|
|
314
|
+
expect(entry && { type: entry.type, tab: entry.ui.tab, group: entry.ui.group, default: entry.default }).toEqual({
|
|
315
|
+
type: 'boolean',
|
|
316
|
+
tab: 'shell',
|
|
317
|
+
group: 'Bash',
|
|
318
|
+
default: true,
|
|
319
|
+
});
|
|
320
|
+
expect(entry?.ui.description).toContain('off in RPC mode');
|
|
321
|
+
});
|
|
307
322
|
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{pg}from"./index-qj9tcz44.js";import"./index-4kchzh9y.js";import"./index-mtjbp5ga.js";export{pg as MergeDiffView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./index-3amzzsdk.js";import"./index-26a4afcr.js";import{eb}from"./index-5qtnmn76.js";export{eb as diagram};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_h}from"./index-c8ta3k4g.js";export{_h as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Ih}from"./index-c8ta3k4g.js";export{Ih as default};
|