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.
- package/OVERVIEW.md +27 -0
- package/README.md +65 -134
- package/client/action-button.tsx +4 -1
- package/client/activity-panel.tsx +6 -4
- package/client/agent-appearance.tsx +257 -0
- package/client/agent-card.tsx +2 -1
- package/client/agent-picker-text.ts +23 -4
- package/client/agent-picker.tsx +5 -8
- package/client/board-sheet.tsx +48 -16
- package/client/board-text.ts +12 -2
- package/client/brand.ts +1 -0
- package/client/chat-chrome.tsx +318 -0
- package/client/chat-compose-tools.tsx +314 -0
- package/client/chat-dictation.tsx +133 -0
- package/client/chat-more.tsx +119 -0
- package/client/chat-panel.tsx +401 -146
- package/client/chat-quick.tsx +198 -0
- package/client/chat-text.ts +25 -6
- package/client/column-sheet.tsx +93 -23
- package/client/conversation-model.ts +19 -5
- package/client/duty-sheet.tsx +321 -0
- package/client/duty-text.ts +20 -0
- package/client/fullscreen-header.tsx +28 -13
- package/client/fullscreen-theme.ts +38 -0
- package/client/host-details.tsx +269 -0
- package/client/host-styles.ts +129 -0
- package/client/host-switches.tsx +197 -73
- package/client/incidents-card.tsx +2 -1
- package/client/janitor-card.tsx +1 -1
- package/client/library-card.tsx +2 -1
- package/client/list-text.ts +8 -6
- package/client/lobby-board.tsx +73 -53
- package/client/machine-card.tsx +225 -85
- package/client/messenger-styles.ts +216 -0
- package/client/new-agent-form.tsx +153 -61
- package/client/new-agent-model.ts +2 -0
- package/client/notes-card.tsx +111 -83
- package/client/notes-days.tsx +1 -1
- package/client/office-brand-context.ts +44 -0
- package/client/office-column.tsx +2 -1
- package/client/office-keyboard.ts +79 -0
- package/client/office-link.ts +7 -1
- package/client/office-mark.tsx +29 -0
- package/client/office-modal.tsx +440 -0
- package/client/office-settings.tsx +75 -30
- package/client/office-state.ts +12 -2
- package/client/office-surface.tsx +591 -81
- package/client/pixel/actors.ts +2 -1
- package/client/pixel/art.ts +33 -19
- package/client/pixel/pixel-office.tsx +2 -2
- package/client/prompt-coach.tsx +152 -0
- package/client/qa-card.tsx +2 -1
- package/client/review-card.tsx +2 -1
- package/client/room-board.tsx +26 -2
- package/client/scene-picker.tsx +158 -0
- package/client/scene-previews.ts +10 -0
- package/client/session-pane.tsx +25 -5
- package/client/session-panel-detail.tsx +238 -0
- package/client/session-panel.tsx +222 -137
- package/client/session-styles.ts +224 -1
- package/client/session-transcript.tsx +243 -0
- package/client/sessions-panel.tsx +181 -22
- package/client/sessions-text.ts +18 -0
- package/client/settings-sections.tsx +126 -0
- package/client/sidebar-launcher.ts +29 -0
- package/client/ssh-hosts.tsx +331 -0
- package/client/ssh-metrics.ts +76 -0
- package/client/standup-card.tsx +2 -1
- package/client/structure-view.tsx +20 -3
- package/client/styles.ts +170 -62
- package/client/team-chat-preview.tsx +96 -0
- package/client/transcript-styles.ts +90 -0
- package/client/use-device-switch.ts +21 -12
- package/client/use-duty-actions.ts +43 -0
- package/client/use-group-photo.ts +48 -0
- package/client/use-new-agent.ts +4 -0
- package/client/use-street.ts +8 -0
- package/client/workspace-office-tools.tsx +102 -0
- package/client/workspace-overlay-route.web.ts +47 -0
- package/client/workspace-overlay.tsx +195 -0
- package/client/world/adapter.ts +37 -2
- package/client/world/escape.ts +58 -0
- package/client/world/use-world-feed.ts +6 -2
- package/client/world/workspace-dock.ts +6 -0
- package/client/world/world-api.ts +45 -4
- package/client/world/world-bridge-page.ts +14 -3
- package/client/world/world-bridge.ts +50 -5
- package/client/world/world-frame.web.ts +8 -0
- package/client/world/world-view-native.tsx +31 -10
- package/client/world/world-view-shared.ts +36 -7
- package/client/world/world-view.tsx +93 -21
- package/docs/office.md +148 -58
- package/index.client.tsx +13 -6
- package/index.server.ts +125 -9
- package/package.json +2 -1
- package/server/activity.ts +42 -19
- package/server/agent-tools.ts +11 -5
- package/server/board-service.ts +381 -10
- package/server/brand-logo.ts +34 -0
- package/server/chat-group.ts +83 -0
- package/server/chat-service.ts +406 -62
- package/server/chat-store.ts +1 -4
- package/server/directory.ts +22 -7
- package/server/duty-service.ts +230 -0
- package/server/group-photo.ts +39 -0
- package/server/home-departure.ts +47 -0
- package/server/hub.ts +43 -1
- package/server/live-ports.ts +114 -18
- package/server/lobby-pickup.ts +170 -0
- package/server/machine/details.ts +91 -0
- package/server/mention-queue.ts +14 -0
- package/server/office.ts +110 -6
- package/server/paths.ts +9 -0
- package/server/ssh/LICENSE.paseo +211 -0
- package/server/ssh/client.ts +401 -0
- package/server/ssh/discovery.ts +230 -0
- package/server/ssh/installed.ts +104 -0
- package/server/ssh/monitor.ts +104 -0
- package/server/ssh/pid-files.ts +194 -0
- package/server/ssh/read.ts +136 -0
- package/server/subagent-names.ts +4 -0
- package/server/words.generated.ts +1 -1
- package/server/world.generated.ts +1 -1
- package/shared/appearance.ts +43 -0
- package/shared/branding.ts +53 -0
- package/shared/chat-words.ts +2 -2
- package/shared/contracts.ts +135 -4
- package/shared/duties.ts +100 -0
- package/shared/host-details.ts +25 -0
- package/shared/lobby-assignment.ts +34 -0
- package/shared/model.ts +9 -1
- package/shared/names.ts +2 -0
- package/shared/settings.ts +14 -3
- package/shared/ssh.ts +34 -0
- package/shared/upstream/README.md +1 -3
- package/shared/upstream/chat-engine.d.ts +4 -0
- package/shared/upstream/prompt-coach.d.ts +6 -0
- package/shared/upstream/prompt-coach.js +178 -0
package/client/office-link.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SetStateAction } from "react";
|
|
2
2
|
import type { PluginTheme } from "@getpaseo/plugin";
|
|
3
3
|
import type { PluginSurfaceProps } from "@getpaseo/plugin/client";
|
|
4
|
-
import type { ChatMessage } from "../shared/contracts.js";
|
|
4
|
+
import type { ChatImage, ChatMessage } from "../shared/contracts.js";
|
|
5
5
|
import type { NewAgentChoice } from "./new-agent-model.js";
|
|
6
6
|
import type { OfficeStyles } from "./styles.js";
|
|
7
7
|
import type { OfficeState } from "./use-office.js";
|
|
@@ -12,6 +12,8 @@ export interface OfficeLink {
|
|
|
12
12
|
select(agentId: string): void;
|
|
13
13
|
/** Shows the agent's session. */
|
|
14
14
|
openSession(agentId: string): void;
|
|
15
|
+
/** Shows the agent's workspace over the office; absent where the surface has no such view. */
|
|
16
|
+
openWorkspace?(agentId: string): void;
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
/** What the surface hands each panel of its column. */
|
|
@@ -33,6 +35,10 @@ export interface ChatDraft {
|
|
|
33
35
|
setText(next: SetStateAction<string>): void;
|
|
34
36
|
replyTo: ChatMessage | null;
|
|
35
37
|
setReplyTo(next: ChatMessage | null): void;
|
|
38
|
+
recipient: string | null;
|
|
39
|
+
setRecipient(agentId: string | null): void;
|
|
40
|
+
images: (ChatImage & { id: number; name: string })[];
|
|
41
|
+
setImages(next: SetStateAction<ChatDraft["images"]>): void;
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
/**
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useCallback, useMemo, useState } from "react";
|
|
2
|
+
import { Image } from "react-native";
|
|
3
|
+
import { Icon } from "@getpaseo/plugin/client/ui";
|
|
4
|
+
import type { OfficeBrand } from "./brand.js";
|
|
5
|
+
|
|
6
|
+
const brandImage = { width: 24, height: 24 };
|
|
7
|
+
|
|
8
|
+
export function OfficeMark({
|
|
9
|
+
brand,
|
|
10
|
+
fallbackColor,
|
|
11
|
+
}: {
|
|
12
|
+
brand: OfficeBrand;
|
|
13
|
+
fallbackColor: string;
|
|
14
|
+
}) {
|
|
15
|
+
const [failedLogo, setFailedLogo] = useState<string | null>(null);
|
|
16
|
+
const logo = useMemo(() => (brand.logoUrl ? { uri: brand.logoUrl } : null), [brand.logoUrl]);
|
|
17
|
+
const failed = useCallback(() => setFailedLogo(brand.logoUrl), [brand.logoUrl]);
|
|
18
|
+
return logo && failedLogo !== brand.logoUrl ? (
|
|
19
|
+
<Image
|
|
20
|
+
accessible={false}
|
|
21
|
+
source={logo}
|
|
22
|
+
resizeMode="contain"
|
|
23
|
+
style={brandImage}
|
|
24
|
+
onError={failed}
|
|
25
|
+
/>
|
|
26
|
+
) : (
|
|
27
|
+
<Icon name="Building2" size={20} color={brand.color ?? fallbackColor} />
|
|
28
|
+
);
|
|
29
|
+
}
|
|
@@ -0,0 +1,440 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createContext,
|
|
3
|
+
useCallback,
|
|
4
|
+
useContext,
|
|
5
|
+
useLayoutEffect,
|
|
6
|
+
useMemo,
|
|
7
|
+
useRef,
|
|
8
|
+
useState,
|
|
9
|
+
type CSSProperties,
|
|
10
|
+
type KeyboardEvent,
|
|
11
|
+
type MouseEvent,
|
|
12
|
+
type PointerEvent,
|
|
13
|
+
type ReactNode,
|
|
14
|
+
type SyntheticEvent,
|
|
15
|
+
} from "react";
|
|
16
|
+
import { RegisterWorkspaceDock } from "./world/workspace-dock.js";
|
|
17
|
+
import { View } from "react-native";
|
|
18
|
+
import type { PluginTheme } from "@getpaseo/plugin";
|
|
19
|
+
import {
|
|
20
|
+
Icon,
|
|
21
|
+
Modal as PaseoModal,
|
|
22
|
+
ScrollView,
|
|
23
|
+
type ModalProps,
|
|
24
|
+
type ModalContentProps,
|
|
25
|
+
} from "@getpaseo/plugin/client/ui";
|
|
26
|
+
import type { OfficeStyles } from "./styles.js";
|
|
27
|
+
|
|
28
|
+
interface DialogAppearance {
|
|
29
|
+
theme: PluginTheme;
|
|
30
|
+
styles: OfficeStyles;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
type OfficeModalProps = ModalProps & {
|
|
34
|
+
size?: "standard" | "wide" | "settings";
|
|
35
|
+
headerActions?: ReactNode;
|
|
36
|
+
dockRequest?: object;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// The stock modal owns its header; on that surface the workspace toolbar belongs in the body.
|
|
40
|
+
export function useFullscreenDialog(): boolean {
|
|
41
|
+
return useContext(Fullscreen) !== null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const CameraDock = createContext<HTMLButtonElement | null>(null);
|
|
45
|
+
const Fullscreen = createContext<DialogAppearance | null>(null);
|
|
46
|
+
|
|
47
|
+
// The native dialog's top layer keeps it above the fullscreen scene and its iframe.
|
|
48
|
+
const dialogCss = `
|
|
49
|
+
.paseo-office-dialog {
|
|
50
|
+
width: min(640px, calc(100% - 32px)); max-width: none; max-height: calc(100% - 32px);
|
|
51
|
+
margin: auto; padding: 0; box-sizing: border-box; overflow: hidden; font-family: inherit;
|
|
52
|
+
border: 1px solid var(--office-border); border-radius: 16px;
|
|
53
|
+
background: var(--office-panel); color: var(--office-text);
|
|
54
|
+
box-shadow: 0 24px 80px rgba(0,0,0,.32), 0 4px 18px rgba(0,0,0,.18);
|
|
55
|
+
}
|
|
56
|
+
.paseo-office-dialog[data-size="wide"] { width: min(1120px, calc(100% - 32px)); }
|
|
57
|
+
.paseo-office-dialog[data-size="wide"] .office-dialog-bounded { height: min(84dvh, 880px); }
|
|
58
|
+
.paseo-office-dialog[data-size="settings"] .office-dialog-bounded { height: min(620px, calc(100dvh - 110px)); }
|
|
59
|
+
.paseo-office-dialog .office-dialog-tools { min-width: 0; }
|
|
60
|
+
.paseo-office-dialog[inert] { position: fixed; inset: 0; margin: auto; z-index: 10; pointer-events: none; }
|
|
61
|
+
.paseo-office-dialog::backdrop { background: rgba(6,10,16,.5); backdrop-filter: blur(3px); }
|
|
62
|
+
.paseo-office-dialog .office-dialog-frame {
|
|
63
|
+
display: flex; flex-direction: column; max-height: calc(100dvh - 36px); min-height: 0;
|
|
64
|
+
}
|
|
65
|
+
.paseo-office-dialog .office-dialog-head {
|
|
66
|
+
flex: none; display: flex; align-items: center; gap: 12px;
|
|
67
|
+
padding: 12px 16px 12px 20px; border-bottom: 1px solid var(--office-border);
|
|
68
|
+
}
|
|
69
|
+
.paseo-office-dialog .office-dialog-icon {
|
|
70
|
+
flex: none; width: 32px; height: 32px; display: grid; place-items: center;
|
|
71
|
+
border-radius: 9px; background: var(--office-control);
|
|
72
|
+
}
|
|
73
|
+
.paseo-office-dialog h2 {
|
|
74
|
+
flex: 1; min-width: 0; margin: 0; font: 650 18px/1.3 system-ui,sans-serif;
|
|
75
|
+
letter-spacing: -.02em; overflow-wrap: anywhere;
|
|
76
|
+
}
|
|
77
|
+
.paseo-office-dialog .office-dialog-close {
|
|
78
|
+
flex: none; display: grid; place-items: center; width: 36px; height: 36px; padding: 0;
|
|
79
|
+
background: transparent; color: var(--office-muted); cursor: pointer;
|
|
80
|
+
border: 1px solid transparent; border-radius: 9px;
|
|
81
|
+
}
|
|
82
|
+
.paseo-office-dialog .office-dialog-close:hover {
|
|
83
|
+
background: var(--office-control); color: var(--office-text); border-color: var(--office-border);
|
|
84
|
+
}
|
|
85
|
+
.paseo-office-dialog .office-dialog-close:focus-visible {
|
|
86
|
+
outline: 2px solid var(--office-text); outline-offset: 2px;
|
|
87
|
+
}
|
|
88
|
+
.paseo-office-dialog .office-dialog-bounded {
|
|
89
|
+
display: flex; flex-direction: column; height: 72dvh; min-height: 0;
|
|
90
|
+
}
|
|
91
|
+
.office-workspace-dock {
|
|
92
|
+
align-self: stretch; flex: none; display: flex; justify-content: center;
|
|
93
|
+
padding: 5px 12px max(5px, env(safe-area-inset-bottom)); background: var(--office-panel);
|
|
94
|
+
border-top: 1px solid var(--office-border);
|
|
95
|
+
}
|
|
96
|
+
.office-workspace-dock[hidden] { display: none; }
|
|
97
|
+
.office-workspace-dock button {
|
|
98
|
+
max-width: 100%; display: flex; align-items: center; gap: 8px; border-radius: 10px;
|
|
99
|
+
background: var(--office-control); color: var(--office-text); border: 1px solid var(--office-border);
|
|
100
|
+
padding: 7px 12px; cursor: pointer; font: 600 13px/1.4 system-ui,sans-serif;
|
|
101
|
+
}
|
|
102
|
+
.office-workspace-dock button span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
103
|
+
.office-workspace-dock button:hover { border-color: var(--office-muted); }
|
|
104
|
+
.office-workspace-dock button:focus-visible { outline: 2px solid var(--office-text); }
|
|
105
|
+
@media (max-width: 700px) {
|
|
106
|
+
.paseo-office-dialog[data-size="wide"] .office-dialog-head { flex-wrap: wrap; gap: 6px 8px; }
|
|
107
|
+
.paseo-office-dialog .office-dialog-tools { order: 1; width: 100%; }
|
|
108
|
+
}
|
|
109
|
+
@media (max-width: 600px), (pointer: coarse) {
|
|
110
|
+
.paseo-office-dialog .office-dialog-close { width: 44px; height: 44px; }
|
|
111
|
+
}
|
|
112
|
+
@media (max-width: 600px) {
|
|
113
|
+
.paseo-office-dialog, .paseo-office-dialog[data-size="wide"] { width: calc(100% - 16px); max-height: calc(100% - 16px); border-radius: 12px; }
|
|
114
|
+
.paseo-office-dialog .office-dialog-frame { max-height: calc(100dvh - 20px); }
|
|
115
|
+
.paseo-office-dialog .office-dialog-head { padding: 6px 8px 6px 14px; gap: 10px; }
|
|
116
|
+
}
|
|
117
|
+
`;
|
|
118
|
+
|
|
119
|
+
export function OfficeDialogs({
|
|
120
|
+
fullscreen,
|
|
121
|
+
theme,
|
|
122
|
+
styles,
|
|
123
|
+
children,
|
|
124
|
+
}: DialogAppearance & {
|
|
125
|
+
fullscreen: boolean;
|
|
126
|
+
children: ReactNode;
|
|
127
|
+
}) {
|
|
128
|
+
const appearance = useMemo(
|
|
129
|
+
() => (fullscreen ? { theme, styles } : null),
|
|
130
|
+
[fullscreen, theme, styles],
|
|
131
|
+
);
|
|
132
|
+
const [cameraButton, registerDock] = useState<HTMLButtonElement | null>(null);
|
|
133
|
+
return (
|
|
134
|
+
<RegisterWorkspaceDock.Provider value={registerDock}>
|
|
135
|
+
<CameraDock.Provider value={cameraButton}>
|
|
136
|
+
<Fullscreen.Provider value={appearance}>{children}</Fullscreen.Provider>
|
|
137
|
+
</CameraDock.Provider>
|
|
138
|
+
</RegisterWorkspaceDock.Provider>
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** Keep Tab inside this dialog even at its edges, where the browser can otherwise focus its toolbar. */
|
|
143
|
+
function cycleFocus(event: KeyboardEvent<HTMLDialogElement>): void {
|
|
144
|
+
if (event.key !== "Tab" || event.defaultPrevented) return;
|
|
145
|
+
const dialog = event.currentTarget;
|
|
146
|
+
const items = [
|
|
147
|
+
...dialog.querySelectorAll<HTMLElement>(
|
|
148
|
+
"button, input, textarea, select, iframe, a[href], [tabindex]",
|
|
149
|
+
),
|
|
150
|
+
].filter(
|
|
151
|
+
(item) =>
|
|
152
|
+
item.tabIndex >= 0 &&
|
|
153
|
+
!item.matches(":disabled, [aria-disabled=true]") &&
|
|
154
|
+
item.getClientRects().length > 0,
|
|
155
|
+
);
|
|
156
|
+
const edge = event.shiftKey ? items[0] : items.at(-1);
|
|
157
|
+
if (document.activeElement !== edge) return;
|
|
158
|
+
event.preventDefault();
|
|
159
|
+
const next = event.shiftKey ? items.at(-1) : items[0];
|
|
160
|
+
next?.focus();
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function dockBounds(button: HTMLButtonElement, page: Document) {
|
|
164
|
+
const bounds = button.getBoundingClientRect();
|
|
165
|
+
if (button.ownerDocument === page) return bounds;
|
|
166
|
+
const frame = button.ownerDocument.defaultView?.frameElement?.getBoundingClientRect();
|
|
167
|
+
return {
|
|
168
|
+
left: (frame?.left ?? 0) + bounds.left,
|
|
169
|
+
top: (frame?.top ?? 0) + bounds.top,
|
|
170
|
+
width: bounds.width,
|
|
171
|
+
height: bounds.height,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function BrowserDialog({
|
|
176
|
+
title,
|
|
177
|
+
icon,
|
|
178
|
+
headerActions,
|
|
179
|
+
dockRequest,
|
|
180
|
+
size,
|
|
181
|
+
onOpenChange,
|
|
182
|
+
children,
|
|
183
|
+
theme: { colors },
|
|
184
|
+
}: OfficeModalProps & DialogAppearance) {
|
|
185
|
+
const cameraButton = useContext(CameraDock);
|
|
186
|
+
const dialog = useRef<HTMLDialogElement>(null);
|
|
187
|
+
const restoreButton = useRef<HTMLButtonElement>(null);
|
|
188
|
+
const minimizeButton = useRef<HTMLButtonElement>(null);
|
|
189
|
+
const [dockVisible, setDockVisible] = useState(false);
|
|
190
|
+
const [docked, setDocked] = useState<object | null>(null);
|
|
191
|
+
const minimized = !!dockRequest && docked === dockRequest;
|
|
192
|
+
const minimize = useCallback(() => {
|
|
193
|
+
setDockVisible(true);
|
|
194
|
+
setDocked(dockRequest ?? null);
|
|
195
|
+
}, [dockRequest]);
|
|
196
|
+
const restore = useCallback(() => setDocked(null), []);
|
|
197
|
+
const pressedBackdrop = useRef(false);
|
|
198
|
+
const close = useCallback(() => onOpenChange(false), [onOpenChange]);
|
|
199
|
+
const cancel = useCallback(
|
|
200
|
+
(event: SyntheticEvent) => {
|
|
201
|
+
// The board may interpret Escape as Back from its picker and keep the dialog open.
|
|
202
|
+
event.preventDefault();
|
|
203
|
+
close();
|
|
204
|
+
},
|
|
205
|
+
[close],
|
|
206
|
+
);
|
|
207
|
+
const pointerDown = useCallback((event: PointerEvent<HTMLDialogElement>) => {
|
|
208
|
+
pressedBackdrop.current = event.target === event.currentTarget;
|
|
209
|
+
}, []);
|
|
210
|
+
const clicked = useCallback(
|
|
211
|
+
(event: MouseEvent<HTMLDialogElement>) => {
|
|
212
|
+
if (pressedBackdrop.current && event.target === event.currentTarget) close();
|
|
213
|
+
pressedBackdrop.current = false;
|
|
214
|
+
},
|
|
215
|
+
[close],
|
|
216
|
+
);
|
|
217
|
+
useLayoutEffect(() => {
|
|
218
|
+
const element = dialog.current;
|
|
219
|
+
const opener = document.activeElement;
|
|
220
|
+
element?.showModal();
|
|
221
|
+
return () => {
|
|
222
|
+
element?.close();
|
|
223
|
+
if (opener instanceof HTMLElement && opener.isConnected)
|
|
224
|
+
opener.focus({ preventScroll: true });
|
|
225
|
+
};
|
|
226
|
+
}, []);
|
|
227
|
+
useLayoutEffect(() => {
|
|
228
|
+
if (!cameraButton || !dockRequest || !dockVisible) return;
|
|
229
|
+
const label = `Restore ${title}`;
|
|
230
|
+
cameraButton.setAttribute("aria-label", label);
|
|
231
|
+
cameraButton.title = label;
|
|
232
|
+
cameraButton.hidden = false;
|
|
233
|
+
cameraButton.addEventListener("click", restore);
|
|
234
|
+
return () => {
|
|
235
|
+
cameraButton.hidden = true;
|
|
236
|
+
cameraButton.removeEventListener("click", restore);
|
|
237
|
+
};
|
|
238
|
+
}, [cameraButton, dockRequest, dockVisible, restore, title]);
|
|
239
|
+
// Closing a native dialog releases the floor and leaves its iframe and React children mounted.
|
|
240
|
+
const wasMinimized = useRef(false);
|
|
241
|
+
useLayoutEffect(() => {
|
|
242
|
+
const element = dialog.current;
|
|
243
|
+
const button = cameraButton ?? restoreButton.current;
|
|
244
|
+
if (!element || !button || (!minimized && !wasMinimized.current)) return;
|
|
245
|
+
if (minimized && wasMinimized.current && !element.open) return;
|
|
246
|
+
wasMinimized.current = minimized;
|
|
247
|
+
// Release the top layer before animating. Its backdrop otherwise intercepts the next
|
|
248
|
+
// session click while the workspace is shrinking toward the camera toolbar.
|
|
249
|
+
if (minimized) {
|
|
250
|
+
element.close();
|
|
251
|
+
element.inert = true;
|
|
252
|
+
element.show();
|
|
253
|
+
} else {
|
|
254
|
+
if (element.open) element.close();
|
|
255
|
+
element.inert = false;
|
|
256
|
+
element.showModal();
|
|
257
|
+
}
|
|
258
|
+
const from = element.getBoundingClientRect();
|
|
259
|
+
const to = dockBounds(button, element.ownerDocument);
|
|
260
|
+
const finish = () => {
|
|
261
|
+
if (minimized) {
|
|
262
|
+
element.close();
|
|
263
|
+
element.inert = false;
|
|
264
|
+
button.focus({ preventScroll: true });
|
|
265
|
+
} else {
|
|
266
|
+
setDockVisible(false);
|
|
267
|
+
minimizeButton.current?.focus({ preventScroll: true });
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
if (
|
|
271
|
+
!element.animate ||
|
|
272
|
+
window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ||
|
|
273
|
+
!from.width ||
|
|
274
|
+
!to.width
|
|
275
|
+
) {
|
|
276
|
+
finish();
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
const x = to.left + to.width / 2 - from.left - from.width / 2;
|
|
280
|
+
const y = to.top + to.height / 2 - from.top - from.height / 2;
|
|
281
|
+
const frames = [
|
|
282
|
+
{ transform: "none", opacity: 1 },
|
|
283
|
+
{
|
|
284
|
+
transform: `translate(${x * 0.55}px, ${y * 0.4}px) scale(.70,.58)`,
|
|
285
|
+
opacity: 0.98,
|
|
286
|
+
offset: 0.45,
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
transform: `translate(${x}px, ${y}px) scale(${to.width / from.width},${to.height / from.height})`,
|
|
290
|
+
opacity: 0.28,
|
|
291
|
+
},
|
|
292
|
+
];
|
|
293
|
+
const animation = element.animate(frames, {
|
|
294
|
+
duration: 320,
|
|
295
|
+
easing: "ease-in-out",
|
|
296
|
+
direction: minimized ? "normal" : "reverse",
|
|
297
|
+
});
|
|
298
|
+
animation.onfinish = () => {
|
|
299
|
+
finish();
|
|
300
|
+
};
|
|
301
|
+
return () => {
|
|
302
|
+
animation.onfinish = null;
|
|
303
|
+
animation.cancel();
|
|
304
|
+
};
|
|
305
|
+
}, [minimized, cameraButton]);
|
|
306
|
+
const tokens = useMemo(
|
|
307
|
+
() =>
|
|
308
|
+
({
|
|
309
|
+
"--office-panel": colors.surface0,
|
|
310
|
+
"--office-control": colors.surface2,
|
|
311
|
+
"--office-border": colors.border,
|
|
312
|
+
"--office-text": colors.foreground,
|
|
313
|
+
"--office-muted": colors.foregroundMuted,
|
|
314
|
+
}) as CSSProperties,
|
|
315
|
+
[colors],
|
|
316
|
+
);
|
|
317
|
+
return (
|
|
318
|
+
<>
|
|
319
|
+
<dialog
|
|
320
|
+
ref={dialog}
|
|
321
|
+
className="paseo-office-dialog"
|
|
322
|
+
data-size={size}
|
|
323
|
+
style={tokens}
|
|
324
|
+
aria-label={title}
|
|
325
|
+
onCancel={cancel}
|
|
326
|
+
onKeyDown={cycleFocus}
|
|
327
|
+
onPointerDown={pointerDown}
|
|
328
|
+
onClick={clicked}
|
|
329
|
+
>
|
|
330
|
+
<style>{dialogCss}</style>
|
|
331
|
+
<div className="office-dialog-frame">
|
|
332
|
+
<header className="office-dialog-head">
|
|
333
|
+
{icon && (
|
|
334
|
+
<span className="office-dialog-icon" aria-hidden>
|
|
335
|
+
{icon}
|
|
336
|
+
</span>
|
|
337
|
+
)}
|
|
338
|
+
<h2>{title}</h2>
|
|
339
|
+
{headerActions && <div className="office-dialog-tools">{headerActions}</div>}
|
|
340
|
+
{dockRequest && (
|
|
341
|
+
<button
|
|
342
|
+
ref={minimizeButton}
|
|
343
|
+
type="button"
|
|
344
|
+
className="office-dialog-close"
|
|
345
|
+
aria-label="Minimize workspace"
|
|
346
|
+
title="Minimize workspace"
|
|
347
|
+
onClick={minimize}
|
|
348
|
+
>
|
|
349
|
+
<Icon name="Minus" size={18} color="currentColor" />
|
|
350
|
+
</button>
|
|
351
|
+
)}
|
|
352
|
+
<button
|
|
353
|
+
type="button"
|
|
354
|
+
className="office-dialog-close"
|
|
355
|
+
aria-label={`Close ${title}`}
|
|
356
|
+
title="Close"
|
|
357
|
+
onClick={close}
|
|
358
|
+
>
|
|
359
|
+
<Icon name="X" size={18} color="currentColor" />
|
|
360
|
+
</button>
|
|
361
|
+
</header>
|
|
362
|
+
{children}
|
|
363
|
+
</div>
|
|
364
|
+
</dialog>
|
|
365
|
+
{dockRequest && (
|
|
366
|
+
<div
|
|
367
|
+
role="toolbar"
|
|
368
|
+
aria-label="Minimized workspaces"
|
|
369
|
+
className="office-workspace-dock"
|
|
370
|
+
style={tokens}
|
|
371
|
+
hidden={!dockVisible || !!cameraButton}
|
|
372
|
+
>
|
|
373
|
+
<button
|
|
374
|
+
ref={restoreButton}
|
|
375
|
+
type="button"
|
|
376
|
+
aria-label={`Restore ${title}`}
|
|
377
|
+
title={`Restore ${title}`}
|
|
378
|
+
onClick={restore}
|
|
379
|
+
>
|
|
380
|
+
<Icon name="PanelsTopLeft" size={16} color="currentColor" />
|
|
381
|
+
<span>{title}</span>
|
|
382
|
+
</button>
|
|
383
|
+
</div>
|
|
384
|
+
)}
|
|
385
|
+
</>
|
|
386
|
+
);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
export function OfficeModal({ size, headerActions, dockRequest, ...props }: OfficeModalProps) {
|
|
390
|
+
const appearance = useContext(Fullscreen);
|
|
391
|
+
if (appearance === null) return <PaseoModal {...props} />;
|
|
392
|
+
return props.open ? (
|
|
393
|
+
<BrowserDialog
|
|
394
|
+
{...props}
|
|
395
|
+
size={size}
|
|
396
|
+
headerActions={headerActions}
|
|
397
|
+
dockRequest={dockRequest}
|
|
398
|
+
{...appearance}
|
|
399
|
+
/>
|
|
400
|
+
) : null;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
OfficeModal.Content = function Content({
|
|
404
|
+
children,
|
|
405
|
+
scrollable = true,
|
|
406
|
+
style,
|
|
407
|
+
contentContainerStyle,
|
|
408
|
+
}: ModalContentProps) {
|
|
409
|
+
const appearance = useContext(Fullscreen);
|
|
410
|
+
const bodyStyle = useMemo(
|
|
411
|
+
() => [appearance?.styles.dialogBody, contentContainerStyle],
|
|
412
|
+
[appearance, contentContainerStyle],
|
|
413
|
+
);
|
|
414
|
+
const boundedBodyStyle = useMemo(
|
|
415
|
+
() => [appearance?.styles.columnBody, bodyStyle, style],
|
|
416
|
+
[appearance, bodyStyle, style],
|
|
417
|
+
);
|
|
418
|
+
if (appearance === null) {
|
|
419
|
+
return (
|
|
420
|
+
<PaseoModal.Content
|
|
421
|
+
scrollable={scrollable}
|
|
422
|
+
style={style}
|
|
423
|
+
contentContainerStyle={contentContainerStyle}
|
|
424
|
+
>
|
|
425
|
+
{children}
|
|
426
|
+
</PaseoModal.Content>
|
|
427
|
+
);
|
|
428
|
+
}
|
|
429
|
+
if (scrollable)
|
|
430
|
+
return (
|
|
431
|
+
<ScrollView style={style} contentContainerStyle={bodyStyle}>
|
|
432
|
+
{children}
|
|
433
|
+
</ScrollView>
|
|
434
|
+
);
|
|
435
|
+
return (
|
|
436
|
+
<div className="office-dialog-bounded">
|
|
437
|
+
<View style={boundedBodyStyle}>{children}</View>
|
|
438
|
+
</div>
|
|
439
|
+
);
|
|
440
|
+
};
|
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { OfficeBrandContext } from "./office-brand-context.js";
|
|
2
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
3
|
+
import { Text, View } from "react-native";
|
|
4
|
+
import { OfficeModal } from "./office-modal.js";
|
|
3
5
|
import type { PluginSurfaceProps } from "@getpaseo/plugin/client";
|
|
4
6
|
import { HostSwitches } from "./host-switches.js";
|
|
7
|
+
import { settingsLayout } from "./settings-sections.js";
|
|
5
8
|
import { LanguageSetting } from "./language-switch.js";
|
|
6
9
|
import { LabeledSwitch } from "./labeled-switch.js";
|
|
7
10
|
import { deviceProblemOf, hasTouchScreen, readPointer, useViewChoice } from "./office-surface.js";
|
|
8
|
-
import { useOfficeStyles } from "./styles.js";
|
|
11
|
+
import { useOfficeStyles, type OfficeStyles } from "./styles.js";
|
|
9
12
|
import { useBoardActions } from "./use-board-actions.js";
|
|
10
13
|
import { useOffice } from "./use-office.js";
|
|
11
|
-
import {
|
|
14
|
+
import { useOfficeScene } from "./use-street.js";
|
|
12
15
|
import { useSoundSwitch } from "./use-sound.js";
|
|
16
|
+
import { SceneChoices } from "./scene-picker.js";
|
|
13
17
|
import { ViewSwitch } from "./view-switch.js";
|
|
14
18
|
|
|
15
|
-
/**
|
|
16
|
-
* The office's settings, under the app's Settings: what the host holds (wakes, agent tools, the
|
|
17
|
-
* stand-up notes, the incident trackers, the 3D floor's plan) and this device's view and Sound
|
|
18
|
-
* switch. The office's page shows none of them, so a phone's floor is not covered. The screen
|
|
19
|
-
* follows the office's state for the wakes and the schedules' failures, so the host does its "an
|
|
20
|
-
* office surface is open" work while it is open.
|
|
21
|
-
*/
|
|
22
19
|
export function OfficeSettings({ theme, layout }: PluginSurfaceProps) {
|
|
23
20
|
const touchScreen = useMemo(
|
|
24
21
|
() => hasTouchScreen(layout.platform, layout.platform === "web" ? readPointer() : null),
|
|
@@ -28,41 +25,89 @@ export function OfficeSettings({ theme, layout }: PluginSurfaceProps) {
|
|
|
28
25
|
const office = useOffice();
|
|
29
26
|
const actions = useBoardActions();
|
|
30
27
|
const view = useViewChoice(layout.platform);
|
|
31
|
-
const street =
|
|
28
|
+
const street = useOfficeScene(layout);
|
|
32
29
|
const sound = useSoundSwitch();
|
|
30
|
+
return (
|
|
31
|
+
<OfficeSettingsFields
|
|
32
|
+
office={office}
|
|
33
|
+
styles={styles}
|
|
34
|
+
actions={actions}
|
|
35
|
+
view={view}
|
|
36
|
+
street={street}
|
|
37
|
+
sound={sound}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface FieldsProps {
|
|
43
|
+
office: ReturnType<typeof useOffice>;
|
|
44
|
+
styles: OfficeStyles;
|
|
45
|
+
actions: ReturnType<typeof useBoardActions>;
|
|
46
|
+
view: ReturnType<typeof useViewChoice>;
|
|
47
|
+
street: ReturnType<typeof useOfficeScene>;
|
|
48
|
+
sound: ReturnType<typeof useSoundSwitch>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function OfficeSettingsFields({ office, styles, actions, view, street, sound }: FieldsProps) {
|
|
52
|
+
const language = useMemo(() => <LanguageSetting styles={styles} />, [styles]);
|
|
33
53
|
// Frozen data says nothing of the wakes: the switch is then not usable.
|
|
34
54
|
const live = office.subscription.status !== "error" && office.subscription.status !== "closed";
|
|
35
55
|
return (
|
|
36
|
-
<
|
|
56
|
+
<OfficeBrandContext.Provider value={office.state.brand}>
|
|
37
57
|
<HostSwitches
|
|
58
|
+
language={language}
|
|
38
59
|
wake={office.loaded && live ? office.state.wake : null}
|
|
39
60
|
actions={actions}
|
|
40
61
|
styles={styles}
|
|
41
62
|
deviceProblem={
|
|
42
|
-
deviceProblemOf(view.unsaved, sound.unsaved) ??
|
|
63
|
+
deviceProblemOf(view.unsaved, sound.unsaved) ??
|
|
64
|
+
(street.unsaved ? "Unable to save the scene on this device." : null)
|
|
43
65
|
}
|
|
44
66
|
scheduleError={office.state.notes?.scheduleError ?? null}
|
|
45
67
|
weather={office.state.weather}
|
|
46
68
|
incidents={office.state.incidents}
|
|
47
69
|
>
|
|
48
70
|
<>
|
|
49
|
-
<
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
onChange={street.set}
|
|
61
|
-
styles={styles}
|
|
62
|
-
/>
|
|
71
|
+
<SceneChoices choice={street} styles={styles} />
|
|
72
|
+
<View style={settingsLayout.strip}>
|
|
73
|
+
<Text style={styles.sheetLabel}>Office view</Text>
|
|
74
|
+
<ViewSwitch
|
|
75
|
+
options={view.options}
|
|
76
|
+
value={view.choice}
|
|
77
|
+
onChange={view.choose}
|
|
78
|
+
styles={styles}
|
|
79
|
+
/>
|
|
80
|
+
<LabeledSwitch label="Sound" value={sound.on} onChange={sound.set} styles={styles} />
|
|
81
|
+
</View>
|
|
63
82
|
</>
|
|
64
83
|
</HostSwitches>
|
|
65
|
-
|
|
66
|
-
</View>
|
|
84
|
+
</OfficeBrandContext.Provider>
|
|
67
85
|
);
|
|
68
86
|
}
|
|
87
|
+
|
|
88
|
+
export function FullscreenSettings({
|
|
89
|
+
open,
|
|
90
|
+
onClose,
|
|
91
|
+
...fields
|
|
92
|
+
}: FieldsProps & {
|
|
93
|
+
open: boolean;
|
|
94
|
+
onClose(): void;
|
|
95
|
+
}) {
|
|
96
|
+
return (
|
|
97
|
+
<OfficeModal title="Office settings" size="settings" open={open} onOpenChange={onClose}>
|
|
98
|
+
<OfficeModal.Content scrollable={false} contentContainerStyle={settingsLayout.flush}>
|
|
99
|
+
<OfficeSettingsFields {...fields} />
|
|
100
|
+
</OfficeModal.Content>
|
|
101
|
+
</OfficeModal>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function useOfficeSettingsDialog(fullscreen: boolean, nativeSettings?: () => void) {
|
|
106
|
+
const [open, setOpen] = useState(false);
|
|
107
|
+
const show = useCallback(() => setOpen(true), []);
|
|
108
|
+
const close = useCallback(() => setOpen(false), []);
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
if (!fullscreen) close();
|
|
111
|
+
}, [fullscreen, close]);
|
|
112
|
+
return { open: fullscreen && open, show: fullscreen ? show : nativeSettings, close };
|
|
113
|
+
}
|
package/client/office-state.ts
CHANGED
|
@@ -27,6 +27,7 @@ export function applyOfficeEvent(state: OfficeSnapshot, event: OfficeEvent): Off
|
|
|
27
27
|
activity: event.activity,
|
|
28
28
|
doing: event.doing ?? {},
|
|
29
29
|
checklists: event.checklists ?? {},
|
|
30
|
+
checklistProgress: event.checklistProgress,
|
|
30
31
|
};
|
|
31
32
|
case "board":
|
|
32
33
|
return { ...state, boards: { ...state.boards, [event.board]: event.posts } };
|
|
@@ -66,12 +67,21 @@ export function applyChatEvent(chat: ChatSnapshot | null, event: OfficeEvent): C
|
|
|
66
67
|
const messages = known
|
|
67
68
|
? base.messages.map((m) => (m.id === change.message.id ? change.message : m))
|
|
68
69
|
: [...base.messages, change.message];
|
|
69
|
-
|
|
70
|
+
const recalledPin = change.message.recalled && change.message.id === base.pinned;
|
|
71
|
+
return {
|
|
72
|
+
...base,
|
|
73
|
+
messages: messages.slice(-CHAT_MESSAGE_MAX),
|
|
74
|
+
...(recalledPin ? { pinned: null } : {}),
|
|
75
|
+
};
|
|
70
76
|
}
|
|
71
77
|
case "typing":
|
|
72
78
|
return { ...base, typing: change.names };
|
|
73
79
|
case "all":
|
|
74
|
-
return {
|
|
80
|
+
return {
|
|
81
|
+
...base,
|
|
82
|
+
messages: change.messages,
|
|
83
|
+
...(change.pinned === undefined ? {} : { pinned: change.pinned }),
|
|
84
|
+
};
|
|
75
85
|
case "act":
|
|
76
86
|
return base;
|
|
77
87
|
}
|