zidane-ui 9.5.2 → 9.6.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 (201) hide show
  1. package/dist/adapters/index.d.ts +2 -1
  2. package/dist/adapters/index.js +2 -1
  3. package/dist/adapters/server-git-host.js +67 -0
  4. package/dist/adapters/server-host.js +9 -0
  5. package/dist/adapters/server-oauth-flow.d.ts +2 -2
  6. package/dist/adapters/server-oauth-flow.js +1 -1
  7. package/dist/adapters/server-projects.d.ts +53 -2
  8. package/dist/adapters/server-projects.js +4 -3
  9. package/dist/adapters/server-session-host.js +112 -4
  10. package/dist/channels/BindingEditorDialog.js +1 -1
  11. package/dist/channels/ChannelDefaultsSection.js +1 -1
  12. package/dist/channels/ChannelsSettingsSection.js +1 -1
  13. package/dist/channels/ConnectionSetupDialog.js +1 -1
  14. package/dist/channels/HeldRepliesList.js +1 -1
  15. package/dist/channels/ProjectChannelsSection.js +1 -1
  16. package/dist/chat/HostTranscript.js +1 -0
  17. package/dist/chat/SessionGroupHeader.js +2 -2
  18. package/dist/chat/composer/ComposerBadges.d.ts +27 -1
  19. package/dist/chat/composer/ComposerBadges.js +41 -5
  20. package/dist/chat/composer/ConversationBadges.d.ts +6 -0
  21. package/dist/chat/composer/ConversationBadges.js +70 -3
  22. package/dist/chat/composer/DraftPickers.js +4 -0
  23. package/dist/chat/composer/ServerScopeToggle.d.ts +16 -1
  24. package/dist/chat/composer/ServerScopeToggle.js +90 -47
  25. package/dist/chat/composer/index.d.ts +2 -2
  26. package/dist/chat/composer/use-draft-target.d.ts +18 -2
  27. package/dist/chat/composer/use-draft-target.js +74 -7
  28. package/dist/chat/composer/use-new-session-defaults.d.ts +3 -1
  29. package/dist/chat/composer/use-new-session-defaults.js +19 -14
  30. package/dist/chat/composer/use-send-prompt.js +2 -2
  31. package/dist/chat/headless/composer/index.d.ts +2 -2
  32. package/dist/chat/headless/composer/index.js +2 -2
  33. package/dist/chat/headless/composer/labels-chrome.d.ts +7 -0
  34. package/dist/chat/headless/composer/labels-chrome.js +7 -0
  35. package/dist/chat/headless/composer/labels-editor.d.ts +4 -0
  36. package/dist/chat/headless/composer/labels-editor.js +4 -0
  37. package/dist/chat/headless/composer/models.d.ts +2 -0
  38. package/dist/chat/headless/composer/new-session-defaults.d.ts +12 -1
  39. package/dist/chat/headless/composer/new-session-defaults.js +30 -1
  40. package/dist/chat/headless/draft-target.d.ts +27 -6
  41. package/dist/chat/headless/draft-target.js +36 -3
  42. package/dist/chat/headless/host.d.ts +7 -0
  43. package/dist/chat/headless/index.d.ts +4 -4
  44. package/dist/chat/headless/index.js +29 -29
  45. package/dist/chat/headless/labels.d.ts +4 -0
  46. package/dist/chat/headless/send-flow.d.ts +2 -0
  47. package/dist/chat/headless/send-flow.js +2 -1
  48. package/dist/chat/headless/session-list.d.ts +4 -0
  49. package/dist/chat/headless/sidebar/index.d.ts +2 -2
  50. package/dist/chat/headless/sidebar/labels.d.ts +9 -1
  51. package/dist/chat/headless/sidebar/labels.js +4 -0
  52. package/dist/chat/headless/sidebar/rows.d.ts +48 -7
  53. package/dist/chat/headless/sidebar/rows.js +121 -22
  54. package/dist/chat/headless/sidebar/types.d.ts +5 -0
  55. package/dist/chat/headless/transcript/fold-actions.d.ts +8 -3
  56. package/dist/chat/headless/transcript/fold-actions.js +29 -1
  57. package/dist/chat/index.d.ts +2 -2
  58. package/dist/chat/index.js +2 -2
  59. package/dist/chat/rich-composer/RichComposer.js +58 -11
  60. package/dist/chat/rich-composer/composer-controls.d.ts +5 -1
  61. package/dist/chat/rich-composer/composer-controls.js +4 -4
  62. package/dist/chat/rich-composer/composer-keys.js +2 -2
  63. package/dist/chat/rich-composer/draft-collab.d.ts +91 -0
  64. package/dist/chat/rich-composer/draft-collab.js +310 -0
  65. package/dist/chat/rich-composer/use-composer-editor.d.ts +2 -0
  66. package/dist/chat/rich-composer/use-draft-collab.d.ts +53 -0
  67. package/dist/chat/rich-composer/use-draft-collab.js +92 -0
  68. package/dist/chat/rich-composer/use-draft-mirror.d.ts +11 -0
  69. package/dist/chat/rich-composer/use-draft-mirror.js +38 -9
  70. package/dist/chat/sidebar/InboxList.js +1 -1
  71. package/dist/chat/sidebar/ProjectIcon.d.ts +6 -2
  72. package/dist/chat/sidebar/ProjectIcon.js +7 -3
  73. package/dist/chat/sidebar/SessionSidebar.d.ts +30 -1
  74. package/dist/chat/sidebar/SessionSidebar.js +79 -7
  75. package/dist/chat/sidebar/SidebarGroupHeader.d.ts +12 -4
  76. package/dist/chat/sidebar/SidebarGroupHeader.js +70 -28
  77. package/dist/chat/sidebar/index.d.ts +2 -2
  78. package/dist/chat/transcript/actions.d.ts +6 -0
  79. package/dist/chat/transcript/fold.d.ts +2 -1
  80. package/dist/chat/transcript/fold.js +26 -1
  81. package/dist/chat/transcript/index.js +3 -3
  82. package/dist/chat/transcript/notices.d.ts +5 -2
  83. package/dist/chat/transcript/notices.js +23 -3
  84. package/dist/chat/transcript/script-input.d.ts +1 -1
  85. package/dist/components/Avatar.d.ts +36 -0
  86. package/dist/components/Avatar.js +56 -0
  87. package/dist/components/AvatarStack.d.ts +58 -0
  88. package/dist/components/AvatarStack.js +187 -0
  89. package/dist/components/Tabs.d.ts +6 -1
  90. package/dist/components/Tabs.js +43 -39
  91. package/dist/core.css +19 -1
  92. package/dist/dist/{index-DPbpsCtl.d.ts → index-ChabiHpR.d.ts} +1 -1
  93. package/dist/dist/index.d.ts +1 -1
  94. package/dist/git/headless/environment.d.ts +15 -0
  95. package/dist/git/headless/environment.js +18 -1
  96. package/dist/git/headless/github.d.ts +11 -0
  97. package/dist/git/headless/github.js +15 -0
  98. package/dist/git/headless/host.d.ts +109 -0
  99. package/dist/git/headless/index.d.ts +5 -4
  100. package/dist/git/headless/index.js +4 -3
  101. package/dist/git/headless/labels.d.ts +16 -1
  102. package/dist/git/headless/labels.js +25 -1
  103. package/dist/git/testing/contract.d.ts +22 -4
  104. package/dist/git/testing/contract.js +173 -3
  105. package/dist/git/testing/index.d.ts +22 -1
  106. package/dist/git/testing/index.js +135 -1
  107. package/dist/index.d.ts +3 -1
  108. package/dist/index.js +3 -1
  109. package/dist/labels.d.ts +4 -0
  110. package/dist/labels.js +4 -0
  111. package/dist/onboarding/headless/labels.d.ts +4 -0
  112. package/dist/session/DraftPeopleStack.d.ts +24 -0
  113. package/dist/session/DraftPeopleStack.js +48 -0
  114. package/dist/session/NewProjectDialog.d.ts +28 -8
  115. package/dist/session/NewProjectDialog.js +225 -40
  116. package/dist/session/PersonCard.d.ts +29 -0
  117. package/dist/session/PersonCard.js +199 -0
  118. package/dist/session/ProjectArtifactsSection.d.ts +4 -1
  119. package/dist/session/ProjectArtifactsSection.js +149 -34
  120. package/dist/session/ProjectHome.d.ts +1 -1
  121. package/dist/session/ProjectHome.js +23 -4
  122. package/dist/session/ProjectName.d.ts +11 -6
  123. package/dist/session/ProjectName.js +27 -13
  124. package/dist/session/ProjectPeopleStack.d.ts +26 -0
  125. package/dist/session/ProjectPeopleStack.js +56 -0
  126. package/dist/session/ProjectPublishDialog.js +9 -3
  127. package/dist/session/ProjectSettingsDialog.d.ts +1 -1
  128. package/dist/session/ProjectSettingsDialog.js +171 -66
  129. package/dist/session/ProjectShareDialog.d.ts +1 -1
  130. package/dist/session/ProjectShareDialog.js +16 -6
  131. package/dist/session/ProjectToolsSection.js +88 -96
  132. package/dist/session/ProjectUsage.d.ts +4 -1
  133. package/dist/session/ProjectUsage.js +13 -4
  134. package/dist/session/SessionDetailsDialog.d.ts +5 -1
  135. package/dist/session/SessionDetailsDialog.js +67 -10
  136. package/dist/session/SessionPeopleStack.js +19 -37
  137. package/dist/session/SessionProjectPicker.d.ts +54 -0
  138. package/dist/session/SessionProjectPicker.js +175 -0
  139. package/dist/session/SessionProvider.d.ts +15 -1
  140. package/dist/session/SessionProvider.js +28 -6
  141. package/dist/session/UsageSection.d.ts +2 -4
  142. package/dist/session/UsageSection.js +57 -55
  143. package/dist/session/headless/draft-collab.d.ts +55 -0
  144. package/dist/session/headless/draft-collab.js +127 -0
  145. package/dist/session/headless/draft-room.d.ts +124 -0
  146. package/dist/session/headless/draft-room.js +340 -0
  147. package/dist/session/headless/drafts.d.ts +93 -0
  148. package/dist/session/headless/drafts.js +79 -0
  149. package/dist/session/headless/fixture-drafts.d.ts +54 -0
  150. package/dist/session/headless/fixture-drafts.js +286 -0
  151. package/dist/session/headless/fixture-host.d.ts +18 -2
  152. package/dist/session/headless/fixture-host.js +41 -7
  153. package/dist/session/headless/fixture-projects.d.ts +6 -4
  154. package/dist/session/headless/fixture-projects.js +25 -4
  155. package/dist/session/headless/host.d.ts +34 -6
  156. package/dist/session/headless/index.d.ts +6 -3
  157. package/dist/session/headless/index.js +6 -3
  158. package/dist/session/headless/labels.d.ts +47 -2
  159. package/dist/session/headless/labels.js +17 -1
  160. package/dist/session/headless/people.d.ts +27 -3
  161. package/dist/session/headless/people.js +38 -20
  162. package/dist/session/headless/project-artifact-labels.d.ts +7 -0
  163. package/dist/session/headless/project-artifact-labels.js +7 -0
  164. package/dist/session/headless/project-artifacts.d.ts +8 -0
  165. package/dist/session/headless/project-artifacts.js +15 -1
  166. package/dist/session/headless/project-labels.d.ts +25 -0
  167. package/dist/session/headless/project-labels.js +25 -0
  168. package/dist/session/headless/shared-with.d.ts +28 -0
  169. package/dist/session/headless/shared-with.js +51 -0
  170. package/dist/session/host-context.d.ts +11 -0
  171. package/dist/session/host-context.js +14 -0
  172. package/dist/session/index.d.ts +7 -3
  173. package/dist/session/index.js +6 -2
  174. package/dist/session/new-project-parts.d.ts +67 -0
  175. package/dist/session/new-project-parts.js +470 -0
  176. package/dist/session/project-artifact-parts.d.ts +2 -1
  177. package/dist/session/project-artifact-parts.js +5 -2
  178. package/dist/session/project-people.d.ts +14 -0
  179. package/dist/session/project-people.js +86 -0
  180. package/dist/session/share-people.d.ts +12 -0
  181. package/dist/session/share-people.js +1 -1
  182. package/dist/session/testing/contract.d.ts +6 -3
  183. package/dist/session/testing/contract.js +24 -3
  184. package/dist/session/testing/drafts.contract.d.ts +30 -0
  185. package/dist/session/testing/drafts.contract.js +126 -0
  186. package/dist/session/testing/index.d.ts +2 -1
  187. package/dist/session/testing/index.js +2 -1
  188. package/dist/session/use-home-projects.d.ts +11 -2
  189. package/dist/session/use-home-projects.js +142 -5
  190. package/dist/session/useDraftCollab.d.ts +24 -0
  191. package/dist/session/useDraftCollab.js +78 -0
  192. package/dist/settings/headless/search.d.ts +1 -1
  193. package/dist/settings/index.js +9 -9
  194. package/dist/settings/sections/index.js +1 -1
  195. package/dist/settings/sections/providers/CredentialSources.d.ts +5 -5
  196. package/dist/settings/sections/providers/CredentialSources.js +5 -22
  197. package/dist/settings/sections/providers/labels.d.ts +1 -9
  198. package/dist/settings/sections/providers/labels.js +1 -9
  199. package/dist/styles.css +20 -9
  200. package/package.json +4 -3
  201. package/src/styles/sidebar.css +2 -3
@@ -4,57 +4,149 @@ import { FIELD_LABEL_CLASS, INPUT_CLASS } from "../components/Form.js";
4
4
  import { IconButton } from "../components/IconButton.js";
5
5
  import { Notice } from "../components/Notice.js";
6
6
  import { errorMessage } from "../components/report-error.js";
7
+ import { Segmented } from "../components/Segmented.js";
7
8
  import { useTooltip } from "../components/Tooltip.js";
9
+ import { useGitHost, useGitLabels } from "../git/GitProvider.js";
10
+ import { githubErrorText } from "../git/headless/labels.js";
8
11
  import { useDisplayPath } from "../hooks/useDisplayPath.js";
9
12
  import { basename } from "../path.js";
10
- import { useSessionProjects } from "./SessionProvider.js";
13
+ import { useCarrySessionHost } from "./host-context.js";
14
+ import { AccessField, RepoHomeField, repoCloneUrl } from "./new-project-parts.js";
15
+ import { useHostProjects, useSessionHost, useSessionProjects } from "./SessionProvider.js";
11
16
  import { useSessionLabels } from "./useSessionLabels.js";
12
- import { useCallback, useId, useState } from "react";
13
- import { jsx, jsxs } from "react/jsx-runtime";
14
- import { PROJECT_NAME_MAX } from "zidane/chat/pure";
17
+ import { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
18
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
19
+ import { PROJECT_NAME_MAX, sessionKey } from "zidane/chat/pure";
15
20
  // src/session/NewProjectDialog.tsx
16
21
  /**
17
22
  * The New project dialog. Renders nothing without `SessionHost.projects.create`.
18
23
  *
19
24
  * @param props - The {@link NewProjectDialogProps}.
20
25
  */
21
- function NewProjectDialog({ onClose, onCreated, className, style }) {
22
- const projects = useSessionProjects();
26
+ function NewProjectDialog({ onClose, onCreated, hostId, home: startHome, className, style }) {
27
+ const own = useSessionProjects();
28
+ const theirs = useHostProjects(hostId ?? null);
29
+ const projects = hostId === void 0 ? own : theirs;
23
30
  const labels = useSessionLabels();
31
+ const gitLabels = useGitLabels();
32
+ const github = useGitHost()?.githubRepos;
24
33
  const [name, setName] = useState("");
25
34
  const [home, setHome] = useState(null);
26
35
  const [busy, setBusy] = useState(false);
27
36
  const [nameMissing, setNameMissing] = useState(false);
28
37
  const [error, setError] = useState(null);
38
+ const [homeKind, setHomeKind] = useState(startHome === "repo" ? "repo" : "none");
39
+ const [repo, setRepo] = useState(null);
40
+ const [repoMissing, setRepoMissing] = useState(false);
41
+ const [access, setAccess] = useState("private");
42
+ const [invited, setInvited] = useState([]);
43
+ const [made, setMade] = useState(null);
44
+ const [uncovered, setUncovered] = useState(false);
29
45
  const formId = useId();
30
46
  const nameId = useId();
31
47
  const nameHintId = useId();
48
+ const homeId = useId();
49
+ const accessId = useId();
50
+ const sharing = projects?.sharing;
51
+ const users = useMemo(() => sharing ? () => sharing.users() : void 0, [sharing]);
52
+ const self = useSessionHost().sharing?.self?.(sessionKey(hostId ?? null, ""));
53
+ const onRepo = useCallback((pick) => {
54
+ setRepo(pick);
55
+ setRepoMissing(false);
56
+ }, []);
32
57
  const create = projects?.create;
58
+ const offered = useRef(false);
59
+ useEffect(() => {
60
+ if (create) offered.current = true;
61
+ else if (offered.current) onClose();
62
+ }, [create, onClose]);
33
63
  if (!create) return null;
34
64
  const pickFolder = projects.pickFolder;
35
65
  const named = name.trim();
36
- const submit = () => {
37
- if (busy) return;
38
- if (named === "" && home === null) {
66
+ const repoHome = Boolean(sharing) || startHome === "repo";
67
+ const onRepoHome = repoHome && homeKind === "repo";
68
+ const folderHome = !repoHome || homeKind === "folder" ? home : null;
69
+ const locked = busy || uncovered;
70
+ const repoPending = onRepoHome && repo?.kind === "create" && repo.verdict !== "available";
71
+ const failed = (message, detail) => {
72
+ setBusy(false);
73
+ setError({
74
+ message,
75
+ ...detail ? { detail } : {}
76
+ });
77
+ };
78
+ const repoUrl = async (pick) => {
79
+ if (pick.kind === "url") return {
80
+ url: pick.url,
81
+ uncovered: false
82
+ };
83
+ const key = `${pick.owner}/${pick.name}`;
84
+ if (made?.key === key) return made;
85
+ try {
86
+ const answer = await github.create({
87
+ ...hostId ? { hostId } : {},
88
+ owner: pick.owner,
89
+ name: pick.name,
90
+ private: pick.private
91
+ });
92
+ if (!answer.ok) {
93
+ failed(githubErrorText(answer.error, gitLabels), answer.error.detail);
94
+ return null;
95
+ }
96
+ const kept = {
97
+ key,
98
+ url: repoCloneUrl(answer.url),
99
+ uncovered: answer.hasApp && !answer.appCovered
100
+ };
101
+ setMade(kept);
102
+ return kept;
103
+ } catch (err) {
104
+ failed(labels.projectRepoCreateFailed, errorMessage(err));
105
+ return null;
106
+ }
107
+ };
108
+ const submit = async () => {
109
+ if (locked) return;
110
+ if (onRepoHome && (!repo || repo.kind === "create" && repo.verdict !== "available")) {
111
+ if (!repo) setRepoMissing(true);
112
+ return;
113
+ }
114
+ if (named === "" && folderHome === null && !onRepoHome) {
39
115
  setNameMissing(true);
40
116
  document.getElementById(nameId)?.focus();
41
117
  return;
42
118
  }
43
119
  setBusy(true);
44
120
  setError(null);
45
- create({
121
+ const homeRepo = onRepoHome && repo ? await repoUrl(repo) : null;
122
+ if (onRepoHome && !homeRepo) return;
123
+ const input = {
46
124
  ...named ? { name: named } : {},
47
- ...home ? { home } : {}
48
- }).then((project) => {
49
- onCreated?.(project);
50
- onClose();
51
- }, (err) => {
125
+ ...folderHome ? { home: folderHome } : {},
126
+ ...homeRepo ? { homeRepo: {
127
+ url: homeRepo.url,
128
+ ...repo?.kind === "url" && repo.base ? { base: repo.base } : {}
129
+ } } : {},
130
+ ...sharing && access === "invite" && invited.length > 0 ? { members: invited.map((i) => ({
131
+ userId: i.person.userId,
132
+ grant: i.grant
133
+ })) } : {},
134
+ ...sharing && access === "open" ? { open: true } : {}
135
+ };
136
+ let project;
137
+ try {
138
+ project = await create(input);
139
+ } catch (err) {
140
+ failed(labels.projectCreateFailed, errorMessage(err));
141
+ return;
142
+ }
143
+ onCreated?.(project);
144
+ if (homeRepo?.uncovered) {
52
145
  setBusy(false);
53
- setError({
54
- message: labels.projectCreateFailed,
55
- detail: errorMessage(err)
56
- });
57
- });
146
+ setUncovered(true);
147
+ return;
148
+ }
149
+ onClose();
58
150
  };
59
151
  const choose = pickFolder && (() => {
60
152
  setError(null);
@@ -74,9 +166,14 @@ function NewProjectDialog({ onClose, onCreated, className, style }) {
74
166
  onClose,
75
167
  ...className ? { className } : {},
76
168
  ...style ? { style } : {},
77
- footer: /* @__PURE__ */ jsxs("div", {
169
+ footer: /* @__PURE__ */ jsx("div", {
78
170
  className: "flex justify-end gap-2",
79
- children: [/* @__PURE__ */ jsx("button", {
171
+ children: uncovered ? /* @__PURE__ */ jsx("button", {
172
+ type: "button",
173
+ className: BTN_PRIMARY,
174
+ onClick: onClose,
175
+ children: labels.projectDone
176
+ }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("button", {
80
177
  type: "button",
81
178
  className: BTN_SECONDARY,
82
179
  onClick: onClose,
@@ -85,10 +182,10 @@ function NewProjectDialog({ onClose, onCreated, className, style }) {
85
182
  type: "submit",
86
183
  form: formId,
87
184
  className: BTN_PRIMARY,
88
- disabled: busy,
185
+ disabled: busy || repoPending,
89
186
  "aria-busy": busy || void 0,
90
187
  children: busy ? labels.projectCreating : labels.projectCreate
91
- })]
188
+ })] })
92
189
  }),
93
190
  children: /* @__PURE__ */ jsxs("form", {
94
191
  id: formId,
@@ -110,10 +207,10 @@ function NewProjectDialog({ onClose, onCreated, className, style }) {
110
207
  value: name,
111
208
  maxLength: PROJECT_NAME_MAX,
112
209
  autoFocus: true,
113
- disabled: busy,
210
+ disabled: locked,
114
211
  "aria-invalid": nameMissing || void 0,
115
212
  "aria-describedby": nameMissing ? nameHintId : void 0,
116
- placeholder: labels.projectNamePlaceholder(home ? basename(home) : null),
213
+ placeholder: labels.projectNamePlaceholder(folderHome ? basename(folderHome) : onRepoHome && repo ? repo.name : null),
117
214
  onChange: (event) => {
118
215
  setName(event.target.value);
119
216
  setNameMissing(false);
@@ -129,12 +226,88 @@ function NewProjectDialog({ onClose, onCreated, className, style }) {
129
226
  })
130
227
  })
131
228
  ] }),
132
- choose && /* @__PURE__ */ jsx(FolderField, {
229
+ repoHome ? /* @__PURE__ */ jsxs("div", {
230
+ role: "group",
231
+ "aria-labelledby": homeId,
232
+ className: "flex flex-col gap-2",
233
+ children: [
234
+ /* @__PURE__ */ jsx("span", {
235
+ id: homeId,
236
+ className: `${FIELD_LABEL_CLASS} !mb-0`,
237
+ children: labels.projectHome
238
+ }),
239
+ /* @__PURE__ */ jsx(Segmented, {
240
+ size: "sm",
241
+ ariaLabel: labels.projectHome,
242
+ value: homeKind,
243
+ onChange: setHomeKind,
244
+ options: [
245
+ {
246
+ value: "none",
247
+ label: labels.projectHomeNone,
248
+ disabled: locked
249
+ },
250
+ ...choose ? [{
251
+ value: "folder",
252
+ label: labels.projectFolder,
253
+ disabled: locked
254
+ }] : [],
255
+ {
256
+ value: "repo",
257
+ label: labels.projectHomeRepo,
258
+ disabled: locked
259
+ }
260
+ ],
261
+ className: "self-start"
262
+ }),
263
+ homeKind === "folder" && choose && /* @__PURE__ */ jsx(FolderField, {
264
+ home,
265
+ busy: locked,
266
+ bare: true,
267
+ onChoose: choose,
268
+ onClear: () => setHome(null)
269
+ }),
270
+ homeKind === "repo" && /* @__PURE__ */ jsx(RepoHomeField, {
271
+ github,
272
+ hostId,
273
+ projectName: named,
274
+ busy: locked,
275
+ onChange: onRepo
276
+ }),
277
+ homeKind === "repo" && repoMissing && /* @__PURE__ */ jsx(Notice, {
278
+ tone: "error",
279
+ compact: true,
280
+ children: labels.projectRepoRequired
281
+ })
282
+ ]
283
+ }) : choose && /* @__PURE__ */ jsx(FolderField, {
133
284
  home,
134
- busy,
285
+ busy: locked,
135
286
  onChoose: choose,
136
287
  onClear: () => setHome(null)
137
288
  }),
289
+ users && /* @__PURE__ */ jsxs("div", {
290
+ role: "group",
291
+ "aria-labelledby": accessId,
292
+ className: "flex flex-col gap-2",
293
+ children: [/* @__PURE__ */ jsx("span", {
294
+ id: accessId,
295
+ className: `block text-xs text-[var(--zg-text-muted)] mb-1 !mb-0`,
296
+ children: labels.projectAccess
297
+ }), /* @__PURE__ */ jsx(AccessField, {
298
+ users,
299
+ ...self ? { self } : {},
300
+ access,
301
+ onAccess: setAccess,
302
+ invited,
303
+ onInvited: setInvited,
304
+ busy: locked
305
+ })]
306
+ }),
307
+ uncovered && /* @__PURE__ */ jsx(Notice, {
308
+ tone: "warning",
309
+ children: gitLabels.githubAppUncovered
310
+ }),
138
311
  error && /* @__PURE__ */ jsx(Notice, {
139
312
  tone: "error",
140
313
  ...error.detail ? { detail: error.detail } : {},
@@ -144,8 +317,8 @@ function NewProjectDialog({ onClose, onCreated, className, style }) {
144
317
  })
145
318
  });
146
319
  }
147
- /** The folder: its path (whole in a tooltip), Set folder… (Change folder… once picked) and Remove folder. */
148
- function FolderField({ home, busy, onChoose, onClear }) {
320
+ /** The folder: its path (whole in a tooltip), Set folder… (Change folder… once picked) and Remove folder. `bare`: no label of its own. */
321
+ function FolderField({ home, busy, bare = false, onChoose, onClear }) {
149
322
  const labels = useSessionLabels();
150
323
  const display = useDisplayPath();
151
324
  const shown = home ? display.path(home) : labels.projectNoFolder;
@@ -156,10 +329,11 @@ function FolderField({ home, busy, onChoose, onClear }) {
156
329
  const labelId = useId();
157
330
  return /* @__PURE__ */ jsxs("div", {
158
331
  role: "group",
159
- "aria-labelledby": labelId,
160
- children: [/* @__PURE__ */ jsx("span", {
332
+ "aria-labelledby": bare ? void 0 : labelId,
333
+ "aria-label": bare ? labels.projectFolder : void 0,
334
+ children: [!bare && /* @__PURE__ */ jsx("span", {
161
335
  id: labelId,
162
- className: FIELD_LABEL_CLASS,
336
+ className: "block text-xs text-[var(--zg-text-muted)] mb-1",
163
337
  children: labels.projectFolder
164
338
  }), /* @__PURE__ */ jsxs("div", {
165
339
  className: "flex items-center gap-2 min-w-0 min-h-8",
@@ -192,24 +366,35 @@ function FolderField({ home, busy, onChoose, onClear }) {
192
366
  });
193
367
  }
194
368
  /**
195
- * Opens New project on the modal layer. `undefined` without `SessionHost.projects.create` or a modal layer.
369
+ * Opens New project on the modal layer. `undefined` without the host's `projects.create` or a modal layer.
196
370
  *
197
371
  * @param onCreated - Called with the project once created (open its home).
372
+ * @param target - The host to make it on, and how the dialog starts. Absent: the window's own projects.
198
373
  */
199
- function useNewProject(onCreated) {
200
- const create = useSessionProjects()?.create;
374
+ function useNewProject(onCreated, target) {
375
+ const hostId = target?.hostId;
376
+ const startHome = target?.home;
377
+ const own = useSessionProjects()?.create;
378
+ const theirs = useHostProjects(hostId ?? null)?.create;
379
+ const create = hostId === void 0 ? own : theirs;
201
380
  const modal = useOptionalModal();
202
381
  const open = modal?.open;
203
382
  const close = modal?.close;
383
+ const carry = useCarrySessionHost();
204
384
  const show = useCallback(() => {
205
- open?.(/* @__PURE__ */ jsx(NewProjectDialog, {
385
+ open?.(carry(/* @__PURE__ */ jsx(NewProjectDialog, {
206
386
  onClose: () => close?.(),
207
- ...onCreated ? { onCreated } : {}
208
- }));
387
+ ...onCreated ? { onCreated } : {},
388
+ ...hostId !== void 0 ? { hostId } : {},
389
+ ...startHome ? { home: startHome } : {}
390
+ })));
209
391
  }, [
210
392
  open,
211
393
  close,
212
- onCreated
394
+ carry,
395
+ onCreated,
396
+ hostId,
397
+ startHome
213
398
  ]);
214
399
  return create && open ? show : void 0;
215
400
  }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * A person's card (a face's hover card in an `AvatarStack`): their face, name and email, whether they are online or
3
+ * when they were last seen, then the projects and the sessions you share with them (`sharing.shared`). What you share
4
+ * is read when the card first opens and kept a short while per person (`./headless/shared-with`); it is read again
5
+ * when they come online or go, when the projects change, and when who shares a session changes. A section with
6
+ * nothing in it, or without its opener, does not show: each row opens the project or the session. A project on a
7
+ * server (`hostId`, an app that asks several) wears the server's glyph and opens with its server.
8
+ */
9
+ import { CSSProperties } from "react";
10
+ import { PresencePerson } from "zidane/ipc";
11
+ /** Props for {@link PersonCard}. */
12
+ export interface PersonCardProps {
13
+ /** The person. */
14
+ person: PresencePerson;
15
+ /** Opens a project's home; `hostId`: the server it is on (`SharedProjectView.hostId`). Absent: no Projects section. */
16
+ onOpenProject?: (projectId: string, hostId?: string) => void;
17
+ /** Opens a session. Absent: no Sessions section. */
18
+ onOpenSession?: (sessionId: string) => void;
19
+ /** Extra classes on the root. */
20
+ className?: string;
21
+ /** Inline styles on the root. */
22
+ style?: CSSProperties;
23
+ }
24
+ /**
25
+ * Renders a person's card.
26
+ *
27
+ * @param props - The {@link PersonCardProps}.
28
+ */
29
+ export declare function PersonCard({ person, onOpenProject, onOpenSession, className, style }: PersonCardProps): import("react").JSX.Element;
@@ -0,0 +1,199 @@
1
+ import { relativeTime } from "../chat/headless/session-list.js";
2
+ import { ProjectIconGlyph } from "../chat/sidebar/ProjectIcon.js";
3
+ import { useChatLabels } from "../chat/useChatLabels.js";
4
+ import { Avatar } from "../components/Avatar.js";
5
+ import { MenuRow } from "../components/Menu.js";
6
+ import { Skeleton } from "../components/Skeleton.js";
7
+ import { createSharedWithCache } from "./headless/shared-with.js";
8
+ import { useSessionProjects, useSessionSharing } from "./SessionProvider.js";
9
+ import { useSessionLabels } from "./useSessionLabels.js";
10
+ import { useEffect, useRef, useState } from "react";
11
+ import { jsx, jsxs } from "react/jsx-runtime";
12
+ import { ageStep } from "zidane/chat/pure";
13
+ // src/session/PersonCard.tsx
14
+ /** One cache per host's `shared`: every card of the window shares it. */
15
+ const caches = /* @__PURE__ */ new WeakMap();
16
+ function cacheOf(shared) {
17
+ let cache = caches.get(shared);
18
+ if (!cache) {
19
+ cache = createSharedWithCache(shared);
20
+ caches.set(shared, cache);
21
+ }
22
+ return cache;
23
+ }
24
+ /**
25
+ * What the caller shares with `userId`: `undefined` while it loads, `null` without `shared` or when the read failed.
26
+ *
27
+ * @param userId - The person.
28
+ * @param online - Whether they are online now: a change reads again.
29
+ */
30
+ function useSharedWith(userId, online) {
31
+ const sharing = useSessionSharing();
32
+ const projects = useSessionProjects();
33
+ const shared = sharing?.shared;
34
+ const cache = shared ? cacheOf(shared) : null;
35
+ const [answer, setAnswer] = useState(() => {
36
+ const hit = cache?.peek(userId);
37
+ return hit ? {
38
+ userId,
39
+ view: hit
40
+ } : null;
41
+ });
42
+ const [changes, setChanges] = useState(0);
43
+ useEffect(() => {
44
+ if (!cache) return void 0;
45
+ const stale = () => {
46
+ cache.clear();
47
+ setChanges((n) => n + 1);
48
+ };
49
+ const stops = [projects?.list.subscribe(stale), sharing?.onChanged?.(stale)];
50
+ return () => stops.forEach((stop) => stop?.());
51
+ }, [
52
+ cache,
53
+ projects,
54
+ sharing
55
+ ]);
56
+ const seenOnline = useRef(online);
57
+ useEffect(() => {
58
+ if (!cache) return void 0;
59
+ const force = seenOnline.current !== online;
60
+ seenOnline.current = online;
61
+ let live = true;
62
+ cache.load(userId, force).then((view) => live && setAnswer({
63
+ userId,
64
+ view
65
+ }), () => live && setAnswer({
66
+ userId,
67
+ view: null
68
+ }));
69
+ return () => {
70
+ live = false;
71
+ };
72
+ }, [
73
+ cache,
74
+ userId,
75
+ online,
76
+ changes
77
+ ]);
78
+ if (!cache) return null;
79
+ return answer?.userId === userId ? answer.view : void 0;
80
+ }
81
+ /** A row while what you share loads, at a row's size. */
82
+ function SkeletonRow() {
83
+ return /* @__PURE__ */ jsxs("div", {
84
+ className: "flex items-center gap-2 px-2 py-1.5",
85
+ "data-testid": "person-card-loading",
86
+ children: [/* @__PURE__ */ jsx(Skeleton, {
87
+ width: 16,
88
+ height: 16,
89
+ className: "rounded-zg-sm"
90
+ }), /* @__PURE__ */ jsx("span", {
91
+ className: "text-sm",
92
+ children: /* @__PURE__ */ jsx(Skeleton, {
93
+ width: 160,
94
+ height: 10,
95
+ className: "inline-block align-middle overflow-hidden",
96
+ children: "\xA0"
97
+ })
98
+ })]
99
+ });
100
+ }
101
+ /**
102
+ * Renders a person's card.
103
+ *
104
+ * @param props - The {@link PersonCardProps}.
105
+ */
106
+ function PersonCard({ person, onOpenProject, onOpenSession, className = "", style }) {
107
+ const labels = useSessionLabels();
108
+ const chatLabels = useChatLabels();
109
+ const view = useSharedWith(person.userId, person.online);
110
+ const name = person.name.trim() || labels.peopleUnnamed;
111
+ const email = person.email ?? view?.person.email;
112
+ const lastSeenAt = person.lastSeenAt ?? view?.person.lastSeenAt;
113
+ const [now] = useState(Date.now);
114
+ const status = person.online ? labels.personOnline : lastSeenAt !== void 0 ? labels.personLastSeen(relativeTime(lastSeenAt, Math.max(now, lastSeenAt), chatLabels), ageStep(lastSeenAt, Math.max(now, lastSeenAt), 7).kind === "duration") : void 0;
115
+ const projects = onOpenProject ? view?.projects ?? [] : [];
116
+ const sessions = onOpenSession ? view?.sessions ?? [] : [];
117
+ const loading = view === void 0 && Boolean(onOpenProject || onOpenSession);
118
+ return /* @__PURE__ */ jsxs("div", {
119
+ className: `p-1.5 ${className}`.trimEnd(),
120
+ style,
121
+ "aria-busy": loading || void 0,
122
+ "data-testid": "person-card",
123
+ children: [
124
+ /* @__PURE__ */ jsxs("div", {
125
+ className: "flex items-center gap-2.5 px-2 pt-1.5 pb-1.5 min-w-0",
126
+ children: [/* @__PURE__ */ jsx(Avatar, {
127
+ name: person.name,
128
+ ...person.avatar ? { avatar: person.avatar } : {},
129
+ online: person.online,
130
+ size: "md"
131
+ }), /* @__PURE__ */ jsxs("span", {
132
+ className: "flex-1 min-w-0",
133
+ children: [
134
+ /* @__PURE__ */ jsx("span", {
135
+ className: "block truncate text-sm font-medium text-[var(--zg-text)]",
136
+ children: /* @__PURE__ */ jsx("bdi", { children: name })
137
+ }),
138
+ email && email !== person.name && /* @__PURE__ */ jsx("span", {
139
+ className: "block truncate text-xs text-[var(--zg-text-muted)]",
140
+ children: email
141
+ }),
142
+ status && /* @__PURE__ */ jsx("span", {
143
+ className: "block truncate text-xs text-[var(--zg-text-muted)]",
144
+ children: status
145
+ })
146
+ ]
147
+ })]
148
+ }),
149
+ loading && /* @__PURE__ */ jsx(SkeletonRow, {}),
150
+ (projects.length > 0 || sessions.length > 0) && /* @__PURE__ */ jsxs("div", {
151
+ className: "max-h-72 overflow-y-auto",
152
+ children: [projects.length > 0 && /* @__PURE__ */ jsxs("section", {
153
+ className: "pt-1.5",
154
+ children: [/* @__PURE__ */ jsx("h3", {
155
+ className: "zg-section-label m-0 px-2 pb-0.5",
156
+ children: labels.personProjects
157
+ }), /* @__PURE__ */ jsx("ul", {
158
+ className: "m-0 p-0 list-none",
159
+ children: projects.map((project) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(MenuRow, {
160
+ size: "sm",
161
+ icon: /* @__PURE__ */ jsx(ProjectIconGlyph, {
162
+ size: "xs",
163
+ ...project.icon ? { icon: {
164
+ kind: "emoji",
165
+ value: project.icon
166
+ } } : {},
167
+ server: project.hostId !== void 0
168
+ }),
169
+ title: project.name,
170
+ onClick: () => project.hostId ? onOpenProject(project.id, project.hostId) : onOpenProject(project.id)
171
+ }) }, project.id))
172
+ })]
173
+ }), sessions.length > 0 && /* @__PURE__ */ jsxs("section", {
174
+ className: "pt-1.5",
175
+ children: [/* @__PURE__ */ jsx("h3", {
176
+ className: "zg-section-label m-0 px-2 pb-0.5",
177
+ children: labels.personSessions
178
+ }), /* @__PURE__ */ jsx("ul", {
179
+ className: "m-0 p-0 list-none",
180
+ children: sessions.map((session) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(MenuRow, {
181
+ size: "sm",
182
+ icon: /* @__PURE__ */ jsx("span", {
183
+ "aria-hidden": true,
184
+ className: "i-ph-chat-circle"
185
+ }),
186
+ title: session.title,
187
+ trailing: /* @__PURE__ */ jsx("span", {
188
+ className: "zg-meta",
189
+ children: relativeTime(session.updatedAt, Math.max(now, session.updatedAt), chatLabels)
190
+ }),
191
+ onClick: () => onOpenSession(session.sessionId)
192
+ }) }, session.sessionId))
193
+ })]
194
+ })]
195
+ })
196
+ ]
197
+ });
198
+ }
199
+ export { PersonCard };
@@ -1,13 +1,16 @@
1
1
  import { SessionProjectArtifacts } from "./headless/host.js";
2
+ import { ArtifactsRead } from "./project-artifact-parts.js";
2
3
  import { SectionProps } from "./project-settings-parts.js";
3
4
  /** Props for {@link ProjectArtifactsSection}. */
4
5
  export interface ProjectArtifactsSectionProps extends SectionProps {
5
6
  /** The host's project artifacts. */
6
7
  artifacts: SessionProjectArtifacts;
8
+ /** The rows as the caller read them (the dialog, for its tab's count). Absent: the section reads them on mount. */
9
+ read?: ArtifactsRead;
7
10
  }
8
11
  /**
9
12
  * The Artifacts section of a project's settings.
10
13
  *
11
14
  * @param props - The {@link ProjectArtifactsSectionProps}.
12
15
  */
13
- export declare function ProjectArtifactsSection({ artifacts, project, run, grants, said }: ProjectArtifactsSectionProps): import("react").JSX.Element;
16
+ export declare function ProjectArtifactsSection({ artifacts, project, run, grants, said, read: given }: ProjectArtifactsSectionProps): import("react").JSX.Element;