@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.
Files changed (126) hide show
  1. package/README.md +602 -84
  2. package/dist/accountApi.d.ts +31 -0
  3. package/dist/accountApi.js +182 -0
  4. package/dist/agentSwitcher.d.ts +109 -0
  5. package/dist/agentSwitcher.js +165 -0
  6. package/dist/ago.d.ts +8 -0
  7. package/dist/ago.js +26 -0
  8. package/dist/allocations.d.ts +41 -0
  9. package/dist/allocations.js +76 -0
  10. package/dist/api.d.ts +1213 -66
  11. package/dist/base64.d.ts +3 -0
  12. package/dist/base64.js +15 -0
  13. package/dist/chatHandoff.d.ts +12 -0
  14. package/dist/chatHandoff.js +27 -0
  15. package/dist/chatStrings.d.ts +188 -0
  16. package/dist/chatStrings.js +217 -0
  17. package/dist/claudeAccounts.d.ts +149 -0
  18. package/dist/claudeAccounts.js +328 -0
  19. package/dist/claudeApi.js +1 -1
  20. package/dist/claudeSignIn.d.ts +80 -0
  21. package/dist/claudeSignIn.js +249 -0
  22. package/dist/commandsApi.d.ts +11 -1
  23. package/dist/commandsApi.js +24 -5
  24. package/dist/contextRow.d.ts +25 -0
  25. package/dist/contextRow.js +16 -0
  26. package/dist/createPwCodeApi.d.ts +52 -5
  27. package/dist/createPwCodeApi.js +20 -2
  28. package/dist/directories.d.ts +161 -0
  29. package/dist/directories.js +301 -0
  30. package/dist/goal.d.ts +89 -0
  31. package/dist/goal.js +164 -0
  32. package/dist/howSessionsAppear.d.ts +12 -0
  33. package/dist/howSessionsAppear.js +24 -0
  34. package/dist/imageFit.d.ts +23 -0
  35. package/dist/imageFit.js +27 -0
  36. package/dist/images.d.ts +28 -0
  37. package/dist/images.js +38 -6
  38. package/dist/index.d.ts +41 -3
  39. package/dist/index.js +40 -4
  40. package/dist/loadError.d.ts +8 -0
  41. package/dist/loadError.js +19 -0
  42. package/dist/locales/en/agentTranscript.js +75 -22
  43. package/dist/locales/en/agents.js +76 -14
  44. package/dist/locales/en.d.ts +129 -21
  45. package/dist/locales/es/agentTranscript.js +75 -22
  46. package/dist/locales/es/agents.js +76 -14
  47. package/dist/locales/ja/agentTranscript.js +78 -25
  48. package/dist/locales/ja/agents.js +49 -124
  49. package/dist/locales/ko/agentTranscript.js +75 -22
  50. package/dist/locales/ko/agents.js +76 -14
  51. package/dist/locales/zh/agentTranscript.js +73 -20
  52. package/dist/locales/zh/agents.js +76 -14
  53. package/dist/machine.d.ts +4 -0
  54. package/dist/modelPicker.d.ts +79 -0
  55. package/dist/modelPicker.js +107 -0
  56. package/dist/models.d.ts +47 -0
  57. package/dist/models.js +49 -0
  58. package/dist/notices.d.ts +2 -1
  59. package/dist/notices.js +75 -21
  60. package/dist/platformDefaults.d.ts +22 -0
  61. package/dist/platformDefaults.js +30 -0
  62. package/dist/preferences.d.ts +78 -0
  63. package/dist/preferences.js +128 -0
  64. package/dist/pullRequestList.d.ts +60 -0
  65. package/dist/pullRequestList.js +125 -0
  66. package/dist/query.d.ts +6 -2
  67. package/dist/query.js +85 -10
  68. package/dist/session.d.ts +10 -2
  69. package/dist/session.js +12 -8
  70. package/dist/sessionActions.d.ts +115 -0
  71. package/dist/sessionActions.js +186 -0
  72. package/dist/sessionEvents.d.ts +8 -3
  73. package/dist/sessionEvents.js +10 -5
  74. package/dist/sessionGroups.d.ts +50 -0
  75. package/dist/sessionGroups.js +73 -0
  76. package/dist/sessionHeader.d.ts +14 -0
  77. package/dist/sessionHeader.js +16 -0
  78. package/dist/sessionList.d.ts +182 -0
  79. package/dist/sessionList.js +333 -0
  80. package/dist/sessionScreen.d.ts +193 -0
  81. package/dist/sessionScreen.js +213 -0
  82. package/dist/sessionsApi.d.ts +13 -3
  83. package/dist/sessionsApi.js +90 -33
  84. package/dist/settingsApi.d.ts +38 -0
  85. package/dist/settingsApi.js +151 -0
  86. package/dist/startPage.d.ts +153 -0
  87. package/dist/startPage.js +174 -0
  88. package/dist/startSession.d.ts +172 -0
  89. package/dist/startSession.js +256 -0
  90. package/dist/terminalHandoffPanel.d.ts +30 -0
  91. package/dist/terminalHandoffPanel.js +33 -0
  92. package/dist/transcript.d.ts +2 -0
  93. package/dist/transcript.js +62 -26
  94. package/dist/types.d.ts +11 -1
  95. package/dist/usageLimit.d.ts +8 -0
  96. package/dist/usageLimit.js +13 -0
  97. package/dist/useAwayRecap.d.ts +30 -0
  98. package/dist/useAwayRecap.js +75 -0
  99. package/dist/useComposer.d.ts +145 -0
  100. package/dist/useComposer.js +295 -0
  101. package/dist/useComposerImages.d.ts +71 -0
  102. package/dist/useComposerImages.js +218 -0
  103. package/dist/useComposerPastes.d.ts +70 -0
  104. package/dist/useComposerPastes.js +130 -0
  105. package/dist/useConversation.d.ts +199 -0
  106. package/dist/useConversation.js +314 -0
  107. package/dist/useSubagent.d.ts +104 -0
  108. package/dist/useSubagent.js +212 -0
  109. package/dist/useTranscript.d.ts +23 -3
  110. package/dist/useTranscript.js +76 -19
  111. package/dist/wording.js +2 -2
  112. package/dist/workingDirectories.d.ts +63 -0
  113. package/dist/workingDirectories.js +95 -0
  114. package/dist/worktreeChoice.d.ts +31 -0
  115. package/dist/worktreeChoice.js +38 -0
  116. package/locales/en/agentTranscript.json +69 -21
  117. package/locales/en/agents.json +73 -13
  118. package/locales/es/agentTranscript.json +69 -21
  119. package/locales/es/agents.json +73 -13
  120. package/locales/ja/agentTranscript.json +72 -24
  121. package/locales/ja/agents.json +73 -13
  122. package/locales/ko/agentTranscript.json +69 -21
  123. package/locales/ko/agents.json +73 -13
  124. package/locales/zh/agentTranscript.json +67 -19
  125. package/locales/zh/agents.json +73 -13
  126. package/package.json +6 -3
@@ -34,7 +34,7 @@ function forgetPlaced(unechoed, detail) {
34
34
  }
35
35
  /** Holds the live transcript for one session. The host still owns the socket
36
36
  * and the fetch: it feeds events to `onEvent` and posts through `send`. */
37
- function usePwCodeTranscript({ sessionId, subagent, detail, send, steer, withdraw, onEffect, goalNotice, compactionNotice, recapNotice, words, imageUrl }) {
37
+ function usePwCodeTranscript({ sessionId, subagent, detail, send, steer, withdraw, withdrawDirection, onEffect, goalNotice, compactionNotice, recapNotice, words, imageUrl }) {
38
38
  const [transcript, setTranscript] = useState(null);
39
39
  const transcriptRef = useRef(null);
40
40
  const [sending, setSending] = useState(false);
@@ -46,10 +46,12 @@ function usePwCodeTranscript({ sessionId, subagent, detail, send, steer, withdra
46
46
  const sendRef = useRef(send);
47
47
  const steerRef = useRef(steer);
48
48
  const withdrawRef = useRef(withdraw);
49
+ const withdrawDirectionRef = useRef(withdrawDirection);
49
50
  const onEffectRef = useRef(onEffect);
50
51
  sendRef.current = send;
51
52
  steerRef.current = steer;
52
53
  withdrawRef.current = withdraw;
54
+ withdrawDirectionRef.current = withdrawDirection;
53
55
  onEffectRef.current = onEffect;
54
56
  const goalNoticeRef = useRef(goalNotice);
55
57
  goalNoticeRef.current = goalNotice;
@@ -153,26 +155,32 @@ function usePwCodeTranscript({ sessionId, subagent, detail, send, steer, withdra
153
155
  ]);
154
156
  /** True once the running turn took the text, or the refusal if it may have.
155
157
  * Commands and shell escapes change the next turn, so like the TUI they wait. */
156
- const trySteer = useCallback(async (text, { pastes, images, previews }) => {
158
+ const trySteer = useCallback(async (text, { typed, pastes, images, previews }) => {
157
159
  const steerTo = steerRef.current;
158
160
  if (!steerTo || !turnRunning(transcriptRef.current) || /^[/!]/.test(text.trimStart())) return false;
159
161
  ownSeq.current += 1;
160
162
  const localId = `own-${ownSeq.current}`;
161
163
  unechoed.current.set(localId, {
162
164
  text,
165
+ typed,
163
166
  pastes,
167
+ images,
164
168
  previews,
165
169
  steered: true
166
170
  });
167
171
  apply((state) => appendSteeredMessage(state, text, localId, pastes, previews));
168
172
  const result = await steerTo(text, pastes, images);
169
- if ("delivered" in result && result.delivered) return true;
173
+ if ("delivered" in result && result.delivered) {
174
+ const sent = unechoed.current.get(localId);
175
+ if (sent && result.id) sent.noteId = result.id;
176
+ return true;
177
+ }
170
178
  unechoed.current.delete(localId);
171
179
  apply((state) => dropMessage(state, localId));
172
180
  return "lost" in result ? result.lost : false;
173
181
  }, [apply]);
174
182
  const sendMessage = useCallback(async (text, options = {}) => {
175
- const { pastes, images, previews } = options;
183
+ const { typed, pastes, images, previews } = options;
176
184
  setSending(true);
177
185
  const steered = options.steer !== false && await trySteer(text, options);
178
186
  if (steered) {
@@ -184,7 +192,9 @@ function usePwCodeTranscript({ sessionId, subagent, detail, send, steer, withdra
184
192
  const localId = `own-${ownSeq.current}`;
185
193
  unechoed.current.set(localId, {
186
194
  text,
195
+ typed,
187
196
  pastes,
197
+ images,
188
198
  previews
189
199
  });
190
200
  const append = subagent ? appendTurnMessage : appendOwnMessage;
@@ -213,11 +223,38 @@ function usePwCodeTranscript({ sessionId, subagent, detail, send, steer, withdra
213
223
  ]);
214
224
  const resolveApproval = useCallback((approvalId) => apply((state) => resolveApprovalEverywhere(state, approvalId)), [apply]);
215
225
  const noteShellRun = useCallback((command, output) => apply((state) => appendShellRun(state, command, output)), [apply]);
216
- const queuedTurn = (id) => {
226
+ /** Takes back a message queued as a turn of its own, or one steered into
227
+ * the turn that the model has not been handed yet. */
228
+ const withdrawal = (id) => {
217
229
  const sent = unechoed.current.get(id);
218
- const queued = transcriptRef.current?.queued.some((m) => m.id === id);
219
- return sent && !sent.steered && queued ? sent.turnId : void 0;
230
+ const state = transcriptRef.current;
231
+ if (!sent || !state) return;
232
+ const { noteId, turnId } = sent;
233
+ if (sent.steered) {
234
+ const withdrawNote = withdrawDirectionRef.current;
235
+ return noteId && withdrawNote && state.steered.some((m) => m.id === id) ? () => withdrawNote(noteId) : void 0;
236
+ }
237
+ const withdrawTurn = withdrawRef.current;
238
+ return turnId && withdrawTurn && state.queued.some((m) => m.id === id) ? () => withdrawTurn(turnId) : void 0;
220
239
  };
240
+ const canRemoveQueued = useCallback((id) => !!withdrawal(id), []);
241
+ /** The message as it was sent once the machine gave it back, or the refusal. */
242
+ const withdrawMessage = useCallback(async (id) => {
243
+ const withdrawIt = withdrawal(id);
244
+ const sent = unechoed.current.get(id);
245
+ if (!withdrawIt || !sent) return null;
246
+ const result = await withdrawIt();
247
+ if (result.error) return { refusal: result.error };
248
+ unechoed.current.delete(id);
249
+ if (sent.turnId) ownTurnIds.current.delete(sent.turnId);
250
+ apply((state) => dropMessage(state, id));
251
+ return { sent };
252
+ }, [apply]);
253
+ const removeQueued = useCallback(async (id) => {
254
+ const outcome = await withdrawMessage(id);
255
+ return outcome && "refusal" in outcome ? outcome.refusal : null;
256
+ }, [withdrawMessage]);
257
+ const takingBack = useRef(false);
221
258
  return {
222
259
  transcript,
223
260
  sending,
@@ -225,18 +262,38 @@ function usePwCodeTranscript({ sessionId, subagent, detail, send, steer, withdra
225
262
  sendMessage,
226
263
  resolveApproval,
227
264
  noteShellRun,
228
- canRemoveQueued: useCallback((id) => !!withdrawRef.current && !!queuedTurn(id), []),
229
- removeQueued: useCallback(async (id) => {
230
- const turnId = queuedTurn(id);
231
- const withdrawFrom = withdrawRef.current;
232
- if (!turnId || !withdrawFrom) return null;
233
- const result = await withdrawFrom(turnId);
234
- if (result.error) return result.error;
235
- unechoed.current.delete(id);
236
- ownTurnIds.current.delete(turnId);
237
- apply((state) => dropMessage(state, id));
238
- return null;
239
- }, [apply]),
265
+ canRemoveQueued,
266
+ removeQueued,
267
+ takeBackPending: useCallback(async () => {
268
+ if (takingBack.current) return {
269
+ taken: [],
270
+ refusal: null
271
+ };
272
+ takingBack.current = true;
273
+ try {
274
+ const state = transcriptRef.current;
275
+ const ids = state ? [...state.steered, ...state.queued].map((m) => m.id) : [];
276
+ const outcomes = [];
277
+ for (const id of ids.toReversed()) outcomes.unshift(await withdrawMessage(id));
278
+ const taken = [];
279
+ let refusal = null;
280
+ for (const outcome of outcomes) if (outcome && "sent" in outcome) {
281
+ const { text, typed, pastes, images, previews } = outcome.sent;
282
+ taken.push({
283
+ text: typed ?? text,
284
+ pastes,
285
+ images,
286
+ previews
287
+ });
288
+ } else if (outcome) refusal ??= outcome.refusal;
289
+ return {
290
+ taken,
291
+ refusal
292
+ };
293
+ } finally {
294
+ takingBack.current = false;
295
+ }
296
+ }, [withdrawMessage]),
240
297
  cursor: useCallback(() => transcriptRef.current?.cursor ?? 0, [])
241
298
  };
242
299
  }
package/dist/wording.js CHANGED
@@ -82,8 +82,8 @@ function composerState(args) {
82
82
  if (status === "awaiting_approval") {
83
83
  const answer = waitsOnAnswer(approvals);
84
84
  return {
85
- placeholder: t(answer ? "detail.composerAwaitingAnswer" : "detail.composerAwaiting"),
86
- hint: t(answer ? "detail.footerAwaitingAnswer" : "detail.footerAwaiting"),
85
+ placeholder: answer ? t("detail.composerAwaitingAnswer") : t("detail.composerAwaiting"),
86
+ hint: answer ? t("detail.footerAwaitingAnswer") : t("detail.footerAwaiting"),
87
87
  locked: true
88
88
  };
89
89
  }
@@ -0,0 +1,63 @@
1
+ import type { PwCodeApi } from './createPwCodeApi.js';
2
+ import type { PwCodeTranslator } from './messages.js';
3
+ import type { PwCodeAddedDirectory, PwCodeAllowedDirectory } from './types.js';
4
+ type Translate = PwCodeTranslator<'agents'>;
5
+ /** Where a path's last segment starts, at its last separator. */
6
+ export declare const lastSegmentAt: (path: string) => number;
7
+ /** The path's segments, each with the separator that ends it. */
8
+ export declare function pathSegments(path: string): string[];
9
+ /** The monospace `head`, `full` pixels wide, cut to the whole characters and ellipsis that fit in `room`; null when it fits whole. */
10
+ export declare function cutToFit(head: string, full: number, room: number): string | null;
11
+ /** The letter spacing that stretches `cut`, from the monospace `head` `full` pixels wide, across `room`, so the sliver a whole-character cut leaves is spread between its characters rather than left blank beside them; none for a single character. */
12
+ export declare function cutSpacing(head: string, full: number, room: number, cut: string): number;
13
+ /** A path cut as far as it goes: the prefix, an ellipsis for what leads to the last segment, and that segment. */
14
+ export declare function shortestPath(path: string, prefix?: string): string;
15
+ declare const scopes: readonly ['local', 'project', 'user'];
16
+ /** Where pw code saves a directory it adds for every session. */
17
+ export type PwCodeDirectoryScope = (typeof scopes)[number];
18
+ /** A directory saved in settings outlives the session, which cannot remove it. */
19
+ export declare const isSavedDirectory: (dir: PwCodeAddedDirectory) => boolean;
20
+ /** The settings a directory is saved in, of those this package knows. */
21
+ export declare function directoryScopes(dir: PwCodeAddedDirectory): PwCodeDirectoryScope[];
22
+ /** What an approval let the session do in a directory, and whether that
23
+ * reaches below it. */
24
+ export declare function allowedAccess({ edit, subtree, }: PwCodeAllowedDirectory): 'edit' | 'read' | 'editFolder' | 'readFolder';
25
+ /** A session's working directory as it is written, on its machine. */
26
+ export interface PwCodeWorkingDirectoryText {
27
+ /** Stays whole before the path, which may be cut from the middle. */
28
+ prefix: string;
29
+ text: string;
30
+ /** What a control that opens the session's directories is called. */
31
+ label: string;
32
+ }
33
+ export declare function workingDirectoryText(machineName: string, workspace: string, t: Translate): PwCodeWorkingDirectoryText;
34
+ export interface PwCodeAddedDirectoryRow {
35
+ path: string;
36
+ /** Where it is kept, a line each: the session alone, or each settings file it is saved in. */
37
+ scopes: string[];
38
+ /** Only one added for the session alone: one saved in settings outlives it. */
39
+ removable: boolean;
40
+ removeLabel: string;
41
+ }
42
+ export interface PwCodeAllowedDirectoryRow {
43
+ path: string;
44
+ access: string;
45
+ }
46
+ /** A session's added and allowed directories as they are listed. */
47
+ export interface PwCodeSessionDirectories {
48
+ added: PwCodeAddedDirectoryRow[];
49
+ /** How the ones saved in settings are removed instead, while one is listed. */
50
+ savedNote: string | undefined;
51
+ allowed: PwCodeAllowedDirectoryRow[];
52
+ }
53
+ export declare function sessionDirectories(added: readonly PwCodeAddedDirectory[], allowed: readonly PwCodeAllowedDirectory[], t: Translate): PwCodeSessionDirectories;
54
+ /** Removing the directories added for a session only, one request per path at
55
+ * a time. A refusal puts the path back, so it can be tried again. */
56
+ export declare function useRemoveSessionDirectory(api: Pick<PwCodeApi, 'removeSessionDirectory'>, machine: string, sessionId: string): {
57
+ /** The paths whose removal is under way. */
58
+ pending: ReadonlySet<string>;
59
+ /** Why the last removal failed: the machine's refusal, or what was thrown. */
60
+ error: unknown;
61
+ remove: (path: string) => Promise<void>;
62
+ };
63
+ export {};
@@ -0,0 +1,95 @@
1
+ import { useState } from "react";
2
+ // src/workingDirectories.ts
3
+ /** Where a path's last segment starts, at its last separator. */
4
+ var lastSegmentAt = (path) => Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\"), 0);
5
+ /** The path's segments, each with the separator that ends it. */
6
+ function pathSegments(path) {
7
+ return path.match(/[^/\\]*[/\\]|[^/\\]+$/g) ?? [];
8
+ }
9
+ /** The monospace `head`, `full` pixels wide, cut to the whole characters and ellipsis that fit in `room`; null when it fits whole. */
10
+ function cutToFit(head, full, room) {
11
+ const chars = [...head];
12
+ if (full <= room + .5 || chars.length === 0) return null;
13
+ const fit = Math.floor(room / (full / chars.length) + .01);
14
+ return fit > 0 ? `${chars.slice(0, fit - 1).join("")}…` : "";
15
+ }
16
+ /** The letter spacing that stretches `cut`, from the monospace `head` `full` pixels wide, across `room`, so the sliver a whole-character cut leaves is spread between its characters rather than left blank beside them; none for a single character. */
17
+ function cutSpacing(head, full, room, cut) {
18
+ const chars = [...head].length;
19
+ const shown = [...cut].length;
20
+ if (shown < 2 || chars === 0) return 0;
21
+ return Math.max(room - shown * (full / chars), 0) / (shown - 1);
22
+ }
23
+ /** A path cut as far as it goes: the prefix, an ellipsis for what leads to the last segment, and that segment. */
24
+ function shortestPath(path, prefix = "") {
25
+ const cut = lastSegmentAt(path);
26
+ return `${prefix}${cut > 0 ? "…" : ""}${path.slice(cut)}`;
27
+ }
28
+ var scopes = [
29
+ "local",
30
+ "project",
31
+ "user"
32
+ ];
33
+ var isScope = (scope) => scopes.includes(scope);
34
+ /** A directory saved in settings outlives the session, which cannot remove it. */
35
+ var isSavedDirectory = (dir) => (dir.scopes ?? []).length > 0;
36
+ /** The settings a directory is saved in, of those this package knows. */
37
+ function directoryScopes(dir) {
38
+ return (dir.scopes ?? []).filter(isScope);
39
+ }
40
+ /** What an approval let the session do in a directory, and whether that
41
+ * reaches below it. */
42
+ function allowedAccess({ edit, subtree }) {
43
+ if (!subtree) return edit ? "editFolder" : "readFolder";
44
+ return edit ? "edit" : "read";
45
+ }
46
+ function workingDirectoryText(machineName, workspace, t) {
47
+ const prefix = `${machineName}:`;
48
+ const text = `${prefix}${workspace}`;
49
+ return {
50
+ prefix,
51
+ text,
52
+ label: t("detail.workingDirectory", { path: text })
53
+ };
54
+ }
55
+ function sessionDirectories(added, allowed, t) {
56
+ return {
57
+ added: added.map((dir) => ({
58
+ path: dir.path,
59
+ scopes: isSavedDirectory(dir) ? directoryScopes(dir).map((scope) => t(`detail.directoryScope.${scope}`)) : [t("detail.directoryScope.session")],
60
+ removable: !isSavedDirectory(dir),
61
+ removeLabel: t("detail.removeDirectory", { path: dir.path })
62
+ })),
63
+ savedNote: added.some(isSavedDirectory) ? t("detail.savedDirectoriesNote") : void 0,
64
+ allowed: allowed.map((dir) => ({
65
+ path: dir.path,
66
+ access: t(`detail.allowedAccess.${allowedAccess(dir)}`)
67
+ }))
68
+ };
69
+ }
70
+ /** Removing the directories added for a session only, one request per path at
71
+ * a time. A refusal puts the path back, so it can be tried again. */
72
+ function useRemoveSessionDirectory(api, machine, sessionId) {
73
+ const [pending, setPending] = useState(/* @__PURE__ */ new Set());
74
+ const [error, setError] = useState(null);
75
+ const remove = async (path) => {
76
+ if (pending.has(path)) return;
77
+ setPending((current) => new Set(current).add(path));
78
+ setError(null);
79
+ const refusal = await api.removeSessionDirectory(machine, sessionId, path).catch((thrown) => thrown);
80
+ if (refusal) {
81
+ setError(refusal);
82
+ setPending((current) => {
83
+ const next = new Set(current);
84
+ next.delete(path);
85
+ return next;
86
+ });
87
+ }
88
+ };
89
+ return {
90
+ pending,
91
+ error,
92
+ remove
93
+ };
94
+ }
95
+ export { allowedAccess, cutSpacing, cutToFit, directoryScopes, isSavedDirectory, lastSegmentAt, pathSegments, sessionDirectories, shortestPath, useRemoveSessionDirectory, workingDirectoryText };
@@ -0,0 +1,31 @@
1
+ import type { Schemas } from './apiClient.js';
2
+ import type { PwCodeApi } from './createPwCodeApi.js';
3
+ type Worktree = Schemas['AgentSessionWorktree'];
4
+ /** Some of what removing a worktree would delete: the lines its machine
5
+ * sent, and how many more there are. */
6
+ export interface PwCodeWorktreeLines {
7
+ total: number;
8
+ lines: string[];
9
+ more: number;
10
+ }
11
+ /** What removing a worktree would delete, as git lists it. */
12
+ export interface PwCodeWorktreeWork {
13
+ /** git could not say what the worktree holds. */
14
+ unchecked: boolean;
15
+ /** Files changed or not tracked; null for none. */
16
+ files: PwCodeWorktreeLines | null;
17
+ /** Commits no other branch holds; null for none. */
18
+ commits: PwCodeWorktreeLines | null;
19
+ }
20
+ /** Null when removing the worktree would delete nothing git knows of. */
21
+ export declare function worktreeWork(worktree: Worktree): PwCodeWorktreeWork | null;
22
+ /** The worktree a session works in, for deleting the session, with the
23
+ * choice to remove it too. It is kept unless removing it is chosen;
24
+ * `onChange` hears the worktree's root then, and undefined once it is kept. */
25
+ export declare function useWorktreeChoice(api: Pick<PwCodeApi, 'useSessionWorktree'>, session: Schemas['AgentSession'] | undefined, onChange: (removeRoot: string | undefined) => void): {
26
+ /** The worktree, while the session works in one. */
27
+ worktree: Worktree | undefined;
28
+ remove: boolean;
29
+ choose: (remove: boolean) => void;
30
+ };
31
+ export {};
@@ -0,0 +1,38 @@
1
+ import { useState } from "react";
2
+ // src/worktreeChoice.ts
3
+ function workLines(lines, total) {
4
+ if (total === 0) return null;
5
+ const shown = lines ?? [];
6
+ return {
7
+ total,
8
+ lines: shown,
9
+ more: Math.max(total - shown.length, 0)
10
+ };
11
+ }
12
+ /** Null when removing the worktree would delete nothing git knows of. */
13
+ function worktreeWork(worktree) {
14
+ const { fileCount = 0, commitCount = 0, unchecked } = worktree;
15
+ if (!unchecked && fileCount === 0 && commitCount === 0) return null;
16
+ return {
17
+ unchecked: !!unchecked,
18
+ files: workLines(worktree.files, fileCount),
19
+ commits: workLines(worktree.commits, commitCount)
20
+ };
21
+ }
22
+ /** The worktree a session works in, for deleting the session, with the
23
+ * choice to remove it too. It is kept unless removing it is chosen;
24
+ * `onChange` hears the worktree's root then, and undefined once it is kept. */
25
+ function useWorktreeChoice(api, session, onChange) {
26
+ const { data } = api.useSessionWorktree(session);
27
+ const [remove, setRemove] = useState(false);
28
+ const root = data?.root;
29
+ return {
30
+ worktree: root ? data : void 0,
31
+ remove,
32
+ choose: (next) => {
33
+ setRemove(next);
34
+ onChange(next ? root : void 0);
35
+ }
36
+ };
37
+ }
38
+ export { useWorktreeChoice, worktreeWork };
@@ -24,19 +24,21 @@
24
24
  "denyPath": "No, deny",
25
25
  "allowCall": "Yes, allow this call",
26
26
  "denyCall": "No, deny this call",
27
- "denyWithFeedback": "No, and provide feedback to the agent",
28
- "feedbackPlaceholder": "Tell the agent what to do instead…",
27
+ "denyWithFeedback": "No, and tell the assistant why",
28
+ "feedbackPlaceholder": "Tell the assistant what to do instead…",
29
29
  "answered": "Answered",
30
- "allowedBy": "Allowed by {name}",
31
- "deniedBy": "Denied by {name}",
30
+ "allowedBy": "{name} approved",
31
+ "allowedWithChangesBy": "{name} approved with changes",
32
+ "deniedBy": "{name} denied",
32
33
  "allowed": "Allowed",
34
+ "allowedWithChanges": "Allowed with changes",
33
35
  "denied": "Denied",
34
- "allowedByReviewer": "Allowed by the auto-reviewer",
35
- "deniedByReviewer": "Denied by the auto-reviewer",
36
+ "allowedByReviewer": "Auto-reviewer approved",
37
+ "deniedByReviewer": "Auto-reviewer denied",
36
38
  "approvalExpired": "Expired without an answer",
37
39
  "approvalTimedOut": "Denied: no answer in time",
38
- "reviewTimedOut": "Denied: the auto-reviewer timed out",
39
- "reviewFailed": "Denied: the auto-reviewer failed",
40
+ "reviewTimedOut": "Auto-review timed out",
41
+ "reviewFailed": "Auto-review failed",
40
42
  "writeOwnAnswer": "Write my own answer…",
41
43
  "subagent": "Task",
42
44
  "tasks": "Tasks",
@@ -48,7 +50,7 @@
48
50
  "approvalDenied": "Declined",
49
51
  "approvalRequestExpired": "This request expired. Ask again to run it.",
50
52
  "approvalWaitingOn": "Waiting for {name} to answer",
51
- "feedbackLabel": "Feedback for the agent",
53
+ "feedbackLabel": "Feedback for the assistant",
52
54
  "ownAnswerLabel": "Your answer",
53
55
  "typeYourAnswer": "Type your answer…",
54
56
  "questionsLabel": "Questions",
@@ -122,7 +124,10 @@
122
124
  "remove": "Remove queued message",
123
125
  "waiting": "Queued · sends when this reply finishes",
124
126
  "waitingNextStep": "Queued · reaches the agent after its current step",
125
- "handedOver": "Sent to the running turn"
127
+ "handedOver": "Sent to the running turn",
128
+ "edit": "Edit",
129
+ "editLabel": "Edit queued messages",
130
+ "editHint": "Press ↑ to edit queued messages"
126
131
  },
127
132
  "paste": {
128
133
  "title": "Pasted text",
@@ -131,7 +136,58 @@
131
136
  "remove": "Remove paste"
132
137
  },
133
138
  "thinking": {
134
- "thoughtProcess": "Thought process"
139
+ "label": "Thinking",
140
+ "ellipsis": "Thinking…",
141
+ "thoughtFor": "Thought for {duration}",
142
+ "thoughtProcess": "Thought process",
143
+ "activity": "Activity",
144
+ "ranToolCalls": "{count, plural, one {Ran # tool call} other {Ran # tool calls}}",
145
+ "ranToolCallsAs": "{count, plural, one {Ran # tool call as {name}} other {Ran # tool calls as {name}}}"
146
+ },
147
+ "activity": {
148
+ "tokens": "↑{input} ↓{output} tokens",
149
+ "stop": "Stop"
150
+ },
151
+ "input": {
152
+ "stopGenerating": "Stop generating (Escape)",
153
+ "loadingCommands": "Loading commands…"
154
+ },
155
+ "thread": {
156
+ "jumpToPrompt": "Go to message: {text}"
157
+ },
158
+ "find": {
159
+ "label": "Find in conversation",
160
+ "count": "{current, number} of {total, number}",
161
+ "countCapped": "{current, number} of {total, number}+",
162
+ "none": "No results",
163
+ "previous": "Previous match",
164
+ "next": "Next match",
165
+ "close": "Close find"
166
+ },
167
+ "chrome": {
168
+ "jumpToLatest": "Jump to latest"
169
+ },
170
+ "messageMeta": {
171
+ "copyLabel": "message"
172
+ },
173
+ "attachmentManager": {
174
+ "unnamedImage": "Image attachment",
175
+ "unnamedFile": "File",
176
+ "open": "Open {name}",
177
+ "download": "Download {name}",
178
+ "previousImage": "Previous image",
179
+ "nextImage": "Next image",
180
+ "imagePosition": "{position, number} of {total, number}",
181
+ "fullImageFailed": "Couldn't load the full image. Showing a preview."
182
+ },
183
+ "markdownImage": {
184
+ "untitled": "Image",
185
+ "open": "Open {name} on GitHub"
186
+ },
187
+ "sidebar": {
188
+ "openSidebar": "Open sidebar",
189
+ "closeSidebar": "Close sidebar",
190
+ "manageProviders": "Manage providers"
135
191
  },
136
192
  "modelPicker": {
137
193
  "choose": "Model",
@@ -140,11 +196,7 @@
140
196
  "loading": "Loading models…",
141
197
  "failed": "Failed to load models",
142
198
  "none": "No models available",
143
- "sharedBy": "Shared by {owner}",
144
- "connecting": "Connecting…",
145
- "notResponding": "Not responding",
146
- "manageProvider": "Manage provider",
147
- "selectFirst": "Select a model first"
199
+ "sharedBy": "Shared by {owner}"
148
200
  },
149
201
  "allocationPicker": {
150
202
  "choose": "Allocation",
@@ -153,10 +205,6 @@
153
205
  },
154
206
  "providerIssue": {
155
207
  "keyRejected": "API key rejected",
156
- "unreachable": "Endpoint unreachable",
157
- "keyRejectedHint": "The provider rejected this connection's API key. Update the key in the provider settings to resume.",
158
- "unreachableHint": "The provider's endpoint did not respond. Check the endpoint URL and network access.",
159
- "bannerKeyRejected": "API key rejected for “{provider}”",
160
- "bannerUnreachable": "“{provider}” is unreachable"
208
+ "unreachable": "Endpoint unreachable"
161
209
  }
162
210
  }