@bridgebrew/sessions 0.0.33 → 0.0.38

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/branch-name.ts ADDED
@@ -0,0 +1,34 @@
1
+ // A session's branch name (research-083): from a model's answer (`type/topic`), else from the words of the message
2
+ // that asked for the work.
3
+ /** A branch name from a message (research-083): its first words, lowercase, joined by `-`; empty when it has none.
4
+ * A URL gives none of them (plugins#73). The fallback of a model's name (`typedBranch`). */
5
+ export const branchSlug = (text: string) =>
6
+ text
7
+ .replace(/\b[a-z][a-z0-9+.-]*:\/\/\S*/gi, ' ')
8
+ .toLowerCase()
9
+ .normalize('NFKD')
10
+ .replace(/[\u0300-\u036f'’]/g, '')
11
+ .split(/[^a-z0-9]+/)
12
+ .filter(Boolean)
13
+ .slice(0, 6)
14
+ // Whole words within 40 characters (a single longer word cut).
15
+ .reduce(
16
+ (name, word) =>
17
+ !name ? word.slice(0, 40) : name.length + 1 + word.length <= 40 ? `${name}-${word}` : name,
18
+ '',
19
+ );
20
+
21
+ /** The example of the prompt that asks a model for a branch name: never taken as its answer (plugins#110). */
22
+ export const BRANCH_EXAMPLE = 'fix/e2e-shards';
23
+
24
+ /** A model's answer as a `type/topic` branch name (`fix/login-timeout`), `undefined` when it is not one or is the prompt's
25
+ * own example (a model echoing it would name every branch the same). */
26
+ export const typedBranch = (answer: string) => {
27
+ // Its first line: a model may go on after the name (plugins#84).
28
+ const name = (answer.trim().split('\n')[0] ?? '').trim().replace(/^`+|`+$/g, '');
29
+ return name.length <= 40 &&
30
+ /^(feat|fix|chore|ci|docs|refactor|test)\/[a-z0-9]+(-[a-z0-9]+)*$/.test(name) &&
31
+ name !== BRANCH_EXAMPLE
32
+ ? name
33
+ : undefined;
34
+ };
@@ -1,7 +1,8 @@
1
- // A session's branch from its page (research-083): its Git button (`@bridge/session-ui/git-actions`) acts on its branch's
2
- // folder, and archiving the branch's last session offers to delete that folder (never one with work not committed or not pushed; the git branch
3
- // stays). Both go through the project plugin's Branches routes (`/<slug>/api/project/branches/…`, bridgebrew/bridge#557),
4
- // as the Branches screen does: the same checks, the owner's page.
1
+ // A session's branch from its page (research-083): archiving the branch's last session offers to delete that folder
2
+ // (never one with work not committed or not pushed; the git branch stays), through the project plugin's Branches
3
+ // routes (`/<slug>/api/project/branches/…`, bridgebrew/bridge#557), as the Branches screen does: the same checks, the
4
+ // owner's page. Its Git button is the `git` plugin's (`sessions.details`, bridge-plugins#256); `installGit` installs
5
+ // that plugin when the workspace lacks it.
5
6
  // ponytail: cleanup is asked, never automatic (merged, inactive, unchanged): its rules are bridge#348.
6
7
  import * as React from 'react';
7
8
  import {
@@ -16,12 +17,17 @@ import {
16
17
  readJson,
17
18
  useToast,
18
19
  } from '@bridge/ui';
19
- import {
20
- GitActions,
21
- useBranch,
22
- type BranchesAnswer,
23
- type BranchesRoute,
24
- } from '@bridge/session-ui/git-actions';
20
+
21
+ /** What the project plugin's Branches route lists of a branch, the part read here. */
22
+ interface ListedBranch {
23
+ name: string;
24
+ folder: string;
25
+ main: boolean;
26
+ dirty: number;
27
+ unpushed: number;
28
+ active: boolean;
29
+ }
30
+ type BranchesRoute = (slug: string, node: string, action?: string) => string;
25
31
 
26
32
  /** The project plugin's Branches route of project `node` in workspace `slug`, or one of its actions. */
27
33
  export const branchesRoute: BranchesRoute = (slug, node, action) =>
@@ -36,43 +42,16 @@ const post = async (slug: string, node: string, action: string, body: Record<str
36
42
  }),
37
43
  );
38
44
 
39
- /** The Git button of session `session`'s branch `branch` (project `node`), in its header: its label and action from the
40
- * branch's state, read again after each turn (`refresh`) and when the page gets the focus back. `pullRequestOpen`: the
41
- * session knows an open pull request of its own (research-086), one Bridge did not record (the agent's `gh pr create`,
42
- * github.com): the button offers Push, not Create PR again. `onGitAnswer`: after each Git action's answer. */
43
- export function BranchActions({
44
- slug,
45
- node,
46
- branch,
47
- session,
48
- refresh,
49
- pullRequestOpen = false,
50
- onGitAnswer,
51
- }: {
52
- slug: string;
53
- node: string;
54
- branch: string;
55
- session: string;
56
- refresh?: unknown;
57
- pullRequestOpen?: boolean;
58
- onGitAnswer?: () => void;
59
- }) {
60
- const [state, take] = useBranch(slug, node, branch, refresh, branchesRoute);
61
- if (!state) return null;
62
- return (
63
- <GitActions
64
- slug={slug}
65
- node={node}
66
- branch={pullRequestOpen && !state.prOpen ? { ...state, prOpen: true } : state}
67
- session={session}
68
- route={branchesRoute}
69
- onAnswer={(answer) => {
70
- take(answer);
71
- onGitAnswer?.();
72
- }}
73
- />
45
+ /** Installs the `git` plugin in workspace `slug` (the Plugins screen's own install). */
46
+ export const installGit = async (slug: string) => {
47
+ await readJson(
48
+ await fetch(`/_bridge/workspaces/${encodeURIComponent(slug)}/plugins/install`, {
49
+ method: 'POST',
50
+ headers: { 'content-type': 'application/json' },
51
+ body: JSON.stringify({ source: '@bridgebrew/git' }),
52
+ }),
74
53
  );
75
- }
54
+ };
76
55
 
77
56
  /** The folder cleanup an archive offers: the branch, and why its folder must stay, if it must. */
78
57
  export interface Cleanup {
@@ -93,7 +72,7 @@ export const cleanupOf = async (
93
72
  // The project plugin's own answer: typed once where it is read.
94
73
  const view = (await readJson(
95
74
  await fetch(branchesRoute(slug, node), { cache: 'no-store' }),
96
- )) as BranchesAnswer;
75
+ )) as { branches: ListedBranch[] };
97
76
  const found = view.branches.find((each) => each.name === branch && !each.main);
98
77
  if (!found) return undefined;
99
78
  const why = [
@@ -29,7 +29,7 @@ import {
29
29
  cn,
30
30
  formatDate,
31
31
  } from '@bridge/ui';
32
- import { oneLine } from '@bridge/session-ui/one-line';
32
+ import { oneLine } from '@bridgebrew/session-ui/one-line';
33
33
  import { Elapsed, Spinner, duration } from './elapsed.tsx';
34
34
  import type { ChildState } from '../listing.ts';
35
35
 
@@ -43,8 +43,8 @@ import {
43
43
  outputMedia,
44
44
  viewedImage,
45
45
  type Attached,
46
- } from '@bridge/session-ui/media';
47
- import { oneLine } from '@bridge/session-ui/one-line';
46
+ } from '@bridgebrew/session-ui/media';
47
+ import { oneLine } from '@bridgebrew/session-ui/one-line';
48
48
  import { cutText } from '../text.ts';
49
49
  import type { PluginComponent } from '../views/library.ts';
50
50
  import type { ViewComponentRenderer, ViewTools } from './views/view.tsx';
@@ -1830,6 +1830,48 @@ function Thought({ text, answered }: { text: string; answered: boolean }) {
1830
1830
 
1831
1831
  /** The user's message: its images (`AttachedImages`), then a bubble, folded past about ten lines; its time, Copy and
1832
1832
  * Reuse on hover. */
1833
+ /** A message's text cut around the mentions the composer writes (plugins#239): `@session:<id>`, `@path` with a `/`
1834
+ * or a `.` in it (`@someone`, `@README` stay text), and `@"path"` for one with a blank; the punctuation after one is
1835
+ * the text's. */
1836
+ export const mentionParts = (text: string) => {
1837
+ const parts: (string | { kind: 'file' | 'session'; value: string })[] = [];
1838
+ let at = 0;
1839
+ for (const found of text.matchAll(/(?<=^|\s)@(?:"([^"\n]+)"|(\S+?))(?=[.,;:!?)]*(?:\s|$))/g)) {
1840
+ const quoted = found[1];
1841
+ const value = quoted ?? found[2]!;
1842
+ const session = quoted ? undefined : /^session:([\w-]+)$/.exec(value)?.[1];
1843
+ if (!quoted && !session && !/[/.]/.test(value)) continue;
1844
+ if (found.index > at) parts.push(text.slice(at, found.index));
1845
+ parts.push(session ? { kind: 'session', value: session } : { kind: 'file', value });
1846
+ at = found.index + found[0].length;
1847
+ }
1848
+ if (at < text.length) parts.push(text.slice(at));
1849
+ return parts;
1850
+ };
1851
+
1852
+ /** A message's text, its mentions as chips. */
1853
+ function MentionText({ text }: { text: string }) {
1854
+ return mentionParts(text).map((part, index) =>
1855
+ typeof part === 'string' ? (
1856
+ part
1857
+ ) : (
1858
+ <span
1859
+ key={index}
1860
+ data-mention={part.kind}
1861
+ title={part.kind === 'session' ? `Session ${part.value}` : part.value}
1862
+ className="inline-flex max-w-full items-center gap-1 rounded-control bg-surface px-1 align-bottom text-[13px]"
1863
+ >
1864
+ <Icon
1865
+ name={part.kind === 'session' ? 'message-square' : 'file'}
1866
+ size={12}
1867
+ className="shrink-0 text-muted"
1868
+ />
1869
+ <span className="truncate">{part.value}</span>
1870
+ </span>
1871
+ ),
1872
+ );
1873
+ }
1874
+
1833
1875
  const UserMessage = React.memo(function UserMessage({
1834
1876
  event,
1835
1877
  onReuse,
@@ -1864,7 +1906,7 @@ const UserMessage = React.memo(function UserMessage({
1864
1906
  !full && 'max-h-60 overflow-hidden',
1865
1907
  )}
1866
1908
  >
1867
- {text}
1909
+ <MentionText text={text ?? ''} />
1868
1910
  </div>
1869
1911
  ) : null}
1870
1912
  {long && (
@@ -0,0 +1,408 @@
1
+ // The open session's details panel, on the right of the conversation (plugins#239 §1): its git rows (its branch, its
2
+ // uncommitted changes as a folder tree, its Git row, and the one Commit changes dialog), drawn by the `git` plugin into
3
+ // `sessions.details` (bridge-plugins#256) from the changes this panel reads (`POST /sessions/changes`); its pull
4
+ // request once linked (its state and checks, `./pull-request.tsx`); its gallery, tags and marks. The panel holds which
5
+ // file the dialog is open at: the git rows open it (the Git row, Open diff, a file of the tree), and so does the
6
+ // conversation (a turn's Review changes, a tool call's file: `diffAsked`). Without the `git` plugin, a quiet Install Git
7
+ // row. Each section says why it is empty: no git, the default branch (no pull request), no GitHub plugin.
8
+ // The same panel is the phone's Details screen (`./mobile.tsx`), pushed with the shell's Back; its git rows come from the
9
+ // `git.session-details` factory there.
10
+ import * as React from 'react';
11
+ import { Button, Icon, TagInput, cn, isRecord } from '@bridge/ui';
12
+ import type { ChangesAnswer } from '@bridgebrew/git/contract.ts';
13
+ import { PullRequestPill, type SessionPullRequest } from './pull-request.tsx';
14
+
15
+ /** A POST to the sessions API (`path` after `/sessions`): its JSON answer, or a rejection with the refusal's `code`. */
16
+ export type Post = (path: string, body: object) => Promise<any>;
17
+
18
+ /** The phone's item for session `id`'s details: under the session's in the shell's tree of items (`parent/child`), so
19
+ * the shell's Back, as the browser's, returns to the session. */
20
+ const DETAILS = '/details';
21
+ export const detailsItem = (id: string) => `${id}${DETAILS}`;
22
+ /** The session an item names, and whether it asks for its details. */
23
+ export const detailsOf = (item: string) =>
24
+ item.endsWith(DETAILS)
25
+ ? { session: item.slice(0, -DETAILS.length), details: true }
26
+ : { session: item, details: false };
27
+
28
+ /** The fields of a session the panel reads. */
29
+ export interface PanelSession {
30
+ id: string;
31
+ node: string;
32
+ branch?: { name: string; folder: string; temporary?: true };
33
+ pullRequest?: SessionPullRequest;
34
+ tags?: string[];
35
+ files?: string[];
36
+ claims?: { path: string; note?: string }[];
37
+ commits?: unknown[];
38
+ lastTurn?: { endedAt: string };
39
+ running?: boolean;
40
+ }
41
+ /** One row of the panel (plugins#239, the owner's rows): its icon, its title, its value or action on the right, and what
42
+ * it holds under it (the changes' tree); a region named `name`. */
43
+ export const Row = ({
44
+ name,
45
+ icon,
46
+ title = name,
47
+ value,
48
+ children,
49
+ }: {
50
+ name: string;
51
+ icon: string;
52
+ title?: React.ReactNode;
53
+ value?: React.ReactNode;
54
+ children?: React.ReactNode;
55
+ }) => (
56
+ <section aria-label={name} className="flex flex-col gap-1 px-4 py-1.5">
57
+ <div className="flex min-h-8 min-w-0 items-center gap-2">
58
+ <Icon name={icon} size={14} className="shrink-0 text-muted" />
59
+ <span className="min-w-0 max-w-[60%] shrink-0 truncate font-medium">{title}</span>
60
+ <span className="flex min-w-0 flex-1 items-center justify-end gap-1.5 text-right text-xs text-secondary">
61
+ {value}
62
+ </span>
63
+ </div>
64
+ {children}
65
+ </section>
66
+ );
67
+ const Note = ({ children }: { children: React.ReactNode }) => (
68
+ <span className="text-xs text-muted">{children}</span>
69
+ );
70
+
71
+ /** What `sessions.details`' entries get (the `git` plugin's rows, contract `sessions` 1.1). */
72
+ export interface GitRowsProps {
73
+ slug: string;
74
+ session: PanelSession;
75
+ /** The changes as the panel read them: `undefined` while read, `null` when unavailable. */
76
+ changes: ChangesAnswer | null | undefined;
77
+ post: Post;
78
+ Row: typeof Row;
79
+ /** The Commit changes dialog: open at a file (none: its top), or closed. */
80
+ diff: { path?: string } | undefined;
81
+ onDiff: (at: { path?: string } | undefined) => void;
82
+ readOnly: boolean;
83
+ onChanged: () => void;
84
+ onOpenSession: (id: string) => void;
85
+ pullRequestOpen: boolean;
86
+ onGitAnswer?: (() => void) | undefined;
87
+ }
88
+
89
+ const TAGS_MAX = 5;
90
+ /** A session's tags (up to five), the workspace's offered as suggestions; `onChange`: the tags after an edit. */
91
+ export function SessionTags({
92
+ tags = [],
93
+ known,
94
+ onChange,
95
+ bare = false,
96
+ }: {
97
+ tags?: string[] | undefined;
98
+ known: string[];
99
+ onChange: (tags: string[]) => void;
100
+ /** Without its own tag icon (a row of the details panel draws one). */
101
+ bare?: boolean;
102
+ }) {
103
+ const listId = React.useId();
104
+ return (
105
+ <div className={cn('flex items-center gap-2', bare && 'min-w-0 flex-1')}>
106
+ {!bare && <Icon name="tag" size={14} className="shrink-0 text-muted" />}
107
+ <TagInput
108
+ aria-label="Tags"
109
+ list={listId}
110
+ placeholder={tags.length < TAGS_MAX ? 'Add a tag…' : ''}
111
+ value={tags}
112
+ onChange={(next: string[]) => onChange(next.slice(0, TAGS_MAX))}
113
+ className="min-w-0 flex-1"
114
+ />
115
+ <datalist id={listId}>
116
+ {known
117
+ .filter((each) => !tags.includes(each))
118
+ .map((each) => (
119
+ <option key={each} value={each} />
120
+ ))}
121
+ </datalist>
122
+ </div>
123
+ );
124
+ }
125
+
126
+ /** The file of `files` (relative to `repository`) that `wanted` names, as an agent named it (absolute, or relative to
127
+ * the session's folder): the same path first, else one ending the other (`src/app.ts` before `app.ts`). */
128
+ export const fileNamed = <T extends { path: string }>(
129
+ files: T[],
130
+ wanted: string,
131
+ repository: string,
132
+ ) =>
133
+ files.find(
134
+ ({ path }) => wanted === path || wanted === `${repository.replace(/\/$/, '')}/${path}`,
135
+ ) ??
136
+ files.find(({ path }) => wanted.endsWith(`/${path}`)) ??
137
+ files.find(({ path }) => path.endsWith(`/${wanted}`));
138
+
139
+ /** The changes `/changes` answered, read as `ChangesAnswer` (its lists empty when missing); `null` when not one. */
140
+ const changesIn = (found: unknown): ChangesAnswer | null => {
141
+ if (!isRecord(found) || (found.repository !== null && typeof found.repository !== 'string')) return null;
142
+ const strings = (value: unknown) =>
143
+ Array.isArray(value) ? value.filter((each): each is string => typeof each === 'string') : [];
144
+ return {
145
+ repository: found.repository,
146
+ ...(found.git === 'missing' && { git: 'missing' as const }),
147
+ files: Array.isArray(found.files)
148
+ ? found.files.flatMap((each: unknown) =>
149
+ isRecord(each) && typeof each.path === 'string'
150
+ ? [
151
+ {
152
+ path: each.path,
153
+ pending: each.pending === true,
154
+ ...(typeof each.added === 'number' && { added: each.added }),
155
+ ...(typeof each.removed === 'number' && { removed: each.removed }),
156
+ },
157
+ ]
158
+ : [],
159
+ )
160
+ : [],
161
+ diff: typeof found.diff === 'string' ? found.diff : '',
162
+ ...(found.byFile === true && { byFile: true }),
163
+ ...(found.cut === true && { cut: true }),
164
+ branch:
165
+ isRecord(found.branch) && typeof found.branch.name === 'string'
166
+ ? {
167
+ name: found.branch.name,
168
+ isDefault: found.branch.isDefault === true,
169
+ remote: found.branch.remote === true,
170
+ upstream: found.branch.upstream === true,
171
+ unpushed: typeof found.branch.unpushed === 'number' ? found.branch.unpushed : 0,
172
+ }
173
+ : null,
174
+ commits: [],
175
+ shared: [],
176
+ others: strings(found.others),
177
+ ...(found.github === 'missing' || found.github === 'ready' ? { github: found.github } : {}),
178
+ };
179
+ };
180
+
181
+ /** The panel of `session` (drawn afresh for each: nothing of the previous one's answers lands on the next). */
182
+ export function DetailsPanel(props: {
183
+ session: PanelSession;
184
+ /** The workspace whose Branches route lists its branches (a worktree's own, research-045). */
185
+ slug: string;
186
+ known: string[];
187
+ post: Post;
188
+ onChanged: () => void;
189
+ /** Its pull request's menu: Sessions' pull request routes. */
190
+ actPullRequest: (action: 'watch' | 'unwatch' | 'unlink') => void;
191
+ /** A phone shown read-only: tags are listed, not edited; the dialog shows the diff alone. */
192
+ readOnly?: boolean;
193
+ /** The diff asked from outside the panel (a tool call's file in the conversation): the Commit changes dialog opens at
194
+ * `path` (none: its top) once the changes are read, again at each new `at`. */
195
+ diffAsked?: { path?: string; at: number } | undefined;
196
+ /** The ask opened the dialog: the page forgets it, so a panel drawn again later does not open it again. */
197
+ onDiffAnswered?: (() => void) | undefined;
198
+ /** Its git rows: `sessions.details` (the `git` plugin's); nothing without that plugin's page. */
199
+ gitRows: (props: GitRowsProps) => React.ReactNode;
200
+ /** Another session sharing files, opened from the dialog. */
201
+ onOpenSession?: ((id: string) => void) | undefined;
202
+ /** After each Git action's answer (its pull request read again). */
203
+ onGitAnswer?: (() => void) | undefined;
204
+ /** Installs the `git` plugin in this workspace (its absence's one action). */
205
+ onInstallGit?: (() => Promise<void>) | undefined;
206
+ /** The rows the page adds (the desktop's): the gallery, and its marks (`Row`s: pinned, settled, snoozed, scheduled,
207
+ * its parent, its stage), after the tags. */
208
+ gallery?: React.ReactNode;
209
+ marks?: React.ReactNode;
210
+ }) {
211
+ return <Panel key={props.session.id} {...props} />;
212
+ }
213
+
214
+ function Panel({
215
+ session,
216
+ slug,
217
+ known,
218
+ post,
219
+ onChanged,
220
+ actPullRequest,
221
+ readOnly = false,
222
+ diffAsked,
223
+ onDiffAnswered,
224
+ gitRows,
225
+ onOpenSession,
226
+ onGitAnswer,
227
+ onInstallGit,
228
+ gallery,
229
+ marks,
230
+ }: React.ComponentProps<typeof DetailsPanel>) {
231
+ const [error, setError] = React.useState('');
232
+ const [changes, setChanges] = React.useState<ChangesAnswer | null>();
233
+ /** Bumped to read the changes again though the session did not change (the Git plugin just installed). */
234
+ const [reads, setReads] = React.useState(0);
235
+ const changesKey = JSON.stringify([
236
+ reads,
237
+ session.id,
238
+ session.files,
239
+ session.commits?.length,
240
+ session.lastTurn?.endedAt,
241
+ ]);
242
+ React.useEffect(() => {
243
+ let live = true;
244
+ post('/changes', { id: session.id }).then(
245
+ (found: unknown) => live && setChanges(changesIn(found)),
246
+ (cause: unknown) => {
247
+ if (!live) return;
248
+ if (isRecord(cause) && cause.code === 'not_a_repository')
249
+ setChanges(changesIn({ repository: null }));
250
+ else {
251
+ setError(cause instanceof Error ? cause.message : String(cause));
252
+ setChanges(null);
253
+ }
254
+ },
255
+ );
256
+ return () => {
257
+ live = false;
258
+ };
259
+ }, [changesKey]);
260
+ /** The Commit changes dialog, and the file it opened at (none: its top). */
261
+ const [diffAt, setDiffAt] = React.useState<{ path?: string }>();
262
+ // Asked from outside: opened once the changes are read, each ask once (the panel may be drawn for it).
263
+ const answered = React.useRef<number>(undefined);
264
+ React.useEffect(() => {
265
+ if (!diffAsked || changes === undefined || answered.current === diffAsked.at) return;
266
+ answered.current = diffAsked.at;
267
+ onDiffAnswered?.();
268
+ const { path } = diffAsked;
269
+ if (path === undefined) return setDiffAt({});
270
+ // A tool call names the file by its full path, the diff by its path in the repository.
271
+ const repository = changes?.repository?.replace(/\/$/, '');
272
+ const pending = (changes?.files ?? [])
273
+ .filter((each) => each.pending && !each.path.endsWith('/'))
274
+ .map((each) => ({ path: each.path }));
275
+ const found = repository ? fileNamed(pending, path, repository) : undefined;
276
+ setDiffAt({
277
+ path:
278
+ found?.path ??
279
+ (repository && path.startsWith(`${repository}/`) ? path.slice(repository.length + 1) : path),
280
+ });
281
+ }, [diffAsked?.at, changes]);
282
+
283
+ const missing = changes?.git === 'missing';
284
+ const noGit = changes === null || changes?.repository === null;
285
+ const [installing, setInstalling] = React.useState(false);
286
+ const pullRequestOpen =
287
+ !!session.branch &&
288
+ session.pullRequest?.headBranch === session.branch.name &&
289
+ (session.pullRequest.state === 'open' || session.pullRequest.state === 'draft');
290
+
291
+ return (
292
+ <div aria-label="Session details" className="flex min-h-0 flex-col py-2 text-sm">
293
+ {!missing &&
294
+ gitRows({
295
+ slug,
296
+ session,
297
+ changes,
298
+ post,
299
+ Row,
300
+ diff: diffAt,
301
+ onDiff: setDiffAt,
302
+ readOnly,
303
+ onChanged,
304
+ onOpenSession: (id) => {
305
+ setDiffAt(undefined);
306
+ onOpenSession?.(id);
307
+ },
308
+ pullRequestOpen,
309
+ onGitAnswer,
310
+ })}
311
+ {missing && (
312
+ <Row
313
+ name="Git"
314
+ icon="git-branch"
315
+ value={
316
+ readOnly || !onInstallGit ? (
317
+ <Note>Git needs the Git plugin.</Note>
318
+ ) : (
319
+ <Button
320
+ size="sm"
321
+ variant="ghost"
322
+ className="-mr-2"
323
+ disabled={installing}
324
+ onClick={() => {
325
+ setInstalling(true);
326
+ setError('');
327
+ onInstallGit()
328
+ .then(
329
+ () => {
330
+ setReads((was) => was + 1);
331
+ onChanged();
332
+ },
333
+ (cause: unknown) =>
334
+ setError(cause instanceof Error ? cause.message : String(cause)),
335
+ )
336
+ .finally(() => setInstalling(false));
337
+ }}
338
+ >
339
+ {installing ? 'Installing…' : 'Install Git'}
340
+ </Button>
341
+ )
342
+ }
343
+ />
344
+ )}
345
+ <div role="separator" className="mx-4 my-1 h-px bg-border" />
346
+ <Row
347
+ name="Pull request"
348
+ icon="git-pull-request"
349
+ value={
350
+ session.pullRequest ? (
351
+ <PullRequestPill
352
+ pullRequest={session.pullRequest}
353
+ act={readOnly ? undefined : actPullRequest}
354
+ />
355
+ ) : (
356
+ <Note>
357
+ {missing
358
+ ? 'Pull requests need the Git plugin.'
359
+ : noGit
360
+ ? 'Not a git repository.'
361
+ : changes?.branch?.isDefault
362
+ ? 'On the default branch: no pull request.'
363
+ : changes?.github === 'missing'
364
+ ? 'Pull requests need the GitHub plugin.'
365
+ : 'None yet. The Git button opens one.'}
366
+ </Note>
367
+ )
368
+ }
369
+ >
370
+ {session.pullRequest?.title && (
371
+ <span className="min-w-0 truncate pl-[22px] text-xs text-secondary">
372
+ {session.pullRequest.title}
373
+ </span>
374
+ )}
375
+ </Row>
376
+ {gallery}
377
+ <Row
378
+ name="Tags"
379
+ icon="tag"
380
+ value={
381
+ readOnly ? (
382
+ <Note>
383
+ {session.tags?.length ? session.tags.map((tag) => `#${tag}`).join(' ') : 'No tags.'}
384
+ </Note>
385
+ ) : (
386
+ <SessionTags
387
+ bare
388
+ tags={session.tags}
389
+ known={known}
390
+ onChange={(tags) => {
391
+ setError('');
392
+ post('/tags', { id: session.id, tags }).then(onChanged, (cause: unknown) =>
393
+ setError(cause instanceof Error ? cause.message : String(cause)),
394
+ );
395
+ }}
396
+ />
397
+ )
398
+ }
399
+ />
400
+ {marks}
401
+ {error && (
402
+ <p role="alert" className="m-0 px-4 py-2 text-xs text-destructive">
403
+ {error}
404
+ </p>
405
+ )}
406
+ </div>
407
+ );
408
+ }
@@ -15,7 +15,7 @@ import {
15
15
  TooltipTrigger,
16
16
  formatDate,
17
17
  } from '@bridge/ui';
18
- import { blobUrl, ImageViewer, type Pinned, type Viewed } from '@bridge/session-ui/media';
18
+ import { blobUrl, ImageViewer, type Pinned, type Viewed } from '@bridgebrew/session-ui/media';
19
19
 
20
20
  /** Where the gallery looks: a node and everything below it, or one session of it. */
21
21
  export interface Scope {