teamroom 0.3.0 → 0.5.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/README.md +11 -2
- package/dist/cli/index.js +61 -14
- package/dist/cli/index.js.map +1 -1
- package/dist/client/agent-events.js +5 -2
- package/dist/client/agent-events.js.map +1 -1
- package/dist/client/agents-md.d.ts +3 -1
- package/dist/client/agents-md.js +6 -3
- package/dist/client/agents-md.js.map +1 -1
- package/dist/client/api-client.d.ts +3 -0
- package/dist/client/api-client.js +20 -0
- package/dist/client/api-client.js.map +1 -1
- package/dist/client/config.d.ts +6 -0
- package/dist/client/config.js +6 -0
- package/dist/client/config.js.map +1 -1
- package/dist/client/git.d.ts +13 -0
- package/dist/client/git.js +46 -1
- package/dist/client/git.js.map +1 -1
- package/dist/client/invite-link.d.ts +6 -0
- package/dist/client/invite-link.js +5 -0
- package/dist/client/invite-link.js.map +1 -1
- package/dist/client/setup-files.d.ts +12 -0
- package/dist/client/setup-files.js +70 -0
- package/dist/client/setup-files.js.map +1 -0
- package/dist/client/workspace.js +1 -1
- package/dist/client/workspace.js.map +1 -1
- package/dist/core/overlap-rule.d.ts +11 -0
- package/dist/core/overlap-rule.js +18 -0
- package/dist/core/overlap-rule.js.map +1 -0
- package/dist/core/room.d.ts +12 -0
- package/dist/core/room.js +42 -16
- package/dist/core/room.js.map +1 -1
- package/dist/core/secrets.d.ts +2 -0
- package/dist/core/secrets.js +5 -0
- package/dist/core/secrets.js.map +1 -1
- package/dist/core/types.d.ts +2 -0
- package/dist/dashboard/MemberList.js +3 -1
- package/dist/dashboard/MemberList.js.map +1 -1
- package/dist/dashboard/RecentActivity.d.ts +2 -2
- package/dist/dashboard/RecentActivity.js +1 -1
- package/dist/dashboard/RecentActivity.js.map +1 -1
- package/dist/dashboard/SessionDetail.js +1 -1
- package/dist/dashboard/SessionDetail.js.map +1 -1
- package/dist/dashboard/model.d.ts +14 -1
- package/dist/dashboard/model.js +33 -3
- package/dist/dashboard/model.js.map +1 -1
- package/dist/mcp/auto-report.js +6 -1
- package/dist/mcp/auto-report.js.map +1 -1
- package/dist/mcp/server.js +1 -1
- package/dist/mcp/server.js.map +1 -1
- package/dist/server/app.d.ts +8 -2
- package/dist/server/app.js +92 -14
- package/dist/server/app.js.map +1 -1
- package/dist/server/serve.d.ts +9 -0
- package/dist/server/serve.js +41 -1
- package/dist/server/serve.js.map +1 -1
- package/dist/store/file-store.d.ts +3 -0
- package/dist/store/file-store.js +32 -1
- package/dist/store/file-store.js.map +1 -1
- package/dist/store/memory-store.d.ts +2 -0
- package/dist/store/memory-store.js +14 -1
- package/dist/store/memory-store.js.map +1 -1
- package/dist/store/store.d.ts +4 -0
- package/dist/store/store.js +3 -0
- package/dist/store/store.js.map +1 -1
- package/dist/web/join-page.d.ts +9 -0
- package/dist/web/join-page.js +119 -0
- package/dist/web/join-page.js.map +1 -0
- package/dist/web/page.d.ts +15 -0
- package/dist/web/page.js +428 -0
- package/dist/web/page.js.map +1 -0
- package/dist/web/payload.d.ts +66 -0
- package/dist/web/payload.js +58 -0
- package/dist/web/payload.js.map +1 -0
- package/dist/web/server.d.ts +19 -0
- package/dist/web/server.js +103 -0
- package/dist/web/server.js.map +1 -0
- package/package.json +1 -1
package/dist/server/serve.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../../src/server/serve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../../src/server/serve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;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AgB,EAAE,IAAY,EAAE,GAAG,GAAe,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE;IAC/F,MAAM,KAAK,GAAG,KAAK,IAAmB,EAAE;QACtC,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC;YAClF,IAAI,OAAO,GAAG,CAAC;gBAAE,UAAU,CAAC,MAAM,EAAE,oBAAoB,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;QAC7F,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,UAAU,CAAC,OAAO,EAAE,wBAAwB,EAAE,EAAE,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACnH,CAAC;IACH,CAAC,CAAC;IACF,KAAK,KAAK,EAAE,CAAC;IACb,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,KAAK,KAAK,EAAE,EAAE,sBAAsB,CAAC,CAAC;IACtE,KAAK,CAAC,KAAK,EAAE,CAAC;IACd,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -13,6 +13,9 @@ export declare class FileRoomStore implements RoomStore {
|
|
|
13
13
|
create(room: Room): Promise<void>;
|
|
14
14
|
get(roomId: string): Promise<Room | null>;
|
|
15
15
|
update(roomId: string, mutate: (room: Room) => Room): Promise<Room>;
|
|
16
|
+
count(): Promise<number>;
|
|
17
|
+
deleteIdle(cutoff: Date): Promise<number>;
|
|
18
|
+
private roomIds;
|
|
16
19
|
private roomPath;
|
|
17
20
|
private readRoom;
|
|
18
21
|
private writeRoom;
|
package/dist/store/file-store.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { promises as fs } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { roomIdSchema } from "../core/schemas.js";
|
|
4
|
-
import { RoomAlreadyExistsError, RoomNotFoundError, StoreLockTimeoutError } from "./store.js";
|
|
4
|
+
import { isIdleSince, RoomAlreadyExistsError, RoomNotFoundError, StoreLockTimeoutError, } from "./store.js";
|
|
5
|
+
const ROOM_FILE_PATTERN = /^(room_[A-Za-z0-9_-]{16})\.json$/;
|
|
5
6
|
const LOCK_RETRY_DELAY_MS = 20;
|
|
6
7
|
const LOCK_TIMEOUT_MS = 5_000;
|
|
7
8
|
/** A lock older than this is assumed to belong to a crashed process. */
|
|
@@ -38,6 +39,36 @@ export class FileRoomStore {
|
|
|
38
39
|
return next;
|
|
39
40
|
});
|
|
40
41
|
}
|
|
42
|
+
async count() {
|
|
43
|
+
return (await this.roomIds()).length;
|
|
44
|
+
}
|
|
45
|
+
async deleteIdle(cutoff) {
|
|
46
|
+
let deleted = 0;
|
|
47
|
+
for (const roomId of await this.roomIds()) {
|
|
48
|
+
const removed = await this.withRoomLock(roomId, async () => {
|
|
49
|
+
const room = await this.readRoom(roomId);
|
|
50
|
+
if (!room || !isIdleSince(room, cutoff))
|
|
51
|
+
return false;
|
|
52
|
+
await fs.rm(this.roomPath(roomId), { force: true });
|
|
53
|
+
return true;
|
|
54
|
+
});
|
|
55
|
+
if (removed)
|
|
56
|
+
deleted += 1;
|
|
57
|
+
}
|
|
58
|
+
return deleted;
|
|
59
|
+
}
|
|
60
|
+
async roomIds() {
|
|
61
|
+
let names;
|
|
62
|
+
try {
|
|
63
|
+
names = await fs.readdir(this.dataDir);
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
if (isNodeError(error, "ENOENT"))
|
|
67
|
+
return [];
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
return names.flatMap((name) => ROOM_FILE_PATTERN.exec(name)?.slice(1, 2) ?? []);
|
|
71
|
+
}
|
|
41
72
|
roomPath(roomId) {
|
|
42
73
|
// Room ids are validated before they reach the store, but a path built from
|
|
43
74
|
// unvalidated input must never escape the data directory.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-store.js","sourceRoot":"","sources":["../../src/store/file-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,
|
|
1
|
+
{"version":3,"file":"file-store.js","sourceRoot":"","sources":["../../src/store/file-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EACL,WAAW,EACX,sBAAsB,EACtB,iBAAiB,EAEjB,qBAAqB,GACtB,MAAM,YAAY,CAAC;AAEpB,MAAM,iBAAiB,GAAG,kCAAkC,CAAC;AAC7D,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAC/B,MAAM,eAAe,GAAG,KAAK,CAAC;AAC9B,wEAAwE;AACxE,MAAM,aAAa,GAAG,MAAM,CAAC;AAE7B;;;;;GAKG;AACH,MAAM,OAAO,aAAa;IAGK,OAAO;IAFnB,eAAe,GAAG,IAAI,GAAG,EAA4B,CAAC;IAEvE,YAA6B,OAAe;uBAAf,OAAO;IAAW,CAAC;IAEhD,KAAK,CAAC,MAAM,CAAC,IAAU;QACrB,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,IAAI,EAAE;YAC1C,IAAI,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;gBAAE,MAAM,IAAI,sBAAsB,CAAC,IAAI,CAA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aAAa,EAAE,CAAC;YAC/C,MAAM,EAAE,CAAC,EAAE,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC;YAAE,MAAM,KAAK,CAAC;IACjD,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAAC,KAAc,EAAE,IAAY;IAC/C,OAAO,KAAK,YAAY,KAAK,IAAK,KAA+B,CAAC,IAAI,KAAK,IAAI,CAAC;AAClF,CAAC;AAED,KAAK,UAAU,KAAK,CAAC,YAAoB;IACvC,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -6,4 +6,6 @@ export declare class MemoryRoomStore implements RoomStore {
|
|
|
6
6
|
create(room: Room): Promise<void>;
|
|
7
7
|
get(roomId: string): Promise<Room | null>;
|
|
8
8
|
update(roomId: string, mutate: (room: Room) => Room): Promise<Room>;
|
|
9
|
+
count(): Promise<number>;
|
|
10
|
+
deleteIdle(cutoff: Date): Promise<number>;
|
|
9
11
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RoomAlreadyExistsError, RoomNotFoundError } from "./store.js";
|
|
1
|
+
import { isIdleSince, RoomAlreadyExistsError, RoomNotFoundError } from "./store.js";
|
|
2
2
|
/** In-process store for tests and throwaway local servers. Data is lost on restart. */
|
|
3
3
|
export class MemoryRoomStore {
|
|
4
4
|
rooms = new Map();
|
|
@@ -19,5 +19,18 @@ export class MemoryRoomStore {
|
|
|
19
19
|
this.rooms.set(roomId, structuredClone(next));
|
|
20
20
|
return structuredClone(next);
|
|
21
21
|
}
|
|
22
|
+
async count() {
|
|
23
|
+
return this.rooms.size;
|
|
24
|
+
}
|
|
25
|
+
async deleteIdle(cutoff) {
|
|
26
|
+
let deleted = 0;
|
|
27
|
+
for (const [roomId, room] of this.rooms) {
|
|
28
|
+
if (!isIdleSince(room, cutoff))
|
|
29
|
+
continue;
|
|
30
|
+
this.rooms.delete(roomId);
|
|
31
|
+
deleted += 1;
|
|
32
|
+
}
|
|
33
|
+
return deleted;
|
|
34
|
+
}
|
|
22
35
|
}
|
|
23
36
|
//# sourceMappingURL=memory-store.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-store.js","sourceRoot":"","sources":["../../src/store/memory-store.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAkB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"memory-store.js","sourceRoot":"","sources":["../../src/store/memory-store.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,iBAAiB,EAAkB,MAAM,YAAY,CAAC;AAEpG,uFAAuF;AACvF,MAAM,OAAO,eAAe;IACT,KAAK,GAAG,IAAI,GAAG,EAAgB,CAAC;IAEjD,KAAK,CAAC,MAAM,CAAC,IAAU;QACrB,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAAE,MAAM,IAAI,sBAAsB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACvE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,MAAc;QACtB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACpC,OAAO,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,MAAc,EAAE,MAA4B;QACvD,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACvC,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAClD,MAAM,IAAI,GAAG,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC;QAC9C,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;QAC9C,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,KAAK;QACT,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,MAAY;QAC3B,IAAI,OAAO,GAAG,CAAC,CAAC;QAChB,KAAK,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACxC,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC;gBAAE,SAAS;YACzC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAC1B,OAAO,IAAI,CAAC,CAAC;QACf,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
|
package/dist/store/store.d.ts
CHANGED
|
@@ -19,4 +19,8 @@ export interface RoomStore {
|
|
|
19
19
|
create(room: Room): Promise<void>;
|
|
20
20
|
get(roomId: string): Promise<Room | null>;
|
|
21
21
|
update(roomId: string, mutate: (room: Room) => Room): Promise<Room>;
|
|
22
|
+
count(): Promise<number>;
|
|
23
|
+
/** Deletes rooms nothing has changed since `cutoff` and returns how many went. */
|
|
24
|
+
deleteIdle(cutoff: Date): Promise<number>;
|
|
22
25
|
}
|
|
26
|
+
export declare function isIdleSince(room: Room, cutoff: Date): boolean;
|
package/dist/store/store.js
CHANGED
package/dist/store/store.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/store/store.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IACd,MAAM;IAAlC,YAA4B,MAAc;QACxC,KAAK,CAAC,QAAQ,MAAM,kBAAkB,CAAC,CAAC;sBADd,MAAM;QAEhC,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AAED,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IACnB,MAAM;IAAlC,YAA4B,MAAc;QACxC,KAAK,CAAC,QAAQ,MAAM,kBAAkB,CAAC,CAAC;sBADd,MAAM;QAEhC,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AAED,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAClB,MAAM;IAAlC,YAA4B,MAAc;QACxC,KAAK,CAAC,gDAAgD,MAAM,GAAG,CAAC,CAAC;sBADvC,MAAM;QAEhC,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF"}
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/store/store.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IACd,MAAM;IAAlC,YAA4B,MAAc;QACxC,KAAK,CAAC,QAAQ,MAAM,kBAAkB,CAAC,CAAC;sBADd,MAAM;QAEhC,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AAED,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IACnB,MAAM;IAAlC,YAA4B,MAAc;QACxC,KAAK,CAAC,QAAQ,MAAM,kBAAkB,CAAC,CAAC;sBADd,MAAM;QAEhC,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AAED,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAClB,MAAM;IAAlC,YAA4B,MAAc;QACxC,KAAK,CAAC,gDAAgD,MAAM,GAAG,CAAC,CAAC;sBADvC,MAAM;QAEhC,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AAeD,MAAM,UAAU,WAAW,CAAC,IAAU,EAAE,MAAY;IAClD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The page an invite link opens. The invite code sits after the #, which
|
|
3
|
+
* browsers never send, so the server cannot write it into the page: the
|
|
4
|
+
* script reads it from the address bar and fills in the exact commands.
|
|
5
|
+
*/
|
|
6
|
+
export declare const JOIN_PLACEHOLDER_COMMAND = "teamroom join '<paste the full invite link here>'";
|
|
7
|
+
export declare const JOIN_HTML: string;
|
|
8
|
+
export declare const JOIN_STYLES = "\n:root {\n --paper: #EDF0F3;\n --surface: #FFFFFF;\n --ink: #16233A;\n --muted: #56657A;\n --rule: #CBD3DD;\n --agent: #5B4BD6;\n --overlap: #F4C84A;\n --overlap-ink: #5A4300;\n --words: \"Schibsted Grotesk\", ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif;\n --code: \"JetBrains Mono\", ui-monospace, \"SF Mono\", Menlo, Consolas, monospace;\n color-scheme: light dark;\n}\n@media (prefers-color-scheme: dark) {\n :root {\n --paper: #121A28;\n --surface: #1A2436;\n --ink: #E6ECF3;\n --muted: #9AA8BB;\n --rule: #2C3A50;\n --agent: #9489F2;\n }\n}\n* { box-sizing: border-box; }\nhtml { background: var(--paper); color: var(--ink); font-family: var(--words); font-size: 16px; line-height: 1.5; }\nbody { margin: 0; }\n.join { max-width: 640px; margin: 0 auto; padding: 56px 20px 64px; }\nh1 { font-size: 28px; line-height: 1.2; margin: 0 0 10px; }\n.lede { color: var(--muted); margin: 0 0 32px; }\n.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; gap: 16px; }\n.steps > li { counter-increment: step; background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 18px 20px 20px; }\n.steps h2 { font-size: 17px; margin: 0 0 2px; }\n.steps h2::before { content: counter(step) \". \"; color: var(--muted); }\n.steps p { margin: 0 0 12px; color: var(--muted); }\n.command { display: flex; align-items: flex-start; gap: 8px; }\n.command code { flex: 1; min-width: 0; font-family: var(--code); font-size: 13.5px; background: var(--paper); border: 1px solid var(--rule); border-radius: 4px; padding: 10px 12px; overflow-wrap: anywhere; user-select: all; }\n.command button { flex: none; font: inherit; font-weight: 600; font-size: 14px; color: #FFFFFF; background: var(--agent); border: 0; border-radius: 4px; padding: 10px 16px; line-height: 1.5; cursor: pointer; }\n.command button:focus-visible { outline: 3px solid var(--overlap); outline-offset: 2px; }\n.steps p.problem { margin: 12px 0 0; padding: 10px 12px; border-radius: 4px; background: var(--overlap); color: var(--overlap-ink); }\n.note { margin: 24px 0 0; color: var(--muted); font-size: 14px; }\n@media (max-width: 480px) {\n .command { flex-direction: column; align-items: stretch; }\n}\n";
|
|
9
|
+
export declare const JOIN_SCRIPT = "(function () {\n var ROOM_ID = /^room_[A-Za-z0-9_-]{16}$/;\n var INVITE_CODE = /^tri_[A-Za-z0-9_-]{16,128}$/;\n var COPIED_FOR_MS = 2000;\n\n var roomId = location.pathname.split(\"/\").pop();\n var inviteCode = location.hash.slice(1);\n var joinCommand = document.getElementById(\"join-command\");\n var incomplete = document.getElementById(\"link-incomplete\");\n\n if (ROOM_ID.test(roomId) && INVITE_CODE.test(inviteCode)) {\n joinCommand.textContent = \"teamroom join '\" + location.origin + location.pathname + \"#\" + inviteCode + \"'\";\n } else {\n incomplete.hidden = false;\n }\n\n var buttons = document.querySelectorAll(\"button[data-copy]\");\n for (var index = 0; index < buttons.length; index++) {\n buttons[index].addEventListener(\"click\", copyCommand);\n }\n\n function copyCommand(event) {\n var button = event.currentTarget;\n var text = document.getElementById(button.getAttribute(\"data-copy\")).textContent;\n if (!navigator.clipboard) return;\n navigator.clipboard.writeText(text).then(function () {\n button.textContent = \"Copied\";\n setTimeout(function () { button.textContent = \"Copy\"; }, COPIED_FOR_MS);\n });\n }\n})();\n";
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The page an invite link opens. The invite code sits after the #, which
|
|
3
|
+
* browsers never send, so the server cannot write it into the page: the
|
|
4
|
+
* script reads it from the address bar and fills in the exact commands.
|
|
5
|
+
*/
|
|
6
|
+
export const JOIN_PLACEHOLDER_COMMAND = "teamroom join '<paste the full invite link here>'";
|
|
7
|
+
const FAVICON = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='6' fill='%23F4C84A'/%3E%3C/svg%3E";
|
|
8
|
+
export const JOIN_HTML = `<!DOCTYPE html>
|
|
9
|
+
<html lang="en">
|
|
10
|
+
<head>
|
|
11
|
+
<meta charset="utf-8">
|
|
12
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
13
|
+
<title>Join a teamroom</title>
|
|
14
|
+
<link rel="icon" href="${FAVICON}">
|
|
15
|
+
<link rel="stylesheet" href="/join.css">
|
|
16
|
+
<script src="/join.js" defer></script>
|
|
17
|
+
</head>
|
|
18
|
+
<body>
|
|
19
|
+
<main class="join">
|
|
20
|
+
<h1>You're invited to a teamroom</h1>
|
|
21
|
+
<p class="lede">Once you join, your coding agents and your teammates' agents see which files each of you is changing, before the work collides.</p>
|
|
22
|
+
<ol class="steps">
|
|
23
|
+
<li>
|
|
24
|
+
<h2>Install teamroom</h2>
|
|
25
|
+
<p>Once per computer. It needs Node.js 22 or newer.</p>
|
|
26
|
+
<div class="command"><code id="install-command">npm install --global teamroom</code><button type="button" data-copy="install-command">Copy</button></div>
|
|
27
|
+
</li>
|
|
28
|
+
<li>
|
|
29
|
+
<h2>Join from the repo</h2>
|
|
30
|
+
<p>Run this in the folder of the git repo you work on.</p>
|
|
31
|
+
<div class="command"><code id="join-command">${JOIN_PLACEHOLDER_COMMAND.replace("<", "<").replace(">", ">")}</code><button type="button" data-copy="join-command">Copy</button></div>
|
|
32
|
+
<p id="link-incomplete" class="problem" hidden>This link is missing its invite code, the part after the #. Ask whoever invited you to send the whole link again.</p>
|
|
33
|
+
</li>
|
|
34
|
+
</ol>
|
|
35
|
+
<p class="note">Keep this link to yourself: anyone who has it can join the room.</p>
|
|
36
|
+
</main>
|
|
37
|
+
</body>
|
|
38
|
+
</html>
|
|
39
|
+
`;
|
|
40
|
+
export const JOIN_STYLES = `
|
|
41
|
+
:root {
|
|
42
|
+
--paper: #EDF0F3;
|
|
43
|
+
--surface: #FFFFFF;
|
|
44
|
+
--ink: #16233A;
|
|
45
|
+
--muted: #56657A;
|
|
46
|
+
--rule: #CBD3DD;
|
|
47
|
+
--agent: #5B4BD6;
|
|
48
|
+
--overlap: #F4C84A;
|
|
49
|
+
--overlap-ink: #5A4300;
|
|
50
|
+
--words: "Schibsted Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
|
|
51
|
+
--code: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
|
|
52
|
+
color-scheme: light dark;
|
|
53
|
+
}
|
|
54
|
+
@media (prefers-color-scheme: dark) {
|
|
55
|
+
:root {
|
|
56
|
+
--paper: #121A28;
|
|
57
|
+
--surface: #1A2436;
|
|
58
|
+
--ink: #E6ECF3;
|
|
59
|
+
--muted: #9AA8BB;
|
|
60
|
+
--rule: #2C3A50;
|
|
61
|
+
--agent: #9489F2;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
* { box-sizing: border-box; }
|
|
65
|
+
html { background: var(--paper); color: var(--ink); font-family: var(--words); font-size: 16px; line-height: 1.5; }
|
|
66
|
+
body { margin: 0; }
|
|
67
|
+
.join { max-width: 640px; margin: 0 auto; padding: 56px 20px 64px; }
|
|
68
|
+
h1 { font-size: 28px; line-height: 1.2; margin: 0 0 10px; }
|
|
69
|
+
.lede { color: var(--muted); margin: 0 0 32px; }
|
|
70
|
+
.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; gap: 16px; }
|
|
71
|
+
.steps > li { counter-increment: step; background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 18px 20px 20px; }
|
|
72
|
+
.steps h2 { font-size: 17px; margin: 0 0 2px; }
|
|
73
|
+
.steps h2::before { content: counter(step) ". "; color: var(--muted); }
|
|
74
|
+
.steps p { margin: 0 0 12px; color: var(--muted); }
|
|
75
|
+
.command { display: flex; align-items: flex-start; gap: 8px; }
|
|
76
|
+
.command code { flex: 1; min-width: 0; font-family: var(--code); font-size: 13.5px; background: var(--paper); border: 1px solid var(--rule); border-radius: 4px; padding: 10px 12px; overflow-wrap: anywhere; user-select: all; }
|
|
77
|
+
.command button { flex: none; font: inherit; font-weight: 600; font-size: 14px; color: #FFFFFF; background: var(--agent); border: 0; border-radius: 4px; padding: 10px 16px; line-height: 1.5; cursor: pointer; }
|
|
78
|
+
.command button:focus-visible { outline: 3px solid var(--overlap); outline-offset: 2px; }
|
|
79
|
+
.steps p.problem { margin: 12px 0 0; padding: 10px 12px; border-radius: 4px; background: var(--overlap); color: var(--overlap-ink); }
|
|
80
|
+
.note { margin: 24px 0 0; color: var(--muted); font-size: 14px; }
|
|
81
|
+
@media (max-width: 480px) {
|
|
82
|
+
.command { flex-direction: column; align-items: stretch; }
|
|
83
|
+
}
|
|
84
|
+
`;
|
|
85
|
+
// ES5 on purpose, like the dashboard script: it runs in whatever browser the teammate opens the link in.
|
|
86
|
+
// Only ids and codes of the expected shape are written into the command, so it is always safe to paste into a shell.
|
|
87
|
+
export const JOIN_SCRIPT = `(function () {
|
|
88
|
+
var ROOM_ID = /^room_[A-Za-z0-9_-]{16}$/;
|
|
89
|
+
var INVITE_CODE = /^tri_[A-Za-z0-9_-]{16,128}$/;
|
|
90
|
+
var COPIED_FOR_MS = 2000;
|
|
91
|
+
|
|
92
|
+
var roomId = location.pathname.split("/").pop();
|
|
93
|
+
var inviteCode = location.hash.slice(1);
|
|
94
|
+
var joinCommand = document.getElementById("join-command");
|
|
95
|
+
var incomplete = document.getElementById("link-incomplete");
|
|
96
|
+
|
|
97
|
+
if (ROOM_ID.test(roomId) && INVITE_CODE.test(inviteCode)) {
|
|
98
|
+
joinCommand.textContent = "teamroom join '" + location.origin + location.pathname + "#" + inviteCode + "'";
|
|
99
|
+
} else {
|
|
100
|
+
incomplete.hidden = false;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
var buttons = document.querySelectorAll("button[data-copy]");
|
|
104
|
+
for (var index = 0; index < buttons.length; index++) {
|
|
105
|
+
buttons[index].addEventListener("click", copyCommand);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function copyCommand(event) {
|
|
109
|
+
var button = event.currentTarget;
|
|
110
|
+
var text = document.getElementById(button.getAttribute("data-copy")).textContent;
|
|
111
|
+
if (!navigator.clipboard) return;
|
|
112
|
+
navigator.clipboard.writeText(text).then(function () {
|
|
113
|
+
button.textContent = "Copied";
|
|
114
|
+
setTimeout(function () { button.textContent = "Copy"; }, COPIED_FOR_MS);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
})();
|
|
118
|
+
`;
|
|
119
|
+
//# sourceMappingURL=join-page.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"join-page.js","sourceRoot":"","sources":["../../src/web/join-page.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG,mDAAmD,CAAC;AAE5F,MAAM,OAAO,GACX,iJAAiJ,CAAC;AAEpJ,MAAM,CAAC,MAAM,SAAS,GAAG;;;;;;yBAMA,OAAO;;;;;;;;;;;;;;;;;+CAiBe,wBAAwB,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC;;;;;;;;CAQhH,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4C1B,CAAC;AAEF,yGAAyG;AACzG,qHAAqH;AACrH,MAAM,CAAC,MAAM,WAAW,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+B1B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The browser dashboard: one page, one stylesheet, one script, no build step.
|
|
3
|
+
* Colors and type follow site/index.html. The script never writes HTML from
|
|
4
|
+
* data: notes and file names come from other sessions, so they go in as text.
|
|
5
|
+
*/
|
|
6
|
+
/** Sent with the page, its assets and its data, by `teamroom ui` and by the server. */
|
|
7
|
+
export declare const PAGE_SECURITY_HEADERS: {
|
|
8
|
+
readonly "Content-Security-Policy": "default-src 'none'; script-src 'self'; style-src 'self'; connect-src 'self'; img-src 'self' data:; base-uri 'none'; form-action 'none'; frame-ancestors 'none'";
|
|
9
|
+
readonly "X-Content-Type-Options": "nosniff";
|
|
10
|
+
readonly "Referrer-Policy": "no-referrer";
|
|
11
|
+
readonly "Cache-Control": "no-store";
|
|
12
|
+
};
|
|
13
|
+
export declare const PAGE_HTML = "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<title>teamroom</title>\n<link rel=\"icon\" href=\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='6' fill='%23F4C84A'/%3E%3C/svg%3E\">\n<link rel=\"stylesheet\" href=\"/app.css\">\n<script src=\"/app.js\" defer></script>\n</head>\n<body>\n<header class=\"top\">\n <p class=\"brand\"><span class=\"dot\" aria-hidden=\"true\"></span>teamroom</p>\n <p class=\"where\" id=\"where\">Loading the room\u2026</p>\n <p class=\"updated\" id=\"updated\"></p>\n</header>\n<p class=\"problem\" id=\"problem\" role=\"status\" hidden></p>\n<main>\n <section class=\"verdict\" id=\"verdict\" aria-live=\"polite\"></section>\n <div class=\"columns\">\n <section aria-labelledby=\"who-title\">\n <h2 id=\"who-title\">Who is working</h2>\n <ul class=\"sessions\" id=\"sessions\"></ul>\n </section>\n <section aria-labelledby=\"log-title\">\n <h2 id=\"log-title\">What happened</h2>\n <ol class=\"log\" id=\"log\"></ol>\n </section>\n </div>\n</main>\n<footer class=\"how\">\n <h2>How this works</h2>\n <p>Every folder where someone works on this project shares the names of the files it is changing, never what is in them.</p>\n <p>When two places change the same file, it shows up at the top of this page, and coding agents get a heads-up before they edit it.</p>\n <p id=\"closing\">This page updates on its own. To close it, stop the terminal that opened it.</p>\n</footer>\n</body>\n</html>\n";
|
|
14
|
+
export declare const PAGE_STYLES = "\n:root {\n --paper: #EDF0F3;\n --surface: #FFFFFF;\n --ink: #16233A;\n --muted: #56657A;\n --rule: #CBD3DD;\n --working: #1F8A7A;\n --agent: #5B4BD6;\n --overlap: #F4C84A;\n --overlap-ink: #5A4300;\n --mark-band: var(--overlap);\n --radius-panel: 10px;\n --radius-chip: 4px;\n --words: \"Schibsted Grotesk\", ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif;\n --code: \"JetBrains Mono\", ui-monospace, \"SF Mono\", Menlo, Consolas, monospace;\n color-scheme: light dark;\n}\n@media (prefers-color-scheme: dark) {\n :root {\n --paper: #121A28;\n --surface: #1A2436;\n --ink: #E6ECF3;\n --muted: #9AA8BB;\n --rule: #2C3A50;\n --working: #3DBFA9;\n --agent: #9489F2;\n --overlap-ink: #2A1F00;\n --mark-band: color-mix(in srgb, var(--overlap) 40%, var(--paper));\n }\n}\n* { box-sizing: border-box; }\nhtml { background: var(--paper); color: var(--ink); font-family: var(--words); font-size: 16px; line-height: 1.5; }\nbody { margin: 0 auto; max-width: 1120px; padding: 24px 28px 64px; }\nh1, h2, p, ul, ol { margin: 0; }\nul, ol { padding: 0; list-style: none; }\n.mono { font-family: var(--code); font-size: 0.86em; }\n\n.top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 20px; padding-bottom: 18px; border-bottom: 1px solid var(--rule); }\n.brand { font-weight: 800; letter-spacing: -0.02em; font-size: 18px; display: flex; align-items: center; gap: 8px; }\n.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--overlap); box-shadow: 0 0 0 3px color-mix(in srgb, var(--overlap) 35%, transparent); }\n.where { color: var(--muted); }\n.where strong { color: var(--ink); font-weight: 700; }\n.updated { margin-left: auto; color: var(--muted); font-size: 13px; }\n\n.problem { margin-top: 16px; padding: 10px 14px; border-radius: var(--radius-chip); background: var(--surface); border: 1px solid var(--rule); border-left: 3px solid var(--overlap); }\n\n.verdict { padding: 48px 0 40px; }\n.verdict h1 { max-width: 24ch; font-size: clamp(30px, 4.4vw, 48px); font-weight: 800; letter-spacing: -0.035em; line-height: 1.04; }\n.verdict h1 .mono { font-size: 0.82em; font-weight: 700; letter-spacing: -0.02em; }\n.verdict > p { margin-top: 14px; color: var(--muted); font-size: 18px; max-width: 60ch; }\nmark { color: inherit; background: linear-gradient(transparent 60%, var(--mark-band) 60%, var(--mark-band) 92%, transparent 92%) no-repeat; background-size: 100% 100%; }\n@media (prefers-reduced-motion: no-preference) {\n mark.arrive { animation: band 700ms cubic-bezier(.2,.7,.2,1) both; }\n @keyframes band { from { background-size: 0% 100%; } to { background-size: 100% 100%; } }\n}\n\n.meets { margin-top: 32px; display: grid; gap: 20px; max-width: 920px; }\n.meet { position: relative; display: grid; gap: 16px; align-items: stretch; }\n.meet.two { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }\n.meet.two .file { align-self: center; }\n.meet.two::before { content: \"\"; position: absolute; left: 12%; right: 12%; top: 50%; border-top: 2px solid var(--overlap); }\n.meet.many { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }\n.meet.many .file { grid-column: 1 / -1; justify-self: start; }\n.meet .file { position: relative; font-family: var(--code); font-size: 14px; font-weight: 600; padding: 6px 12px; border-radius: var(--radius-chip); background: var(--overlap); color: var(--overlap-ink); }\n.touch { position: relative; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-panel); padding: 14px 16px; }\n.touch .name { font-weight: 700; font-size: 17px; }\n.touch .who { color: var(--muted); font-size: 14px; }\n.touch .plan { margin-top: 10px; overflow-wrap: anywhere; }\n\n.columns { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 40px; padding-top: 32px; border-top: 1px solid var(--rule); }\n.columns h2, .how h2 { font-size: 15px; font-weight: 700; margin-bottom: 14px; }\n\n.sessions { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-panel); }\n.session { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; gap: 4px 12px; padding: 16px 18px; }\n.session + .session { border-top: 1px solid var(--rule); }\n.state { width: 10px; height: 10px; margin-top: 7px; border-radius: 50%; border: 2px solid var(--rule); }\n.state.on { background: var(--working); border-color: var(--working); }\n.session .title { font-weight: 700; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }\n.session .here { font-weight: 500; font-size: 13px; color: var(--muted); }\n.session .age { color: var(--muted); font-size: 13px; white-space: nowrap; }\n.session .meta, .session .doing, .session .files { grid-column: 2 / 4; }\n.session .meta { color: var(--muted); font-size: 14px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }\n.agent { color: var(--agent); font-weight: 600; }\n.files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }\n.chip { font-family: var(--code); font-size: 12.5px; padding: 1px 7px; border-radius: var(--radius-chip); border: 1px solid var(--rule); background: var(--paper); overflow-wrap: anywhere; }\n.chip.shared { background: var(--overlap); border-color: var(--overlap); color: var(--overlap-ink); }\n.more { font-size: 13px; color: var(--muted); align-self: center; }\n.none { color: var(--muted); padding: 16px 18px; }\n\n.log li { padding: 2px 0 2px 14px; border-left: 3px solid var(--rule); margin-bottom: 14px; }\n.log li.note { border-left-color: var(--ink); }\n.log li.edit { border-left-color: var(--agent); }\n.log li.commit { border-left-color: var(--working); }\n.log .line1 { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 2px 8px; }\n.log .line1 .kind { color: var(--ink); font-weight: 600; }\n.log .text { overflow-wrap: anywhere; }\n.log .times { color: var(--muted); font-size: 13px; margin-left: 6px; }\n\n.how { margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--rule); color: var(--muted); max-width: 68ch; }\n.how p + p { margin-top: 6px; }\n\n@media (max-width: 760px) {\n body { padding: 18px 16px 48px; }\n .columns { grid-template-columns: 1fr; }\n .meet.two { grid-template-columns: 1fr; justify-items: stretch; }\n .meet.two .file { justify-self: center; }\n .meet.two::before { left: 50%; right: auto; top: 10%; bottom: 10%; border-top: 0; border-left: 2px solid var(--overlap); }\n .updated { margin-left: 0; width: 100%; }\n}\n";
|
|
15
|
+
export declare const PAGE_SCRIPT = "\"use strict\";\n(function () {\n var POLL_MS = 3000;\n var MAX_BACKOFF_MS = 30000;\n var REQUEST_TIMEOUT_MS = 10000;\n var FILES_SHOWN = 8;\n var SHARED_FILES_SHOWN = 5;\n var KIND_WORDS = { wip: \"Shared changes\", note: \"Plan\", edit: \"Agent edit\", commit: \"Commit\" };\n\n // A view link carries the room and a read-only key after the #, which the browser never sends to the server.\n var linkParams = new URLSearchParams(location.hash.slice(1));\n var viewRoom = linkParams.get(\"room\");\n var viewKey = linkParams.get(\"key\");\n var hosted = location.pathname === \"/view\";\n var STOP_POLLING = -1;\n\n var failures = 0;\n var lastData = null;\n var lastVerdict = \"\";\n var hadSharedFiles = false;\n\n function el(tag, className, children) {\n var node = document.createElement(tag);\n if (className) node.className = className;\n [].concat(children === undefined ? [] : children).forEach(function (child) {\n if (child === null || child === undefined || child === false || child === \"\") return;\n node.append(child);\n });\n return node;\n }\n\n function plural(count, word) {\n return count + \" \" + word + (count === 1 ? \"\" : \"s\");\n }\n\n function ago(iso, now) {\n var seconds = Math.max(0, Math.round((now - Date.parse(iso)) / 1000));\n if (seconds < 60) return \"just now\";\n var minutes = Math.round(seconds / 60);\n if (minutes < 60) return minutes + \" min ago\";\n var hours = Math.round(minutes / 60);\n if (hours < 48) return plural(hours, \"hour\") + \" ago\";\n return plural(Math.round(hours / 24), \"day\") + \" ago\";\n }\n\n function personName(data, member) {\n return member === data.me ? \"You\" : member;\n }\n\n function renderTop(data) {\n var where = document.getElementById(\"where\");\n var scope = data.room.mode === \"local\"\n ? \"only on this computer\"\n : \"shared with \" + (data.room.people === 1 ? \"1 person\" : data.room.people + \" people\");\n where.replaceChildren(el(\"strong\", \"\", data.room.name), \", \" + scope);\n }\n\n function touchCard(data, session) {\n return el(\"div\", \"touch\", [\n el(\"p\", \"name\", session.label),\n el(\"p\", \"who\", [personName(data, session.member), session.agent ? el(\"span\", \"agent\", \", with \" + session.agent) : \", no agent\"]),\n el(\"p\", \"plan\", session.plan || session.doing)\n ]);\n }\n\n function renderVerdict(data) {\n var byKey = {};\n data.sessions.forEach(function (session) { byKey[session.key] = session; });\n var signature = JSON.stringify([data.sessions.length, data.sharedFiles, data.sharedFiles.map(function (file) {\n return file.sessionKeys.map(function (key) { return byKey[key] && [byKey[key].doing, byKey[key].agent]; });\n })]);\n if (signature === lastVerdict) return;\n lastVerdict = signature;\n\n var verdict = document.getElementById(\"verdict\");\n var hasShared = data.sharedFiles.length > 0;\n var arriving = hasShared && !hadSharedFiles;\n hadSharedFiles = hasShared;\n\n if (data.sessions.length === 0) {\n verdict.replaceChildren(\n el(\"h1\", \"\", \"Nobody has shared any work yet.\"),\n el(\"p\", \"\", [\"Make a commit in a project folder, or run \", el(\"span\", \"mono\", \"teamroom report\"), \", and it shows up here.\"])\n );\n return;\n }\n\n if (!hasShared) {\n verdict.replaceChildren(\n el(\"h1\", \"\", \"Everyone is working in their own files.\"),\n el(\"p\", \"\", \"No file is being changed in two places right now.\")\n );\n return;\n }\n\n var first = data.sharedFiles[0];\n var heading = data.sharedFiles.length === 1\n ? el(\"h1\", \"\", [el(\"mark\", arriving ? \"arrive\" : \"\", el(\"span\", \"mono\", first.path)), \" is being changed in \" + first.sessionKeys.length + \" places.\"])\n : el(\"h1\", \"\", [el(\"mark\", arriving ? \"arrive\" : \"\", plural(data.sharedFiles.length, \"file\")), \" are being changed in more than one place.\"]);\n\n var allMine = data.sharedFiles.every(function (file) {\n return file.sessionKeys.every(function (key) { return byKey[key] && byKey[key].isMine; });\n });\n var advice = allMine\n ? \"These are all your own folders. Let one finish before the other continues, or they will clash when you merge.\"\n : \"Agree on who goes first before \" + (data.sharedFiles.length === 1 && first.sessionKeys.length === 2 ? \"both continue\" : \"everyone continues\") + \". What each one is doing is below.\";\n\n var meets = el(\"div\", \"meets\", data.sharedFiles.slice(0, SHARED_FILES_SHOWN).map(function (file) {\n var touching = file.sessionKeys.map(function (key) { return byKey[key]; }).filter(Boolean);\n var chip = el(\"p\", \"file\", file.path);\n if (touching.length === 2) {\n return el(\"div\", \"meet two\", [touchCard(data, touching[0]), chip, touchCard(data, touching[1])]);\n }\n return el(\"div\", \"meet many\", [chip].concat(touching.map(function (session) { return touchCard(data, session); })));\n }));\n\n verdict.replaceChildren(heading, el(\"p\", \"\", advice), meets);\n }\n\n function renderSessions(data, now) {\n var list = document.getElementById(\"sessions\");\n if (data.sessions.length === 0) {\n list.replaceChildren(el(\"li\", \"none\", \"No one has worked here in the last 3 days.\"));\n return;\n }\n list.replaceChildren.apply(list, data.sessions.map(function (session) {\n var state = el(\"span\", \"state\" + (session.active ? \" on\" : \"\"));\n state.setAttribute(\"title\", session.active ? \"Working now\" : \"Quiet\");\n state.setAttribute(\"aria-label\", session.active ? \"Working now\" : \"Quiet\");\n state.setAttribute(\"role\", \"img\");\n\n var shown = session.files.slice(0, FILES_SHOWN);\n var hidden = session.files.length - shown.length;\n var files = shown.map(function (file) {\n var chip = el(\"span\", \"chip\" + (file.shared ? \" shared\" : \"\"), file.path);\n if (file.shared) chip.setAttribute(\"title\", \"Also being changed somewhere else\");\n return chip;\n });\n if (hidden > 0) files.push(el(\"span\", \"more\", \"and \" + hidden + \" more\"));\n\n return el(\"li\", \"session\", [\n state,\n el(\"p\", \"title\", [session.label, session.isHere ? el(\"span\", \"here\", \"this folder\") : null]),\n el(\"p\", \"age\", ago(session.lastSeen, now)),\n el(\"p\", \"meta\", [\n el(\"span\", \"\", personName(data, session.member)),\n session.branch ? el(\"span\", \"\", [\"on \", el(\"span\", \"mono\", session.branch)]) : null,\n session.agent ? el(\"span\", \"agent\", session.agent) : el(\"span\", \"\", \"No agent\")\n ]),\n el(\"p\", \"doing\", session.plan || session.doing),\n files.length > 0 ? el(\"div\", \"files\", files) : null\n ]);\n }));\n }\n\n function renderLog(data, now) {\n var log = document.getElementById(\"log\");\n if (data.recent.length === 0) {\n log.replaceChildren(el(\"li\", \"\", \"Nothing yet.\"));\n return;\n }\n log.replaceChildren.apply(log, data.recent.map(function (entry) {\n var who = personName(data, entry.member) + (entry.sessionLabel ? \" in \" + entry.sessionLabel : \"\");\n return el(\"li\", entry.kind, [\n el(\"p\", \"line1\", [\n el(\"span\", \"kind\", KIND_WORDS[entry.kind] || entry.kind),\n el(\"span\", \"\", who + (entry.agent ? \", \" + entry.agent : \"\")),\n el(\"span\", \"\", ago(entry.at, now))\n ]),\n el(\"p\", \"text\", [entry.text, entry.count > 1 ? el(\"span\", \"times\", entry.count + \" times\") : null])\n ]);\n }));\n }\n\n function render(data) {\n var now = Date.now();\n renderTop(data);\n renderVerdict(data);\n renderSessions(data, now);\n renderLog(data, now);\n }\n\n function showProblem(message, retryMs) {\n var problem = document.getElementById(\"problem\");\n var shownSince = lastData ? \" Showing what was there \" + ago(lastData.updatedAt, Date.now()) + \".\" : \"\";\n problem.textContent = \"Can't reach the room: \" + message + shownSince + \" Trying again in \" + Math.round(retryMs / 1000) + \" s.\";\n problem.hidden = false;\n }\n\n function showUpdated() {\n document.getElementById(\"updated\").textContent = lastData ? \"Updated \" + ago(lastData.updatedAt, Date.now()) : \"\";\n }\n\n function request(signal) {\n if (!hosted) return fetch(\"/api/dashboard\", { signal: signal, cache: \"no-store\" });\n return fetch(\"/v1/rooms/\" + encodeURIComponent(viewRoom) + \"/dashboard\", {\n signal: signal,\n cache: \"no-store\",\n headers: { Authorization: \"Bearer \" + viewKey }\n });\n }\n\n function stopWith(message) {\n var problem = document.getElementById(\"problem\");\n problem.textContent = message;\n problem.hidden = false;\n document.getElementById(\"where\").textContent = \"\";\n document.querySelector(\"main\").hidden = true;\n }\n\n function poll() {\n var controller = new AbortController();\n var timeout = setTimeout(function () { controller.abort(); }, REQUEST_TIMEOUT_MS);\n request(controller.signal)\n .then(function (response) {\n if (response.status === 401 || response.status === 404) {\n var refused = new Error(\"refused\");\n refused.name = \"Refused\";\n throw refused;\n }\n return response.json().then(function (body) {\n if (!response.ok || !body.data) throw new Error((body.error && body.error.message) || \"the dashboard stopped answering.\");\n return body.data;\n });\n })\n .then(function (data) {\n failures = 0;\n lastData = data;\n document.getElementById(\"problem\").hidden = true;\n render(data);\n })\n .catch(function (error) {\n if (error && error.name === \"Refused\") {\n failures = STOP_POLLING;\n stopWith(\"This link no longer opens the room. The owner may have turned it off or made a new one: ask them for the current link.\");\n return;\n }\n failures += 1;\n var message = error && error.name === \"AbortError\"\n ? \"it took too long to answer.\"\n : error && error.name === \"TypeError\"\n ? (hosted ? \"the server did not answer.\" : \"the terminal that opened this page was closed.\")\n : (error && error.message) || \"unknown error.\";\n showProblem(message, Math.min(POLL_MS * Math.pow(2, failures), MAX_BACKOFF_MS));\n })\n .finally(function () {\n clearTimeout(timeout);\n showUpdated();\n if (failures === STOP_POLLING) return;\n setTimeout(poll, Math.min(POLL_MS * Math.pow(2, failures), MAX_BACKOFF_MS));\n });\n }\n\n if (hosted) {\n document.getElementById(\"closing\").textContent = \"This page updates on its own. It can only look: nothing you do here changes the room.\";\n }\n if (hosted && (!viewRoom || !viewKey)) {\n stopWith(\"This link is missing its key. Ask the room owner for the full view link: it ends with #room=...&key=...\");\n } else {\n poll();\n }\n})();\n";
|