@parallelworks/code 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.
Files changed (118) hide show
  1. package/README.md +625 -113
  2. package/dist/accountApi.d.ts +31 -0
  3. package/dist/accountApi.js +182 -0
  4. package/dist/agentSwitcher.d.ts +120 -0
  5. package/dist/agentSwitcher.js +187 -0
  6. package/dist/ago.d.ts +1 -3
  7. package/dist/ago.js +8 -10
  8. package/dist/allocations.d.ts +41 -0
  9. package/dist/allocations.js +76 -0
  10. package/dist/api.d.ts +1319 -50
  11. package/dist/chatStrings.d.ts +189 -0
  12. package/dist/chatStrings.js +218 -0
  13. package/dist/claudeAccounts.d.ts +57 -2
  14. package/dist/claudeAccounts.js +144 -6
  15. package/dist/claudeApi.d.ts +2 -1
  16. package/dist/claudeApi.js +50 -4
  17. package/dist/claudeSignIn.d.ts +19 -1
  18. package/dist/claudeSignIn.js +12 -2
  19. package/dist/command.d.ts +5 -1
  20. package/dist/command.js +6 -1
  21. package/dist/commandsApi.d.ts +11 -1
  22. package/dist/commandsApi.js +24 -5
  23. package/dist/createPwCodeApi.d.ts +114 -6
  24. package/dist/createPwCodeApi.js +21 -3
  25. package/dist/directories.d.ts +161 -0
  26. package/dist/directories.js +301 -0
  27. package/dist/goal.d.ts +89 -0
  28. package/dist/goal.js +164 -0
  29. package/dist/imageFit.d.ts +23 -0
  30. package/dist/imageFit.js +27 -0
  31. package/dist/images.d.ts +28 -0
  32. package/dist/images.js +38 -6
  33. package/dist/index.d.ts +31 -15
  34. package/dist/index.js +29 -14
  35. package/dist/loadError.d.ts +8 -0
  36. package/dist/loadError.js +19 -0
  37. package/dist/locales/en/agentTranscript.js +74 -12
  38. package/dist/locales/en/agents.js +86 -11
  39. package/dist/locales/en.d.ts +137 -8
  40. package/dist/locales/es/agentTranscript.js +74 -12
  41. package/dist/locales/es/agents.js +86 -11
  42. package/dist/locales/ja/agentTranscript.js +77 -15
  43. package/dist/locales/ja/agents.js +60 -122
  44. package/dist/locales/ko/agentTranscript.js +74 -12
  45. package/dist/locales/ko/agents.js +86 -11
  46. package/dist/locales/zh/agentTranscript.js +72 -10
  47. package/dist/locales/zh/agents.js +86 -11
  48. package/dist/machine.d.ts +2 -0
  49. package/dist/modelPicker.d.ts +79 -0
  50. package/dist/modelPicker.js +107 -0
  51. package/dist/notices.d.ts +2 -0
  52. package/dist/notices.js +67 -32
  53. package/dist/platformDefaults.d.ts +22 -0
  54. package/dist/platformDefaults.js +30 -0
  55. package/dist/preferences.d.ts +78 -0
  56. package/dist/preferences.js +128 -0
  57. package/dist/pullRequestList.d.ts +10 -2
  58. package/dist/pullRequestList.js +41 -22
  59. package/dist/query.d.ts +9 -2
  60. package/dist/query.js +91 -10
  61. package/dist/session.d.ts +11 -2
  62. package/dist/session.js +16 -8
  63. package/dist/sessionActions.d.ts +11 -1
  64. package/dist/sessionActions.js +14 -6
  65. package/dist/sessionEvents.d.ts +37 -5
  66. package/dist/sessionEvents.js +196 -77
  67. package/dist/sessionGroups.d.ts +5 -4
  68. package/dist/sessionGroups.js +6 -5
  69. package/dist/sessionHeader.js +6 -2
  70. package/dist/sessionList.d.ts +68 -15
  71. package/dist/sessionList.js +91 -19
  72. package/dist/sessionScreen.d.ts +197 -0
  73. package/dist/sessionScreen.js +218 -0
  74. package/dist/sessionsApi.d.ts +29 -3
  75. package/dist/sessionsApi.js +180 -33
  76. package/dist/sessionsFeed.d.ts +22 -0
  77. package/dist/sessionsFeed.js +125 -0
  78. package/dist/settingsApi.d.ts +3 -1
  79. package/dist/startPage.d.ts +153 -0
  80. package/dist/startPage.js +174 -0
  81. package/dist/startSession.d.ts +41 -7
  82. package/dist/startSession.js +26 -4
  83. package/dist/todos.d.ts +42 -0
  84. package/dist/todos.js +104 -0
  85. package/dist/transcript.d.ts +1 -2
  86. package/dist/transcript.js +111 -117
  87. package/dist/transcriptRead.d.ts +56 -0
  88. package/dist/transcriptRead.js +121 -0
  89. package/dist/types.d.ts +11 -1
  90. package/dist/useComposer.d.ts +39 -6
  91. package/dist/useComposer.js +73 -9
  92. package/dist/useComposerImages.d.ts +5 -0
  93. package/dist/useComposerImages.js +27 -5
  94. package/dist/useComposerPastes.d.ts +70 -0
  95. package/dist/useComposerPastes.js +125 -0
  96. package/dist/useConversation.d.ts +16 -1
  97. package/dist/useConversation.js +104 -10
  98. package/dist/useMounted.d.ts +3 -0
  99. package/dist/useMounted.js +14 -0
  100. package/dist/useSubagent.d.ts +51 -3
  101. package/dist/useSubagent.js +72 -7
  102. package/dist/useTranscript.d.ts +23 -3
  103. package/dist/useTranscript.js +76 -19
  104. package/dist/wording.d.ts +5 -2
  105. package/dist/wording.js +8 -6
  106. package/dist/workingDirectories.d.ts +31 -0
  107. package/dist/workingDirectories.js +25 -1
  108. package/locales/en/agentTranscript.json +68 -11
  109. package/locales/en/agents.json +82 -10
  110. package/locales/es/agentTranscript.json +68 -11
  111. package/locales/es/agents.json +82 -10
  112. package/locales/ja/agentTranscript.json +71 -14
  113. package/locales/ja/agents.json +82 -10
  114. package/locales/ko/agentTranscript.json +68 -11
  115. package/locales/ko/agents.json +82 -10
  116. package/locales/zh/agentTranscript.json +66 -9
  117. package/locales/zh/agents.json +82 -10
  118. package/package.json +6 -3
package/README.md CHANGED
@@ -1,96 +1,376 @@
1
1
  # @parallelworks/code
2
2
 
3
3
  Shared client logic for pw code sessions on Parallel Works ACTIVATE: the calls
4
- and data hooks a session's pages read through, what a session's daemon sends,
5
- and the transcript its history and live event stream reduce to. Every app that
6
- shows a session uses the same code, so a session reads the same in each.
4
+ and data hooks a session's screens read through, what a session's daemon sends,
5
+ the transcript its history and live event stream reduce to, and what each
6
+ screen around it shows. Every app that shows a session uses the same code, so
7
+ a session reads the same in each.
7
8
 
8
9
  It draws nothing. The host hands it an API client, which carries the
9
10
  platform's address and signs each request, and a way to open its sockets; it
10
11
  renders the messages this package turns the session into, worded in the
11
- reader's language.
12
+ reader's language, with its own components.
12
13
 
13
14
  ```bash
14
- pnpm add @parallelworks/code @parallelworks/ui react openapi-fetch swr use-intl
15
+ pnpm add @parallelworks/code @parallelworks/ui @parallelworks/problem react openapi-fetch swr use-intl
15
16
  ```
16
17
 
17
- `@parallelworks/ui`, `react`, `openapi-fetch`, `swr` and `use-intl` are peer
18
- dependencies. Only the ui package's two entries without a DOM are imported:
19
- `@parallelworks/ui/ai/headless`, for the message and part types and the
20
- reducers that build them, and `@parallelworks/ui/headless`, for its duration
21
- format, its strings and its clock.
18
+ `@parallelworks/ui` (0.136.0 or newer), `@parallelworks/problem`, `react`,
19
+ `openapi-fetch`, `swr` and `use-intl` are peer dependencies. Only the ui
20
+ package's two entries without a DOM are imported:
21
+ `@parallelworks/ui/ai/headless`, for the message and part types, the reducers
22
+ that build them and the chat's shared rules, such as its paste cards and the
23
+ model it picks first, and `@parallelworks/ui/headless`, for its duration and
24
+ byte formats and its clock. Of `@parallelworks/problem`, only its root, to
25
+ read an error's code as the host's own error messages do.
22
26
 
23
27
  ## What is in it
24
28
 
29
+ Most hooks take the API this package builds over the host's client, and
30
+ callbacks for whatever the host does itself: navigating, asking the reader,
31
+ showing a toast, wording an error. Types are exported beside each.
32
+
33
+ ### The API and the wire
34
+
25
35
  - `createPwCodeApi(client, options)`, the calls and SWR data hooks of pw code
26
36
  sessions over the host's `openapi-fetch` client: the sessions and machines
27
- listed (`useSessions`, `useMachines`), a session's transcript
28
- (`useSessionDetail`), its live event feed (`useSessionEvents`), what can be
29
- done to it (`useSessionMutations`, `sendMessage`, `steer`, `answerApproval`,
30
- `resolveTyped`, ...), its subagents, pull requests and worktree, and the
31
- Claude Code models, accounts and sign-in of its machine.
37
+ listed (`useSessions`, `useMachines`, `useMachine`,
38
+ `useWaitingSessionCount`), a session's transcript (`useSessionDetail`), its
39
+ live event feed (`useSessionEvents`), what can be done to it
40
+ (`useSessionMutations`, `sendMessage`, `steer`, `withdrawQueued`,
41
+ `withdrawDirection`, `answerApproval`, `resolveTyped`, ...), its settings
42
+ (`useSessionSettings`), its commands (`usePalette`,
43
+ `useBackgroundCommands`, `requestRecap`, `runGoal`), its subagents, pull
44
+ requests, worktree, images and pastes, and the Claude Code models, accounts
45
+ and sign-in of its machine, and the machine's directories
46
+ (`useDirectories`, `usePathCompletion`, `useDirectoryTree`). It also reads
47
+ the platform's models (`usePlatformModels`), the reader's allocations
48
+ (`useAllocations`) and the AI chat a new session is to carry on
49
+ (`useChatHandoff(chatId)`), says whether pw code is on for the reader
50
+ (`usePwCodeEnabled`), and keeps the reader's choices in their account
51
+ (`usePreference`).
32
52
  - The wire types (`PwCodeSessionDetail`, `PwCodeStreamEvent`,
33
53
  `PwCodeApprovalRequest`, ...): a session's replayed history, its event
34
54
  frames and the answers it accepts. A host that generates its API types can
35
55
  assert they extend these.
36
- - The transcript reducers, which are pure functions: `initialTranscript` seeds
37
- a `TranscriptState` from a fetched session, `applyStreamEvent` applies one
56
+ - What the hooks build on, for a host that reads the same routes itself: the
57
+ feed's path (`sessionEventsPath`), the SWR key's prefix
58
+ (`QUERY_KEY_PREFIX`), how often lists are read again (`SESSIONS_REFRESH_MS`,
59
+ `pullRequestsRefreshMs`), the patches a listing takes
60
+ (`patchSessionNames`, `patchPullRequestStates`, `reachedByFeed`), which
61
+ frames change a session's subagents (`changesSubagents`), whether a cached
62
+ copy is still current (`cachedCopyCurrent`), when the session was last read
63
+ (`useLastReadAt`), and the part of a paste a message names it by
64
+ (`pasteRefs`).
65
+
66
+ ### The transcript
67
+
68
+ - The reducers, which are pure functions: `initialTranscript` seeds a
69
+ `TranscriptState` from a fetched session, `applyStreamEvent` applies one
38
70
  event frame to it, and `historyToMessages` maps replayed history alone.
71
+ Beside them, what a transcript holds (`pendingMessages`,
72
+ `pendingApprovals`, `turnRunning`, `bashRunning`, `reviewingCount`,
73
+ `liveSessionStatus`), where its feed resumes (`resumeCursor`), a subagent's
74
+ share of it (`subagentFrame`, `subagentSessionDetail`), and the edits the
75
+ reader's own sends make to it (`appendOwnMessage`, `appendSteeredMessage`,
76
+ `dropMessage`, `resolveApprovalEverywhere`).
39
77
  - `usePwCodeTranscript`, the React state those reduce into, with sending,
40
- steering a running turn, and taking back a queued message.
78
+ steering a running turn, and taking back a message the model has not been
79
+ handed yet, queued behind the turn or steered into it (`canRemoveQueued`,
80
+ `removeQueued`), or every one the machine still holds at once, each with
81
+ its pastes and images, and the first refusal, since one the model read
82
+ meanwhile stays sent (`takeBackPending`, each a `PwCodeTakenBack`).
83
+ The `typed` option of its `sendMessage` keeps what was typed when a command
84
+ resolved it to other text, so it comes back as typed.
41
85
  - `approvalToPart` and `approvalAnswerBody`, between a session's approval
42
86
  requests and the answer it accepts.
43
- - The paths a session's images are served from (`sessionImageUrl`,
44
- `sessionGitHubImageUrl`).
45
- - What a list of sessions and machines means, as pure functions over the
46
- structural `PwCodeSession` and `PwCodeMachine`: which sessions wait on the
47
- reader and in what order they show (`triageSessions`, `newestFirst`,
48
- `needsYou`, `isActiveSession`, `isMidTurn`), the tone a row takes
49
- (`sessionVariant`), whether a machine can be reached or can start a session
50
- (`isMachineDown`, `canStartHere`), the folders a machine's sessions suggest
51
- (`recentDirectories`), and the command that picks a session up in a terminal
52
- (`terminalHandoff`).
53
- - Starting a session, as hooks a host draws its own start screen over:
54
- where it starts (`useStartLocation`, `startMachines`), the permission mode
55
- it starts in (`useStartPermissionMode`, `startingMode`), its model,
56
- allocation and Claude Code account (`useStartModel`), and the start itself
57
- with its first prompt and images (`useStartSession`). The host passes in its
58
- saved preferences and opens the session once it starts.
59
- - The models a session can run (`isClaudeModel`, `runsClaude`, `canRunModel`,
60
- `modelLabel`), the picker a typed command opens (`pickerCommand`), and the
61
- machine's Claude models a model picker offers (`useModelCatalog`).
62
- - A session's working directories: the path helpers that cut a long path to
63
- fit (`pathSegments`, `shortestPath`, `cutToFit`, `cutSpacing`,
64
- `lastSegmentAt`), where a directory is saved (`isSavedDirectory`,
65
- `directoryScopes`), what an approval allowed in one (`allowedAccess`), and
66
- closing one added for the session only (`useRemoveSessionDirectory`).
87
+ - Where a session's images load from: by ref (`sessionImageUrl`,
88
+ `isSessionImageUrl`), and for a GitHub attachment in a pull request the
89
+ session opened, through its machine first (`markdownImageSources`,
90
+ `githubAttachmentAsset`, `sessionGitHubImageUrl`), and the link it becomes
91
+ once none of those loads (`markdownImageLink`).
92
+
93
+ ### An open session
94
+
95
+ - `usePwCodeConversation`, the session's conversation: its live transcript,
96
+ sends routed to its machine and taking them back while they wait, one at a
97
+ time or all at once (`takeBackPending`, which takes nothing while another
98
+ runs), approvals, the notice above the composer, and its subagents.
99
+ - `usePwCodeComposer`, what the composer can do and how the session stands
100
+ for it: typed text goes out as a message, a direction to the running turn,
101
+ a command or a `!` shell run, and the composer locks while the machine is
102
+ unreachable, the session is archived or live elsewhere, or it waits on an
103
+ approval. Its `recall` takes back what waits into the composer, as ↑ or
104
+ Edit under the queue does on the web: `available` says whether anything
105
+ can come back, and `take` resolves to each message's text and pastes, in
106
+ the order they would have reached the model (to none while another `take`
107
+ runs), having put their images back
108
+ through the `images` option's `restore`. It has the shape of the `recall`
109
+ that `@parallelworks/ui/ai`'s composer takes from 0.139.0. A host drawing
110
+ its own composer stops a turn with `stopTurn`, as that composer's stop
111
+ does: while anything can come back, the composer's own take-back runs
112
+ first, then the turn stops, even when the take-back threw, which
113
+ `stopTurn` resolves to. Its command
114
+ outputs (`useCommandOutputs`) and sent prompts (`promptHistory`, per
115
+ person) go with it.
116
+ - `usePwCodeSessionScreen`, the screen around those two: the banner while
117
+ nothing new can reach the transcript (`sessionBanner`, whose `tone` is
118
+ `danger` for a machine that does not answer and `info` for a session live
119
+ elsewhere), the activity line (`sessionActivity`), whether the turn waits
120
+ at its account's usage limit as that line says, which it doesn't while the
121
+ feed reconnects (`waitingAtLimit`, for the Claude Code account panel), the
122
+ goal (`goalLabel`, whose dot, a `PwCodeGoalMark`, has the `info` tone,
123
+ unlit while paused and pulsing while a check runs), what shows when the
124
+ transcript never loaded (`loadErrorMessage`), the command menu and the
125
+ settings row.
126
+ The goal itself is read, edited, paused, resumed and cleared from a panel
127
+ over `useSessionGoal` (a `PwCodeSessionGoal`), which also gives the panel's
128
+ `view` and `note`, the run's `state`, `lastCheck` and `pausedNote`, which
129
+ of pause and resume to offer (`toggle`), when nothing can be asked
130
+ (`busy`), and the draft of a rewritten condition (`draft`, `setDraft`,
131
+ `startEdit`, `empty`, `unchanged`, `canSave`, `saving`, `save`). Its
132
+ working time runs with `useGoalElapsed` and is rounded by `goalElapsed`;
133
+ `goalFacts` says what follows the state.
134
+ Its parts: how stale the transcript is (`useStaleFor`), the draft's key
135
+ (`sessionDraftKey`), which picker the composer opens (`useSessionPicker`),
136
+ the model it runs (`sessionModel`), the settings' options
137
+ (`sessionSettingsOptions`), what the machine allows
138
+ of Claude Code (`claudeOnMachine`), and the account a Claude model runs as
139
+ (`claudeAccountChip`).
140
+ The task list pinned above the composer (`useTodoPanel`, a
141
+ `PwCodeTodoPanel`) gives its title, how far along it is (`progress`), the
142
+ running task a folded panel names (`running`), up to six rows from the one
143
+ before the running task, each with its status in words (`rows`), and the
144
+ control that shows the rest or fewer again (`more`).
145
+ - Images and pastes sent with a message. `useComposerImages` holds the images
146
+ until there is a session to save them with, through the host's encoder,
147
+ which throws `PwCodeImageTooLarge` for one it cannot fit; `fitImageWith`
148
+ works out the sizes an image is written at to fit `IMAGE_MAX_BYTES` and
149
+ `IMAGE_MAX_SIDE`, `IMAGE_TYPES` are the types a session takes, and
150
+ `nextImageSeq` numbers an image's placeholder. `useComposerImages`'
151
+ `restore` puts back the images of a message taken back, already saved with
152
+ the session, and `withoutAppendedImages` takes the placeholders its send
153
+ appended out of that message's text. `useComposerPastes` says where a
154
+ session's long pastes are saved and past what size, set by its model until
155
+ it is live, `usePasteCards` turns
156
+ each one past it into a card that goes as its placeholder, and
157
+ `pasteCardText` words a card.
158
+ - A recap written while the reader is away (`useAwayRecap`), as pw code
159
+ writes one while its terminal is out of focus.
160
+ - Subagents: one subagent's conversation in place of the main one
161
+ (`usePwCodeSubagent`), with what its screen shows: whether it is still
162
+ loading or never loaded (`loading`, and `failed` from its `subagent`
163
+ read's `error`), whether messages show their author (`showAuthor`), its
164
+ activity line (`activity`), where a queued message goes
165
+ (`queueDelivery`), taking one back (`canRemoveQueued`, `removeQueued`) or
166
+ all of them into the composer (`recall`, as the main composer's), its
167
+ composer's draft key (`draftKey`), the `id` its `promptHistory` takes
168
+ (`historyId`), and the model it runs on (`model`) and
169
+ that model's name (`modelLabel`, from the `modelNames` option, the session
170
+ state's). Beside it, the switcher that lists them
171
+ (`usePwCodeAgentSwitcher`, `switcherAgent`, `usePwCodeAgentLine`,
172
+ `useAgentTypeLabel`), taking one that is not running off the list, which
173
+ shows the main conversation again when it was the one in view and the
174
+ screen that asked is still open (`useDismissSubagent`), the mark each
175
+ agent shows for its state (`agentMark`), and the tone of its state's word
176
+ (`stateTone`, a `PwCodeStateTone` the host maps to its colors) and whether
177
+ that word shows beside the mark (`flagged`), the main conversation's
178
+ included.
179
+ - Where typed text goes (`slashAction`, `shellCommand`), the commands a
180
+ session offers (`paletteOptions`), read from the structural
181
+ `PwCodePalette`, whether a direction that got no answer may have landed
182
+ (`steerMayHaveLanded`), and which running tool calls carry the offer to
183
+ move a turn's commands to the background (`offersBackground`,
184
+ `BACKGROUND_TOOL`).
185
+ - What a session's header offers: picking the session up in a terminal
186
+ (`terminalHandoffPanel`, `handoffCommandParts`), the line a turn shows while
187
+ it waits for a usage limit (`useUsageLimitWait`), the worktree the session
188
+ works in, read again when it moves (`useFollowedWorktree`), and how sessions
189
+ get listed (`howSessionsAppear`).
190
+ - A session's working directories: how one is written on its machine
191
+ (`workingDirectoryText`, `PwCodeWorkingDirectoryText`), the path helpers
192
+ that cut a long path to fit (`pathSegments`, `shortestPath`, `cutToFit`,
193
+ `cutSpacing`, `lastSegmentAt`), where a directory is saved
194
+ (`isSavedDirectory`, `directoryScopes`), what an approval allowed in one
195
+ (`allowedAccess`), the added and allowed ones as they are listed
196
+ (`sessionDirectories`, `PwCodeSessionDirectories`,
197
+ `PwCodeAddedDirectoryRow`, `PwCodeAllowedDirectoryRow`), and closing one
198
+ added for the session only (`useRemoveSessionDirectory`).
67
199
  - The choice to keep or remove a session's worktree when the session is
68
200
  deleted (`useWorktreeChoice`), and what removing it would delete
69
201
  (`worktreeWork`).
70
- - Where typed text goes (`slashAction`, `shellCommand`) and the commands a
71
- session offers (`paletteOptions`), read from the structural `PwCodePalette`.
72
202
  - The short label of a pull or merge request link (`pullRequestLabel`,
73
- `pastedPullRequestLabel`), and how a session's pull requests are listed:
74
- their order (`orderPullRequests`), which fold into a count and how the
75
- counts read (`foldPullRequests`, `donePullRequestsToFold`,
76
- `pullRequestGroupState`, `pullRequestWords`), and the row of directories
77
- and pull requests under a session's title (`sessionContextRow`).
78
- - What a session's header offers: picking the session up in a terminal
79
- (`terminalHandoffPanel`), the line a turn shows while it waits for a usage
80
- limit (`useUsageLimitWait`), the worktree the session works in, read again
81
- when it moves (`useFollowedWorktree`), and how sessions get listed
82
- (`howSessionsAppear`).
203
+ `pastedPullRequestLabel`, `pullRequestShortLabel`, `pullRequestKind`), and
204
+ how a session's pull requests are listed: their order
205
+ (`orderPullRequests`), the tone each state shows in (`pullRequestTone`),
206
+ which fold into a count and how the counts read
207
+ (`foldPullRequests`, `pullRequestGroupState`, `pullRequestWords`), with
208
+ the merged and closed ones folding even when they fit once a row has
209
+ `FOLD_DONE_PULL_REQUESTS_FROM` of them (`donePullRequestsToFold`), and the
210
+ row of directories and pull requests under a session's title
211
+ (`sessionContextRow`), whose states the API's `useSessionPullRequestStates`
212
+ reads for the links the session lists.
213
+
214
+ ### The session list
215
+
216
+ - What a list of sessions and machines means, as pure functions over the
217
+ structural `PwCodeSession` and `PwCodeMachine`: which row is which session
218
+ (`sessionKey`, `isSession`), which sessions wait on the reader and in what
219
+ order they show (`triageSessions`, `newestFirst`, `needsYou`,
220
+ `isActiveSession`, `isMidTurn`), the tone a row takes (`sessionVariant`),
221
+ whether a machine can be reached or can start a session (`isMachineDown`,
222
+ `isConnected`, `canStartHere`), computers apart from resources
223
+ (`isComputer`, `splitMachines`), the folders a machine's sessions suggest
224
+ (`recentDirectories`), and the command that picks a session up in a
225
+ terminal (`terminalHandoff`).
226
+ - `useSessionList`, the list in sections: the pinned sessions, each of the
227
+ reader's groups, then the rest by whether they wait on the reader, are live,
228
+ rest or are archived (`sessionSections`, the one that waits on the reader
229
+ with a `tone`), with folding, dropping a session on a section (`canDrag`,
230
+ `dropSession`), naming a group without the spaces around its name and the
231
+ words of the prompts for it (`renameGroup`, `groupNameWords`,
232
+ `groupDeleteWords`), the menus and keys of a row, a group and the list, and
233
+ the error to show in the list's place while no listing has loaded
234
+ (`loadError`). Beside it, what a search lists (`searchedSessions`), what it
235
+ finds a session by (`sessionSearchText`) and how well
236
+ (`sessionSearchScore`, over the host's own fuzzy scorer, a
237
+ `PwCodeSearchScorer` such as cmdk's `defaultFilter`), the state a result
238
+ shows (`sessionSearchStatus`), each row's mark and second line
239
+ (`sessionMark`, `sessionRowState`), what a session's mark on a collapsed
240
+ list is called (`sessionRailLabel`), and the rows of a machine the listing
241
+ lost, kept so they can say why (`useRetainedSessions`).
242
+ - `useSessionActions`, what can be done to a session from the list and the
243
+ flows behind each: renaming, pinning, grouping, forking, leaving its
244
+ worktree, stopping, archiving, restoring and deleting, asking the reader
245
+ first where it should. Its `rename` carries the words of the prompt for the
246
+ name, and `nameToSave` is the name a prompt saves, or none.
247
+ - The reader's groups (`useSessionGroups`), and the sessions in each
248
+ (`listGroups`, `inFlightFirst`, `groupOf`).
249
+
250
+ ### Starting a session
251
+
252
+ - Hooks a host draws its own start screen over: where it starts
253
+ (`useStartLocation`, `startMachines`, `machineMenu`, and the chip naming
254
+ the machine, `machineChip`, whose `dot` has the `success` tone once one is
255
+ chosen, and which says the machines are still being found while
256
+ `finding`), the permission mode it
257
+ starts in and the machine's bounds on its picker (`useStartPermissionMode`,
258
+ a `PwCodeStartPermission`, `startingMode`), its model, allocation and
259
+ Claude Code account (`useStartModel`), and the start itself with its first
260
+ prompt and images (`useStartSession`). The host passes in its saved
261
+ preferences and opens the session once it starts. `startControls`
262
+ (`PwCodeStartControls`) says which controls are locked while it starts or
263
+ until a machine is chosen, and whether the model picker reads the
264
+ machine's Claude models ahead (`canStart`).
265
+ - Choosing that directory: a machine's directories as it lists them
266
+ (`listDirectories` and `useDirectories` on the API), and the rows a path
267
+ field offers under what is typed, the directory it names, the recent ones
268
+ and the directories inside it (the API's `usePathCompletion`, over
269
+ `pathCompletions`), with the helpers that read typed text as a path
270
+ (`splitTypedPath`, `typedDirectory`, `joinDirectory`, `parentDirectory`,
271
+ `isPathText`, `listedText`), and the refusal of a path that is no
272
+ directory the machine can list (`isUnlistedDirectory`).
273
+ `usePathCompletion` also returns each row as shown (`PwCodePathRow`:
274
+ whether choosing it lists its folders, and the line beside its name), the
275
+ rows in their headed sections (`sections`, from `pathSections`), the line
276
+ under them (`note`, from `pathNote`, which words a failed listing with the
277
+ host's `describeError`), whether to offer browsing, on a machine that lists
278
+ its folders (`canBrowse`), and where browsing opens (`browseFrom`, from
279
+ `browseStart`). `pickedOnClose` is the directory a field closed with an
280
+ edited path picks, and `directoryChip` words the chip naming the directory.
281
+ - Browsing for it: a folder tree of the machine, where it opens, its title
282
+ and the way up (the API's `useDirectoryTree`), and the folders it shows,
283
+ hidden ones only when asked for (`visibleFolders`).
284
+ - The screen around the composer (`useStartScreen`, `PwCodeStartScreen`):
285
+ whether the listing is still loading or never loaded (`loading`,
286
+ `failed`), whether the composer shows or the host says no machine can
287
+ start a session (`showComposer`), whether nothing is listed, so the host
288
+ explains how sessions appear (`explainEmpty`), and answering a listed
289
+ session's question (`answer`).
290
+ - What a start screen offers besides: the sessions to pick back up
291
+ (`startShortlist`, `waitingSince`) with the mark a live one shows
292
+ (`shortlistMark`) and the questions they wait on (`waitingQuestions`); the
293
+ session or chat its address asks for (`startSearch`, `useSessionLink`)
294
+ with the card shown while a linked session is looked for
295
+ (`sessionLinkNotice`, whose `tone` is `warning` once it is missing); the
296
+ composer's commands (`startCommands`) and draft key
297
+ (`newSessionDraftKey`); and a chat handed to a new session, read with the
298
+ API's `useChatHandoff`: the composer's `placeholder`, the `notice` above it
299
+ naming the chat or why it did not load (whose `tone` is then `warning`),
300
+ and its first prompt
301
+ (`chatHandoffStart`, `chatHandoffPrompt`).
302
+ - The models a session can run (`isClaudeModel`, `runsClaude`,
303
+ `canRunModel`, `modelLabel`), the picker a typed command opens
304
+ (`pickerCommand`), and the model picker: the platform's models by provider
305
+ and the machine's Claude ones (`useModelPicker`, `modelGroups`,
306
+ `platformModelStatus`, `providerIssueOf`, `useModelCatalog`). For a host
307
+ with no chat of its own to take them from, `usePlatformDefaults` gives the
308
+ platform model and allocation a chat would select.
309
+ - The allocations a model bills (`useModelAllocations`, `billsAllocation`),
310
+ and the rules behind them (`aiAllocations`, `allocationsForType`,
311
+ `allocationProblem`, `allocationChoice`, `allocationUsage`).
312
+
313
+ ### Claude Code accounts
314
+
315
+ - A machine's accounts as a panel lists them, with adding, signing in,
316
+ removing and choosing one (`useClaudeAccountPanel`, given the
317
+ `machineName` its words name the machine by). It words each view in the
318
+ reader's language: its title and description, why Claude Code can't run on
319
+ the machine, where signing in happens, the question a removal asks, and
320
+ the line under each account's name, its email or how to sign it in on the
321
+ machine (`detail`, a `ClaudeAccountDetail`). It also says which of the
322
+ list's controls show and the row the list starts on, and
323
+ `useClaudeAccountStartRow` moves the host's highlight there, and back
324
+ whenever the selected or first enabled row changes, such as when the
325
+ accounts' sign-in states arrive. Its setter must keep its identity, as a
326
+ `useState` setter does: a new one moves the highlight back too.
327
+ Given `waitingAtLimit`, the session screen's, it asks for another account
328
+ to continue on (`handoff`) and offers to take the other sessions on the
329
+ spent one along (`others`, `moveOthers`, `setMoveOthers`), under the label
330
+ `moveOthersLabel`, null when the option doesn't show. `onMovedOthers` is
331
+ handed the words that say how many moved.
332
+ - The sign-in itself, run in the host's terminal (`useClaudeSignIn`, also
333
+ given `machineName`), with the sign-in page to offer opening, what to do,
334
+ a note when earlier output was dropped, the label that leaves it, and,
335
+ once signed in, the host's `onUse` to offer (`use`).
336
+ `canOpenSignInLink` says whether a link in its output may be opened: web
337
+ addresses only, never a script or a local file.
338
+ - The steps of a removal and of naming a new account
339
+ (`useClaudeAccountRemoval`, `useClaudeAccountName`, `claudeAccountName`),
340
+ an account's usage limits (`useClaudeAccountUsage`), and the refusal that
341
+ asks for a sign-in first (`claudeSignInRequired`).
342
+
343
+ ### Preferences
344
+
345
+ Each choice a client keeps for the reader, under the key and fallback every
346
+ client uses (`startModePreference`, `startEffortPreference`,
347
+ `startMachinePreference`, `startAccountPreference`, `lastModelPreference`,
348
+ `chatModelPreference`, `foldedGroupsPreference`, `sessionGroupsPreference`,
349
+ `showHiddenPreference`), and the rules for keeping it
350
+ (`useStartModePreference`, `useStartEffortPreference`,
351
+ `useStartMachinePreference`, `useStartAccountPreference`,
352
+ `useLastModelPreference`). Each rule takes the preference as a `[value, set]`
353
+ pair, from `usePreference` or the host's own store.
354
+ `useStartDefaultsFromSession` takes the start mode, effort and account
355
+ preferences and returns the callbacks for `useSessionSettings` that make a
356
+ pick in an open session where new sessions start.
357
+
358
+ ### Words
359
+
83
360
  - The messages a session is shown in, in English, Spanish, Japanese, Korean
84
- and Chinese (`loadPwCodeMessages`), and the words built from them: a
85
- session's label and status (`sessionLabel`, `sessionStateText`), why a
86
- machine can't be reached (`machineHint`), what the composer says while it is
87
- locked (`composerState`), and the transcript's own lines
88
- (`useTranscriptWords`, `useGoalNotice`, `useCompactionNotice`,
89
- `useRecapNotice`, `useToolStrings`).
361
+ and Chinese (`loadPwCodeMessages`, `pwCodeLocales`, `isPwCodeLocale`), and
362
+ the words built from them: a session's label and status (`sessionLabel`,
363
+ `sessionStateText`, `sessionStatusText`), why a machine can't be reached
364
+ (`machineHint`), what the composer says while it is locked
365
+ (`composerState`), and the transcript's own lines (`useTranscriptWords`,
366
+ `useGoalNotice`, `useCompactionNotice`, `useRecapNotice`, `useResumeTime`,
367
+ `turnDuration`, `useToolStrings`).
368
+ - Every word of `@parallelworks/ui/ai`'s chat a session's screens show, by
369
+ `ChatStrings` section (`usePwCodeChatStrings`), for a host to pass as its
370
+ chat config's `strings`.
90
371
  - How long ago something happened, as "5m", for labels passed as strings
91
- (`useCompactAgo`). It reads `@parallelworks/ui`'s `time` strings, which a
92
- host sets on `UIProvider`, or on `UIStringsProvider` where there is no DOM,
93
- and re-reads every 30 seconds on the ui package's clock.
372
+ (`useCompactAgo`). It reads the `agents` messages and re-reads every 30
373
+ seconds on the ui package's clock.
94
374
 
95
375
  ## Messages
96
376
 
@@ -155,85 +435,317 @@ Create it once per client, at module level. Its hooks key SWR's cache as
155
435
  `@parallelworks/client/swr`'s hooks do (`['api', path, init]`, or `null` for a
156
436
  read they skip), and throw the client's error as those do, so a host that reads
157
437
  the same routes through those shares their cache entries, and revalidating one
158
- revalidates the other. `hidden`, when given, says the app is out of sight,
159
- where animation frames do not run and feed frames are applied as they arrive.
438
+ revalidates the other. Only `usePwCodeEnabled` keys its read by the path alone,
439
+ `'/api/previews'`, as a host reading previews with plain SWR keys it.
440
+ `useSessionDetail` gives up a read still on its way once it no longer shows
441
+ that session, so the connection goes to the one the reader moved on to.
442
+
443
+ Its other options:
444
+
445
+ - `hidden`, when given, says the app is out of sight, where animation frames
446
+ do not run, so feed frames are applied as they arrive.
447
+ - `onPreferenceError` hears a preference that failed to save; it shows its
448
+ saved value again.
449
+ - `previewsByRef` reads a transcript with each image's preview left to its
450
+ ref, to be loaded when it is drawn. Set it only where the host loads an
451
+ image from its URL on the platform's API signed in as the API client is, as
452
+ a browser on the platform's origin does.
453
+ - `transcriptEndFirst` reads a session's transcript end first and draws the
454
+ end of the conversation while the rest arrives, which over a slow
455
+ connection is most of the wait. Set it only where the client's `fetch` hands
456
+ over a response's body as it arrives (`response.body`), as a browser's does
457
+ and React Native's own does not. Until the whole transcript is there the
458
+ composer is disabled and nothing that waits on the reader is drawn.
160
459
 
161
460
  The package carries the types of the routes it calls (`PwCodePaths`), generated
162
461
  from the platform's OpenAPI spec. A client whose own API types lack one of
163
462
  those routes, or type one differently, is refused at compile time, naming the
164
463
  routes it lacks; regenerate the host's types from a newer spec.
165
464
 
166
- ## Using the hook
465
+ pw code is a preview (`PW_CODE_PREVIEW`). Its routes answer 404 for a reader
466
+ without it, so check
467
+ `pwCode.usePwCodeEnabled()`, undefined until the reader's previews load,
468
+ before offering it; `pwCodeEnabled(previews)` answers the same from previews
469
+ the host has already read.
470
+
471
+ ## An open session
167
472
 
168
473
  ```tsx
169
474
  import {
170
- pasteRefs,
171
- pendingMessages,
172
- turnRunning,
173
- usePwCodeTranscript,
475
+ isSession,
476
+ sessionSettingsOptions,
477
+ useGoalNotice,
478
+ usePwCodeComposer,
479
+ usePwCodeConversation,
480
+ usePwCodeSessionScreen,
481
+ useStaleFor,
174
482
  } from '@parallelworks/code'
175
483
  import { pwCode } from './pwCode'
176
484
 
177
- function useSession(machine: string, sessionId: string) {
178
- // The session's status, history and last seq.
179
- const { data: detail, mutate } = pwCode.useSessionDetail(
485
+ function useOpenSession(machine: string, sessionId: string, host: Host) {
486
+ const sessions = pwCode.useSessions()
487
+ const listed = sessions.data?.sessions?.find(s =>
488
+ isSession(s, machine, sessionId)
489
+ )
490
+ const read = pwCode.useSessionDetail(machine, sessionId, listed)
491
+ const machineRead = pwCode.useMachine(machine)
492
+ const conversation = usePwCodeConversation({
493
+ api: pwCode,
494
+ machine,
495
+ sessionId,
496
+ sessions,
497
+ detail: read,
498
+ describeError: host.describeError,
499
+ notify: host.toast,
500
+ onCleared: id => host.openSession(machine, id),
501
+ onMoved: copy => host.openSession(copy.machineId, copy.id),
502
+ // Without it, a goal's progress takes no line in the transcript.
503
+ goalNotice: useGoalNotice(),
504
+ })
505
+ // Resumed from the cursor once this visit has read the session itself: a
506
+ // copy cached by an earlier visit trails the feed.
507
+ const feed = pwCode.useSessionEvents(
180
508
  machine,
181
509
  sessionId,
182
- undefined
510
+ read.fresh ? conversation.cursor : undefined,
511
+ conversation.onEvent
183
512
  )
184
- const { transcript, onEvent, cursor, sendMessage } = usePwCodeTranscript({
513
+ const staleFor = useStaleFor(read.data, feed.connected)
514
+ const composer = usePwCodeComposer({
515
+ api: pwCode,
516
+ machine,
185
517
  sessionId,
186
- detail,
187
- // Resolves to { turnId, queued } once accepted, or { error } to show.
188
- send: async (text, pastes, images) => {
189
- const { data, error } = await pwCode.sendMessage(machine, sessionId, {
190
- text,
191
- ...pasteRefs(pastes),
192
- ...(images ? { images } : {}),
193
- })
194
- return error ? { error: error.message } : data
195
- },
196
- onEffect: effect => {
197
- // What a frame asks of the host: 'refetch', 'cleared', 'state' or 'notice'.
198
- if (effect.type === 'refetch') {
199
- void mutate()
200
- }
201
- },
518
+ conversation,
519
+ machineInfo: machineRead.machine,
520
+ feed,
521
+ staleFor,
522
+ notify: host.toast,
523
+ onCleared: id => host.openSession(machine, id),
524
+ onArchived: host.showList,
202
525
  })
203
- // The feed reconnects from cursor(), the last seq applied.
204
- pwCode.useSessionEvents(machine, sessionId, cursor, onEvent)
205
-
206
- return {
207
- messages: transcript?.messages ?? [],
208
- streaming: transcript?.streaming ?? null,
209
- queued: transcript ? pendingMessages(transcript) : [],
210
- running: turnRunning(transcript),
211
- sendMessage,
212
- }
526
+ const settings = pwCode.useSessionSettings({
527
+ ...sessionSettingsOptions(machine, conversation, composer),
528
+ onPatched: () => void read.mutate(),
529
+ onError: conversation.showError,
530
+ })
531
+ const screen = usePwCodeSessionScreen({
532
+ conversation,
533
+ composer,
534
+ read,
535
+ machine: machineRead,
536
+ staleFor,
537
+ settings,
538
+ images: [],
539
+ describeError: host.describeError,
540
+ })
541
+ return { conversation, composer, settings, screen }
213
542
  }
214
543
  ```
215
544
 
216
- `steer` hands text to the turn that is running and `withdraw` takes a queued
217
- message back; without them every message sent during a turn waits for it to
218
- end. `goalNotice`, `compactionNotice`, `recapNotice` and `words` supply the
219
- transcript's own lines in the reader's language: `useGoalNotice()`,
220
- `useCompactionNotice()`, `useRecapNotice()` and `useTranscriptWords()` give
221
- them from this package's messages. `imageUrl` turns an image's `ref` into the URL the host serves it
222
- from.
545
+ Call it from a component mounted once per session, keyed by machine and
546
+ session as the web's session page is. Its reads and its transcript keep what
547
+ they learned of the session they first showed, so a screen that moves to
548
+ another session in place shows that session's copy cached by an earlier
549
+ visit, resumes its feed from that copy, and carries over messages still on
550
+ their way to the old one.
551
+
552
+ `conversation.all` is what the transcript draws: its messages, the one
553
+ streaming, then those queued behind the turn. `composer.send` sends what was
554
+ typed, and `screen` says what goes around them. A host that wants only the
555
+ transcript runs `usePwCodeTranscript` over the same detail and feed, with its
556
+ own `send` and `steer`, `withdraw` and `withdrawDirection` to take back a
557
+ queued or a steered message by the `turnId` its `send` or the `id` its `steer`
558
+ resolved to, and an `onEffect` that does what a frame asks:
559
+ `refetch`, `cleared`, `state` or `notice`. `goalNotice`, `compactionNotice`,
560
+ `recapNotice` and `words` supply the transcript's own lines in the reader's
561
+ language, from `useGoalNotice()`, `useCompactionNotice()`, `useRecapNotice()`
562
+ and `useTranscriptWords()`; without them those lines are missing or in
563
+ English. `imageUrl` turns an
564
+ image's `ref` into the URL it loads from, as
565
+ `ref => sessionImageUrl(machine, sessionId, ref)` does; without it an image
566
+ opens only at its preview's size, and one read with `previewsByRef` does not
567
+ show.
223
568
 
224
569
  On the web, `SessionView` from `@parallelworks/ui/ai` draws these messages. A
225
570
  host with its own components renders `ChatMessage` and its parts itself.
226
571
 
572
+ ## On React Native
573
+
574
+ The package runs on the Hermes that React Native 0.88 ships, once four
575
+ FormatJS polyfills have loaded. Load them before anything imports
576
+ `@parallelworks/ui` or `@parallelworks/code`, in this order: each needs the
577
+ ones above it, and `@parallelworks/ui` builds formatters when it loads. The
578
+ last three carry the data of the five languages the messages come in. In an
579
+ Expo Router app, that is an entry file, named as `main` in the app's
580
+ `package.json`, that imports them and then `expo-router/entry`:
581
+
582
+ ```js
583
+ import '@formatjs/intl-locale/polyfill.js'
584
+ import '@formatjs/intl-pluralrules/polyfill-force.js'
585
+ import '@formatjs/intl-pluralrules/locale-data/en.js'
586
+ import '@formatjs/intl-pluralrules/locale-data/es.js'
587
+ import '@formatjs/intl-pluralrules/locale-data/ja.js'
588
+ import '@formatjs/intl-pluralrules/locale-data/ko.js'
589
+ import '@formatjs/intl-pluralrules/locale-data/zh.js'
590
+ import '@formatjs/intl-numberformat/polyfill-force.js'
591
+ import '@formatjs/intl-numberformat/locale-data/en.js'
592
+ import '@formatjs/intl-numberformat/locale-data/es.js'
593
+ import '@formatjs/intl-numberformat/locale-data/ja.js'
594
+ import '@formatjs/intl-numberformat/locale-data/ko.js'
595
+ import '@formatjs/intl-numberformat/locale-data/zh.js'
596
+ import '@formatjs/intl-listformat/polyfill-force.js'
597
+ import '@formatjs/intl-listformat/locale-data/en.js'
598
+ import '@formatjs/intl-listformat/locale-data/es.js'
599
+ import '@formatjs/intl-listformat/locale-data/ja.js'
600
+ import '@formatjs/intl-listformat/locale-data/ko.js'
601
+ import '@formatjs/intl-listformat/locale-data/zh.js'
602
+ import 'expo-router/entry'
603
+ ```
604
+
605
+ These versions were checked: `@formatjs/intl-locale` 5.4.3,
606
+ `@formatjs/intl-pluralrules` 7.0.4, `@formatjs/intl-numberformat` 10.0.4 and
607
+ `@formatjs/intl-listformat` 9.0.3. NumberFormat is forced because Hermes' own
608
+ ignores compact notation and unit display: a token count reads "12,345" for
609
+ "12.3K", and a reset "360 sec" for "6m".
610
+
611
+ Dates follow the device's own formatter by design, with no polyfill, so they
612
+ read as the phone writes them, which differs slightly from the web. On iOS,
613
+ English puts a narrow no-break space before AM and PM and "at" between the
614
+ date and the time ("Nov 14, 2026 at 3:30 PM" where the web writes "Nov 14,
615
+ 2026, 3:30 PM"), Japanese puts the weekday before the time, and Japanese and
616
+ Chinese put a space beside the weekday. Android's formatter is not checked,
617
+ and can differ in other ways.
618
+
619
+ The package opens no socket, keeps nothing on the device, encodes no image
620
+ and navigates nowhere. The host supplies each:
621
+
622
+ - The event feed's socket, as `createPwCodeApi`'s `openSocket`. The platform
623
+ takes its credential only from an `Authorization` header or its session
624
+ cookie, never from a query parameter, so open it with the header React
625
+ Native's `WebSocket` takes in its third argument:
626
+
627
+ ```ts
628
+ openSocket: async path =>
629
+ new WebSocket(`wss://activate.example.com${path}`, undefined, {
630
+ headers: { Authorization: `Bearer ${await accessToken()}` },
631
+ }),
632
+ ```
633
+
634
+ - Whether the app is out of sight, as `hidden`, and whether the reader is away
635
+ from a session, as `useAwayRecap`'s `presence` (`away`, and `watch`, which
636
+ calls `leave` and `back` as that changes), both read from the app's state.
637
+ - Images: `useComposerImages`' `encode`, which writes a picked image as base64
638
+ within `IMAGE_MAX_BYTES` and `IMAGE_MAX_SIDE` and throws
639
+ `PwCodeImageTooLarge` for one it cannot fit (`fitImageWith` works out the
640
+ sizes over the host's own `write`), and its `preview` and `release`. A
641
+ transcript names a full-size image by its path on the platform's API
642
+ (`sessionImageUrl`, and `markdownImageSources` for a GitHub attachment),
643
+ which the host loads from the platform's address, signed in as its API
644
+ client is.
645
+ - Preferences:
646
+ `pwCode.usePreference(startModePreference.key, startModePreference.fallback)`
647
+ keeps a choice in the reader's account, as every client does; a host that
648
+ keeps them itself passes its own `[value, set]` pair to the rules, to
649
+ `useSessionGroups`, and to `useSessionList` as `folded`, whose `set` takes
650
+ an update function.
651
+ - Navigation, through callbacks: `useStartSession`'s `onStarted`,
652
+ `useSessionActions`' `showStart` and `showSession`,
653
+ `usePwCodeConversation`'s `onCleared` and `onMoved`, `usePwCodeComposer`'s
654
+ `onCleared` and `onArchived`, `useSessionLink`'s `open`, `useSessionList`'s
655
+ `newSession`, `useModelPicker`'s `onAccounts`,
656
+ `useClaudeAccountPanel`'s `onClose` and `useDismissSubagent`'s `showMain`.
657
+ Of these, `usePwCodeComposer`'s `onCleared` and `onArchived` and
658
+ `useDismissSubagent`'s `showMain` are not called once the screen that asked
659
+ has closed, so an answer that comes late leaves the reader where they went.
660
+ - What the reader is told and asked: `describeError`, `notify`,
661
+ `useClaudeAccountPanel`'s `onMovedOthers`, and
662
+ `useSessionActions`' `confirm`; Claude Code's sign-in runs in the host's
663
+ terminal, `useClaudeSignIn`'s `terminal`.
664
+
665
+ The package is checked on the Hermes React Native 0.88.1 ships for iOS, with
666
+ this setup: it loads before any polyfill does, and once they have loaded its
667
+ functions, hooks and messages print what they print on the web, but for the
668
+ date differences above.
669
+
227
670
  ## No DOM
228
671
 
229
672
  The build imports `react`, `luxon`, `swr`, `use-intl`, `gemoji` (for the
230
- emoji shortcodes in a session's name), `@parallelworks/ui/ai/headless` and
231
- `@parallelworks/ui/headless`, and its declarations `openapi-fetch` too, and
232
- nothing else, so it loads where there
233
- is no DOM: a React Native bundle, a server, a test. It opens sockets only
234
- through the host's `openSocket`. The reducers need no React at all.
673
+ emoji shortcodes in a session's name), `@parallelworks/ui/ai/headless`,
674
+ `@parallelworks/ui/headless` and `@parallelworks/problem`, and its
675
+ declarations `openapi-fetch` too, and nothing else, so it loads where there is
676
+ no DOM: a React Native bundle, a server, a test. Nor does it use what Hermes
677
+ lacks, such as `URL.canParse`, `structuredClone` or `Intl.Segmenter`. It opens
678
+ sockets only through the host's `openSocket`. The reducers need no React at
679
+ all.
235
680
 
236
681
  ## Versions
237
682
 
238
683
  The wire types follow the pw code daemon. Before 1.0 a minor release can
239
684
  change them.
685
+
686
+ ### Breaking changes since 0.3.0
687
+
688
+ - `usePwCodeSubagent` takes `listed`, the subagent's switcher row
689
+ (`switcherAgent`), and `usage`, its tokens as the session's feed last
690
+ counted them, and no longer takes `name`: it names the subagent itself and
691
+ returns it as `agent`.
692
+ - `useSessionList`'s `folded` setter is handed an update function,
693
+ `(previous) => string[]`, in place of the new keys, so a store that has not
694
+ loaded them yet applies it to them rather than to its fallback. A
695
+ `[value, set]` pair from `useState` or `usePreference` takes it as it is.
696
+ - `useSessionList`'s `dropSession` leaves an archived session where it was,
697
+ and its `renameGroup` saves the name without the spaces around it, and
698
+ nothing for a blank one. The API's `useSessionPullRequestStates` takes the
699
+ links a session lists and returns the states of only the pull and merge
700
+ requests among them, leaving any other link out.
701
+ - `useClaudeAccountPanel` and `useClaudeSignIn` require a `machineName`
702
+ option, the machine's name as the reader knows it, which their words name
703
+ the machine by.
704
+ - `usePwCodeComposer`'s `images` option requires `restore` beside `take`
705
+ and `taking`, to put back the images of a message taken back.
706
+ `useComposerImages` returns it, so a host passing what that returns
707
+ changes nothing; one passing its own `{ take, taking }` adds it.
708
+ - Peer dependencies: `@parallelworks/problem` (`>=0.6.1 <1`) is new, and
709
+ `@parallelworks/ui` needs 0.136.0 or newer, up from 0.132.0.
710
+ - The host's API types must include eight more routes, which
711
+ `createPwCodeApi` now calls: `/api/allocations`, `/api/openai/v1/models`,
712
+ `/api/previews`, `/api/user/preferences`,
713
+ `/api/aichat/conversations/{id}`,
714
+ `/api/code/machines/{machine}/directories`,
715
+ `/api/code/machines/{machine}/sessions/{id}/direction/withdraw` and
716
+ `/api/code/machines/{machine}/sessions/{id}/subagents/{subId}/direction/withdraw`.
717
+ - `sessionSections`, `listGroups` and `inFlightFirst` take sessions with an
718
+ `id`, and list live sessions newest begun first (`createdAt`) rather than
719
+ newest updated, so a row holds still while its session works.
720
+ - `useCompactAgo` words its ages from the `agents` messages, not from
721
+ `@parallelworks/ui`'s `time` strings, and counts days past a year ("400d",
722
+ not "1y").
723
+ - `answerApproval` resolves to what was thrown when the request failed,
724
+ rather than rejecting.
725
+ - `useSessionMutations`' `pinSession`, `groupSession` and `restoreSession`
726
+ show the change in the list before the machine answers, and take it back if
727
+ it refuses.
728
+ - The main conversation's author has `kind: 'agent'`, so it is drawn as an
729
+ agent rather than a person.
730
+ - The approval messages in `agentTranscript` now read as ACTIVATE's AI chat
731
+ words them. In English and Spanish: `transcript.denyWithFeedback` ("No, and
732
+ tell the assistant why"), `transcript.feedbackPlaceholder`,
733
+ `transcript.feedbackLabel`, `transcript.allowedBy` ("{name} approved"),
734
+ `transcript.deniedBy` ("{name} denied"), `transcript.allowedByReviewer`
735
+ ("Auto-reviewer approved"), `transcript.deniedByReviewer`,
736
+ `transcript.reviewTimedOut` ("Auto-review timed out") and
737
+ `transcript.reviewFailed`. In Japanese, Korean and Chinese:
738
+ `transcript.denyWithFeedback`, `transcript.feedbackPlaceholder`,
739
+ `transcript.feedbackLabel`, `transcript.reviewTimedOut` and
740
+ `transcript.reviewFailed`, and also `transcript.allowCall`,
741
+ `transcript.denyCall`, `transcript.allowed`, `transcript.approvalLabel`,
742
+ `transcript.approvalAllowed`, `transcript.approvalDenied` and
743
+ `transcript.approvalWaitingOn` in Japanese, `transcript.allowCall`,
744
+ `transcript.denyCall`, `transcript.approvalDenied` and
745
+ `transcript.approvalWaitingOn` in Korean, and `transcript.approvalLabel` and
746
+ `transcript.approvalWaitingOn` in Chinese.
747
+ - `start.otherPath` is gone from the `agents` messages in every language,
748
+ since the start screen's path field now lists a machine's directories.
749
+ So are `claude.current`, `claude.fiveHour`, `claude.week`,
750
+ `sidebar.groupRunning`, `sidebar.groupWaiting`, `sidebar.moreOptions` and
751
+ `detail.loading`, which nothing in the package said.