paseo-office 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/OVERVIEW.md +27 -0
  2. package/README.md +65 -134
  3. package/client/action-button.tsx +4 -1
  4. package/client/activity-panel.tsx +6 -4
  5. package/client/agent-appearance.tsx +257 -0
  6. package/client/agent-card.tsx +2 -1
  7. package/client/agent-picker-text.ts +23 -4
  8. package/client/agent-picker.tsx +5 -8
  9. package/client/board-sheet.tsx +48 -16
  10. package/client/board-text.ts +12 -2
  11. package/client/brand.ts +1 -0
  12. package/client/chat-chrome.tsx +318 -0
  13. package/client/chat-compose-tools.tsx +314 -0
  14. package/client/chat-dictation.tsx +133 -0
  15. package/client/chat-more.tsx +119 -0
  16. package/client/chat-panel.tsx +401 -146
  17. package/client/chat-quick.tsx +198 -0
  18. package/client/chat-text.ts +25 -6
  19. package/client/column-sheet.tsx +93 -23
  20. package/client/conversation-model.ts +19 -5
  21. package/client/duty-sheet.tsx +321 -0
  22. package/client/duty-text.ts +20 -0
  23. package/client/fullscreen-header.tsx +28 -13
  24. package/client/fullscreen-theme.ts +38 -0
  25. package/client/host-details.tsx +269 -0
  26. package/client/host-styles.ts +129 -0
  27. package/client/host-switches.tsx +197 -73
  28. package/client/incidents-card.tsx +2 -1
  29. package/client/janitor-card.tsx +1 -1
  30. package/client/library-card.tsx +2 -1
  31. package/client/list-text.ts +8 -6
  32. package/client/lobby-board.tsx +73 -53
  33. package/client/machine-card.tsx +225 -85
  34. package/client/messenger-styles.ts +216 -0
  35. package/client/new-agent-form.tsx +153 -61
  36. package/client/new-agent-model.ts +2 -0
  37. package/client/notes-card.tsx +111 -83
  38. package/client/notes-days.tsx +1 -1
  39. package/client/office-brand-context.ts +44 -0
  40. package/client/office-column.tsx +2 -1
  41. package/client/office-keyboard.ts +79 -0
  42. package/client/office-link.ts +7 -1
  43. package/client/office-mark.tsx +29 -0
  44. package/client/office-modal.tsx +440 -0
  45. package/client/office-settings.tsx +75 -30
  46. package/client/office-state.ts +12 -2
  47. package/client/office-surface.tsx +591 -81
  48. package/client/pixel/actors.ts +2 -1
  49. package/client/pixel/art.ts +33 -19
  50. package/client/pixel/pixel-office.tsx +2 -2
  51. package/client/prompt-coach.tsx +152 -0
  52. package/client/qa-card.tsx +2 -1
  53. package/client/review-card.tsx +2 -1
  54. package/client/room-board.tsx +26 -2
  55. package/client/scene-picker.tsx +158 -0
  56. package/client/scene-previews.ts +10 -0
  57. package/client/session-pane.tsx +25 -5
  58. package/client/session-panel-detail.tsx +238 -0
  59. package/client/session-panel.tsx +222 -137
  60. package/client/session-styles.ts +224 -1
  61. package/client/session-transcript.tsx +243 -0
  62. package/client/sessions-panel.tsx +181 -22
  63. package/client/sessions-text.ts +18 -0
  64. package/client/settings-sections.tsx +126 -0
  65. package/client/sidebar-launcher.ts +29 -0
  66. package/client/ssh-hosts.tsx +331 -0
  67. package/client/ssh-metrics.ts +76 -0
  68. package/client/standup-card.tsx +2 -1
  69. package/client/structure-view.tsx +20 -3
  70. package/client/styles.ts +170 -62
  71. package/client/team-chat-preview.tsx +96 -0
  72. package/client/transcript-styles.ts +90 -0
  73. package/client/use-device-switch.ts +21 -12
  74. package/client/use-duty-actions.ts +43 -0
  75. package/client/use-group-photo.ts +48 -0
  76. package/client/use-new-agent.ts +4 -0
  77. package/client/use-street.ts +8 -0
  78. package/client/workspace-office-tools.tsx +102 -0
  79. package/client/workspace-overlay-route.web.ts +47 -0
  80. package/client/workspace-overlay.tsx +195 -0
  81. package/client/world/adapter.ts +37 -2
  82. package/client/world/escape.ts +58 -0
  83. package/client/world/use-world-feed.ts +6 -2
  84. package/client/world/workspace-dock.ts +6 -0
  85. package/client/world/world-api.ts +45 -4
  86. package/client/world/world-bridge-page.ts +14 -3
  87. package/client/world/world-bridge.ts +50 -5
  88. package/client/world/world-frame.web.ts +8 -0
  89. package/client/world/world-view-native.tsx +31 -10
  90. package/client/world/world-view-shared.ts +36 -7
  91. package/client/world/world-view.tsx +93 -21
  92. package/docs/office.md +148 -58
  93. package/index.client.tsx +13 -6
  94. package/index.server.ts +125 -9
  95. package/package.json +2 -1
  96. package/server/activity.ts +42 -19
  97. package/server/agent-tools.ts +11 -5
  98. package/server/board-service.ts +381 -10
  99. package/server/brand-logo.ts +34 -0
  100. package/server/chat-group.ts +83 -0
  101. package/server/chat-service.ts +406 -62
  102. package/server/chat-store.ts +1 -4
  103. package/server/directory.ts +22 -7
  104. package/server/duty-service.ts +230 -0
  105. package/server/group-photo.ts +39 -0
  106. package/server/home-departure.ts +47 -0
  107. package/server/hub.ts +43 -1
  108. package/server/live-ports.ts +114 -18
  109. package/server/lobby-pickup.ts +170 -0
  110. package/server/machine/details.ts +91 -0
  111. package/server/mention-queue.ts +14 -0
  112. package/server/office.ts +110 -6
  113. package/server/paths.ts +9 -0
  114. package/server/ssh/LICENSE.paseo +211 -0
  115. package/server/ssh/client.ts +401 -0
  116. package/server/ssh/discovery.ts +230 -0
  117. package/server/ssh/installed.ts +104 -0
  118. package/server/ssh/monitor.ts +104 -0
  119. package/server/ssh/pid-files.ts +194 -0
  120. package/server/ssh/read.ts +136 -0
  121. package/server/subagent-names.ts +4 -0
  122. package/server/words.generated.ts +1 -1
  123. package/server/world.generated.ts +1 -1
  124. package/shared/appearance.ts +43 -0
  125. package/shared/branding.ts +53 -0
  126. package/shared/chat-words.ts +2 -2
  127. package/shared/contracts.ts +135 -4
  128. package/shared/duties.ts +100 -0
  129. package/shared/host-details.ts +25 -0
  130. package/shared/lobby-assignment.ts +34 -0
  131. package/shared/model.ts +9 -1
  132. package/shared/names.ts +2 -0
  133. package/shared/settings.ts +14 -3
  134. package/shared/ssh.ts +34 -0
  135. package/shared/upstream/README.md +1 -3
  136. package/shared/upstream/chat-engine.d.ts +4 -0
  137. package/shared/upstream/prompt-coach.d.ts +6 -0
  138. package/shared/upstream/prompt-coach.js +178 -0
@@ -0,0 +1,314 @@
1
+ import { useCallback, useEffect, useRef, useState, type ChangeEvent } from "react";
2
+ import { Text, View } from "react-native";
3
+ import { TextInput, ScrollView } from "@getpaseo/plugin/client/ui";
4
+ import { CHAT_IMAGE_CHARS, CHAT_IMAGE_LIMIT, type ChatRequest } from "../shared/contracts.js";
5
+ import type { ChatDraft } from "./office-link.js";
6
+ import type { OfficeStyles } from "./styles.js";
7
+ import { ActionButton, failureText } from "./action-button.js";
8
+ import type { MentionOption } from "./chat-text.js";
9
+ import { ChatMore, type ChatShortcuts } from "./chat-more.js";
10
+ import { ChatIcon, ToField } from "./chat-chrome.js";
11
+
12
+ function PollForm({
13
+ run,
14
+ onClose,
15
+ styles,
16
+ }: {
17
+ run(request: ChatRequest): Promise<boolean>;
18
+ onClose(): void;
19
+ styles: OfficeStyles;
20
+ }) {
21
+ const [question, setQuestion] = useState(""),
22
+ [choices, setChoices] = useState("");
23
+ const options = choices
24
+ .split("\n")
25
+ .map((option) => option.trim())
26
+ .filter(Boolean);
27
+ const valid =
28
+ question.trim() !== "" &&
29
+ options.length >= 2 &&
30
+ options.length <= 6 &&
31
+ options.every((o) => o.length <= 60);
32
+ const create = useCallback(async () => {
33
+ if (
34
+ await run({
35
+ op: "poll",
36
+ question: question.trim(),
37
+ options: choices
38
+ .split("\n")
39
+ .map((option) => option.trim())
40
+ .filter(Boolean),
41
+ })
42
+ )
43
+ onClose();
44
+ }, [run, question, choices, onClose]);
45
+ return (
46
+ <ScrollView
47
+ style={styles.messenger.pollScroll}
48
+ keyboardShouldPersistTaps="handled"
49
+ contentContainerStyle={styles.sheetField}
50
+ >
51
+ <Text accessibilityRole="header" style={styles.chatName}>
52
+ New poll
53
+ </Text>
54
+ <TextInput
55
+ accessibilityLabel="Poll question"
56
+ placeholder="Ask a question"
57
+ placeholderTextColor={styles.placeholderColor}
58
+ value={question}
59
+ onChangeText={setQuestion}
60
+ maxLength={120}
61
+ style={styles.fieldInput}
62
+ />
63
+ <TextInput
64
+ accessibilityLabel="Poll choices"
65
+ placeholder="2–6 options, one per line"
66
+ placeholderTextColor={styles.placeholderColor}
67
+ multiline
68
+ value={choices}
69
+ onChangeText={setChoices}
70
+ maxLength={365}
71
+ style={styles.fieldInput}
72
+ />
73
+ <View style={styles.actions}>
74
+ <ActionButton
75
+ label="Post poll"
76
+ pendingLabel="Posting…"
77
+ onPress={create}
78
+ disabled={!valid}
79
+ primary
80
+ styles={styles}
81
+ />
82
+ <ActionButton
83
+ label="Cancel poll"
84
+ pendingLabel="Cancel poll"
85
+ onPress={onClose}
86
+ styles={styles}
87
+ />
88
+ </View>
89
+ </ScrollView>
90
+ );
91
+ }
92
+
93
+ /** Resize photos before sending. Only the selected session receives the image bytes. */
94
+ let imageId = 0;
95
+ async function readImage(file: File): Promise<ChatDraft["images"][number]> {
96
+ const bitmap = await createImageBitmap(file);
97
+ try {
98
+ const canvas = document.createElement("canvas");
99
+ const scale = Math.min(1, 1600 / Math.max(bitmap.width, bitmap.height));
100
+ canvas.width = Math.max(1, Math.round(bitmap.width * scale));
101
+ canvas.height = Math.max(1, Math.round(bitmap.height * scale));
102
+ const ctx = canvas.getContext("2d");
103
+ if (!ctx) throw new Error("The browser could not read this image.");
104
+ ctx.fillStyle = "#fff";
105
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
106
+ ctx.drawImage(bitmap, 0, 0, canvas.width, canvas.height);
107
+ let url = canvas.toDataURL("image/jpeg", 0.82);
108
+ if (url.length > 480000) url = canvas.toDataURL("image/jpeg", 0.6);
109
+ const data = url.slice(url.indexOf(",") + 1);
110
+ if (!url.startsWith("data:image/jpeg;base64,") || data.length > CHAT_IMAGE_CHARS)
111
+ throw new Error("The image is too large. Choose a smaller image.");
112
+ return { id: ++imageId, name: file.name, mimeType: "image/jpeg", data };
113
+ } finally {
114
+ bitmap.close();
115
+ }
116
+ }
117
+
118
+ function ImagePicker({
119
+ draft,
120
+ styles,
121
+ onReading,
122
+ }: {
123
+ draft: ChatDraft;
124
+ styles: OfficeStyles;
125
+ onReading(value: boolean): void;
126
+ }) {
127
+ const ref = useRef<HTMLInputElement>(null);
128
+ const mounted = useRef(true);
129
+ const loading = useRef(false);
130
+ useEffect(() => {
131
+ mounted.current = true;
132
+ return () => {
133
+ mounted.current = false;
134
+ onReading(false);
135
+ };
136
+ }, [onReading]);
137
+ const [error, setError] = useState<string | null>(null);
138
+ const open = useCallback(() => ref.current?.click(), []);
139
+ const { images, setImages } = draft;
140
+ const pick = useCallback(
141
+ async (event: ChangeEvent<HTMLInputElement>) => {
142
+ const files = Array.from(event.currentTarget.files ?? []);
143
+ event.currentTarget.value = "";
144
+ if (files.length > CHAT_IMAGE_LIMIT - images.length) {
145
+ setError("Choose up to four images.");
146
+ return;
147
+ }
148
+ if (loading.current) return;
149
+ loading.current = true;
150
+ onReading(true);
151
+ try {
152
+ const additions = await Promise.all(files.map(readImage));
153
+ if (!mounted.current) return;
154
+ setImages((previous) => [...previous, ...additions].slice(0, CHAT_IMAGE_LIMIT));
155
+ setError(null);
156
+ } catch (caught) {
157
+ if (mounted.current) setError(failureText("Attach image", caught));
158
+ } finally {
159
+ loading.current = false;
160
+ if (mounted.current) onReading(false);
161
+ }
162
+ },
163
+ [images.length, setImages, onReading],
164
+ );
165
+ return (
166
+ <>
167
+ <input
168
+ type="file"
169
+ ref={ref}
170
+ multiple
171
+ accept="image/*"
172
+ hidden
173
+ onChange={pick}
174
+ aria-label="Choose images"
175
+ />
176
+ <ChatIcon name="ImagePlus" label="Attach images" onPress={open} styles={styles} />
177
+ {error && (
178
+ <Text accessibilityRole="alert" style={styles.actionError}>
179
+ {error}
180
+ </Text>
181
+ )}
182
+ </>
183
+ );
184
+ }
185
+
186
+ function ImageDrafts({ draft, styles }: { draft: ChatDraft; styles: OfficeStyles }) {
187
+ return (
188
+ <View style={styles.chatReactions}>
189
+ {draft.images.map((image) => (
190
+ <ImagePreview key={image.id} image={image} setImages={draft.setImages} styles={styles} />
191
+ ))}
192
+ </View>
193
+ );
194
+ }
195
+ function ImagePreview({
196
+ image,
197
+ setImages,
198
+ styles,
199
+ }: {
200
+ image: ChatDraft["images"][number];
201
+ setImages: ChatDraft["setImages"];
202
+ styles: OfficeStyles;
203
+ }) {
204
+ const remove = useCallback(
205
+ () => setImages((items) => items.filter((item) => item !== image)),
206
+ [setImages, image],
207
+ );
208
+ return (
209
+ <View style={styles.messenger.preview}>
210
+ <img
211
+ alt={image.name}
212
+ width={40}
213
+ height={40}
214
+ src={`data:image/jpeg;base64,${image.data}`}
215
+ style={previewStyle}
216
+ />
217
+ <ChatIcon name="X" label={`Remove ${image.name}`} onPress={remove} styles={styles} />
218
+ </View>
219
+ );
220
+ }
221
+ const previewStyle = { objectFit: "cover", borderRadius: 6 } as const;
222
+
223
+ export function ComposeTools({
224
+ draft,
225
+ members,
226
+ web,
227
+ run,
228
+ styles,
229
+ setReading,
230
+ insertMention,
231
+ stickersOpen,
232
+ toggleStickers,
233
+ onUse,
234
+ openSession,
235
+ onBoard,
236
+ onDuties,
237
+ onNewAgent,
238
+ onGroupPhoto,
239
+ }: ChatShortcuts & {
240
+ onUse(message: string): void;
241
+ openSession(id: string): void;
242
+ draft: ChatDraft;
243
+ members: readonly MentionOption[];
244
+ web: boolean;
245
+ run(request: ChatRequest): Promise<boolean>;
246
+ styles: OfficeStyles;
247
+ setReading(value: boolean): void;
248
+ insertMention(): void;
249
+ stickersOpen: boolean;
250
+ toggleStickers(): void;
251
+ }) {
252
+ const { recipient, setRecipient } = draft;
253
+ const [panel, setPanel] = useState<"more" | "poll" | null>(null);
254
+ const pollOpen = panel === "poll";
255
+ const togglePoll = useCallback(() => setPanel((p) => (p === "poll" ? null : "poll")), []);
256
+ const toggleMore = useCallback(() => setPanel((p) => (p === "more" ? null : "more")), []);
257
+ const close = useCallback(() => setPanel(null), []);
258
+ return (
259
+ <>
260
+ <ToField
261
+ openSession={openSession}
262
+ members={members}
263
+ value={recipient}
264
+ onPick={setRecipient}
265
+ styles={styles}
266
+ />
267
+ <View style={styles.messenger.toolbar}>
268
+ <ChatIcon
269
+ name="Smile"
270
+ label="Stickers"
271
+ active={stickersOpen}
272
+ onPress={toggleStickers}
273
+ styles={styles}
274
+ />
275
+ <ChatIcon
276
+ name="ChartNoAxesColumnIncreasing"
277
+ label="Create poll"
278
+ active={pollOpen}
279
+ onPress={togglePoll}
280
+ styles={styles}
281
+ />
282
+ <ChatIcon name="AtSign" label="Mention someone" onPress={insertMention} styles={styles} />
283
+ {web && recipient && (
284
+ <ImagePicker key={recipient} draft={draft} styles={styles} onReading={setReading} />
285
+ )}
286
+ <ChatIcon
287
+ name="Ellipsis"
288
+ label="More chat actions"
289
+ active={panel === "more"}
290
+ onPress={toggleMore}
291
+ styles={styles}
292
+ />
293
+ </View>
294
+ {panel === "more" && (
295
+ <ChatMore
296
+ draft={draft}
297
+ web={web}
298
+ onUse={onUse}
299
+ onClose={close}
300
+ styles={styles}
301
+ onBoard={onBoard}
302
+ onDuties={onDuties}
303
+ onNewAgent={onNewAgent}
304
+ onGroupPhoto={onGroupPhoto}
305
+ />
306
+ )}
307
+ {pollOpen && <PollForm run={run} onClose={close} styles={styles} />}
308
+ {draft.images.length > 0 && <ImageDrafts draft={draft} styles={styles} />}
309
+ {draft.images.length > 0 && !recipient && (
310
+ <Text style={styles.chatMeta}>Choose a session for the attached images.</Text>
311
+ )}
312
+ </>
313
+ );
314
+ }
@@ -0,0 +1,133 @@
1
+ import { useCallback, useEffect, useRef, useState } from "react";
2
+ import { Text } from "react-native";
3
+ import { CHAT_TEXT_MAX } from "../shared/contracts.js";
4
+ import type { ChatDraft } from "./office-link.js";
5
+ import type { OfficeStyles } from "./styles.js";
6
+ import { ActionButton } from "./action-button.js";
7
+
8
+ /** Only the Web Speech API surface used by the composer. Safari exposes the prefixed constructor. */
9
+ interface SpeechEvents {
10
+ result: {
11
+ resultIndex: number;
12
+ results: ArrayLike<{ isFinal: boolean; 0: { transcript: string } }>;
13
+ };
14
+ error: { error: string };
15
+ end: Event;
16
+ }
17
+ interface Recognition {
18
+ lang: string;
19
+ continuous: boolean;
20
+ interimResults: boolean;
21
+ addEventListener<T extends keyof SpeechEvents>(
22
+ type: T,
23
+ listener: (event: SpeechEvents[T]) => void,
24
+ options: { signal: AbortSignal },
25
+ ): void;
26
+ start(): void;
27
+ stop(): void;
28
+ abort(): void;
29
+ }
30
+ type SpeechConstructor = new () => Recognition;
31
+ function speechConstructor(): SpeechConstructor | undefined {
32
+ if (typeof window === "undefined") return undefined;
33
+ const api = window as Window & {
34
+ SpeechRecognition?: SpeechConstructor;
35
+ webkitSpeechRecognition?: SpeechConstructor;
36
+ };
37
+ return api.SpeechRecognition ?? api.webkitSpeechRecognition;
38
+ }
39
+
40
+ export function Dictation({
41
+ setText,
42
+ styles,
43
+ }: {
44
+ setText: ChatDraft["setText"];
45
+ styles: OfficeStyles;
46
+ }) {
47
+ const [listening, setListening] = useState(false);
48
+ const [error, setError] = useState("");
49
+ const current = useRef<{ voice: Recognition; listeners: AbortController } | null>(null);
50
+ useEffect(
51
+ () => () => {
52
+ const active = current.current;
53
+ if (active) {
54
+ active.listeners.abort();
55
+ active.voice.abort();
56
+ }
57
+ },
58
+ [],
59
+ );
60
+ const toggle = useCallback(() => {
61
+ if (current.current) {
62
+ current.current.voice.stop();
63
+ return;
64
+ }
65
+ const Speech = speechConstructor();
66
+ if (!Speech) return;
67
+ const voice = new Speech();
68
+ voice.lang = document.documentElement.lang || navigator.language;
69
+ voice.continuous = true;
70
+ voice.interimResults = false;
71
+ let consumed = 0;
72
+ const listeners = new AbortController();
73
+ const options = { signal: listeners.signal };
74
+ voice.addEventListener(
75
+ "result",
76
+ ({ resultIndex, results }) => {
77
+ const words = [];
78
+ for (let n = Math.max(resultIndex, consumed); n < results.length; n++) {
79
+ if (results[n].isFinal) {
80
+ words.push(results[n][0].transcript);
81
+ consumed = n + 1;
82
+ }
83
+ }
84
+ const phrase = words.join(" ").trim();
85
+ if (phrase)
86
+ setText((previous) =>
87
+ (previous.trimEnd() + " " + phrase).trimStart().slice(0, CHAT_TEXT_MAX),
88
+ );
89
+ },
90
+ options,
91
+ );
92
+ const finish = () => {
93
+ listeners.abort();
94
+ current.current = null;
95
+ setListening(false);
96
+ };
97
+ voice.addEventListener("end", finish, options);
98
+ voice.addEventListener(
99
+ "error",
100
+ ({ error: why }) => {
101
+ if (why !== "aborted")
102
+ setError(
103
+ why === "not-allowed"
104
+ ? "Allow microphone access in your browser to dictate."
105
+ : "Dictation stopped. Check your microphone and try again.",
106
+ );
107
+ finish();
108
+ },
109
+ options,
110
+ );
111
+ current.current = { voice, listeners };
112
+ setError("");
113
+ try {
114
+ voice.start();
115
+ setListening(true);
116
+ } catch {
117
+ finish();
118
+ setError("Your browser could not start dictation.");
119
+ }
120
+ }, [setText]);
121
+ if (!speechConstructor()) return null;
122
+ const label = listening ? "Stop dictation" : "Dictate message";
123
+ return (
124
+ <>
125
+ <ActionButton label={label} pendingLabel={label} onPress={toggle} styles={styles} />
126
+ {error && (
127
+ <Text accessibilityRole="alert" style={styles.actionError}>
128
+ {error}
129
+ </Text>
130
+ )}
131
+ </>
132
+ );
133
+ }
@@ -0,0 +1,119 @@
1
+ import { useCallback, useState } from "react";
2
+ import { Text, View } from "react-native";
3
+ import { ActionButton } from "./action-button.js";
4
+ import { ChatIcon } from "./chat-chrome.js";
5
+ import { Dictation } from "./chat-dictation.js";
6
+ import { QuickMessages } from "./chat-quick.js";
7
+ import type { ChatDraft } from "./office-link.js";
8
+ import type { OfficeStyles } from "./styles.js";
9
+
10
+ export interface ChatShortcuts {
11
+ onBoard?(): void;
12
+ onDuties?(): void;
13
+ onNewAgent?(): void;
14
+ onGroupPhoto?(): Promise<void>;
15
+ }
16
+
17
+ export function ChatMore({
18
+ draft,
19
+ web,
20
+ styles,
21
+ onClose,
22
+ onBoard,
23
+ onDuties,
24
+ onNewAgent,
25
+ onGroupPhoto,
26
+ onUse,
27
+ }: ChatShortcuts & {
28
+ draft: ChatDraft;
29
+ web: boolean;
30
+ styles: OfficeStyles;
31
+ onClose(): void;
32
+ onUse(prompt: string): void;
33
+ }) {
34
+ const [quick, setQuick] = useState(false);
35
+ const toggle = useCallback(() => setQuick((value) => !value), []);
36
+ const board = useCallback(() => {
37
+ onClose();
38
+ onBoard?.();
39
+ }, [onClose, onBoard]);
40
+ const dutyBoard = useCallback(() => {
41
+ onClose();
42
+ onDuties?.();
43
+ }, [onClose, onDuties]);
44
+ const newAgent = useCallback(() => {
45
+ onClose();
46
+ onNewAgent?.();
47
+ }, [onClose, onNewAgent]);
48
+ const photo = useCallback(async () => {
49
+ await onGroupPhoto?.();
50
+ onClose();
51
+ }, [onClose, onGroupPhoto]);
52
+ const pick = useCallback(
53
+ (text: string) => {
54
+ onClose();
55
+ onUse(text);
56
+ },
57
+ [onClose, onUse],
58
+ );
59
+ return (
60
+ <View style={styles.messenger.morePanel}>
61
+ <View style={styles.messenger.quickRow}>
62
+ <Text accessibilityRole="header" style={styles.messenger.sectionTitle}>
63
+ {quick ? "Quick messages" : "More actions"}
64
+ </Text>
65
+ <ChatIcon
66
+ label={quick ? "Back to chat actions" : "Close chat actions"}
67
+ name={quick ? "ArrowLeft" : "X"}
68
+ onPress={quick ? toggle : onClose}
69
+ styles={styles}
70
+ />
71
+ </View>
72
+ {quick ? (
73
+ <QuickMessages text={draft.text} onUse={pick} styles={styles} />
74
+ ) : (
75
+ <View style={styles.messenger.toolbar}>
76
+ <ActionButton
77
+ label="Quick messages"
78
+ pendingLabel="Quick messages"
79
+ onPress={toggle}
80
+ styles={styles}
81
+ />
82
+ {onBoard && (
83
+ <ActionButton
84
+ label="Lobby board"
85
+ pendingLabel="Lobby board"
86
+ onPress={board}
87
+ styles={styles}
88
+ />
89
+ )}
90
+ {onDuties && (
91
+ <ActionButton
92
+ label="Duty board"
93
+ pendingLabel="Duty board"
94
+ onPress={dutyBoard}
95
+ styles={styles}
96
+ />
97
+ )}
98
+ {onNewAgent && (
99
+ <ActionButton
100
+ label="New agent"
101
+ pendingLabel="New agent"
102
+ onPress={newAgent}
103
+ styles={styles}
104
+ />
105
+ )}
106
+ {onGroupPhoto && (
107
+ <ActionButton
108
+ label="Take office photo"
109
+ pendingLabel="Taking photo…"
110
+ onPress={photo}
111
+ styles={styles}
112
+ />
113
+ )}
114
+ {web && <Dictation setText={draft.setText} styles={styles} />}
115
+ </View>
116
+ )}
117
+ </View>
118
+ );
119
+ }