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
@@ -1,3 +1,5 @@
1
+ import { useChatKeyboard } from "./office-keyboard.js";
2
+ import { OfficeBrandContext } from "./office-brand-context.js";
1
3
  import {
2
4
  useCallback,
3
5
  useEffect,
@@ -17,6 +19,7 @@ import {
17
19
  } from "@getpaseo/plugin/client";
18
20
  import { Icon, ScrollView } from "@getpaseo/plugin/client/ui";
19
21
  import {
22
+ LOBBY,
20
23
  notesReadRpc,
21
24
  type ChatMessage,
22
25
  type WeatherScene,
@@ -36,9 +39,13 @@ import { sheetLeavesFirstOn } from "./agent-picker-text.js";
36
39
  import { AttentionStrip, type StripCard } from "./attention-strip.js";
37
40
  import { resourcesOpener } from "./beside.js";
38
41
  import { BoardSheet } from "./board-sheet.js";
42
+ import { DutySheet } from "./duty-sheet.js";
43
+ import { useDutyActions } from "./use-duty-actions.js";
39
44
  import { authorName } from "./board-text.js";
40
45
  import { useChatSeen } from "./chat-seen.js";
41
- import { ChatPanel } from "./chat-panel.js";
46
+ import { TeamChatPreview } from "./team-chat-preview.js";
47
+ import { useGroupPhoto } from "./use-group-photo.js";
48
+ import { ChatPanel, FloatingTeamChat } from "./chat-panel.js";
42
49
  import { unreadCount, unreadLabel } from "./chat-text.js";
43
50
  import {
44
51
  COLUMN_MIN,
@@ -52,8 +59,9 @@ import { weatherEntry } from "./weather-text.js";
52
59
  import { incidentsEntry } from "./incidents-text.js";
53
60
  import { janitorNote, janitorRows } from "./context-text.js";
54
61
  import { JanitorCard } from "./janitor-card.js";
62
+ import { useSshServers } from "./ssh-hosts.js";
55
63
  import { MachineCard } from "./machine-card.js";
56
- import { hostNote, namedMachine, type HostNote } from "../shared/machine-text.js";
64
+ import { hostNote, memoryPercent, namedMachine, type HostNote } from "../shared/machine-text.js";
57
65
  import {
58
66
  buildOfficeModel,
59
67
  orderRoomsForFocus,
@@ -61,12 +69,22 @@ import {
61
69
  type OfficeRoom,
62
70
  } from "../shared/model.js";
63
71
  import type { FocusRequest } from "./focus-request.js";
64
- import { ColumnBar, ColumnSheet } from "./column-sheet.js";
65
- import { SessionPane, sessionOf, sessionTabsOf, type SessionContext } from "./session-pane.js";
72
+ import { ColumnBar, ColumnDialog, ColumnSheet } from "./column-sheet.js";
73
+ import {
74
+ SessionPane,
75
+ sessionChildren,
76
+ sessionOf,
77
+ sessionTabsOf,
78
+ type SessionContext,
79
+ } from "./session-pane.js";
66
80
  import { useReplyDrafts } from "./use-reply-drafts.js";
81
+ import { OfficeWorkspace, type WorkspaceSelection } from "./workspace-office-tools.js";
82
+ import { OfficeDialogs } from "./office-modal.js";
83
+ import { FullscreenSettings, useOfficeSettingsDialog } from "./office-settings.js";
67
84
  import { OfficeColumn, type ColumnBadges, type ColumnSession } from "./office-column.js";
68
85
  import { EMPTY_CHOICE, type NewAgentChoice } from "./new-agent-model.js";
69
86
  import type { ChatDraft, ColumnPanelProps, NewAgentDraft, OfficeLink } from "./office-link.js";
87
+ import type { SidebarLauncher } from "./sidebar-launcher.js";
70
88
  import { SessionsPanel } from "./sessions-panel.js";
71
89
  import { PixelOffice } from "./pixel/pixel-office.js";
72
90
  import { StructureView } from "./structure-view.js";
@@ -74,10 +92,12 @@ import { SESSION_RAIL_MIN, useOfficeStyles, type OfficeStyles } from "./styles.j
74
92
  import { useAgentActions, type AgentActions } from "./use-agent-actions.js";
75
93
  import { useBoardActions } from "./use-board-actions.js";
76
94
  import { useDeviceSwitch } from "./use-device-switch.js";
95
+ import { fullscreenTheme } from "./fullscreen-theme.js";
77
96
  import { FullscreenHeader, type SidebarControls } from "./fullscreen-header.js";
78
97
  import { useColumn, type ColumnState } from "./use-column.js";
79
98
  import { LibraryCard } from "./library-card.js";
80
99
  import { NotesCard } from "./notes-card.js";
100
+ import { leaveFullscreenAfter, lockEscape, pageUsesEscape, unlockEscape } from "./world/escape.js";
81
101
  import { todayZone } from "./notes-text.js";
82
102
  import { QaCard } from "./qa-card.js";
83
103
  import { ReviewCard } from "./review-card.js";
@@ -97,7 +117,7 @@ import { ViewSwitch } from "./view-switch.js";
97
117
  import { hasWebGL2 } from "./web-env.web.js";
98
118
  import { hasScriptFrame } from "./world/script-frame-kit.js";
99
119
  import { useFloorPlan } from "./world/use-floor-plan.js";
100
- import { useStreetSwitch } from "./use-street.js";
120
+ import { useOfficeScene } from "./use-street.js";
101
121
  import { WorldView } from "./world/world-view.js";
102
122
  import { WorldViewNative } from "./world/world-view-native.js";
103
123
 
@@ -528,6 +548,7 @@ function SurfaceNotices({
528
548
  interface PanelButtonProps {
529
549
  /** What it opens, and what a screen reader calls it. */
530
550
  label: string;
551
+ caption?: string | undefined;
531
552
  /** A Lucide name. */
532
553
  icon: string;
533
554
  screenId: string;
@@ -546,6 +567,7 @@ interface PanelButtonProps {
546
567
  */
547
568
  function PanelButton({
548
569
  label,
570
+ caption,
549
571
  icon,
550
572
  screenId,
551
573
  size,
@@ -570,7 +592,7 @@ function PanelButton({
570
592
  onPressOut={pressOut}
571
593
  onHoverIn={hoverIn}
572
594
  onHoverOut={hoverOut}
573
- style={styles.segment}
595
+ style={caption ? styles.sidebarButton : styles.segment}
574
596
  >
575
597
  {hovered || pressed ? <View style={styles.segmentHoverFill} /> : null}
576
598
  {/* The count sits on the icon's corner, inside the pill that clips. */}
@@ -582,6 +604,11 @@ function PanelButton({
582
604
  </View>
583
605
  ) : null}
584
606
  </View>
607
+ {caption && (
608
+ <Text numberOfLines={1} style={styles.sidebarButtonText}>
609
+ {caption}
610
+ </Text>
611
+ )}
585
612
  </Pressable>
586
613
  );
587
614
  }
@@ -613,6 +640,8 @@ function SettingsButton({ onOpen, compact, touchScreen, color, styles }: Setting
613
640
  }
614
641
 
615
642
  interface SurfaceBodyProps {
643
+ onPhotoReady: ReturnType<typeof useGroupPhoto>["onPhotoReady"];
644
+ fullscreen?: { active: boolean; toggle(): void } | undefined;
616
645
  office: OfficeState;
617
646
  model: OfficeModel;
618
647
  rooms: readonly OfficeRoom[];
@@ -629,7 +658,15 @@ interface SurfaceBodyProps {
629
658
  /** Null from the 3D office, when the chosen person is tapped again. */
630
659
  onSelectAgent(agentId: string | null): void;
631
660
  onOpenSession: ((agentId: string) => void) | undefined;
661
+ onOpenAgentWorkspace(agentId: string): void;
632
662
  onOpenBoard(roomId: string): void;
663
+ /**
664
+ * The duty board's editor: the 3D pantry's board and the List's lobby card open it. Absent while
665
+ * the host has sent no duty list.
666
+ */
667
+ onOpenDuties: (() => void) | undefined;
668
+ /** The 3D office acted out a pretend duty with this agent's figure. */
669
+ onDutyActed(id: string, agentId: string): void;
633
670
  machine: Machine | null;
634
671
  onOpenMachine(): void;
635
672
  /** The 3D wall screen's: absent on an app that cannot show Resources beside the floor. */
@@ -649,10 +686,12 @@ interface SurfaceBodyProps {
649
686
  platform: Platform;
650
687
  /** The device's Sound switch, which the 3D office follows and its button sets. */
651
688
  sound: SoundSwitch;
652
- street: boolean | null;
689
+ street: ReturnType<typeof useOfficeScene>;
653
690
  }
654
691
 
655
692
  function SurfaceBody({
693
+ onPhotoReady,
694
+ fullscreen,
656
695
  office,
657
696
  model,
658
697
  rooms,
@@ -667,7 +706,10 @@ function SurfaceBody({
667
706
  name,
668
707
  onSelectAgent,
669
708
  onOpenSession,
709
+ onOpenAgentWorkspace,
670
710
  onOpenBoard,
711
+ onOpenDuties,
712
+ onDutyActed,
671
713
  machine,
672
714
  onOpenMachine,
673
715
  onOpenResources,
@@ -708,6 +750,8 @@ function SurfaceBody({
708
750
  const World = worldViewFor(platform);
709
751
  return (
710
752
  <World
753
+ onPhotoReady={onPhotoReady}
754
+ fullscreen={fullscreen}
711
755
  model={model}
712
756
  theme={theme}
713
757
  styles={styles}
@@ -717,10 +761,12 @@ function SurfaceBody({
717
761
  selectedAgentId={selectedAgentId}
718
762
  onSelectAgent={onSelectAgent}
719
763
  onSelectBoard={onOpenBoard}
764
+ onOpenDuties={onOpenDuties}
765
+ onDutyActed={onDutyActed}
720
766
  machine={machine}
721
767
  onOpenMachine={onOpenMachine}
722
768
  onOpenResources={onOpenResources}
723
- onOpenSession={onOpenSession}
769
+ onOpenAgentWorkspace={onOpenAgentWorkspace}
724
770
  onOpenLibrary={onOpenLibrary}
725
771
  onOpenNotes={onOpenNotes}
726
772
  meeting={meeting}
@@ -729,7 +775,13 @@ function SurfaceBody({
729
775
  onOpenIncidents={onOpenIncidents}
730
776
  onProblem={onSceneProblem}
731
777
  sound={sound}
732
- streetOn={street}
778
+ streetOn={street.scene.on === null ? null : street.scene.on === "city"}
779
+ scene={street.scene.on ?? undefined}
780
+ night={
781
+ street.lighting.on === "auto" || street.lighting.on === null
782
+ ? undefined
783
+ : street.lighting.on === "night"
784
+ }
733
785
  />
734
786
  );
735
787
  }
@@ -761,6 +813,7 @@ function SurfaceBody({
761
813
  onSelectAgent={onSelectAgent}
762
814
  onOpenSession={onOpenSession}
763
815
  onOpenBoard={onOpenBoard}
816
+ onOpenDuties={onOpenDuties}
764
817
  />
765
818
  );
766
819
  }
@@ -804,6 +857,7 @@ function useCardOpening(live: boolean): CardOpening {
804
857
  }
805
858
 
806
859
  interface ViewControlsProps {
860
+ keyboardVisible: boolean;
807
861
  badges: ColumnBadges;
808
862
  sidebars?: SidebarControls;
809
863
  full: ReturnType<typeof useFullscreen>;
@@ -812,6 +866,10 @@ interface ViewControlsProps {
812
866
  viewChoice: ViewChoiceState;
813
867
  /** The device refused to store a press on the 3D floor's Sound button. */
814
868
  soundUnsaved: boolean;
869
+ toolbarLabels: boolean;
870
+ onTeam(): void;
871
+ machine: Machine | null;
872
+ onMachine?: () => void;
815
873
  onChange(next: OfficeViewChoice): void;
816
874
  compact: boolean;
817
875
  touchScreen: boolean;
@@ -820,14 +878,42 @@ interface ViewControlsProps {
820
878
  styles: OfficeStyles;
821
879
  }
822
880
 
881
+ function HostResourceButton({
882
+ machine,
883
+ onOpen,
884
+ styles,
885
+ }: {
886
+ machine: Machine | null;
887
+ onOpen(): void;
888
+ styles: OfficeStyles;
889
+ }) {
890
+ const percent = machine ? memoryPercent(machine) : null;
891
+ return (
892
+ <Pressable
893
+ accessibilityRole="button"
894
+ accessibilityLabel="Host resources"
895
+ onPress={onOpen}
896
+ style={styles.sidebarButton}
897
+ >
898
+ <Icon name="Cpu" size={15} color={String(styles.sidebarButtonText.color)} />
899
+ <Text style={styles.sidebarButtonText}>{percent === null ? "Host" : `RAM ${percent}%`}</Text>
900
+ </Pressable>
901
+ );
902
+ }
903
+
823
904
  /** The view switch and the settings button. */
824
905
  function ViewControls({
906
+ keyboardVisible,
825
907
  badges,
826
908
  sidebars,
827
909
  full,
828
910
  floorDrawn,
829
911
  viewChoice,
830
912
  soundUnsaved,
913
+ toolbarLabels,
914
+ onTeam,
915
+ machine,
916
+ onMachine,
831
917
  onChange,
832
918
  compact,
833
919
  touchScreen,
@@ -847,8 +933,29 @@ function ViewControls({
847
933
  ),
848
934
  [viewChoice.options, viewChoice.choice, onChange, styles],
849
935
  );
936
+ const showOffice = useCallback(() => {
937
+ onChange(viewChoice.options.includes("3d") ? "3d" : "2d");
938
+ sidebars?.column.show("activity");
939
+ }, [onChange, viewChoice.options, sidebars]);
940
+ if (compact && keyboardVisible) return null;
850
941
  const actions = (
851
942
  <>
943
+ {sidebars && onMachine && (
944
+ <HostResourceButton machine={machine} onOpen={onMachine} styles={styles} />
945
+ )}
946
+ {sidebars && (
947
+ <PanelButton
948
+ label="Team chat"
949
+ caption={toolbarLabels ? "Team chat" : undefined}
950
+ icon="MessageCircle"
951
+ screenId="team"
952
+ size={18}
953
+ count={badges.chat}
954
+ color={color}
955
+ onOpen={onTeam}
956
+ styles={styles}
957
+ />
958
+ )}
852
959
  {full.available ? (
853
960
  <PanelButton
854
961
  label={full.active ? "Exit full screen" : "Full screen"}
@@ -884,6 +991,7 @@ function ViewControls({
884
991
  sidebars={sidebars}
885
992
  badges={badges}
886
993
  modes={modes}
994
+ onOffice={showOffice}
887
995
  color={color}
888
996
  styles={styles}
889
997
  >
@@ -893,10 +1001,11 @@ function ViewControls({
893
1001
  </>
894
1002
  );
895
1003
  }
1004
+ const floating = floorDrawn && !compact;
896
1005
  return (
897
1006
  <View
898
- testID={floorDrawn ? "office-view-corner" : "office-view-row"}
899
- style={floorDrawn ? styles.viewCorner : styles.viewRow}
1007
+ testID={floating ? "office-view-corner" : "office-view-row"}
1008
+ style={floating ? styles.viewCorner : styles.viewRow}
900
1009
  >
901
1010
  <View style={styles.viewControls}>
902
1011
  {modes}
@@ -940,6 +1049,7 @@ function SessionsSidebar({
940
1049
  }
941
1050
 
942
1051
  interface ColumnPanelSwitchProps extends ColumnPanelProps {
1052
+ onCloseChat?: (() => void) | undefined;
943
1053
  tab: ColumnTab;
944
1054
  /** The Attention tab's content. */
945
1055
  attention: ReactNode;
@@ -948,7 +1058,7 @@ interface ColumnPanelSwitchProps extends ColumnPanelProps {
948
1058
  }
949
1059
 
950
1060
  /** The chosen tab's panel. Only that one is mounted: Chat counts as seen while it is. */
951
- function ColumnPanel({ tab, attention, draft, ...panel }: ColumnPanelSwitchProps) {
1061
+ function ColumnPanel({ tab, attention, draft, onCloseChat, ...panel }: ColumnPanelSwitchProps) {
952
1062
  if (tab === "attention") {
953
1063
  return (
954
1064
  <ScrollView contentContainerStyle={panel.styles.columnAttention}>{attention}</ScrollView>
@@ -956,7 +1066,7 @@ function ColumnPanel({ tab, attention, draft, ...panel }: ColumnPanelSwitchProps
956
1066
  }
957
1067
  if (tab === "sessions") return <SessionsPanel {...panel} />;
958
1068
  if (tab === "activity") return <ActivityPanel {...panel} />;
959
- return <ChatPanel {...panel} draft={draft} />;
1069
+ return <ChatPanel {...panel} draft={draft} onClose={onCloseChat} />;
960
1070
  }
961
1071
 
962
1072
  interface ColumnViewPanelProps extends Omit<ColumnPanelSwitchProps, "tab"> {
@@ -972,6 +1082,9 @@ function ColumnViewPanel({ view, session, ...panel }: ColumnViewPanelProps) {
972
1082
  return (
973
1083
  <SessionPane
974
1084
  agentId={view.agentId}
1085
+ inSheet={panel.layout.compact}
1086
+ subagents={sessionChildren(model, view.agentId)}
1087
+ onOpenSubagent={panel.link.openSession}
975
1088
  agent={agent}
976
1089
  room={room}
977
1090
  reply={replies.texts.get(view.agentId) ?? ""}
@@ -989,7 +1102,12 @@ function ColumnViewPanel({ view, session, ...panel }: ColumnViewPanelProps) {
989
1102
  function useChatDraft(): ChatDraft {
990
1103
  const [text, setText] = useState("");
991
1104
  const [replyTo, setReplyTo] = useState<ChatMessage | null>(null);
992
- return useMemo(() => ({ text, setText, replyTo, setReplyTo }), [text, replyTo]);
1105
+ const [recipient, setRecipient] = useState<string | null>(null);
1106
+ const [images, setImages] = useState<ChatDraft["images"]>([]);
1107
+ return useMemo(
1108
+ () => ({ text, setText, replyTo, setReplyTo, recipient, setRecipient, images, setImages }),
1109
+ [text, replyTo, recipient, images],
1110
+ );
993
1111
  }
994
1112
 
995
1113
  /** What is chosen and typed in the Sessions tab's New agent form: the surface's, as the chat's is. */
@@ -1079,16 +1197,40 @@ function useColumnContent({
1079
1197
  * dismissing the sheet leaves an open session open. A row press must not leave the agent's card
1080
1198
  * under the sheet, so the sheet closes first; a session opens in the sheet.
1081
1199
  */
1082
- function useColumnSheet(column: ColumnState, compact: boolean, select: (agentId: string) => void) {
1200
+ function useOfficeColumn(compact: boolean, integrated: boolean, openChat: () => void): ColumnState {
1201
+ const column = useColumn(compact);
1202
+ const { show, view } = column;
1203
+ return useMemo(
1204
+ () => ({
1205
+ ...column,
1206
+ view:
1207
+ integrated && view.kind === "tab" && view.tab === "chat"
1208
+ ? { kind: "tab", tab: "activity" }
1209
+ : view,
1210
+ show(tab) {
1211
+ if (integrated && tab === "chat") openChat();
1212
+ else show(tab);
1213
+ },
1214
+ }),
1215
+ [column, view, show, integrated, openChat],
1216
+ );
1217
+ }
1218
+
1219
+ function useColumnSheet(
1220
+ column: ColumnState,
1221
+ compact: boolean,
1222
+ floatingChat: boolean,
1223
+ select: (agentId: string) => void,
1224
+ ) {
1083
1225
  const [open, setOpen] = useState(false);
1084
1226
  const closeSheet = useCallback(() => setOpen(false), []);
1085
1227
  const { show, openSession: openInColumn } = column;
1086
1228
  const openTab = useCallback(
1087
1229
  (tab: ColumnTab) => {
1088
1230
  show(tab);
1089
- setOpen(true);
1231
+ setOpen(!(floatingChat && tab === "chat"));
1090
1232
  },
1091
- [show],
1233
+ [show, floatingChat],
1092
1234
  );
1093
1235
  const openSession = useCallback(
1094
1236
  (agentId: string) => {
@@ -1112,6 +1254,28 @@ function useColumnSheet(column: ColumnState, compact: boolean, select: (agentId:
1112
1254
  return { sheetView, openTab, closeSheet, openSession, link, sheetLink };
1113
1255
  }
1114
1256
 
1257
+ function sceneSelection(
1258
+ compact: boolean,
1259
+ platform: Platform,
1260
+ view: ColumnView | null,
1261
+ card: string | null,
1262
+ ) {
1263
+ if (compact && platform !== "web" && view?.kind === "session") return view.agentId;
1264
+ return card;
1265
+ }
1266
+
1267
+ function usesOfficeKeyboard(
1268
+ platform: Platform,
1269
+ floating: boolean,
1270
+ compact: boolean,
1271
+ sheet: ColumnView | null,
1272
+ column: ColumnView,
1273
+ ) {
1274
+ if (compact && platform !== "web") return false; // The native conversation dialog owns its keyboard.
1275
+ const visible = compact ? sheet : column;
1276
+ return floating || (visible?.kind === "tab" && visible.tab === "chat");
1277
+ }
1278
+
1115
1279
  type ColumnSheetState = ReturnType<typeof useColumnSheet>;
1116
1280
 
1117
1281
  interface PhoneSheetProps extends Omit<ColumnPanelProps, "link"> {
@@ -1143,12 +1307,43 @@ function PhoneSheet({
1143
1307
  const closeShown = useCallback(() => {
1144
1308
  if (shown !== null) closeSession(shown);
1145
1309
  }, [shown, closeSession]);
1146
- if (!compact) return null;
1310
+ if (!compact || !view) return null;
1147
1311
  const title = sessions.find((each) => each.agentId === shown)?.title ?? null;
1312
+ const identity = shown ? sessionOf(session.model, shown) : null;
1313
+ const nativeDialog = panel.layout.platform !== "web";
1314
+ const content = (
1315
+ <ColumnViewPanel
1316
+ view={view}
1317
+ onCloseChat={nativeDialog ? undefined : sheet.closeSheet}
1318
+ session={session}
1319
+ attention={attention}
1320
+ {...panel}
1321
+ link={sheet.sheetLink}
1322
+ />
1323
+ );
1324
+ if (nativeDialog) {
1325
+ return (
1326
+ <ColumnDialog
1327
+ view={view}
1328
+ sessionTitle={title}
1329
+ identity={identity}
1330
+ color={color}
1331
+ styles={panel.styles}
1332
+ onBack={back}
1333
+ onDismiss={sheet.closeSheet}
1334
+ >
1335
+ <OfficeBrandContext.Provider value={panel.office.state.brand}>
1336
+ {content}
1337
+ </OfficeBrandContext.Provider>
1338
+ </ColumnDialog>
1339
+ );
1340
+ }
1148
1341
  return (
1149
1342
  <ColumnSheet
1150
1343
  open={view}
1151
1344
  sessionTitle={title}
1345
+ sessionAgent={identity?.agent}
1346
+ sessionRoom={identity?.room}
1152
1347
  color={color}
1153
1348
  iconSize={20}
1154
1349
  platform={panel.layout.platform}
@@ -1157,20 +1352,13 @@ function PhoneSheet({
1157
1352
  onCloseSession={closeShown}
1158
1353
  styles={panel.styles}
1159
1354
  >
1160
- {view === null ? null : (
1161
- <ColumnViewPanel
1162
- view={view}
1163
- session={session}
1164
- attention={attention}
1165
- {...panel}
1166
- link={sheet.sheetLink}
1167
- />
1168
- )}
1355
+ {content}
1169
1356
  </ColumnSheet>
1170
1357
  );
1171
1358
  }
1172
1359
 
1173
1360
  interface PhoneBarProps {
1361
+ keyboardVisible: boolean;
1174
1362
  compact: boolean;
1175
1363
  sheet: ColumnSheetState;
1176
1364
  sessions: readonly ColumnSession[];
@@ -1180,8 +1368,16 @@ interface PhoneBarProps {
1180
1368
  }
1181
1369
 
1182
1370
  /** On a compact surface, the column's tabs as a bar under the floor; nothing on a wide one. */
1183
- function PhoneBar({ compact, sheet, sessions, badges, color, styles }: PhoneBarProps) {
1184
- if (!compact) return null;
1371
+ function PhoneBar({
1372
+ keyboardVisible,
1373
+ compact,
1374
+ sheet,
1375
+ sessions,
1376
+ badges,
1377
+ color,
1378
+ styles,
1379
+ }: PhoneBarProps) {
1380
+ if (!compact || keyboardVisible) return null;
1185
1381
  return (
1186
1382
  <ColumnBar
1187
1383
  open={sheet.sheetView}
@@ -1286,24 +1482,83 @@ function useSurfaceLayout(deviceCompact: boolean, styles: OfficeStyles, fullscre
1286
1482
  * at `contribute`: each call returns a new component type, so calling it while rendering would
1287
1483
  * remount the office.
1288
1484
  */
1289
- export function createOfficeSurface(openSettings: () => void) {
1485
+ export function createOfficeSurface(openSettings: () => void, launcher: SidebarLauncher) {
1290
1486
  return function Surface(props: OfficeSurfaceProps) {
1291
- return <OfficeSurface {...props} onOpenSettings={openSettings} />;
1487
+ return <OfficeSurface {...props} onOpenSettings={openSettings} launcher={launcher} />;
1292
1488
  };
1293
1489
  }
1294
1490
 
1295
- function useFullscreen(platform: Platform) {
1491
+ function useFullscreen(props: OfficeSurfaceProps, launcher: SidebarLauncher | undefined) {
1492
+ const { platform } = props.layout;
1493
+ const startExpanded =
1494
+ platform === "web" && !("workspaceId" in props) && props.params?.layout === "fullscreen";
1296
1495
  const root = useRef<View>(null);
1297
1496
  const [fullscreen, setFullscreen] = useState(false);
1497
+ const [expandedInPage, setExpandedInPage] = useState(startExpanded);
1298
1498
  const [fullscreenError, setFullscreenError] = useState(false);
1299
1499
  const canFullscreen =
1300
1500
  platform === "web" && typeof document !== "undefined" && document.fullscreenEnabled;
1301
1501
  useEffect(() => {
1302
1502
  if (!canFullscreen) return;
1303
- const changed = () => setFullscreen(Object.is(document.fullscreenElement, root.current));
1503
+ const changed = () => {
1504
+ const active = Object.is(document.fullscreenElement, root.current);
1505
+ if (active) setExpandedInPage(false);
1506
+ setFullscreen(active);
1507
+ // The scene's Escape (getting up from an activity, leaving walk-in) is the browser's own
1508
+ // while fullscreen: hold it for the page, and give it back with fullscreen.
1509
+ if (active) lockEscape(navigator);
1510
+ else unlockEscape(navigator);
1511
+ };
1512
+ // With Escape held, a press nothing used leaves fullscreen as it did before.
1513
+ const pressed = (event: KeyboardEvent) => {
1514
+ if (!Object.is(document.fullscreenElement, root.current)) return;
1515
+ leaveFullscreenAfter(event, pageUsesEscape(document), document);
1516
+ };
1304
1517
  document.addEventListener("fullscreenchange", changed);
1305
- return () => document.removeEventListener("fullscreenchange", changed);
1518
+ document.addEventListener("keydown", pressed, true);
1519
+ return () => {
1520
+ document.removeEventListener("fullscreenchange", changed);
1521
+ document.removeEventListener("keydown", pressed, true);
1522
+ unlockEscape(navigator);
1523
+ };
1306
1524
  }, [canFullscreen]);
1525
+ // A sidebar press on a retained screen must not activate a hidden floor.
1526
+ const launch = useCallback(() => {
1527
+ const element = root.current as unknown as HTMLElement | null;
1528
+ if (!element?.isConnected) return false;
1529
+ const rect = element.getBoundingClientRect();
1530
+ if (
1531
+ rect.width <= 0 ||
1532
+ rect.height <= 0 ||
1533
+ rect.bottom <= 0 ||
1534
+ rect.right <= 0 ||
1535
+ rect.left >= window.innerWidth ||
1536
+ rect.top >= window.innerHeight ||
1537
+ element.checkVisibility?.({ visibilityProperty: true }) === false
1538
+ )
1539
+ return false;
1540
+ setFullscreenError(false);
1541
+ if (document.fullscreenElement !== element) {
1542
+ if (
1543
+ canFullscreen &&
1544
+ typeof element.requestFullscreen === "function" &&
1545
+ navigator.userActivation?.isActive !== false
1546
+ ) {
1547
+ void element.requestFullscreen().catch(() => setExpandedInPage(true));
1548
+ } else {
1549
+ setExpandedInPage(true);
1550
+ }
1551
+ }
1552
+ return true;
1553
+ }, [canFullscreen]);
1554
+ useEffect(() => {
1555
+ if (platform === "web") return launcher?.register(launch);
1556
+ }, [platform, launcher, launch]);
1557
+ // The cold launch can mount after browser user activation has expired. Its
1558
+ // one-page layout still opens, with the toolbar available to enter fullscreen.
1559
+ useEffect(() => {
1560
+ if (startExpanded && launcher?.takeScreenLaunch()) launch();
1561
+ }, [startExpanded, launcher, launch]);
1307
1562
  const toggleFullscreen = useCallback(async () => {
1308
1563
  const element = root.current as unknown as HTMLElement | null;
1309
1564
  if (!element) return;
@@ -1318,6 +1573,7 @@ function useFullscreen(platform: Platform) {
1318
1573
  return {
1319
1574
  root,
1320
1575
  active: fullscreen,
1576
+ integrated: fullscreen || expandedInPage,
1321
1577
  error: fullscreenError,
1322
1578
  available: canFullscreen,
1323
1579
  toggle: toggleFullscreen,
@@ -1326,14 +1582,19 @@ function useFullscreen(platform: Platform) {
1326
1582
 
1327
1583
  function useFullscreenPanels(
1328
1584
  active: boolean,
1585
+ fullscreen: boolean,
1586
+ platform: Platform,
1329
1587
  compact: boolean,
1330
1588
  surfaceWidth: number,
1331
1589
  column: ColumnState,
1332
1590
  sheet: ColumnSheetState,
1333
1591
  select: (id: string | null) => void,
1334
1592
  selectFromStrip: (id: string) => void,
1593
+ openWorkspace: (agentId: string) => void,
1335
1594
  ) {
1595
+ const directSessions = active || (compact && platform !== "web");
1336
1596
  const docked = active && !compact && surfaceWidth > 0;
1597
+ const sessionsAvailable = docked && fullscreen;
1337
1598
  const { on: sessionsHidden, set: hideSessions } = useDeviceSwitch("sessionsHidden", false);
1338
1599
  const sessionsOpen = sessionsHidden !== true;
1339
1600
  const sidebarWidth = Math.max(SESSION_RAIL_MIN, Math.min(312, Math.round(surfaceWidth * 0.24)));
@@ -1341,31 +1602,38 @@ function useFullscreenPanels(
1341
1602
  const sidebars: SidebarControls | undefined = docked
1342
1603
  ? {
1343
1604
  sessionsOpen,
1605
+ sessionsAvailable,
1344
1606
  column,
1345
1607
  hideSessions,
1346
1608
  }
1347
1609
  : undefined;
1348
1610
  const { openSession } = sheet;
1611
+ // A Sessions row's own button goes straight to the agent's workspace, past its details.
1349
1612
  const link = useMemo(
1350
- () => (active ? { select: openSession, openSession } : sheet.link),
1351
- [active, openSession, sheet.link],
1613
+ (): OfficeLink => ({
1614
+ ...(directSessions ? { select: openSession, openSession } : sheet.link),
1615
+ openWorkspace,
1616
+ }),
1617
+ [directSessions, openSession, sheet.link, openWorkspace],
1352
1618
  );
1353
1619
  const selectAgent = useCallback(
1354
1620
  (id: string | null) => {
1355
- if (active && id !== null) openSession(id);
1621
+ if (directSessions && id !== null) openSession(id);
1356
1622
  else select(id);
1357
1623
  },
1358
- [active, openSession, select],
1624
+ [directSessions, openSession, select],
1359
1625
  );
1360
1626
  return {
1361
1627
  docked,
1628
+ controlsAboveFloor: docked || compact,
1629
+ sessionsAvailable,
1362
1630
  sidebars,
1363
1631
  sessionsOpen,
1364
1632
  railSize,
1365
1633
  link,
1366
1634
  selectAgent,
1367
- selectFromStrip: active ? openSession : selectFromStrip,
1368
- width: docked && sessionsOpen ? surfaceWidth - sidebarWidth : surfaceWidth,
1635
+ selectFromStrip: directSessions ? openSession : selectFromStrip,
1636
+ width: sessionsAvailable && sessionsOpen ? surfaceWidth - sidebarWidth : surfaceWidth,
1369
1637
  column: useMemo(
1370
1638
  () =>
1371
1639
  docked && column.view.kind === "tab" && column.view.tab === "sessions"
@@ -1373,18 +1641,143 @@ function useFullscreenPanels(
1373
1641
  : column,
1374
1642
  [column, docked],
1375
1643
  ),
1376
- sheet: useMemo(() => (active ? { ...sheet, sheetLink: link } : sheet), [sheet, link, active]),
1644
+ sheet: useMemo(
1645
+ () => (directSessions ? { ...sheet, sheetLink: link } : sheet),
1646
+ [sheet, link, directSessions],
1647
+ ),
1377
1648
  };
1378
1649
  }
1379
1650
 
1651
+ function selectAgentDetail(
1652
+ id: string | null,
1653
+ model: OfficeModel,
1654
+ activities: OfficeState["state"]["activity"],
1655
+ ) {
1656
+ if (!id) return { agent: null, activity: null };
1657
+ return { agent: model.agents.get(id) ?? null, activity: activities[id] ?? null };
1658
+ }
1659
+
1660
+ function OfficeMessenger({
1661
+ open,
1662
+ link,
1663
+ onOpen,
1664
+ onClose,
1665
+ ...panel
1666
+ }: Omit<Parameters<typeof FloatingTeamChat>[0], "onClose"> & {
1667
+ open: boolean;
1668
+ onOpen(): void;
1669
+ onClose(): void;
1670
+ }) {
1671
+ const sessionLink = useMemo(
1672
+ (): OfficeLink => ({
1673
+ select(id) {
1674
+ onClose();
1675
+ link.select(id);
1676
+ },
1677
+ openSession(id) {
1678
+ onClose();
1679
+ link.openSession(id);
1680
+ },
1681
+ }),
1682
+ [link, onClose],
1683
+ );
1684
+ const { messenger } = panel.styles;
1685
+ return (
1686
+ <View
1687
+ pointerEvents="box-none"
1688
+ style={panel.layout.compact ? messenger.compactAnchor : messenger.floorAnchor}
1689
+ >
1690
+ {open ? (
1691
+ <FloatingTeamChat {...panel} link={sessionLink} onClose={onClose} />
1692
+ ) : (
1693
+ <TeamChatPreview chat={panel.office.chat} onOpen={onOpen} compact={panel.layout.compact} />
1694
+ )}
1695
+ </View>
1696
+ );
1697
+ }
1698
+
1699
+ function useMessengerTasks(
1700
+ board: BoardSheetState,
1701
+ sidebars: SidebarControls | undefined,
1702
+ sheet: ColumnSheetState,
1703
+ column: ColumnState,
1704
+ compact: boolean,
1705
+ newAgent: NewAgentDraft,
1706
+ closeChat: () => void,
1707
+ ) {
1708
+ const { open } = board;
1709
+ const onBoard = useCallback(() => open(LOBBY), [open]);
1710
+ const { openTab } = sheet;
1711
+ const { show } = column;
1712
+ const { setOpen } = newAgent;
1713
+ const onNewAgent = useCallback(() => {
1714
+ closeChat();
1715
+ if (sidebars) sidebars.hideSessions(false);
1716
+ else if (compact) openTab("sessions");
1717
+ else show("sessions");
1718
+ setOpen(true);
1719
+ }, [sidebars, compact, openTab, show, setOpen, closeChat]);
1720
+ return { onBoard, onNewAgent };
1721
+ }
1722
+ function workspaceNavigation({ layout, navigation }: OfficeSurfaceProps) {
1723
+ return layout.compact || layout.platform !== "web" ? navigation : undefined;
1724
+ }
1725
+
1726
+ function useWorkspaceOverlay(
1727
+ model: OfficeModel,
1728
+ openBoard: (id: string) => void,
1729
+ mobileNavigation: PluginScreenProps["navigation"],
1730
+ ) {
1731
+ const [workspace, setWorkspace] = useState<WorkspaceSelection | null>(null);
1732
+ const closeWorkspace = useCallback(() => setWorkspace(null), []);
1733
+ const showWorkspace = useCallback(
1734
+ (workspaceId: string) => {
1735
+ if (mobileNavigation) mobileNavigation.openWorkspace({ workspaceId });
1736
+ else setWorkspace({ workspaceId, agentId: null });
1737
+ },
1738
+ [mobileNavigation],
1739
+ );
1740
+ const showAgentWorkspace = useCallback(
1741
+ (agentId: string) => {
1742
+ if (mobileNavigation) mobileNavigation.openAgent({ agentId });
1743
+ else setWorkspace({ workspaceId: model.agents.get(agentId)?.workspaceId ?? null, agentId });
1744
+ },
1745
+ [model.agents, mobileNavigation],
1746
+ );
1747
+ const openWorkspaceBoard = useCallback(
1748
+ (id: string) => {
1749
+ closeWorkspace();
1750
+ openBoard(id);
1751
+ },
1752
+ [closeWorkspace, openBoard],
1753
+ );
1754
+ return { workspace, closeWorkspace, showWorkspace, showAgentWorkspace, openWorkspaceBoard };
1755
+ }
1756
+
1757
+ function useHostResources(machine: Machine | null, live: boolean) {
1758
+ const [machineOpen, setMachineOpen] = useState(false);
1759
+ const openMachine = useCallback(() => setMachineOpen(true), []);
1760
+ const closeMachine = useCallback(() => setMachineOpen(false), []);
1761
+ const ssh = useSshServers(live && (machineOpen || machine === null));
1762
+ const hasSsh = ssh.servers.length > 0;
1763
+ const hostEntry = useMemo((): StripCard | null => {
1764
+ if (machine) return { title: "Host", note: hostNote(machine), onOpen: openMachine };
1765
+ if (hasSsh)
1766
+ return { title: "Host", note: { text: "SSH hosts", tone: "muted" }, onOpen: openMachine };
1767
+ return null;
1768
+ }, [machine, hasSsh, openMachine]);
1769
+ return { machineOpen: machineOpen && live, openMachine, closeMachine, hostEntry, ssh };
1770
+ }
1771
+
1380
1772
  /** One surface for both places: the sidebar screen and a workspace tab. */
1381
1773
  export function OfficeSurface(
1382
1774
  props: OfficeSurfaceProps & {
1383
1775
  /** Absent only in tests and on a host that gives no way to its settings. */
1384
1776
  onOpenSettings?: () => void;
1777
+ launcher?: SidebarLauncher;
1385
1778
  },
1386
1779
  ) {
1387
- const { theme, layout, navigation, onOpenSettings } = props;
1780
+ const { layout, navigation, onOpenSettings } = props;
1388
1781
  const focusRoomId = "workspaceId" in props ? props.workspaceId : null;
1389
1782
  // Asked once for the surface's life, like the app: a mouse plugged into a tablet does not
1390
1783
  // shrink its controls.
@@ -1392,15 +1785,14 @@ export function OfficeSurface(
1392
1785
  () => hasTouchScreen(layout.platform, layout.platform === "web" ? readPointer() : null),
1393
1786
  [layout.platform],
1394
1787
  );
1788
+ const full = useFullscreen(props, props.launcher);
1789
+ const theme = fullscreenTheme(props.theme, full.integrated);
1395
1790
  const styles = useOfficeStyles(theme, layout.compact, touchScreen);
1396
- const full = useFullscreen(layout.platform);
1791
+
1397
1792
  const office = useOffice();
1398
1793
  const actions = useAgentActions();
1399
1794
  const boardActions = useBoardActions();
1400
1795
  const { machine: reading, cleanUp } = useMachine();
1401
- const [machineOpen, setMachineOpen] = useState(false);
1402
- const openMachine = useCallback(() => setMachineOpen(true), []);
1403
- const closeMachine = useCallback(() => setMachineOpen(false), []);
1404
1796
  const tidy = useJanitor();
1405
1797
  const dismissIncidents = useIncidents();
1406
1798
  const [janitorOpen, setJanitorOpen] = useState(false);
@@ -1409,8 +1801,15 @@ export function OfficeSurface(
1409
1801
  const readNotes = useRpc(notesReadRpc);
1410
1802
  const notesTimeZone = useNotesTimeZone();
1411
1803
  const viewChoice = useViewChoice(layout.platform);
1804
+ const settings = useOfficeSettingsDialog(
1805
+ full.integrated || viewChoice.choice === "3d",
1806
+ onOpenSettings,
1807
+ );
1808
+ const [teamOpen, setTeamOpen] = useState(false);
1809
+ const openTeam = useCallback(() => setTeamOpen((value) => !value), []);
1810
+ const closeTeam = useCallback(() => setTeamOpen(false), []);
1412
1811
  // One Sound switch for the floor: the 3D office follows it, and the corner shows a refused save.
1413
- const street = useStreetSwitch(layout);
1812
+ const street = useOfficeScene(layout);
1414
1813
  const sound = useSoundSwitch();
1415
1814
  const model = useMemo(() => buildOfficeModel(office.state), [office.state]);
1416
1815
  const { surfaceWidth, measure, compact, floorStyle, setDragging } = useSurfaceLayout(
@@ -1418,7 +1817,7 @@ export function OfficeSurface(
1418
1817
  styles,
1419
1818
  full.active,
1420
1819
  );
1421
- const column = useColumn(compact);
1820
+ const column = useOfficeColumn(compact, full.integrated, openTeam);
1422
1821
  const machine = useMemo(() => namedMachine(reading, model.agents), [reading, model.agents]);
1423
1822
  const rooms = useMemo(
1424
1823
  () => orderRoomsForFocus(model.rooms, focusRoomId),
@@ -1427,7 +1826,21 @@ export function OfficeSurface(
1427
1826
  const name = useCallback((author: string) => authorName(author, model.agents), [model.agents]);
1428
1827
  // In error or closed the data is frozen: no strip, no card and no board sheet to act on it.
1429
1828
  const live = office.subscription.status !== "error" && office.subscription.status !== "closed";
1829
+ const { machineOpen, openMachine, closeMachine, hostEntry, ssh } = useHostResources(
1830
+ machine,
1831
+ live,
1832
+ );
1430
1833
  const board = useBoardSheet(model, live);
1834
+ const dutyCard = useCardOpening(live);
1835
+ // Until the host sends its duty list (an older host has none) nothing offers the duty board.
1836
+ const openDuties = model.dutyList === null ? undefined : dutyCard.show;
1837
+ const dutyActions = useDutyActions();
1838
+ const { acted } = dutyActions;
1839
+ // A report the host refuses changes nothing: its duty board is what the scene is told next.
1840
+ const dutyActed = useCallback(
1841
+ (id: string, agentId: string) => void acted(id, agentId).catch(() => undefined),
1842
+ [acted],
1843
+ );
1431
1844
  const notesCard = useCardOpening(live);
1432
1845
  const { show: openNotes, close: closeNotes } = notesCard;
1433
1846
  const incidentsCard = useCardOpening(live);
@@ -1439,10 +1852,8 @@ export function OfficeSurface(
1439
1852
  closeStandup();
1440
1853
  openNotes();
1441
1854
  }, [closeStandup, openNotes]);
1442
- const showWorkspace = useMemo(() => {
1443
- if (navigation === undefined) return undefined;
1444
- return (workspaceId: string) => navigation.openWorkspace({ workspaceId });
1445
- }, [navigation]);
1855
+ const { workspace, closeWorkspace, showWorkspace, showAgentWorkspace, openWorkspaceBoard } =
1856
+ useWorkspaceOverlay(model, board.open, workspaceNavigation(props));
1446
1857
  const qa = useQa(model, live);
1447
1858
  const readLog = useScriptLog();
1448
1859
  const reviews = useReviews({
@@ -1463,16 +1874,35 @@ export function OfficeSurface(
1463
1874
  setFocusRequest((previous) => nextFocusRequest(previous, agentId));
1464
1875
  }, []);
1465
1876
  // Every way in to a session ends in the column: its tab, or the phone's sheet.
1466
- const sheet = useColumnSheet(column, compact, setSelectedId);
1877
+ const sheet = useColumnSheet(column, compact, full.integrated, setSelectedId);
1878
+ const {
1879
+ spaceStyle,
1880
+ measureKeyboard,
1881
+ visible: chatKeyboardVisible,
1882
+ } = useChatKeyboard(
1883
+ full.root,
1884
+ layout.platform,
1885
+ usesOfficeKeyboard(layout.platform, teamOpen, compact, sheet.sheetView, column.view),
1886
+ );
1887
+ const onSurfaceLayout = useCallback(
1888
+ (event: LayoutChangeEvent) => {
1889
+ measure(event);
1890
+ measureKeyboard();
1891
+ },
1892
+ [measure, measureKeyboard],
1893
+ );
1467
1894
  const { openSession } = sheet;
1468
1895
  const panels = useFullscreenPanels(
1896
+ full.integrated,
1469
1897
  full.active,
1898
+ layout.platform,
1470
1899
  compact,
1471
1900
  surfaceWidth,
1472
1901
  column,
1473
1902
  sheet,
1474
1903
  setSelectedId,
1475
1904
  selectFromStrip,
1905
+ showAgentWorkspace,
1476
1906
  );
1477
1907
  // The writer opens in the column like any session; the office is left only by "Open in workspace".
1478
1908
  const openWriter = useCallback(
@@ -1484,8 +1914,8 @@ export function OfficeSurface(
1484
1914
  [closeStandup, closeNotes, openSession],
1485
1915
  );
1486
1916
  const openResources = useMemo(
1487
- () => resourcesOpener(navigation, openMachine),
1488
- [navigation, openMachine],
1917
+ () => (full.integrated ? openMachine : resourcesOpener(navigation, openMachine)),
1918
+ [full.integrated, navigation, openMachine],
1489
1919
  );
1490
1920
  // The panels of the column reach this surface through the link: a row press opens the card, as
1491
1921
  // a List row does, and "Open session" shows the session.
@@ -1506,11 +1936,6 @@ export function OfficeSurface(
1506
1936
  useEffect(() => {
1507
1937
  if (kept !== selectedId) setSelectedId(kept);
1508
1938
  }, [kept, selectedId]);
1509
- const hostEntry = useMemo(
1510
- (): StripCard | null =>
1511
- machine === null ? null : { title: "Host", note: hostNote(machine), onOpen: openMachine },
1512
- [machine, openMachine],
1513
- );
1514
1939
  const contexts = useMemo(
1515
1940
  () => janitorRows(model.agents.values(), model.waitingOn),
1516
1941
  [model.agents, model.waitingOn],
@@ -1524,10 +1949,10 @@ export function OfficeSurface(
1524
1949
  () => incidentsEntry(incidents, openIncidents),
1525
1950
  [incidents, openIncidents],
1526
1951
  );
1527
- const settingsStripEntry = useSettingsEntry(office.state, onOpenSettings);
1952
+ const settingsStripEntry = useSettingsEntry(office.state, settings.show);
1528
1953
  const weatherStripEntry = useMemo(
1529
- () => weatherEntry(office.state.weather, onOpenSettings),
1530
- [office.state.weather, onOpenSettings],
1954
+ () => weatherEntry(office.state.weather, settings.show),
1955
+ [office.state.weather, settings.show],
1531
1956
  );
1532
1957
  // The strip's cards, each only while it has something to say. An incident comes first.
1533
1958
  const cards = useMemo(
@@ -1567,11 +1992,31 @@ export function OfficeSurface(
1567
1992
  onLeave: sheet.closeSheet,
1568
1993
  styles,
1569
1994
  });
1570
- const selected = kept === null ? null : (model.agents.get(kept) ?? null);
1571
- const selectedActivity = kept === null ? null : (office.state.activity[kept] ?? null);
1995
+ const selected = selectAgentDetail(kept, model, office.state.activity);
1572
1996
  // The panels size their controls for the surface they are in, not only for the device.
1573
1997
  const panelLayout = useMemo(() => ({ ...layout, compact }), [layout, compact]);
1574
- const panel = { office, styles, theme, layout: panelLayout, attention, draft, newAgent };
1998
+ const { onPhotoReady, onGroupPhoto } = useGroupPhoto();
1999
+ const chatTasks = useMessengerTasks(
2000
+ board,
2001
+ panels.sidebars,
2002
+ sheet,
2003
+ column,
2004
+ compact,
2005
+ newAgent,
2006
+ closeTeam,
2007
+ );
2008
+ const panel = {
2009
+ office,
2010
+ styles,
2011
+ theme,
2012
+ layout: panelLayout,
2013
+ attention,
2014
+ draft,
2015
+ newAgent,
2016
+ ...chatTasks,
2017
+ onDuties: openDuties,
2018
+ onGroupPhoto,
2019
+ };
1575
2020
  const sessions = useMemo(
1576
2021
  () => sessionTabsOf(column.sessions, model.agents),
1577
2022
  [column.sessions, model.agents],
@@ -1579,30 +2024,41 @@ export function OfficeSurface(
1579
2024
  const { closeSession } = column;
1580
2025
  const replies = useReplyDrafts(column.sessions);
1581
2026
  const session = useMemo(
1582
- (): SessionContext => ({ model, replies, actions, navigation, closeSession }),
1583
- [model, replies, actions, navigation, closeSession],
2027
+ (): SessionContext => ({
2028
+ model,
2029
+ replies,
2030
+ actions,
2031
+ showWorkspace: showAgentWorkspace,
2032
+ closeSession,
2033
+ }),
2034
+ [model, replies, actions, showAgentWorkspace, closeSession],
1584
2035
  );
1585
2036
  const color = theme.colors.foreground;
1586
2037
  const controls = (
1587
2038
  <ViewControls
2039
+ keyboardVisible={chatKeyboardVisible}
1588
2040
  badges={badges}
1589
2041
  full={full}
1590
2042
  sidebars={panels.sidebars}
1591
2043
  floorDrawn={floorDrawn}
1592
2044
  viewChoice={viewChoice}
1593
2045
  soundUnsaved={sound.unsaved}
2046
+ toolbarLabels={surfaceWidth >= 1100}
2047
+ onTeam={openTeam}
2048
+ machine={machine}
2049
+ onMachine={hostEntry?.onOpen}
1594
2050
  onChange={changeView}
1595
- compact={layout.compact}
2051
+ compact={compact}
1596
2052
  touchScreen={touchScreen}
1597
2053
  color={color}
1598
- onOpenSettings={onOpenSettings}
2054
+ onOpenSettings={settings.show}
1599
2055
  styles={styles}
1600
2056
  />
1601
2057
  );
1602
2058
  // One tree in both layouts, so a flip between them does not draw the floor again: compact adds
1603
2059
  // the sheet in the floor's box and the bar under the row, wide adds the column beside the floor.
1604
- return (
1605
- <View ref={full.root} style={styles.screen} onLayout={measure}>
2060
+ const surface = (
2061
+ <View ref={full.root} style={styles.screen} onLayout={onSurfaceLayout}>
1606
2062
  <SurfaceNotices
1607
2063
  fullscreenError={full.error}
1608
2064
  choice={viewChoice.choice}
@@ -1610,9 +2066,9 @@ export function OfficeSurface(
1610
2066
  retryScene={retryScene}
1611
2067
  styles={styles}
1612
2068
  />
1613
- {panels.docked && controls}
2069
+ {panels.controlsAboveFloor && controls}
1614
2070
  <View style={styles.officeRow}>
1615
- {panels.docked ? (
2071
+ {panels.sessionsAvailable ? (
1616
2072
  <SessionsSidebar
1617
2073
  {...panel}
1618
2074
  link={panels.link}
@@ -1620,9 +2076,11 @@ export function OfficeSurface(
1620
2076
  size={panels.railSize}
1621
2077
  />
1622
2078
  ) : null}
1623
- <View style={floorStyle}>
1624
- {!panels.docked && controls}
2079
+ <View testID="office-floor-pane" style={floorStyle}>
2080
+ {!panels.controlsAboveFloor && controls}
1625
2081
  <SurfaceBody
2082
+ onPhotoReady={onPhotoReady}
2083
+ fullscreen={full.available ? full : undefined}
1626
2084
  office={office}
1627
2085
  model={model}
1628
2086
  rooms={rooms}
@@ -1630,14 +2088,17 @@ export function OfficeSurface(
1630
2088
  theme={theme}
1631
2089
  focusRoomId={focusRoomId}
1632
2090
  focusRequest={focusRequest}
1633
- selectedAgentId={kept}
2091
+ selectedAgentId={sceneSelection(compact, layout.platform, sheet.sheetView, kept)}
1634
2092
  styles={styles}
1635
2093
  compact={layout.compact}
1636
2094
  actions={actions}
1637
2095
  name={name}
1638
2096
  onSelectAgent={panels.selectAgent}
1639
2097
  onOpenSession={openSession}
2098
+ onOpenAgentWorkspace={showAgentWorkspace}
1640
2099
  onOpenBoard={board.open}
2100
+ onOpenDuties={openDuties}
2101
+ onDutyActed={dutyActed}
1641
2102
  machine={machine}
1642
2103
  onOpenMachine={openMachine}
1643
2104
  onOpenResources={openResources}
@@ -1652,7 +2113,7 @@ export function OfficeSurface(
1652
2113
  onSceneProblem={setSceneProblem}
1653
2114
  platform={layout.platform}
1654
2115
  sound={sound}
1655
- street={street.on}
2116
+ street={street}
1656
2117
  />
1657
2118
  <PhoneSheet
1658
2119
  compact={compact}
@@ -1663,6 +2124,15 @@ export function OfficeSurface(
1663
2124
  color={color}
1664
2125
  {...panel}
1665
2126
  />
2127
+ {full.integrated && (
2128
+ <OfficeMessenger
2129
+ open={teamOpen}
2130
+ {...panel}
2131
+ link={panels.link}
2132
+ onOpen={openTeam}
2133
+ onClose={closeTeam}
2134
+ />
2135
+ )}
1666
2136
  </View>
1667
2137
  <WideColumn
1668
2138
  sessions={sessions}
@@ -1682,22 +2152,26 @@ export function OfficeSurface(
1682
2152
  </View>
1683
2153
  <PhoneBar
1684
2154
  compact={compact}
2155
+ keyboardVisible={chatKeyboardVisible}
1685
2156
  sheet={sheet}
1686
2157
  sessions={sessions}
1687
2158
  badges={badges}
1688
2159
  color={color}
1689
2160
  styles={styles}
1690
2161
  />
2162
+ <View aria-hidden testID="office-keyboard-space" style={spaceStyle} />
1691
2163
  <AgentCard
1692
- agent={selected}
1693
- activity={selectedActivity}
2164
+ agent={selected.agent}
2165
+ activity={selected.activity}
1694
2166
  actions={actions}
1695
2167
  onOpenSession={openSession}
1696
2168
  styles={styles}
1697
2169
  onClose={closeCard}
1698
2170
  />
1699
2171
  <MachineCard
1700
- machine={live ? machine : null}
2172
+ workspaces={office.state.workspaces}
2173
+ ssh={ssh}
2174
+ machine={machine}
1701
2175
  open={machineOpen}
1702
2176
  cleanUp={cleanUp}
1703
2177
  styles={styles}
@@ -1781,6 +2255,42 @@ export function OfficeSurface(
1781
2255
  styles={styles}
1782
2256
  onClose={board.close}
1783
2257
  />
2258
+ <DutySheet
2259
+ open={dutyCard.open}
2260
+ list={model.dutyList}
2261
+ rows={model.duties}
2262
+ name={name}
2263
+ actions={dutyActions}
2264
+ styles={styles}
2265
+ onClose={dutyCard.close}
2266
+ />
2267
+ <OfficeWorkspace
2268
+ selection={workspace}
2269
+ hostId={props.host.id}
2270
+ session={session}
2271
+ styles={styles}
2272
+ layout={panelLayout}
2273
+ onSelect={showAgentWorkspace}
2274
+ onBoard={full.integrated ? board.open : openWorkspaceBoard}
2275
+ onClose={closeWorkspace}
2276
+ />
2277
+ <FullscreenSettings
2278
+ open={settings.open}
2279
+ onClose={settings.close}
2280
+ office={office}
2281
+ actions={boardActions}
2282
+ styles={styles}
2283
+ view={viewChoice}
2284
+ street={street}
2285
+ sound={sound}
2286
+ />
1784
2287
  </View>
1785
2288
  );
2289
+ return (
2290
+ <OfficeBrandContext.Provider value={office.state.brand}>
2291
+ <OfficeDialogs fullscreen={full.integrated} theme={theme} styles={styles}>
2292
+ {surface}
2293
+ </OfficeDialogs>
2294
+ </OfficeBrandContext.Provider>
2295
+ );
1786
2296
  }