@parallelworks/code 0.2.0 → 0.4.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 +602 -84
- package/dist/accountApi.d.ts +31 -0
- package/dist/accountApi.js +182 -0
- package/dist/agentSwitcher.d.ts +109 -0
- package/dist/agentSwitcher.js +165 -0
- package/dist/ago.d.ts +8 -0
- package/dist/ago.js +26 -0
- package/dist/allocations.d.ts +41 -0
- package/dist/allocations.js +76 -0
- package/dist/api.d.ts +1213 -66
- package/dist/base64.d.ts +3 -0
- package/dist/base64.js +15 -0
- package/dist/chatHandoff.d.ts +12 -0
- package/dist/chatHandoff.js +27 -0
- package/dist/chatStrings.d.ts +188 -0
- package/dist/chatStrings.js +217 -0
- package/dist/claudeAccounts.d.ts +149 -0
- package/dist/claudeAccounts.js +328 -0
- package/dist/claudeApi.js +1 -1
- package/dist/claudeSignIn.d.ts +80 -0
- package/dist/claudeSignIn.js +249 -0
- package/dist/commandsApi.d.ts +11 -1
- package/dist/commandsApi.js +24 -5
- package/dist/contextRow.d.ts +25 -0
- package/dist/contextRow.js +16 -0
- package/dist/createPwCodeApi.d.ts +52 -5
- package/dist/createPwCodeApi.js +20 -2
- package/dist/directories.d.ts +161 -0
- package/dist/directories.js +301 -0
- package/dist/goal.d.ts +89 -0
- package/dist/goal.js +164 -0
- package/dist/howSessionsAppear.d.ts +12 -0
- package/dist/howSessionsAppear.js +24 -0
- package/dist/imageFit.d.ts +23 -0
- package/dist/imageFit.js +27 -0
- package/dist/images.d.ts +28 -0
- package/dist/images.js +38 -6
- package/dist/index.d.ts +41 -3
- package/dist/index.js +40 -4
- package/dist/loadError.d.ts +8 -0
- package/dist/loadError.js +19 -0
- package/dist/locales/en/agentTranscript.js +75 -22
- package/dist/locales/en/agents.js +76 -14
- package/dist/locales/en.d.ts +129 -21
- package/dist/locales/es/agentTranscript.js +75 -22
- package/dist/locales/es/agents.js +76 -14
- package/dist/locales/ja/agentTranscript.js +78 -25
- package/dist/locales/ja/agents.js +49 -124
- package/dist/locales/ko/agentTranscript.js +75 -22
- package/dist/locales/ko/agents.js +76 -14
- package/dist/locales/zh/agentTranscript.js +73 -20
- package/dist/locales/zh/agents.js +76 -14
- package/dist/machine.d.ts +4 -0
- package/dist/modelPicker.d.ts +79 -0
- package/dist/modelPicker.js +107 -0
- package/dist/models.d.ts +47 -0
- package/dist/models.js +49 -0
- package/dist/notices.d.ts +2 -1
- package/dist/notices.js +75 -21
- package/dist/platformDefaults.d.ts +22 -0
- package/dist/platformDefaults.js +30 -0
- package/dist/preferences.d.ts +78 -0
- package/dist/preferences.js +128 -0
- package/dist/pullRequestList.d.ts +60 -0
- package/dist/pullRequestList.js +125 -0
- package/dist/query.d.ts +6 -2
- package/dist/query.js +85 -10
- package/dist/session.d.ts +10 -2
- package/dist/session.js +12 -8
- package/dist/sessionActions.d.ts +115 -0
- package/dist/sessionActions.js +186 -0
- package/dist/sessionEvents.d.ts +8 -3
- package/dist/sessionEvents.js +10 -5
- package/dist/sessionGroups.d.ts +50 -0
- package/dist/sessionGroups.js +73 -0
- package/dist/sessionHeader.d.ts +14 -0
- package/dist/sessionHeader.js +16 -0
- package/dist/sessionList.d.ts +182 -0
- package/dist/sessionList.js +333 -0
- package/dist/sessionScreen.d.ts +193 -0
- package/dist/sessionScreen.js +213 -0
- package/dist/sessionsApi.d.ts +13 -3
- package/dist/sessionsApi.js +90 -33
- package/dist/settingsApi.d.ts +38 -0
- package/dist/settingsApi.js +151 -0
- package/dist/startPage.d.ts +153 -0
- package/dist/startPage.js +174 -0
- package/dist/startSession.d.ts +172 -0
- package/dist/startSession.js +256 -0
- package/dist/terminalHandoffPanel.d.ts +30 -0
- package/dist/terminalHandoffPanel.js +33 -0
- package/dist/transcript.d.ts +2 -0
- package/dist/transcript.js +62 -26
- package/dist/types.d.ts +11 -1
- package/dist/usageLimit.d.ts +8 -0
- package/dist/usageLimit.js +13 -0
- package/dist/useAwayRecap.d.ts +30 -0
- package/dist/useAwayRecap.js +75 -0
- package/dist/useComposer.d.ts +145 -0
- package/dist/useComposer.js +295 -0
- package/dist/useComposerImages.d.ts +71 -0
- package/dist/useComposerImages.js +218 -0
- package/dist/useComposerPastes.d.ts +70 -0
- package/dist/useComposerPastes.js +130 -0
- package/dist/useConversation.d.ts +199 -0
- package/dist/useConversation.js +314 -0
- package/dist/useSubagent.d.ts +104 -0
- package/dist/useSubagent.js +212 -0
- package/dist/useTranscript.d.ts +23 -3
- package/dist/useTranscript.js +76 -19
- package/dist/wording.js +2 -2
- package/dist/workingDirectories.d.ts +63 -0
- package/dist/workingDirectories.js +95 -0
- package/dist/worktreeChoice.d.ts +31 -0
- package/dist/worktreeChoice.js +38 -0
- package/locales/en/agentTranscript.json +69 -21
- package/locales/en/agents.json +73 -13
- package/locales/es/agentTranscript.json +69 -21
- package/locales/es/agents.json +73 -13
- package/locales/ja/agentTranscript.json +72 -24
- package/locales/ja/agents.json +73 -13
- package/locales/ko/agentTranscript.json +69 -21
- package/locales/ko/agents.json +73 -13
- package/locales/zh/agentTranscript.json +67 -19
- package/locales/zh/agents.json +73 -13
- package/package.json +6 -3
package/dist/sessionEvents.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PREVIEWS_BY_REF } from "./images.js";
|
|
1
2
|
import { isConnected } from "./machine.js";
|
|
2
3
|
import { useCallback, useEffect, useRef, useState, useSyncExternalStore } from "react";
|
|
3
4
|
// src/sessionEvents.ts
|
|
@@ -5,9 +6,13 @@ var INITIAL_RETRY_MS = 1e3;
|
|
|
5
6
|
var MAX_RETRY_MS = 3e4;
|
|
6
7
|
var SOCKET_OPEN = 1;
|
|
7
8
|
var SOCKET_CLOSED = 3;
|
|
8
|
-
/** The path a session's event feed is served at, resuming after frame `after`.
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
/** The path a session's event feed is served at, resuming after frame `after`.
|
|
10
|
+
* With `previewsByRef` the images a tool read come without their previews,
|
|
11
|
+
* which the host loads by URL: a preview is tens of kilobytes, and over a slow
|
|
12
|
+
* connection what the session says next waits behind it. */
|
|
13
|
+
function sessionEventsPath(machine, id, after, previewsByRef = false) {
|
|
14
|
+
const previews = previewsByRef ? `&previews=${PREVIEWS_BY_REF}` : "";
|
|
15
|
+
return `/ws/code/machines/${encodeURIComponent(machine)}/sessions/${encodeURIComponent(id)}/events?after=${after}${previews}`;
|
|
11
16
|
}
|
|
12
17
|
/** Frames after which the list of subagents may read differently: one started
|
|
13
18
|
* or ended, one asked for or got an approval, or a turn began or closed. */
|
|
@@ -114,7 +119,7 @@ function useReconnectingSocket({ open, path, connectionKey, enabled, onOpen, onM
|
|
|
114
119
|
}, [enabled, connectionKey]);
|
|
115
120
|
return connected;
|
|
116
121
|
}
|
|
117
|
-
function sessionEvents({ openSocket, hidden }) {
|
|
122
|
+
function sessionEvents({ openSocket, hidden, previewsByRef = false }) {
|
|
118
123
|
const openFeeds = /* @__PURE__ */ new Map();
|
|
119
124
|
const listeners = /* @__PURE__ */ new Set();
|
|
120
125
|
let fedMachines = /* @__PURE__ */ new Set();
|
|
@@ -166,7 +171,7 @@ function sessionEvents({ openSocket, hidden }) {
|
|
|
166
171
|
}, [key]);
|
|
167
172
|
const connected = useReconnectingSocket({
|
|
168
173
|
open: openSocket,
|
|
169
|
-
path: () => sessionEventsPath(machine, id, cursor?.() ?? 0),
|
|
174
|
+
path: () => sessionEventsPath(machine, id, cursor?.() ?? 0, previewsByRef),
|
|
170
175
|
connectionKey: key,
|
|
171
176
|
enabled: cursor !== void 0,
|
|
172
177
|
onOpen: () => setFeed({
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type Dispatch, type SetStateAction } from 'react';
|
|
2
|
+
import { type PwCodeMachine } from './machine.js';
|
|
3
|
+
import { type PwCodeSession } from './session.js';
|
|
4
|
+
/** A group the reader made. Its name is theirs, so the host keeps it with
|
|
5
|
+
* their preferences; which group a session is in is on the session, kept by
|
|
6
|
+
* its machine's daemon. */
|
|
7
|
+
export interface SessionGroup {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ListedGroup<S = PwCodeSession> {
|
|
12
|
+
group: SessionGroup;
|
|
13
|
+
sessions: S[];
|
|
14
|
+
waiting: number;
|
|
15
|
+
running: number;
|
|
16
|
+
}
|
|
17
|
+
type Grouped = Pick<PwCodeSession, 'machineId' | 'id' | 'status' | 'liveHost' | 'archivedAt' | 'group' | 'createdAt'>;
|
|
18
|
+
type Machines = ReadonlyMap<string, Pick<PwCodeMachine, 'status'>>;
|
|
19
|
+
export declare function patchGroup(groups: readonly SessionGroup[], id: string, patch: Partial<Omit<SessionGroup, 'id'>>): SessionGroup[];
|
|
20
|
+
/** The reader's group a session is in. One naming a group since deleted is in none. */
|
|
21
|
+
export declare function groupOf(groups: readonly SessionGroup[], session: Pick<PwCodeSession, 'group'>): SessionGroup | undefined;
|
|
22
|
+
/** A turn is running on a machine that still answers. */
|
|
23
|
+
export declare function isWorking(session: Pick<PwCodeSession, 'status'>, machine: Pick<PwCodeMachine, 'status'> | undefined): boolean;
|
|
24
|
+
/** Sessions as a group lists them: what waits on the reader, then what is
|
|
25
|
+
* live, newest begun first, then the rest, with how many wait and how many
|
|
26
|
+
* are working. */
|
|
27
|
+
export declare function inFlightFirst<S extends Grouped>(sessions: readonly S[], machineById: Machines): {
|
|
28
|
+
sessions: S[];
|
|
29
|
+
waiting: number;
|
|
30
|
+
running: number;
|
|
31
|
+
};
|
|
32
|
+
/** Each group's sessions, and the ones in none. Archived sessions stay with
|
|
33
|
+
* the archive. */
|
|
34
|
+
export declare function listGroups<S extends Grouped>(groups: readonly SessionGroup[], sessions: readonly S[], machineById: Machines): {
|
|
35
|
+
listed: ListedGroup<S>[];
|
|
36
|
+
ungrouped: S[];
|
|
37
|
+
};
|
|
38
|
+
export interface SessionGroups {
|
|
39
|
+
groups: SessionGroup[];
|
|
40
|
+
create: (name: string) => SessionGroup;
|
|
41
|
+
patch: (id: string, change: Partial<Omit<SessionGroup, 'id'>>) => void;
|
|
42
|
+
remove: (id: string) => void;
|
|
43
|
+
}
|
|
44
|
+
/** The reader's groups, over state the host keeps for them, as `useState`
|
|
45
|
+
* returns it. `newId` names a group as it is made. */
|
|
46
|
+
export declare function useSessionGroups([groups, setGroups]: readonly [
|
|
47
|
+
SessionGroup[],
|
|
48
|
+
Dispatch<SetStateAction<SessionGroup[]>>
|
|
49
|
+
], newId: () => string): SessionGroups;
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { isMachineDown } from "./machine.js";
|
|
2
|
+
import { isActiveSession, isArchived, needsYou, newestCreatedFirst } from "./session.js";
|
|
3
|
+
import { useCallback, useMemo } from "react";
|
|
4
|
+
// src/sessionGroups.ts
|
|
5
|
+
function patchGroup(groups, id, patch) {
|
|
6
|
+
return groups.map((g) => g.id === id ? {
|
|
7
|
+
...g,
|
|
8
|
+
...patch
|
|
9
|
+
} : g);
|
|
10
|
+
}
|
|
11
|
+
/** The reader's group a session is in. One naming a group since deleted is in none. */
|
|
12
|
+
function groupOf(groups, session) {
|
|
13
|
+
return session.group ? groups.find((g) => g.id === session.group) : void 0;
|
|
14
|
+
}
|
|
15
|
+
/** A turn is running on a machine that still answers. */
|
|
16
|
+
function isWorking(session, machine) {
|
|
17
|
+
return session.status === "running" && !isMachineDown(machine);
|
|
18
|
+
}
|
|
19
|
+
/** Sessions as a group lists them: what waits on the reader, then what is
|
|
20
|
+
* live, newest begun first, then the rest, with how many wait and how many
|
|
21
|
+
* are working. */
|
|
22
|
+
function inFlightFirst(sessions, machineById) {
|
|
23
|
+
const waiting = sessions.filter((s) => needsYou(s, machineById.get(s.machineId)));
|
|
24
|
+
const rest = sessions.filter((s) => !waiting.includes(s));
|
|
25
|
+
const live = newestCreatedFirst(rest.filter(isActiveSession));
|
|
26
|
+
return {
|
|
27
|
+
sessions: [
|
|
28
|
+
...waiting,
|
|
29
|
+
...live,
|
|
30
|
+
...rest.filter((s) => !isActiveSession(s))
|
|
31
|
+
],
|
|
32
|
+
waiting: waiting.length,
|
|
33
|
+
running: live.filter((s) => isWorking(s, machineById.get(s.machineId))).length
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/** Each group's sessions, and the ones in none. Archived sessions stay with
|
|
37
|
+
* the archive. */
|
|
38
|
+
function listGroups(groups, sessions, machineById) {
|
|
39
|
+
const grouped = (s) => isArchived(s) ? void 0 : groupOf(groups, s);
|
|
40
|
+
return {
|
|
41
|
+
listed: groups.map((group) => ({
|
|
42
|
+
group,
|
|
43
|
+
...inFlightFirst(sessions.filter((s) => grouped(s) === group), machineById)
|
|
44
|
+
})),
|
|
45
|
+
ungrouped: sessions.filter((s) => !grouped(s))
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/** The reader's groups, over state the host keeps for them, as `useState`
|
|
49
|
+
* returns it. `newId` names a group as it is made. */
|
|
50
|
+
function useSessionGroups([groups, setGroups], newId) {
|
|
51
|
+
const create = useCallback((name) => {
|
|
52
|
+
const group = {
|
|
53
|
+
id: newId(),
|
|
54
|
+
name
|
|
55
|
+
};
|
|
56
|
+
setGroups((current) => [...current, group]);
|
|
57
|
+
return group;
|
|
58
|
+
}, [setGroups, newId]);
|
|
59
|
+
const patch = useCallback((id, change) => setGroups((current) => patchGroup(current, id, change)), [setGroups]);
|
|
60
|
+
const remove = useCallback((id) => setGroups((current) => current.filter((g) => g.id !== id)), [setGroups]);
|
|
61
|
+
return useMemo(() => ({
|
|
62
|
+
groups,
|
|
63
|
+
create,
|
|
64
|
+
patch,
|
|
65
|
+
remove
|
|
66
|
+
}), [
|
|
67
|
+
groups,
|
|
68
|
+
create,
|
|
69
|
+
patch,
|
|
70
|
+
remove
|
|
71
|
+
]);
|
|
72
|
+
}
|
|
73
|
+
export { groupOf, inFlightFirst, isWorking, listGroups, patchGroup, useSessionGroups };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** The worktree a session works in, as its actions take it, and a way to read it again. */
|
|
2
|
+
export type PwCodeWorktreeRef = {
|
|
3
|
+
root: string;
|
|
4
|
+
refresh: () => void;
|
|
5
|
+
};
|
|
6
|
+
/** The worktree `useSessionWorktree` read, read again whenever the live
|
|
7
|
+
* session reports it moved; undefined while the session works where it
|
|
8
|
+
* launched. */
|
|
9
|
+
export declare function useFollowedWorktree(worktree: {
|
|
10
|
+
data?: {
|
|
11
|
+
root?: string | undefined;
|
|
12
|
+
} | undefined;
|
|
13
|
+
mutate: () => Promise<unknown>;
|
|
14
|
+
}, liveWorktree: string | undefined): PwCodeWorktreeRef | undefined;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
// src/sessionHeader.ts
|
|
3
|
+
/** The worktree `useSessionWorktree` read, read again whenever the live
|
|
4
|
+
* session reports it moved; undefined while the session works where it
|
|
5
|
+
* launched. */
|
|
6
|
+
function useFollowedWorktree(worktree, liveWorktree) {
|
|
7
|
+
const { data, mutate } = worktree;
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
mutate();
|
|
10
|
+
}, [liveWorktree, mutate]);
|
|
11
|
+
return data?.root ? {
|
|
12
|
+
root: data.root,
|
|
13
|
+
refresh: () => void mutate()
|
|
14
|
+
} : void 0;
|
|
15
|
+
}
|
|
16
|
+
export { useFollowedWorktree };
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import type { PwCodeApiError, Schemas } from './apiClient.js';
|
|
2
|
+
import type { PwCodeApi } from './createPwCodeApi.js';
|
|
3
|
+
import { type PwCodeMachine } from './machine.js';
|
|
4
|
+
import { type PwCodeTranslator } from './messages.js';
|
|
5
|
+
import { type PwCodeSession, sessionVariant } from './session.js';
|
|
6
|
+
import { type NamePromptWords, type OpenSessionRef, type SessionActions, type SessionMenuItem, type SessionRowKey } from './sessionActions.js';
|
|
7
|
+
import { type SessionGroup, type SessionGroups } from './sessionGroups.js';
|
|
8
|
+
import { sessionLabel, sessionStateText } from './wording.js';
|
|
9
|
+
type Session = Schemas['AgentSession'];
|
|
10
|
+
type Translate = PwCodeTranslator<'agents'>;
|
|
11
|
+
type Machines = ReadonlyMap<string, Pick<PwCodeMachine, 'status'>>;
|
|
12
|
+
type Listed = Pick<PwCodeSession, 'machineId' | 'id' | 'status' | 'liveHost' | 'archivedAt' | 'pinnedAt' | 'group' | 'createdAt' | 'updatedAt'>;
|
|
13
|
+
/** Where a session dropped on a section goes: with the pinned ones, into one
|
|
14
|
+
* of the reader's groups or out of any, or into the archive. */
|
|
15
|
+
export type SessionDropTarget = {
|
|
16
|
+
pinned: true;
|
|
17
|
+
} | {
|
|
18
|
+
groupId: string | null;
|
|
19
|
+
} | {
|
|
20
|
+
archived: true;
|
|
21
|
+
};
|
|
22
|
+
export type SessionSectionKind = 'pinned' | 'group' | 'needsYou' | 'active' | 'inactive' | 'archived';
|
|
23
|
+
export interface SessionSection<S> {
|
|
24
|
+
/** The same on every visit, so a host can keep which sections are folded by it. */
|
|
25
|
+
key: string;
|
|
26
|
+
kind: SessionSectionKind;
|
|
27
|
+
label: string;
|
|
28
|
+
sessions: S[];
|
|
29
|
+
target: SessionDropTarget;
|
|
30
|
+
/** How many of its sessions wait on the reader and how many are working,
|
|
31
|
+
* for the pinned ones and the reader's groups, whose headings count them. */
|
|
32
|
+
rollup?: {
|
|
33
|
+
waiting: number;
|
|
34
|
+
running: number;
|
|
35
|
+
};
|
|
36
|
+
group?: SessionGroup;
|
|
37
|
+
/** Set on the sessions that wait on the reader, whose heading draws the eye. */
|
|
38
|
+
tone?: 'attention' | undefined;
|
|
39
|
+
}
|
|
40
|
+
export declare const groupSectionKey: (id: string) => string;
|
|
41
|
+
/** The sections a list of sessions reads in: the pinned ones, each of the
|
|
42
|
+
* reader's groups, then the rest by whether they need the reader, are live,
|
|
43
|
+
* are at rest or are archived. A pinned session is listed with the pinned
|
|
44
|
+
* ones alone; it keeps its group and goes back to it once it is unpinned. */
|
|
45
|
+
export declare function sessionSections<S extends Listed>(sessions: S[], groups: readonly SessionGroup[], machineById: Machines, t: Translate): SessionSection<S>[];
|
|
46
|
+
/** The archive is listed only while it holds a session, so a dragged one
|
|
47
|
+
* would otherwise have nowhere to be dropped until the first is archived. */
|
|
48
|
+
export declare function withArchiveSection<S>(sections: SessionSection<S>[], t: Translate): SessionSection<S>[];
|
|
49
|
+
export declare function isUngroupedTarget(target: SessionDropTarget): boolean;
|
|
50
|
+
/** The sessions a search lists: archived ones stay out until a search reaches for them. */
|
|
51
|
+
export declare function searchedSessions<S extends Pick<PwCodeSession, 'archivedAt'>>(sessions: readonly S[], search: string): S[];
|
|
52
|
+
/** What a search finds a session by: `value` its label, machine, directory,
|
|
53
|
+
* id and pull requests, and `keywords` the name it was given or gave itself. */
|
|
54
|
+
export declare function sessionSearchText(session: Pick<PwCodeSession, 'machineId' | 'id' | 'name' | 'autoName' | 'preview' | 'workspace' | 'pullRequests'>, machine: Pick<PwCodeMachine, 'name'> | undefined, t: Translate): {
|
|
55
|
+
value: string;
|
|
56
|
+
keywords: string[];
|
|
57
|
+
};
|
|
58
|
+
/** Ranks a fuzzy match of `search` in `value` and its `keywords` from 0 to 1,
|
|
59
|
+
* on command-score's scale, as cmdk's `defaultFilter` and the
|
|
60
|
+
* `command-score` package do. */
|
|
61
|
+
export type PwCodeSearchScorer = (value: string, search: string, keywords: string[]) => number;
|
|
62
|
+
/** How well `search` finds a session by its `sessionSearchText`, 0 for not at
|
|
63
|
+
* all: a pasted pull request link finds the sessions with that one, a number
|
|
64
|
+
* only text holding it as typed, and `score` ranks the rest. */
|
|
65
|
+
export declare function sessionSearchScore({ value, keywords }: {
|
|
66
|
+
value: string;
|
|
67
|
+
keywords: string[];
|
|
68
|
+
}, search: string, score: PwCodeSearchScorer): number;
|
|
69
|
+
/** The state a search result shows: that it is archived, or what a live one
|
|
70
|
+
* is doing. One at rest shows none. */
|
|
71
|
+
export declare function sessionSearchStatus(session: Parameters<typeof sessionStateText>[0] & Pick<PwCodeSession, 'archivedAt'>, machine: Pick<PwCodeMachine, 'status'> | undefined, t: Translate): {
|
|
72
|
+
kind: 'archived' | 'active';
|
|
73
|
+
text: string;
|
|
74
|
+
} | undefined;
|
|
75
|
+
/** What a session's mark on a collapsed list is called: its label, its
|
|
76
|
+
* machine and its state. */
|
|
77
|
+
export declare function sessionRailLabel(session: Parameters<typeof sessionLabel>[0] & Parameters<typeof sessionStateText>[0], machine: Pick<PwCodeMachine, 'name' | 'status'> | undefined, t: Translate): string;
|
|
78
|
+
/** A second line costs a row its height, so the state takes one only when the
|
|
79
|
+
* mark cannot express it: not "idle" or "running", but "waiting on you" and a
|
|
80
|
+
* dead machine. */
|
|
81
|
+
export declare function sessionRowState(session: Parameters<typeof sessionStateText>[0], machine: Pick<PwCodeMachine, 'status'> | undefined, t: Translate): {
|
|
82
|
+
stateText: string;
|
|
83
|
+
showSecondLine: boolean;
|
|
84
|
+
live: boolean;
|
|
85
|
+
};
|
|
86
|
+
/** A pinned session is under the pinned ones' heading, which says so; only an
|
|
87
|
+
* archived one, listed with the archive, needs the mark. */
|
|
88
|
+
export declare function showsPinMark(session: Pick<PwCodeSession, 'pinnedAt' | 'archivedAt'>): boolean;
|
|
89
|
+
/** A session at work shows a turning mark, which tells it from one resting
|
|
90
|
+
* between turns by its shape and so holds with reduced motion. Any other
|
|
91
|
+
* shows a dot in its state's tone, pulsing while it waits on the reader. */
|
|
92
|
+
export declare function sessionMark(session: Pick<PwCodeSession, 'status'>, machine: Pick<PwCodeMachine, 'status'> | undefined): {
|
|
93
|
+
working: true;
|
|
94
|
+
} | {
|
|
95
|
+
working: false;
|
|
96
|
+
tone: ReturnType<typeof sessionVariant<'success'>>;
|
|
97
|
+
pulse: boolean;
|
|
98
|
+
};
|
|
99
|
+
/** The server stores nothing, so a dropped machine contributes no sessions to
|
|
100
|
+
* the next poll; without this its sessions vanish instead of explaining themselves. */
|
|
101
|
+
export declare function useRetainedSessions<S extends Pick<PwCodeSession, 'machineId'>>(machines: readonly Pick<PwCodeMachine, 'id' | 'status'>[], sessions: S[]): S[];
|
|
102
|
+
export interface SessionListOptions<R> {
|
|
103
|
+
api: Pick<PwCodeApi, 'useSessions'>;
|
|
104
|
+
machineById: ReadonlyMap<string, PwCodeMachine>;
|
|
105
|
+
groups: SessionGroups;
|
|
106
|
+
/** The keys of the folded sections as the host keeps them, which may hold
|
|
107
|
+
* anything an older copy stored, and how it keeps new ones. A change is an
|
|
108
|
+
* update from the kept keys, so a store that has not loaded them yet can
|
|
109
|
+
* apply it to them rather than to its fallback. */
|
|
110
|
+
folded: readonly [unknown, (update: (previous: unknown) => string[]) => void];
|
|
111
|
+
open: OpenSessionRef;
|
|
112
|
+
actions: Pick<SessionActions<R>, 'menu' | 'shortcuts' | 'togglePin' | 'moveToGroup' | 'groupBlocked' | 'archiveBlocked' | 'requestArchive'>;
|
|
113
|
+
newSession: () => void;
|
|
114
|
+
/** Asks the reader to name a group: one just made, or one to rename. */
|
|
115
|
+
promptGroupName: (group: SessionGroup) => void;
|
|
116
|
+
/** Asks the reader before a group goes; confirming calls `deleteGroup`.
|
|
117
|
+
* `fromKey` when a key pressed on its heading asked, so the next press may answer it. */
|
|
118
|
+
confirmGroupDelete: (group: SessionGroup, fromKey?: boolean) => void;
|
|
119
|
+
/** Says why a dropped session stays where it was. */
|
|
120
|
+
onBlocked: (reason: string) => void;
|
|
121
|
+
}
|
|
122
|
+
export interface SessionGroupKey {
|
|
123
|
+
keys: string | readonly string[];
|
|
124
|
+
run: () => void;
|
|
125
|
+
}
|
|
126
|
+
/** What asking before a group goes says. */
|
|
127
|
+
export interface GroupDeleteWords {
|
|
128
|
+
title: string;
|
|
129
|
+
description: (group: SessionGroup) => string;
|
|
130
|
+
confirmLabel: string;
|
|
131
|
+
}
|
|
132
|
+
export interface SessionList<R> {
|
|
133
|
+
data: Schemas['AgentSessionsResponse'] | undefined;
|
|
134
|
+
error: PwCodeApiError | undefined;
|
|
135
|
+
/** The first listing has not answered yet. */
|
|
136
|
+
loading: boolean;
|
|
137
|
+
/** Why no listing came, the error to show in the list's place. A poll that
|
|
138
|
+
* fails after one did keeps the last listing and says nothing. */
|
|
139
|
+
loadError: PwCodeApiError | undefined;
|
|
140
|
+
/** The listing, with what a machine that stopped answering listed last. */
|
|
141
|
+
sessions: Session[];
|
|
142
|
+
sections: SessionSection<Session>[];
|
|
143
|
+
/** There is something to search for, or soon may be. */
|
|
144
|
+
searchable: boolean;
|
|
145
|
+
/** The sessions span machines, so each one's names its machine. */
|
|
146
|
+
multiMachine: boolean;
|
|
147
|
+
openSession: Session | undefined;
|
|
148
|
+
/** What a collapsed list shows: what is live, and the open session so it
|
|
149
|
+
* keeps a place while it is idle. */
|
|
150
|
+
rail: Session[];
|
|
151
|
+
folded: string[];
|
|
152
|
+
toggleFold: (key: string) => void;
|
|
153
|
+
/** Folded over the open session, which would otherwise have no mark. */
|
|
154
|
+
holdsOpen: (section: Pick<SessionSection<Session>, 'key' | 'sessions'>) => boolean;
|
|
155
|
+
/** An archived session stays with the archive, so its row is not dragged. */
|
|
156
|
+
canDrag: (session: Session) => boolean;
|
|
157
|
+
/** `key` is the dropped session's `sessionKey`. One `canDrag` refuses stays where it was. */
|
|
158
|
+
dropSession: (key: string, target: SessionDropTarget) => void;
|
|
159
|
+
/** Made first and named second: what joins it is in it either way. */
|
|
160
|
+
newGroup: () => SessionGroup;
|
|
161
|
+
/** Saves the name without the spaces around it. A blank one is not saved,
|
|
162
|
+
* and false says so, for a prompt to stay open. */
|
|
163
|
+
renameGroup: (group: SessionGroup, name: string) => boolean;
|
|
164
|
+
/** What the prompt `promptGroupName` asks for says. */
|
|
165
|
+
groupNameWords: NamePromptWords;
|
|
166
|
+
/** What the question `confirmGroupDelete` asks says. */
|
|
167
|
+
groupDeleteWords: GroupDeleteWords;
|
|
168
|
+
/** Its sessions stay in the list, in no group. */
|
|
169
|
+
deleteGroup: (group: SessionGroup) => void;
|
|
170
|
+
/** The session's actions, with a choice of the reader's groups. */
|
|
171
|
+
menu: (session: Session, row?: R) => SessionMenuItem[];
|
|
172
|
+
groupMenu: (group: SessionGroup) => SessionMenuItem[];
|
|
173
|
+
/** The keys a group's heading takes while it has focus, as its menu shows them. */
|
|
174
|
+
groupShortcuts: (group: SessionGroup) => SessionGroupKey[];
|
|
175
|
+
/** For the list's empty space. */
|
|
176
|
+
listMenu: SessionMenuItem[];
|
|
177
|
+
shortcuts: (session: Session) => SessionRowKey<R>[];
|
|
178
|
+
}
|
|
179
|
+
/** The sessions as a list shows them, in sections, with what the reader can
|
|
180
|
+
* do to a row, a group or the list. */
|
|
181
|
+
export declare function useSessionList<R = unknown>({ api, machineById, groups, folded: [storedFolded, setFolded], open, actions, newSession, promptGroupName, confirmGroupDelete, onBlocked, }: SessionListOptions<R>): SessionList<R>;
|
|
182
|
+
export {};
|