@celljs/ta-host 4.9.0 → 4.9.1

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.
@@ -40,8 +40,8 @@ export interface TaSessionRegistry {
40
40
  }
41
41
  /** The conversations pi keeps in its session files, open or not. */
42
42
  export interface TaSessionCatalog {
43
- /** The latest first. */
44
- list(): Promise<TaSavedSessionInfo[]>;
43
+ /** The latest first, without the files of `open` (sessions open now, which are listed as such). */
44
+ list(open?: ReadonlySet<string>): Promise<TaSavedSessionInfo[]>;
45
45
  }
46
46
  /** The packages pi loads in a directory, and their web extensions. */
47
47
  export interface WebExtensionCatalog {
@@ -60,7 +60,7 @@ export declare class DefaultTaSessionCatalog implements TaSessionCatalog {
60
60
  version: string;
61
61
  summary?: SessionSummary;
62
62
  }>;
63
- list(): Promise<TaSavedSessionInfo[]>;
63
+ list(open?: ReadonlySet<string>): Promise<TaSavedSessionInfo[]>;
64
64
  /** Where pi keeps the sessions it creates (SessionManager.create without a directory). */
65
65
  protected sessionsDir(): Promise<string>;
66
66
  protected files(root: string): Promise<string[]>;
@@ -143,11 +143,13 @@ let DefaultTaSessionCatalog = class DefaultTaSessionCatalog {
143
143
  /** By file: its size and time when read, and what it held. */
144
144
  this.cache = new Map();
145
145
  }
146
- async list() {
146
+ async list(open = new Set()) {
147
147
  const files = await this.files(await this.sessionsDir());
148
+ // An open session's file grows with every message: it is not read again for a list that leaves it out.
149
+ const closed = files.filter(file => !open.has(file));
148
150
  const sessions = [];
149
- for (let i = 0; i < files.length; i += BATCH) {
150
- await Promise.all(files.slice(i, i + BATCH).map(async (file) => {
151
+ for (let i = 0; i < closed.length; i += BATCH) {
152
+ await Promise.all(closed.slice(i, i + BATCH).map(async (file) => {
151
153
  const summary = await this.summary(file);
152
154
  if (summary) {
153
155
  const { piCwd, ...info } = summary;
@@ -8,7 +8,13 @@ export var SignInPageUtil;
8
8
  for (const part of (header !== null && header !== void 0 ? header : '').split(';')) {
9
9
  const [key, ...value] = part.trim().split('=');
10
10
  if (key === name) {
11
- return decodeURIComponent(value.join('='));
11
+ try {
12
+ return decodeURIComponent(value.join('='));
13
+ }
14
+ catch (_a) {
15
+ // Not one of ours: a browser or a page sent it broken.
16
+ return undefined;
17
+ }
12
18
  }
13
19
  }
14
20
  return undefined;
@@ -58,8 +58,8 @@ let TaServerImpl = class TaServerImpl {
58
58
  }
59
59
  listSavedSessions() {
60
60
  return this.guard(async () => {
61
- const open = new Set(this.sessions.list().map(session => session.pi.sessionFile));
62
- return (await this.catalog.list()).filter(session => !open.has(session.sessionFile));
61
+ const open = new Set(this.sessions.list().flatMap(session => { var _a; return (_a = session.pi.sessionFile) !== null && _a !== void 0 ? _a : []; }));
62
+ return this.catalog.list(open);
63
63
  });
64
64
  }
65
65
  attach(sessionId, afterSeq, options) {
@@ -40,8 +40,8 @@ export interface TaSessionRegistry {
40
40
  }
41
41
  /** The conversations pi keeps in its session files, open or not. */
42
42
  export interface TaSessionCatalog {
43
- /** The latest first. */
44
- list(): Promise<TaSavedSessionInfo[]>;
43
+ /** The latest first, without the files of `open` (sessions open now, which are listed as such). */
44
+ list(open?: ReadonlySet<string>): Promise<TaSavedSessionInfo[]>;
45
45
  }
46
46
  /** The packages pi loads in a directory, and their web extensions. */
47
47
  export interface WebExtensionCatalog {
@@ -60,7 +60,7 @@ export declare class DefaultTaSessionCatalog implements TaSessionCatalog {
60
60
  version: string;
61
61
  summary?: SessionSummary;
62
62
  }>;
63
- list(): Promise<TaSavedSessionInfo[]>;
63
+ list(open?: ReadonlySet<string>): Promise<TaSavedSessionInfo[]>;
64
64
  /** Where pi keeps the sessions it creates (SessionManager.create without a directory). */
65
65
  protected sessionsDir(): Promise<string>;
66
66
  protected files(root: string): Promise<string[]>;
@@ -146,11 +146,13 @@ let DefaultTaSessionCatalog = class DefaultTaSessionCatalog {
146
146
  /** By file: its size and time when read, and what it held. */
147
147
  this.cache = new Map();
148
148
  }
149
- async list() {
149
+ async list(open = new Set()) {
150
150
  const files = await this.files(await this.sessionsDir());
151
+ // An open session's file grows with every message: it is not read again for a list that leaves it out.
152
+ const closed = files.filter(file => !open.has(file));
151
153
  const sessions = [];
152
- for (let i = 0; i < files.length; i += BATCH) {
153
- await Promise.all(files.slice(i, i + BATCH).map(async (file) => {
154
+ for (let i = 0; i < closed.length; i += BATCH) {
155
+ await Promise.all(closed.slice(i, i + BATCH).map(async (file) => {
154
156
  const summary = await this.summary(file);
155
157
  if (summary) {
156
158
  const { piCwd, ...info } = summary;
@@ -11,7 +11,13 @@ var SignInPageUtil;
11
11
  for (const part of (header !== null && header !== void 0 ? header : '').split(';')) {
12
12
  const [key, ...value] = part.trim().split('=');
13
13
  if (key === name) {
14
- return decodeURIComponent(value.join('='));
14
+ try {
15
+ return decodeURIComponent(value.join('='));
16
+ }
17
+ catch (_a) {
18
+ // Not one of ours: a browser or a page sent it broken.
19
+ return undefined;
20
+ }
15
21
  }
16
22
  }
17
23
  return undefined;
@@ -61,8 +61,8 @@ let TaServerImpl = class TaServerImpl {
61
61
  }
62
62
  listSavedSessions() {
63
63
  return this.guard(async () => {
64
- const open = new Set(this.sessions.list().map(session => session.pi.sessionFile));
65
- return (await this.catalog.list()).filter(session => !open.has(session.sessionFile));
64
+ const open = new Set(this.sessions.list().flatMap(session => { var _a; return (_a = session.pi.sessionFile) !== null && _a !== void 0 ? _a : []; }));
65
+ return this.catalog.list(open);
66
66
  });
67
67
  }
68
68
  attach(sessionId, afterSeq, options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta-host",
3
- "version": "4.9.0",
3
+ "version": "4.9.1",
4
4
  "description": "ta serve: pi sessions for many clients over WebSocket",
5
5
  "keywords": [
6
6
  "cell-component"
@@ -34,15 +34,15 @@
34
34
  "watch": "tsc -b -w --preserveWatchOutput"
35
35
  },
36
36
  "dependencies": {
37
- "@celljs/ai-agent": "4.9.0",
38
- "@celljs/ai-coding-agent": "4.9.0",
39
- "@celljs/core": "4.9.0",
40
- "@celljs/rpc": "4.9.0",
41
- "@celljs/ta-exec": "4.9.0",
42
- "@celljs/ta-harness": "4.9.0",
43
- "@celljs/ta-protocol": "4.9.0",
44
- "@celljs/ta-relay": "4.9.0",
45
- "@celljs/web": "4.9.0",
37
+ "@celljs/ai-agent": "4.9.1",
38
+ "@celljs/ai-coding-agent": "4.9.1",
39
+ "@celljs/core": "4.9.1",
40
+ "@celljs/rpc": "4.9.1",
41
+ "@celljs/ta-exec": "4.9.1",
42
+ "@celljs/ta-harness": "4.9.1",
43
+ "@celljs/ta-protocol": "4.9.1",
44
+ "@celljs/ta-relay": "4.9.1",
45
+ "@celljs/web": "4.9.1",
46
46
  "@earendil-works/pi-coding-agent": "^1.5.0"
47
47
  },
48
48
  "devDependencies": {