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
@@ -3,7 +3,184 @@ import { StyleSheet } from "react-native";
3
3
 
4
4
  /** Shared by the fullscreen rail and the Sessions tab on a phone. */
5
5
  export function sessionStyles(colors: PluginTheme["colors"], touch: boolean) {
6
+ const hitSize = touch ? 44 : 34;
7
+ const rail = { width: "100%", maxWidth: 880, alignSelf: "center" } as const;
8
+ const iconButton = {
9
+ width: hitSize,
10
+ height: hitSize,
11
+ borderRadius: 8,
12
+ alignItems: "center",
13
+ justifyContent: "center",
14
+ } as const;
15
+ const workspaceButton = {
16
+ minHeight: 44,
17
+ flexDirection: "row",
18
+ alignItems: "center",
19
+ justifyContent: "center",
20
+ gap: 7,
21
+ borderRadius: 9,
22
+ paddingHorizontal: 12,
23
+ backgroundColor: colors.surface1,
24
+ borderWidth: 1,
25
+ borderColor: colors.border,
26
+ } as const;
6
27
  return StyleSheet.create({
28
+ workspaceButton,
29
+ workspacePressed: { ...workspaceButton, backgroundColor: colors.surface2 },
30
+ // The session drawer shares this header with the workspace dialog, from 264 px to desktop.
31
+ deskHead: {
32
+ ...rail,
33
+ gap: 4,
34
+ paddingHorizontal: touch ? 12 : 16,
35
+ paddingTop: 14,
36
+ paddingBottom: 6,
37
+ },
38
+ sheetTools: { paddingHorizontal: 12, paddingTop: 6, backgroundColor: colors.surface0 },
39
+ sheetActionRow: {
40
+ flexDirection: "row",
41
+ alignItems: "center",
42
+ justifyContent: "space-between",
43
+ flexWrap: "wrap",
44
+ columnGap: 8,
45
+ },
46
+ sheetDetails: { paddingTop: 6, gap: 4 },
47
+ identityRow: { flexDirection: "row", alignItems: "flex-start", gap: 6 },
48
+ identity: {
49
+ flex: 1,
50
+ minWidth: 0,
51
+ flexDirection: "row",
52
+ flexWrap: "wrap",
53
+ alignItems: "center",
54
+ columnGap: 18,
55
+ rowGap: 8,
56
+ },
57
+ identityLead: {
58
+ flexDirection: "row",
59
+ alignItems: "center",
60
+ gap: 10,
61
+ minWidth: 0,
62
+ flexBasis: 155,
63
+ flexGrow: 1,
64
+ flexShrink: 1,
65
+ },
66
+ identityName: { fontSize: 17, lineHeight: 22, fontWeight: "700", color: colors.foreground },
67
+ identityText: { flex: 1, minWidth: 0, gap: 2 },
68
+ identityAvatar: {
69
+ width: 36,
70
+ height: 36,
71
+ borderRadius: 11,
72
+ borderWidth: 1,
73
+ borderColor: colors.border,
74
+ backgroundColor: colors.surface2,
75
+ justifyContent: "center",
76
+ alignItems: "center",
77
+ },
78
+ metadata: {
79
+ flexDirection: "row",
80
+ flexWrap: "wrap",
81
+ alignItems: "center",
82
+ gap: 6,
83
+ maxWidth: "100%",
84
+ minWidth: 0,
85
+ },
86
+ metaChip: {
87
+ flexDirection: "row",
88
+ alignItems: "center",
89
+ gap: 5,
90
+ maxWidth: "100%",
91
+ borderRadius: 6,
92
+ backgroundColor: colors.surface1,
93
+ borderWidth: 1,
94
+ borderColor: colors.border,
95
+ paddingHorizontal: 7,
96
+ paddingVertical: 3,
97
+ },
98
+ metaValue: {
99
+ flexShrink: 1,
100
+ fontSize: 12,
101
+ lineHeight: 16,
102
+ fontWeight: "600",
103
+ color: colors.foreground,
104
+ fontVariant: ["tabular-nums"],
105
+ },
106
+ contextTrack: {
107
+ height: 4,
108
+ width: 26,
109
+ borderRadius: 2,
110
+ backgroundColor: colors.surface2,
111
+ overflow: "hidden",
112
+ },
113
+ contextGauge: { height: "100%", backgroundColor: colors.accent },
114
+ deskAction: iconButton,
115
+ deskLink: {
116
+ alignSelf: "flex-start",
117
+ flexDirection: "row",
118
+ alignItems: "center",
119
+ gap: 5,
120
+ minHeight: hitSize,
121
+ paddingHorizontal: 3,
122
+ },
123
+ deskLinkLabel: { fontSize: 12, fontWeight: "600", color: colors.foreground },
124
+ deskActionPressed: { ...iconButton, backgroundColor: colors.surface2 },
125
+ detailTabs: {
126
+ ...rail,
127
+ flexDirection: "row",
128
+ alignItems: "center",
129
+ gap: 4,
130
+ paddingHorizontal: touch ? 8 : 12,
131
+ borderBottomWidth: 1,
132
+ borderColor: colors.border,
133
+ },
134
+ detailTab: {
135
+ minHeight: touch ? 44 : 37,
136
+ flexDirection: "row",
137
+ alignItems: "center",
138
+ justifyContent: "center",
139
+ flexShrink: 1,
140
+ gap: 5,
141
+ paddingHorizontal: 7,
142
+ borderBottomWidth: 2,
143
+ borderBottomColor: "transparent",
144
+ },
145
+ detailTabActive: { borderBottomColor: colors.accent },
146
+ detailLabel: { fontSize: 12, lineHeight: 17, fontWeight: "500", color: colors.foregroundMuted },
147
+ detailLabelActive: {
148
+ fontSize: 12,
149
+ lineHeight: 17,
150
+ fontWeight: "700",
151
+ color: colors.foreground,
152
+ },
153
+ deskComposer: { ...rail, gap: 6, paddingHorizontal: touch ? 12 : 16, paddingVertical: 10 },
154
+ replyShell: {
155
+ flexDirection: "row",
156
+ alignItems: "flex-end",
157
+ gap: 4,
158
+ borderRadius: 12,
159
+ borderWidth: 1,
160
+ borderColor: colors.border,
161
+ padding: 4,
162
+ backgroundColor: colors.surface1,
163
+ },
164
+ replyFocused: { borderColor: colors.accent },
165
+ replyInput: {
166
+ flex: 1,
167
+ minWidth: 0,
168
+ minHeight: hitSize,
169
+ maxHeight: 115,
170
+ textAlignVertical: "top",
171
+ borderWidth: 0,
172
+ borderRadius: 6,
173
+ backgroundColor: "transparent",
174
+ color: colors.foreground,
175
+ paddingHorizontal: 8,
176
+ paddingVertical: touch ? 10 : 7,
177
+ fontSize: touch ? 16 : 14,
178
+ lineHeight: 21,
179
+ },
180
+ send: { ...iconButton, backgroundColor: colors.accent },
181
+ sendDisabled: { ...iconButton, backgroundColor: colors.surface2 },
182
+ sendPressed: { ...iconButton, backgroundColor: colors.accent, opacity: 0.8 },
183
+
7
184
  top: { paddingHorizontal: 12, paddingTop: 8, paddingBottom: 8, gap: 8 },
8
185
  actions: {
9
186
  flexDirection: "row",
@@ -54,6 +231,41 @@ export function sessionStyles(colors: PluginTheme["colors"], touch: boolean) {
54
231
  color: colors.foreground,
55
232
  fontSize: touch ? 16 : 13,
56
233
  },
234
+ clock: {
235
+ fontSize: 11,
236
+ lineHeight: 15,
237
+ color: colors.foregroundMuted,
238
+ fontVariant: ["tabular-nums"],
239
+ marginLeft: "auto",
240
+ },
241
+ workingClock: { color: colors.statusSuccess },
242
+ meterRow: { flexDirection: "row", alignItems: "center", gap: 6, paddingTop: 2 },
243
+ track: {
244
+ flex: 1,
245
+ height: 3,
246
+ borderRadius: 2,
247
+ overflow: "hidden",
248
+ backgroundColor: colors.surface2,
249
+ },
250
+ meterText: {
251
+ fontSize: 10,
252
+ lineHeight: 14,
253
+ color: colors.foregroundMuted,
254
+ fontVariant: ["tabular-nums"],
255
+ },
256
+ tasksFill: { height: 3, backgroundColor: colors.statusSuccess },
257
+ contextFill: { height: 3, backgroundColor: colors.foregroundMuted },
258
+ chevron: {
259
+ marginLeft: "auto",
260
+ marginRight: 4,
261
+ width: 7,
262
+ height: 7,
263
+ borderColor: colors.foregroundMuted,
264
+ borderRightWidth: 1.5,
265
+ borderBottomWidth: 1.5,
266
+ },
267
+ down: { transform: [{ rotate: "45deg" }] },
268
+ right: { transform: [{ rotate: "-45deg" }] },
57
269
  section: { paddingHorizontal: 8, gap: 2, marginBottom: 5 },
58
270
  heading: {
59
271
  flexDirection: "row",
@@ -85,7 +297,7 @@ export function sessionStyles(colors: PluginTheme["colors"], touch: boolean) {
85
297
  alignItems: "center",
86
298
  gap: 8,
87
299
  paddingHorizontal: 6,
88
- paddingVertical: 5,
300
+ paddingVertical: 7,
89
301
  borderRadius: 9,
90
302
  borderWidth: 1,
91
303
  borderColor: "transparent",
@@ -136,5 +348,16 @@ export function sessionStyles(colors: PluginTheme["colors"], touch: boolean) {
136
348
  },
137
349
  detail: { fontSize: 11, lineHeight: 15, color: colors.foregroundMuted },
138
350
  rowTitle: { flexDirection: "row", alignItems: "center", gap: 5 },
351
+ /** A session row and, beside it, the button that opens its workspace. */
352
+ rowWrap: { flexDirection: "row", alignItems: "center", gap: 2 },
353
+ rowMain: { flex: 1, minWidth: 0 },
354
+ rowOpen: {
355
+ width: hitSize,
356
+ minHeight: touch ? 48 : 41,
357
+ alignItems: "center",
358
+ justifyContent: "center",
359
+ borderRadius: 9,
360
+ overflow: "hidden",
361
+ },
139
362
  });
140
363
  }
@@ -0,0 +1,243 @@
1
+ import { type Appearance, AVATARS, shirtColor } from "../shared/appearance.js";
2
+ import { memo, useCallback, useMemo, useState } from "react";
3
+ import { Pressable, StyleSheet, Text, View } from "react-native";
4
+ import { Icon, Markdown } from "@getpaseo/plugin/client/ui";
5
+ import { readLobbyAssignment } from "../shared/lobby-assignment.js";
6
+ import type { ConversationRow } from "./conversation-model.js";
7
+ import { NOTHING_SAID, rowLabel } from "./session-text.js";
8
+ import { avatarInitials } from "./sessions-text.js";
9
+ import type { OfficeStyles } from "./styles.js";
10
+
11
+ type Tool = Extract<ConversationRow, { kind: "tool" }>;
12
+ interface RowProps {
13
+ appearance?: Appearance;
14
+ row: ConversationRow;
15
+ name: string;
16
+ styles: OfficeStyles;
17
+ }
18
+
19
+ function Assignment({
20
+ task,
21
+ original,
22
+ styles,
23
+ }: {
24
+ task: { id: string; body: string; kind: "lobby" | "duty" };
25
+ original: string;
26
+ styles: OfficeStyles;
27
+ }) {
28
+ const [expanded, setExpanded] = useState(false);
29
+ const toggle = useCallback(() => setExpanded((current) => !current), []);
30
+ const s = styles.transcript;
31
+ const what = task.kind === "duty" ? "Duty" : "Lobby task";
32
+ return (
33
+ <View style={s.assignment}>
34
+ <Pressable
35
+ accessibilityRole="button"
36
+ accessibilityLabel={`${what} ${task.id}, original message`}
37
+ aria-expanded={expanded}
38
+ onPress={toggle}
39
+ style={s.disclosure}
40
+ >
41
+ <Icon name="ClipboardList" size={15} color={styles.brandIcon.color} />
42
+ <Text style={s.stepTitle}>{what}</Text>
43
+ <Text style={s.taskId}>{task.id}</Text>
44
+ <Icon
45
+ name={expanded ? "ChevronUp" : "ChevronDown"}
46
+ size={14}
47
+ color={styles.placeholderColor}
48
+ />
49
+ </Pressable>
50
+ <Text selectable style={s.text}>
51
+ {task.body}
52
+ </Text>
53
+ {expanded && (
54
+ <View style={s.raw}>
55
+ <Text selectable style={s.code}>
56
+ {original}
57
+ </Text>
58
+ </View>
59
+ )}
60
+ </View>
61
+ );
62
+ }
63
+
64
+ function imageList(row: ConversationRow) {
65
+ return row.kind === "you" ? row.imageUrls?.join("\n") : undefined;
66
+ }
67
+
68
+ function sameRow(before: RowProps, after: RowProps): boolean {
69
+ const [a, b] = [before.row, after.row];
70
+ return (
71
+ before.name === after.name &&
72
+ before.appearance?.avatar === after.appearance?.avatar &&
73
+ before.appearance?.color === after.appearance?.color &&
74
+ before.styles === after.styles &&
75
+ a.kind === b.kind &&
76
+ a.key === b.key &&
77
+ a.text === b.text &&
78
+ imageList(a) === imageList(b) &&
79
+ (a.kind !== "notice" || (b.kind === "notice" && a.tone === b.tone)) &&
80
+ (a.kind !== "tool" || (b.kind === "tool" && a.outcome === b.outcome))
81
+ );
82
+ }
83
+
84
+ /** Streamed messages update only their own row. Tool lines retain their accessibility labels. */
85
+ const Row = memo(function Row({ row, name, appearance, styles }: RowProps) {
86
+ const s = styles.transcript;
87
+ const label = rowLabel(row, name);
88
+ const borderColor = shirtColor(appearance);
89
+ const avatarStyle = useMemo(
90
+ () => [s.avatar, borderColor && { borderColor, borderWidth: 2 }],
91
+ [s.avatar, borderColor],
92
+ );
93
+ switch (row.kind) {
94
+ case "tool": {
95
+ const status = row.outcome === "failed" ? s.danger : s.warning;
96
+ return (
97
+ <Text
98
+ accessibilityLabel={label}
99
+ selectable
100
+ numberOfLines={1}
101
+ style={row.outcome ? StyleSheet.compose(s.code, status) : s.code}
102
+ >
103
+ {row.text}
104
+ </Text>
105
+ );
106
+ }
107
+ case "notice": {
108
+ const danger = row.tone === "danger";
109
+ return (
110
+ <View style={danger ? StyleSheet.compose(s.notice, s.errorNotice) : s.notice}>
111
+ <Text
112
+ accessibilityLabel={label}
113
+ accessibilityRole={danger ? "alert" : undefined}
114
+ selectable
115
+ style={danger ? StyleSheet.compose(s.text, s.danger) : styles.chatMeta}
116
+ >
117
+ {row.text}
118
+ </Text>
119
+ </View>
120
+ );
121
+ }
122
+ case "you": {
123
+ const task = readLobbyAssignment(row.text);
124
+ if (task && !row.imageUrls?.length)
125
+ return <Assignment task={task} original={row.text} styles={styles} />;
126
+ return (
127
+ <View accessibilityLabel={label} style={s.outgoing}>
128
+ <Text style={s.name}>You</Text>
129
+ {row.imageUrls && (
130
+ <Markdown>{row.imageUrls.map((url) => `![Image](<${url}>)`).join("\n\n")}</Markdown>
131
+ )}
132
+ <Text selectable style={s.text}>
133
+ {row.text}
134
+ </Text>
135
+ </View>
136
+ );
137
+ }
138
+ case "agent":
139
+ return (
140
+ <View accessibilityLabel={label} style={s.assistant}>
141
+ <View style={s.speaker}>
142
+ <View aria-hidden style={avatarStyle}>
143
+ <Text style={s.initials}>
144
+ {appearance?.avatar ? AVATARS[appearance.avatar] : avatarInitials(name)}
145
+ </Text>
146
+ </View>
147
+ <Text style={s.name}>{name}</Text>
148
+ </View>
149
+ <Markdown>{row.text}</Markdown>
150
+ </View>
151
+ );
152
+ }
153
+ }, sameRow);
154
+
155
+ function ToolRun({ rows, name, styles }: { rows: Tool[]; name: string; styles: OfficeStyles }) {
156
+ const [expanded, setExpanded] = useState(false);
157
+ const [hovered, setHovered] = useState(false);
158
+ const toggle = useCallback(() => setExpanded((current) => !current), []);
159
+ const enter = useCallback(() => setHovered(true), []);
160
+ const leave = useCallback(() => setHovered(false), []);
161
+ const s = styles.transcript;
162
+ return (
163
+ <View style={s.steps}>
164
+ <Pressable
165
+ accessibilityRole="button"
166
+ accessibilityLabel={`${rows.length} tool steps`}
167
+ aria-expanded={expanded}
168
+ onPress={toggle}
169
+ onHoverIn={enter}
170
+ onHoverOut={leave}
171
+ style={hovered ? StyleSheet.compose(s.stepButton, s.pressed) : s.stepButton}
172
+ >
173
+ <Icon name="Terminal" size={14} color={styles.placeholderColor} />
174
+ <Text style={s.stepTitle}>{rows.length} tool steps</Text>
175
+ <Icon
176
+ name={expanded ? "ChevronUp" : "ChevronDown"}
177
+ size={14}
178
+ color={styles.placeholderColor}
179
+ />
180
+ </Pressable>
181
+ {expanded && (
182
+ <View style={s.stepList}>
183
+ {rows.map((row) => (
184
+ <Row key={row.key} row={row} name={name} styles={styles} />
185
+ ))}
186
+ </View>
187
+ )}
188
+ </View>
189
+ );
190
+ }
191
+
192
+ /** Errors and canceled steps remain in chronological order even when the surrounding run is folded. */
193
+ function displayRows(
194
+ rows: readonly ConversationRow[],
195
+ steps: boolean,
196
+ ): (ConversationRow | Tool[])[] {
197
+ if (steps) return rows.filter((row) => row.kind === "tool" || row.kind === "notice");
198
+ const result: (ConversationRow | Tool[])[] = [];
199
+ let run: Tool[] | null = null;
200
+ for (const row of rows) {
201
+ if (row.kind === "tool" && !row.outcome) {
202
+ if (run === null) {
203
+ run = [];
204
+ result.push(run);
205
+ }
206
+ run.push(row);
207
+ } else {
208
+ run = null;
209
+ result.push(row);
210
+ }
211
+ }
212
+ return result;
213
+ }
214
+
215
+ export function SessionTranscript({
216
+ appearance,
217
+ rows,
218
+ steps,
219
+ name,
220
+ styles,
221
+ }: {
222
+ rows: readonly ConversationRow[];
223
+ appearance?: Appearance;
224
+ steps: boolean;
225
+ name: string;
226
+ styles: OfficeStyles;
227
+ }) {
228
+ const entries = useMemo(() => displayRows(rows, steps), [rows, steps]);
229
+ if (!entries.length)
230
+ return (
231
+ <Text style={styles.muted}>{steps ? "No steps in the loaded history." : NOTHING_SAID}</Text>
232
+ );
233
+ return (
234
+ <View style={steps ? styles.transcript.steps : styles.transcript.messages}>
235
+ {entries.map((entry) => {
236
+ if (Array.isArray(entry) && entry.length > 1)
237
+ return <ToolRun key={entry[0].key} rows={entry} name={name} styles={styles} />;
238
+ const row = Array.isArray(entry) ? entry[0] : entry;
239
+ return <Row appearance={appearance} key={row.key} row={row} name={name} styles={styles} />;
240
+ })}
241
+ </View>
242
+ );
243
+ }