paseo-office 0.2.0 → 0.2.2

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 (143) 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 +212 -83
  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/tracker-connections.tsx +252 -0
  73. package/client/transcript-styles.ts +90 -0
  74. package/client/use-device-switch.ts +21 -12
  75. package/client/use-duty-actions.ts +43 -0
  76. package/client/use-group-photo.ts +48 -0
  77. package/client/use-new-agent.ts +4 -0
  78. package/client/use-street.ts +8 -0
  79. package/client/workspace-office-tools.tsx +102 -0
  80. package/client/workspace-overlay-route.web.ts +47 -0
  81. package/client/workspace-overlay.tsx +195 -0
  82. package/client/world/adapter.ts +37 -2
  83. package/client/world/escape.ts +58 -0
  84. package/client/world/use-world-feed.ts +6 -2
  85. package/client/world/workspace-dock.ts +6 -0
  86. package/client/world/world-api.ts +45 -4
  87. package/client/world/world-bridge-page.ts +14 -3
  88. package/client/world/world-bridge.ts +50 -5
  89. package/client/world/world-frame.web.ts +8 -0
  90. package/client/world/world-view-native.tsx +31 -10
  91. package/client/world/world-view-shared.ts +36 -7
  92. package/client/world/world-view.tsx +93 -21
  93. package/docs/office.md +165 -64
  94. package/index.client.tsx +13 -6
  95. package/index.server.ts +232 -16
  96. package/package.json +2 -1
  97. package/server/activity.ts +42 -19
  98. package/server/agent-tools.ts +11 -5
  99. package/server/board-service.ts +381 -10
  100. package/server/brand-logo.ts +34 -0
  101. package/server/chat-group.ts +83 -0
  102. package/server/chat-service.ts +406 -62
  103. package/server/chat-store.ts +1 -4
  104. package/server/directory.ts +22 -7
  105. package/server/duty-service.ts +230 -0
  106. package/server/group-photo.ts +39 -0
  107. package/server/home-departure.ts +47 -0
  108. package/server/hub.ts +43 -1
  109. package/server/incidents-jira.ts +19 -7
  110. package/server/incidents-schedule.ts +10 -10
  111. package/server/incidents-sentry.ts +34 -8
  112. package/server/live-ports.ts +114 -18
  113. package/server/lobby-pickup.ts +170 -0
  114. package/server/machine/details.ts +91 -0
  115. package/server/mention-queue.ts +14 -0
  116. package/server/office.ts +110 -6
  117. package/server/paths.ts +14 -0
  118. package/server/ssh/LICENSE.paseo +211 -0
  119. package/server/ssh/client.ts +401 -0
  120. package/server/ssh/discovery.ts +230 -0
  121. package/server/ssh/installed.ts +104 -0
  122. package/server/ssh/monitor.ts +104 -0
  123. package/server/ssh/pid-files.ts +194 -0
  124. package/server/ssh/read.ts +136 -0
  125. package/server/subagent-names.ts +4 -0
  126. package/server/tracker-credentials.ts +141 -0
  127. package/server/words.generated.ts +1 -1
  128. package/server/world.generated.ts +1 -1
  129. package/shared/appearance.ts +43 -0
  130. package/shared/branding.ts +53 -0
  131. package/shared/chat-words.ts +2 -2
  132. package/shared/contracts.ts +199 -5
  133. package/shared/duties.ts +100 -0
  134. package/shared/host-details.ts +25 -0
  135. package/shared/lobby-assignment.ts +34 -0
  136. package/shared/model.ts +9 -1
  137. package/shared/names.ts +2 -0
  138. package/shared/settings.ts +14 -3
  139. package/shared/ssh.ts +34 -0
  140. package/shared/upstream/README.md +1 -3
  141. package/shared/upstream/chat-engine.d.ts +4 -0
  142. package/shared/upstream/prompt-coach.d.ts +6 -0
  143. package/shared/upstream/prompt-coach.js +178 -0
@@ -1,11 +1,18 @@
1
1
  import { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
2
2
  import { Pressable, Text, View } from "react-native";
3
- import { Icon, Modal, TextInput } from "@getpaseo/plugin/client/ui";
4
- import { POST_TEXT_MAX, type Post, type PostKind } from "../shared/contracts.js";
3
+ import { Icon, TextInput } from "@getpaseo/plugin/client/ui";
4
+ import { OfficeModal as Modal } from "./office-modal.js";
5
+ import { LOBBY, POST_TEXT_MAX, type Post, type PostKind } from "../shared/contracts.js";
5
6
  import { ActionButton } from "./action-button.js";
6
7
  import { textAfterSend } from "./agent-card.js";
7
8
  import { AgentPicker } from "./agent-picker.js";
8
- import { NOBODY, choiceLabel, closeStep, keptChoice } from "./agent-picker-text.js";
9
+ import {
10
+ NOBODY,
11
+ choiceLabel,
12
+ closeStep,
13
+ keptChoice,
14
+ recipientLabels,
15
+ } from "./agent-picker-text.js";
9
16
  import { orderBoardPosts } from "./board-text.js";
10
17
  import type { AgentTaskGroup, OfficeRoom } from "../shared/model.js";
11
18
  import { LobbyBody } from "./lobby-board.js";
@@ -51,7 +58,11 @@ interface PostActionsProps {
51
58
  }
52
59
 
53
60
  export function PostWithActions({ post, name, actions, styles }: PostActionsProps) {
54
- const done = useCallback(() => actions.markDone(post.id), [actions, post.id]);
61
+ const finished = post.state === "done";
62
+ const toggleDone = useCallback(
63
+ () => (finished ? actions.reopen(post.id) : actions.markDone(post.id)),
64
+ [actions, finished, post.id],
65
+ );
55
66
  const remove = useCallback(() => actions.remove(post.id), [actions, post.id]);
56
67
  // A deleted post is gone for good, so Delete asks once more. The question moves the buttons
57
68
  // down a line: a second tap in the same place lands on the words, not on a button.
@@ -78,9 +89,9 @@ export function PostWithActions({ post, name, actions, styles }: PostActionsProp
78
89
  <View style={styles.actions}>
79
90
  {post.kind === "task" ? (
80
91
  <ActionButton
81
- label="Mark done"
92
+ label={finished ? "Reopen" : "Mark done"}
82
93
  pendingLabel="Saving..."
83
- onPress={done}
94
+ onPress={toggleDone}
84
95
  styles={styles}
85
96
  />
86
97
  ) : null}
@@ -102,12 +113,13 @@ interface ChoiceFieldProps {
102
113
  label: string;
103
114
  /** The choice now. */
104
115
  value: string;
116
+ inline: boolean;
105
117
  onOpen(): void;
106
118
  styles: OfficeStyles;
107
119
  }
108
120
 
109
121
  /** A form's row that opens a page: what it chooses, the choice, and a chevron. */
110
- function ChoiceField({ id, label, value, onOpen, styles }: ChoiceFieldProps) {
122
+ function ChoiceField({ id, label, value, inline, onOpen, styles }: ChoiceFieldProps) {
111
123
  const [hovered, setHovered] = useState(false);
112
124
  const hoverIn = useCallback(() => setHovered(true), []);
113
125
  const hoverOut = useCallback(() => setHovered(false), []);
@@ -125,10 +137,11 @@ function ChoiceField({ id, label, value, onOpen, styles }: ChoiceFieldProps) {
125
137
  onPressOut={pressOut}
126
138
  onHoverIn={hoverIn}
127
139
  onHoverOut={hoverOut}
128
- style={styles.pickerField}
140
+ style={inline ? styles.lobbyRecipient : styles.pickerField}
129
141
  >
130
142
  {lit ? <View style={styles.pressedFill} /> : null}
131
- <View style={styles.pickerFieldBody}>
143
+ {inline ? <Icon name="UserRound" size={14} color={styles.iconColor} /> : null}
144
+ <View style={inline ? styles.lobbyTaskLine : styles.pickerFieldBody}>
132
145
  <Text style={styles.rowMeta} numberOfLines={1}>
133
146
  {label}
134
147
  </Text>
@@ -136,7 +149,7 @@ function ChoiceField({ id, label, value, onOpen, styles }: ChoiceFieldProps) {
136
149
  {value}
137
150
  </Text>
138
151
  </View>
139
- <Icon name="ChevronRight" size={16} color={styles.iconColor} />
152
+ <Icon name={inline ? "ChevronDown" : "ChevronRight"} size={16} color={styles.iconColor} />
140
153
  </Pressable>
141
154
  );
142
155
  }
@@ -186,6 +199,7 @@ export function useWakeChoice({ rooms, picking, onPicking }: WakeChoiceInput): W
186
199
 
187
200
  interface WakeFieldProps {
188
201
  id: string;
202
+ roomId: string;
189
203
  to: string;
190
204
  rooms: readonly OfficeRoom[];
191
205
  wakesPaused: boolean;
@@ -194,19 +208,24 @@ interface WakeFieldProps {
194
208
  }
195
209
 
196
210
  /** The form's row that opens the page, and while wakes are off, that the agent waits. */
197
- export function WakeField({ id, to, rooms, wakesPaused, onOpen, styles }: WakeFieldProps) {
211
+ export function WakeField({ id, roomId, to, rooms, wakesPaused, onOpen, styles }: WakeFieldProps) {
212
+ const labels = recipientLabels(roomId);
213
+ const paused = wakesPaused && (roomId === LOBBY || to !== NOBODY);
198
214
  return (
199
215
  <View style={styles.sheetField}>
200
216
  <ChoiceField
201
217
  id={id}
202
- label="Wake an agent with it"
203
- value={choiceLabel(to, rooms)}
218
+ label={labels.field}
219
+ value={choiceLabel(to, rooms, labels.defaultChoice)}
220
+ inline={roomId === LOBBY}
204
221
  onOpen={onOpen}
205
222
  styles={styles}
206
223
  />
207
- {to !== NOBODY && wakesPaused ? (
224
+ {paused ? (
208
225
  <Text style={styles.muted}>
209
- Wake agents is off. The agent gets this post when you turn it on.
226
+ {to === NOBODY
227
+ ? "Automatic pickup resumes when you turn on Wake agents."
228
+ : "Wake agents is off. The agent gets this post when you turn it on."}
210
229
  </Text>
211
230
  ) : null}
212
231
  </View>
@@ -300,6 +319,7 @@ function SheetBody({
300
319
  </View>
301
320
  <WakeField
302
321
  id={fieldId}
322
+ roomId={room.id}
303
323
  to={to}
304
324
  rooms={rooms}
305
325
  wakesPaused={wakesPaused}
@@ -383,8 +403,20 @@ export function BoardSheet({
383
403
  [sheetLeavesFirst, onClose, picking],
384
404
  );
385
405
  const board = room ? `${room.name} board` : "Board";
406
+ const pickerTitle = room?.lobby ? "Send task to" : "Wake an agent";
407
+ const icon = useMemo(
408
+ () => (
409
+ <Icon name={picking ? "UsersRound" : "ClipboardList"} size={18} color={styles.iconColor} />
410
+ ),
411
+ [picking, styles.iconColor],
412
+ );
386
413
  return (
387
- <Modal title={picking ? "Wake an agent" : board} open={room !== null} onOpenChange={change}>
414
+ <Modal
415
+ title={picking ? pickerTitle : board}
416
+ icon={icon}
417
+ open={room !== null}
418
+ onOpenChange={change}
419
+ >
388
420
  <Modal.Content>
389
421
  {room?.lobby ? (
390
422
  <LobbyBody
@@ -1,5 +1,5 @@
1
1
  import type { ChecklistStep, OfficeAgent, Post, WakeState } from "../shared/contracts.js";
2
- import { USER_AUTHOR } from "../shared/names.js";
2
+ import { LOBBY, USER_AUTHOR } from "../shared/names.js";
3
3
  import { agentTitle } from "../shared/model.js";
4
4
 
5
5
  /** How many posts a room card shows before it counts the rest. The board sheet shows them all. */
@@ -20,11 +20,19 @@ export function postStateLabel(post: Post, name: (author: string) => string): st
20
20
  return `Task · ${post.state ?? "open"}`;
21
21
  }
22
22
 
23
+ /** Where a claimed lobby task's copy is, or which lobby task a copy came from; null for neither. */
24
+ export function linkLabel(post: Post, name: (author: string) => string): string | null {
25
+ if (post.link === undefined) return null;
26
+ if (post.board !== LOBBY) return `from lobby task ${post.link}`;
27
+ return post.claimedBy === undefined ? null : `on ${name(post.claimedBy)}'s board`;
28
+ }
29
+
23
30
  /** Spec: a post that names an agent shows "from → to". */
24
31
  export function postMeta(post: Post, name: (author: string) => string): string {
25
32
  const people =
26
33
  post.to === undefined ? name(post.author) : `${name(post.author)} → ${name(post.to)}`;
27
- return `${postStateLabel(post, name)} · ${people}`;
34
+ const link = linkLabel(post, name);
35
+ return `${postStateLabel(post, name)} · ${people}${link === null ? "" : ` · ${link}`}`;
28
36
  }
29
37
 
30
38
  /** Who claimed a to-do and whom it names; null when neither. A done to-do is no longer claimed. */
@@ -34,6 +42,8 @@ export function todoMeta(post: Post, name: (author: string) => string): string |
34
42
  parts.push(`claimed by ${name(post.claimedBy)}`);
35
43
  }
36
44
  if (post.to !== undefined) parts.push(`for ${name(post.to)}`);
45
+ const link = linkLabel(post, name);
46
+ if (link !== null) parts.push(link);
37
47
  return parts.length > 0 ? parts.join(" · ") : null;
38
48
  }
39
49
 
package/client/brand.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  /** The host's brand, as the daemon writes it into the web page it serves. */
2
2
  export interface OfficeBrand {
3
+ color?: string;
3
4
  /** Null keeps the product's name. */
4
5
  name: string | null;
5
6
  /** The logo's address in full; null when the brand has none. */
@@ -0,0 +1,318 @@
1
+ import { useOfficeBrand } from "./office-brand-context.js";
2
+ import type { Appearance } from "../shared/appearance.js";
3
+ import { useCallback, useMemo, useState } from "react";
4
+ import { Pressable, Text, View } from "react-native";
5
+ import { Icon, ScrollView, TextInput } from "@getpaseo/plugin/client/ui";
6
+ import { memberAvatar, type MentionOption } from "./chat-text.js";
7
+ import type { OfficeStyles } from "./styles.js";
8
+
9
+ export function ChatIcon({
10
+ name,
11
+ label,
12
+ active,
13
+ onPress,
14
+ styles,
15
+ }: {
16
+ name: string;
17
+ label: string;
18
+ active?: boolean;
19
+ onPress(): void;
20
+ styles: OfficeStyles;
21
+ }) {
22
+ return (
23
+ <Pressable
24
+ accessibilityRole="button"
25
+ accessibilityLabel={label}
26
+ aria-pressed={active}
27
+ onPress={onPress}
28
+ style={styles.messenger.icon}
29
+ >
30
+ <Icon name={name} size={19} color={styles.iconColor} />
31
+ </Pressable>
32
+ );
33
+ }
34
+
35
+ function MemberDisc({
36
+ id,
37
+ name,
38
+ appearance,
39
+ styles,
40
+ }: {
41
+ appearance?: Appearance;
42
+ id: string;
43
+ name: string;
44
+ styles: OfficeStyles;
45
+ }) {
46
+ const avatar = memberAvatar(id, name, appearance);
47
+ const style = useMemo(
48
+ () => [styles.messenger.memberAvatar, { backgroundColor: avatar.color }],
49
+ [styles, avatar.color],
50
+ );
51
+ return (
52
+ <View style={style}>
53
+ <Text style={styles.messenger.memberInitial}>{avatar.initials}</Text>
54
+ </View>
55
+ );
56
+ }
57
+
58
+ export interface ChatMember extends MentionOption {
59
+ status: string;
60
+ }
61
+ function MemberRow({
62
+ member,
63
+ open,
64
+ styles,
65
+ }: {
66
+ member: ChatMember;
67
+ open(id: string): void;
68
+ styles: OfficeStyles;
69
+ }) {
70
+ const show = useCallback(() => open(member.id), [open, member.id]);
71
+ return (
72
+ <Pressable
73
+ accessibilityRole="button"
74
+ accessibilityLabel={`Open ${member.name}, ${member.status}, ${member.room}`}
75
+ onPress={show}
76
+ style={styles.messenger.choice}
77
+ >
78
+ <MemberDisc
79
+ id={member.id}
80
+ appearance={member.appearance}
81
+ name={member.name}
82
+ styles={styles}
83
+ />
84
+ <View style={styles.rowBody}>
85
+ <Text numberOfLines={1} style={styles.chatName}>
86
+ {member.name}
87
+ </Text>
88
+ <Text numberOfLines={1} style={styles.chatMeta}>
89
+ {member.status} · {member.room}
90
+ </Text>
91
+ </View>
92
+ <Icon name="ArrowUpRight" size={15} color={styles.iconColor} />
93
+ </Pressable>
94
+ );
95
+ }
96
+ export function ChatHeader({
97
+ members,
98
+ onOpenSession,
99
+ searching,
100
+ onSearch,
101
+ onClose,
102
+ styles,
103
+ }: {
104
+ members: readonly ChatMember[];
105
+ onOpenSession(id: string): void;
106
+ searching: boolean;
107
+ onSearch(): void;
108
+ onClose?(): void;
109
+ styles: OfficeStyles;
110
+ }) {
111
+ const brand = useOfficeBrand();
112
+ const count = members.length + 1;
113
+ const [expanded, setExpanded] = useState(false);
114
+ const toggle = useCallback(() => setExpanded((value) => !value), []);
115
+ const open = useCallback(
116
+ (id: string) => {
117
+ setExpanded(false);
118
+ onOpenSession(id);
119
+ },
120
+ [onOpenSession],
121
+ );
122
+ return (
123
+ <>
124
+ <View style={styles.messenger.header}>
125
+ <View style={styles.messenger.group} aria-hidden>
126
+ <MemberDisc id="me" name="You" styles={styles} />
127
+ {members.slice(0, 3).map((member) => (
128
+ <MemberDisc
129
+ key={member.id}
130
+ id={member.id}
131
+ appearance={member.appearance}
132
+ name={member.name}
133
+ styles={styles}
134
+ />
135
+ ))}
136
+ </View>
137
+ <Pressable
138
+ accessibilityRole="button"
139
+ accessibilityLabel="Team members"
140
+ aria-expanded={expanded}
141
+ onPress={toggle}
142
+ style={styles.rowBody}
143
+ >
144
+ <Text accessibilityRole="header" style={styles.messenger.title}>
145
+ {brand.name ? `${brand.name} team` : "Office team"}
146
+ </Text>
147
+ <Text style={styles.messenger.subtitle}>
148
+ {count === 1 ? "1 member" : `${count} members`}
149
+ </Text>
150
+ </Pressable>
151
+ <ChatIcon
152
+ name="Search"
153
+ label="Search chat"
154
+ active={searching}
155
+ onPress={onSearch}
156
+ styles={styles}
157
+ />
158
+ {onClose && <ChatIcon name="X" label="Close team chat" onPress={onClose} styles={styles} />}
159
+ </View>
160
+ {expanded && (
161
+ <ScrollView style={styles.messenger.memberList} keyboardShouldPersistTaps="handled">
162
+ <View style={styles.messenger.choice}>
163
+ <MemberDisc id="me" name="You" styles={styles} />
164
+ <Text style={styles.chatName}>You</Text>
165
+ </View>
166
+ {members.map((member) => (
167
+ <MemberRow key={member.id} member={member} open={open} styles={styles} />
168
+ ))}
169
+ </ScrollView>
170
+ )}
171
+ </>
172
+ );
173
+ }
174
+
175
+ function RecipientRow({
176
+ member,
177
+ selected,
178
+ onPick,
179
+ styles,
180
+ }: {
181
+ member: MentionOption | null;
182
+ selected: boolean;
183
+ onPick(id: string | null): void;
184
+ styles: OfficeStyles;
185
+ }) {
186
+ const choose = useCallback(() => onPick(member?.id ?? null), [onPick, member]);
187
+ const label = member?.name ?? "Whole group";
188
+ const hint = member?.room ?? "Ask an available session";
189
+ return (
190
+ <Pressable
191
+ accessibilityRole="radio"
192
+ aria-checked={selected}
193
+ accessibilityLabel={`${label}, ${hint}`}
194
+ onPress={choose}
195
+ style={styles.messenger.choice}
196
+ >
197
+ {member ? (
198
+ <MemberDisc
199
+ id={member.id}
200
+ appearance={member.appearance}
201
+ name={member.name}
202
+ styles={styles}
203
+ />
204
+ ) : (
205
+ <Icon name="UsersRound" size={18} color={styles.iconColor} />
206
+ )}
207
+ <View style={styles.rowBody}>
208
+ <Text numberOfLines={1} style={styles.chatName}>
209
+ {label}
210
+ </Text>
211
+ <Text numberOfLines={1} style={styles.chatMeta}>
212
+ {hint}
213
+ </Text>
214
+ </View>
215
+ {selected && <Icon name="Check" size={16} color={styles.iconColor} />}
216
+ </Pressable>
217
+ );
218
+ }
219
+
220
+ export function ToField({
221
+ openSession,
222
+ members,
223
+ value,
224
+ onPick,
225
+ styles,
226
+ }: {
227
+ members: readonly MentionOption[];
228
+ openSession(id: string): void;
229
+ value: string | null;
230
+ onPick(id: string | null): void;
231
+ styles: OfficeStyles;
232
+ }) {
233
+ const [open, setOpen] = useState(false);
234
+ const [query, setQuery] = useState("");
235
+ const toggle = useCallback(() => {
236
+ setOpen((v) => !v);
237
+ setQuery("");
238
+ }, []);
239
+ const pick = useCallback(
240
+ (id: string | null) => {
241
+ onPick(id);
242
+ setOpen(false);
243
+ setQuery("");
244
+ },
245
+ [onPick],
246
+ );
247
+ const showSession = useCallback(() => {
248
+ if (value !== null) openSession(value);
249
+ }, [value, openSession]);
250
+ const name =
251
+ value === null
252
+ ? "Whole group"
253
+ : (members.find((m) => m.id === value)?.name ?? "Session unavailable");
254
+ const needle = query.trim().toLowerCase();
255
+ const visible = members.filter(
256
+ (m) => m.name.toLowerCase().includes(needle) || m.room.toLowerCase().includes(needle),
257
+ );
258
+ return (
259
+ <View>
260
+ <Pressable
261
+ accessibilityRole="button"
262
+ aria-expanded={open}
263
+ accessibilityLabel={`To: ${name}`}
264
+ onPress={toggle}
265
+ style={styles.messenger.to}
266
+ >
267
+ <Text style={styles.chatMeta}>To</Text>
268
+ <Text numberOfLines={1} style={styles.messenger.chosenName}>
269
+ {name}
270
+ </Text>
271
+ <Icon name="ChevronDown" size={14} color={styles.iconColor} />
272
+ </Pressable>
273
+ {value !== null && !open && (
274
+ <View style={styles.messenger.quickRow}>
275
+ <View style={styles.rowBody}>
276
+ <Text style={styles.chatMeta}>The session receives your message and replies here.</Text>
277
+ </View>
278
+ {members.some((m) => m.id === value) && (
279
+ <ChatIcon
280
+ name="ExternalLink"
281
+ label="Open recipient session"
282
+ onPress={showSession}
283
+ styles={styles}
284
+ />
285
+ )}
286
+ </View>
287
+ )}
288
+ {open && (
289
+ <View style={styles.messenger.picker}>
290
+ {members.length > 8 && (
291
+ <TextInput
292
+ accessibilityLabel="Find a session"
293
+ placeholder="Find a session"
294
+ placeholderTextColor={styles.placeholderColor}
295
+ value={query}
296
+ onChangeText={setQuery}
297
+ style={styles.fieldInput}
298
+ />
299
+ )}
300
+ <ScrollView keyboardShouldPersistTaps="handled">
301
+ <View accessibilityRole="radiogroup" accessibilityLabel="Message recipient">
302
+ <RecipientRow member={null} selected={value === null} onPick={pick} styles={styles} />
303
+ {visible.map((m) => (
304
+ <RecipientRow
305
+ key={m.id}
306
+ member={m}
307
+ selected={value === m.id}
308
+ onPick={pick}
309
+ styles={styles}
310
+ />
311
+ ))}
312
+ </View>
313
+ </ScrollView>
314
+ </View>
315
+ )}
316
+ </View>
317
+ );
318
+ }