@bakers-build/addon-bakers-ui 0.12.1-next.4 → 0.12.1-next.5

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.
@@ -88,6 +88,8 @@ export declare const Markdown: ({ id, source, width }: MarkdownProps) => VNode;
88
88
  export interface HeadlineMarkdownProps {
89
89
  id: string;
90
90
  headline: string;
91
+ /** What stands before the headline, `*` by default; an icon for a few. */
92
+ marker?: string;
91
93
  children: readonly VNode[];
92
94
  paddingBottom?: number;
93
95
  paddingLeft?: number;
@@ -100,4 +102,4 @@ export interface HeadlineMarkdownProps {
100
102
  onMouseDown?: () => void;
101
103
  }
102
104
  /** A `* headline` row above an indented body. */
103
- export declare const HeadlineMarkdown: ({ id, headline, children, paddingBottom, paddingLeft, headlineId, onMouseDown, }: HeadlineMarkdownProps) => VNode;
105
+ export declare const HeadlineMarkdown: ({ id, headline, marker, children, paddingBottom, paddingLeft, headlineId, onMouseDown, }: HeadlineMarkdownProps) => VNode;
@@ -179,7 +179,7 @@ export const Markdown = ({ id, source, width }) => MarkdownLines({
179
179
  ...(width === undefined ? {} : { width }),
180
180
  });
181
181
  /** A `* headline` row above an indented body. */
182
- export const HeadlineMarkdown = ({ id, headline, children, paddingBottom = 1, paddingLeft = 1, headlineId, onMouseDown, }) => {
182
+ export const HeadlineMarkdown = ({ id, headline, marker = '*', children, paddingBottom = 1, paddingLeft = 1, headlineId, onMouseDown, }) => {
183
183
  const row = headlineId ?? `${id}-headline`;
184
184
  return h(BoxRenderable, {
185
185
  id,
@@ -189,7 +189,7 @@ export const HeadlineMarkdown = ({ id, headline, children, paddingBottom = 1, pa
189
189
  paddingBottom,
190
190
  }, h(BoxRenderable, { id: row, flexDirection: 'row', flexShrink: 0 }, paragraphNode({
191
191
  id: `${row}-text`,
192
- runs: [plainRun(`* ${headline}`)],
192
+ runs: [plainRun(`${marker} ${headline}`)],
193
193
  fg: FOREGROUND,
194
194
  width: '100%',
195
195
  flexShrink: 0,
@@ -23,7 +23,9 @@
23
23
  // navigation out of it except Esc.
24
24
  import { markdownRow } from '../../../../Component/markdown/index.js';
25
25
  import { asString } from '../../../../lib/format.js';
26
- import { columnNode, textNode } from '../../../../lib/vnode.js';
26
+ import { FOREGROUND } from '../../../../lib/theme.js';
27
+ import { linkRuns, ticketTopLinks } from '../../../../lib/ticket-links.js';
28
+ import { columnNode, paragraphNode, textNode } from '../../../../lib/vnode.js';
27
29
  /** The sideloaded `bb_run` with this id, or undefined. */
28
30
  export function runResource(document, runId) {
29
31
  if (!runId)
@@ -102,6 +104,24 @@ function keyedSections(document, runId, baseUrl) {
102
104
  ];
103
105
  }
104
106
  const a = run.attributes ?? {};
107
+ // AC-4 (BAKERS-332): the owning ticket's URL and its PRs, before everything.
108
+ const topLinks = ticketTopLinks(document);
109
+ // AC-7: one `* <full URL>` row per link; the terminal makes it an OSC 8 link.
110
+ const linkRow = (key, href) => ({
111
+ key,
112
+ text: `* ${href}`,
113
+ link: href,
114
+ });
115
+ const linkRows = [
116
+ // The served ticket entry leads when present; a stored link never matches its href.
117
+ ...topLinks
118
+ .slice(0, 1)
119
+ .filter((link) => link.href === document.data?.attributes?.url)
120
+ .map((link) => linkRow('link-ticket', link.href)),
121
+ ...topLinks
122
+ .filter((link) => link.pullRequest)
123
+ .map((link, index) => linkRow(`link-pr-${index}`, link.href)),
124
+ ];
105
125
  // The transcript/error payload no longer lives on the entity (BB-556) —
106
126
  // preSave() writes it to a private file and clears the field, so what the
107
127
  // API returns is the byte count, not the text. `bytes > 0` and "unset"
@@ -122,6 +142,13 @@ function keyedSections(document, runId, baseUrl) {
122
142
  };
123
143
  };
124
144
  return [
145
+ {
146
+ key: 'links',
147
+ heading: 'Links',
148
+ rows: linkRows.length > 0
149
+ ? linkRows
150
+ : [{ key: 'links-empty', text: 'No links.' }],
151
+ },
125
152
  {
126
153
  key: 'run',
127
154
  heading: 'Run',
@@ -224,6 +251,7 @@ function flatRows(document, runId, baseUrl) {
224
251
  // starting with `#` must not render one way on screen and another way in a
225
252
  // pipe. Nothing else in an entry is parsed, deliberately — see the header.
226
253
  ...markdownRow(entry.text),
254
+ ...(entry.link === undefined ? {} : { link: entry.link }),
227
255
  })),
228
256
  // The blank row between two sections, which the flattened surface pushed
229
257
  // after every block. The kernel's non-interactive branch drops empties, so
@@ -242,7 +270,15 @@ function flatRows(document, runId, baseUrl) {
242
270
  * that slot is the kernel's to know and a component may not import it.
243
271
  */
244
272
  export function runDetailTree(document, runId, baseUrl) {
245
- return columnNode('run-detail', ...flatRows(document, runId, baseUrl).map((entry) => textRow(entry.key, entry.text, entry.bold)));
273
+ return columnNode('run-detail', ...flatRows(document, runId, baseUrl).map(({ key, text, bold, link }) => link !== undefined
274
+ ? paragraphNode({
275
+ id: `run-detail-${key}`,
276
+ runs: linkRuns(link),
277
+ wrapMode: 'char',
278
+ fg: FOREGROUND,
279
+ width: '100%',
280
+ })
281
+ : textRow(key, text, bold)));
246
282
  }
247
283
  /**
248
284
  * The run block as PLAIN TEXT — the pipe's own output (spec F5).
@@ -5,10 +5,11 @@ import { KeyValue, } from '../../../../Component/key-value/index.js';
5
5
  import { HeadlineMarkdown, MarkdownLines, } from '../../../../Component/markdown/index.js';
6
6
  import { lineText, } from '../../../../Component/section-list/index.js';
7
7
  import { BORDER, FOREGROUND, FOREGROUND_ACTIVE, FOREGROUND_HIGHLIGHT, } from '../../../../lib/theme.js';
8
+ import { linkRuns } from '../../../../lib/ticket-links.js';
8
9
  import { BOLD, DIM, paragraphNode, plainRun, pressHandler, } from '../../../../lib/vnode.js';
9
10
  import { documentTabLabel, ticketContentRowId, } from './model.js';
10
- // Links are NOT here: a URL cannot fit the narrow sidebar without wrapping, so
11
- // they render full-width in the left column (see linksSection) instead.
11
+ // Links are NOT here: they render at the top of the left column (see
12
+ // linksSection), above the documents, so they are visible without scrolling.
12
13
  export const SIDEBAR_TABS = [
13
14
  { id: 'details', label: 'Details' },
14
15
  { id: 'related', label: 'Related' },
@@ -167,9 +168,13 @@ const headlineContent = (id, tabs, activeId, selected, onTab, body) => {
167
168
  marginTop: 1,
168
169
  }, body));
169
170
  };
171
+ // Nerd Font glyphs (nf-fa-link, nf-fa-file_text); without that font the terminal shows a box.
172
+ const LINKS_ICON = '\uf0c1';
173
+ const SUMMARY_ICON = '\uf15c';
170
174
  const overviewDocuments = (id, documents, props) => column(id, { width: '100%', flexGrow: 1, flexShrink: 1, marginTop: 1 }, ...documents.map((entry) => HeadlineMarkdown({
171
175
  id: `${id}-${entry.key}`,
172
176
  headline: documentTabLabel(entry.title),
177
+ ...(entry.title === 'Latest summary' ? { marker: SUMMARY_ICON } : {}),
173
178
  headlineId: ticketContentRowId(entry.key),
174
179
  onMouseDown: () => activate(entry, props.select, props.toggle),
175
180
  paddingBottom: 1,
@@ -344,17 +349,30 @@ const addonsCard = (id, preview, onOpen, selected) => {
344
349
  children: lines,
345
350
  });
346
351
  };
347
- const linksSection = (id, links, activateProperty) => {
348
- // Drop the `none` placeholder linkProperties emits for a linkless ticket, so
349
- // the section is omitted entirely rather than painting "links : none".
350
- const real = links.filter((item) => item.value !== 'none' && item.value !== '');
351
- if (real.length === 0)
352
+ const linksSection = (id, links) => {
353
+ // No served URL and no links: no section at all, never "links : none".
354
+ if (links.length === 0)
352
355
  return null;
356
+ // AC-7: one `* <full URL>` row per link, an OSC 8 link the terminal opens
357
+ // and copies (AC-2). A fixed list per draw, so the ids survive a resize (AC-8).
358
+ const rows = links.map((item, index) => paragraphNode({
359
+ id: `${id}-items-${index}`,
360
+ runs: item.href === undefined
361
+ ? [plainRun(`${item.key}: ${item.value}`)]
362
+ : linkRuns(item.href),
363
+ fg: FOREGROUND_HIGHLIGHT,
364
+ // Char wrap keeps `* ` on the URL's row; word wrap would orphan it.
365
+ ...(item.href === undefined ? {} : { wrapMode: 'char' }),
366
+ }));
353
367
  return HeadlineMarkdown({
354
368
  id,
355
369
  headline: 'links',
356
- paddingBottom: 1,
357
- children: [properties(`${id}-items`, real, activateProperty)],
370
+ marker: LINKS_ICON,
371
+ // The documents' marginTop spaces them; HeadlineMarkdown's default would add a row.
372
+ paddingBottom: 0,
373
+ children: [
374
+ h(BoxRenderable, { id: `${id}-items`, flexDirection: 'column', width: '100%' }, ...rows),
375
+ ],
358
376
  });
359
377
  };
360
378
  /**
@@ -366,7 +384,7 @@ const overview = (id, props) => {
366
384
  const { model } = props;
367
385
  const wide = props.terminalColumns >= WIDE_OVERVIEW_COLUMNS;
368
386
  const main = model.entries.filter((entry) => entry.key !== TECHNICAL_KEY);
369
- const links = linksSection(`${id}-links`, model.sidebar?.links ?? [], props.activateProperty);
387
+ const links = linksSection(`${id}-links`, model.sidebar?.links ?? []);
370
388
  const sidebar = model.sidebar === undefined
371
389
  ? null
372
390
  : sidebarCard(`${id}-sidebar`, model.sidebar, props);
@@ -388,8 +406,10 @@ const overview = (id, props) => {
388
406
  // Side by side it yields WIDTH to the sidebar; stacked, nothing may
389
407
  // squeeze its height below the documents it holds.
390
408
  flexShrink: sideBySide ? 1 : 0,
391
- gap: sideBySide ? 0 : 2,
392
- }, overviewDocuments(`${id}-documents`, main, props), ...(links === null ? [] : [links])), ...(side === null
409
+ },
410
+ // Links first: directly under the header at both widths. The documents'
411
+ // marginTop alone spaces them, one row as between two documents.
412
+ ...(links === null ? [] : [links]), overviewDocuments(`${id}-documents`, main, props)), ...(side === null
393
413
  ? []
394
414
  : [
395
415
  column(`${id}-side`, { width: sideBySide ? '30%' : '100%', flexShrink: 0, gap: 1 }, ...side.filter((node) => node !== null)),
@@ -27,7 +27,7 @@ export interface TicketContentModel {
27
27
  }
28
28
  export type TicketContentTab = 'overview' | 'planning' | 'comments';
29
29
  export declare const documentTabLabel: (title: string) => string;
30
- export declare function ticketContentModel(document: TicketDetailDocument, tab: TicketContentTab, labels: AssignmentLabels | undefined, nowSeconds: number, baseUrl?: string): TicketContentModel;
30
+ export declare function ticketContentModel(document: TicketDetailDocument, tab: TicketContentTab, labels: AssignmentLabels | undefined, nowSeconds: number): TicketContentModel;
31
31
  export declare function ticketContentRowId(key: string): string;
32
32
  export declare function resolveSelectedKey(selectableKeys: readonly string[], previous: string | undefined): string | undefined;
33
33
  export declare function retainExpandedKeys(keys: readonly string[], previous: ReadonlySet<string>): Set<string>;
@@ -1,4 +1,5 @@
1
1
  import { lineText, panelSectionKey, styledOf, } from '../../../../Component/section-list/index.js';
2
+ import { ticketTopLinks } from '../../../../lib/ticket-links.js';
2
3
  import { relativeCreated } from '../comment-item/index.js';
3
4
  import { TICKET_SECTIONS } from '../sections/index.js';
4
5
  import { commentItems, descriptionSummary, firstLineSummary, headerCreatedBy, sectionsForTab, } from '../ticket-detail/index.js';
@@ -22,7 +23,7 @@ const PLANNING_DOCUMENTS = [
22
23
  ];
23
24
  const isBlankLine = (line) => lineText(line).trim() === '';
24
25
  const isBlankBody = (lines) => lines.length === 0 || lines.every(isBlankLine);
25
- const sectionByHeading = (document, labels, nowSeconds, baseUrl) => new Map(sectionsForTab(document, OVERVIEW_TAB, labels, nowSeconds, baseUrl).map((section) => [section.heading, section]));
26
+ const sectionByHeading = (document, labels, nowSeconds) => new Map(sectionsForTab(document, OVERVIEW_TAB, labels, nowSeconds).map((section) => [section.heading, section]));
26
27
  const contentEntry = (key, title, expandable, collapsed, expanded, metadata) => metadata === undefined
27
28
  ? { key, title, expandable, collapsed, expanded }
28
29
  : { key, title, metadata, expandable, collapsed, expanded };
@@ -173,25 +174,6 @@ const technicalProperties = (byHeading, document, labels) => {
173
174
  ...environments,
174
175
  ];
175
176
  };
176
- const linkProperties = (lines) => {
177
- const meaningful = lines.filter((line) => {
178
- const text = lineText(line).trim();
179
- return text !== '' && text !== 'No links.';
180
- });
181
- if (meaningful.length === 0)
182
- return [property('links', '')];
183
- return meaningful.map((line) => {
184
- const text = lineText(line).trim();
185
- const match = /^(.*?)\s+(https?:\/\/\S+)$/.exec(text);
186
- if (match?.[1] !== undefined && match[2] !== undefined) {
187
- return property(match[1], match[2], { href: match[2] });
188
- }
189
- if (text.startsWith('http://') || text.startsWith('https://')) {
190
- return property('link', text, { href: text });
191
- }
192
- return property('link', text);
193
- });
194
- };
195
177
  const relatedProperties = (document) => [
196
178
  originProperty(document, 'source') ?? property('source', ''),
197
179
  ...relatedTicketProperties(document, 'parent_id', 'parent'),
@@ -212,8 +194,8 @@ const hasSummary = (lines) => {
212
194
  .filter((line) => line !== '');
213
195
  return text.length > 0 && text.some((line) => line !== EMPTY_SUMMARY);
214
196
  };
215
- const overviewModel = (document, labels, nowSeconds, baseUrl) => {
216
- const byHeading = sectionByHeading(document, labels, nowSeconds, baseUrl);
197
+ const overviewModel = (document, labels, nowSeconds) => {
198
+ const byHeading = sectionByHeading(document, labels, nowSeconds);
217
199
  const summaryLines = byHeading.get('Latest summary')?.lines ?? [];
218
200
  const documents = [];
219
201
  if (hasSummary(summaryLines)) {
@@ -227,11 +209,16 @@ const overviewModel = (document, labels, nowSeconds, baseUrl) => {
227
209
  documents.push(described('Description', byHeading.get('Description')?.lines ?? ['No description.'], 'No description.'));
228
210
  const details = technicalProperties(byHeading, document, labels);
229
211
  const technical = asLines(details);
230
- const listedLinks = linkProperties(byHeading.get('Links')?.lines ?? []);
231
212
  const origin = originProperty(document);
232
- const links = origin === undefined
233
- ? listedLinks
234
- : [origin, ...listedLinks.filter((item) => item.value !== 'none')];
213
+ // AC-7: each link is its full URL; a non-web origin keeps `origin: value`.
214
+ const links = [
215
+ ...ticketTopLinks(document).map(({ key, href }) => ({
216
+ key,
217
+ value: href,
218
+ href,
219
+ })),
220
+ ...(origin === undefined ? [] : [origin]),
221
+ ];
235
222
  return {
236
223
  entries: [
237
224
  ...documents,
@@ -263,9 +250,9 @@ const commentsModel = (document, nowSeconds) => commentItems(document).map((item
263
250
  : item.bodyLines;
264
251
  return contentEntry(`comment:${item.id}`, item.type, true, blank ? ['No comment content.'] : [], expanded, `${item.author || '—'} · ${relativeCreated(item.created, nowSeconds)}`);
265
252
  });
266
- export function ticketContentModel(document, tab, labels, nowSeconds, baseUrl) {
253
+ export function ticketContentModel(document, tab, labels, nowSeconds) {
267
254
  if (tab === 'overview') {
268
- const { entries, sidebar } = overviewModel(document, labels, nowSeconds, baseUrl);
255
+ const { entries, sidebar } = overviewModel(document, labels, nowSeconds);
269
256
  return {
270
257
  entries,
271
258
  selectableKeys: entries.map((entry) => entry.key),
@@ -161,9 +161,9 @@ export declare function headerState(document: TicketDetailDocument): string;
161
161
  * it is optional so every pre-existing caller and fixture is unchanged, and the
162
162
  * kernel passes the real clock.
163
163
  */
164
- export declare function detailSections(document: TicketDetailDocument, labels?: AssignmentLabels, nowSeconds?: number, baseUrl?: string): Section[];
164
+ export declare function detailSections(document: TicketDetailDocument, labels?: AssignmentLabels, nowSeconds?: number): Section[];
165
165
  /** The detailSections that belong to a given (non-comments) tab, in tab order. */
166
- export declare function sectionsForTab(document: TicketDetailDocument, tabIndex: number, labels?: AssignmentLabels, nowSeconds?: number, baseUrl?: string): Section[];
166
+ export declare function sectionsForTab(document: TicketDetailDocument, tabIndex: number, labels?: AssignmentLabels, nowSeconds?: number): Section[];
167
167
  /**
168
168
  * One item per comment for the collapsible Comments tab: type, author, created
169
169
  * (raw ISO — the plugin formats the relative age), the body RENDERED into
@@ -14,7 +14,6 @@ import { asString, formatDuration } from '../../../../lib/format.js';
14
14
  import { columnNode, DEFAULT_FOREGROUND, FOREGROUND_HIGHLIGHT, textNode, } from '../../../../lib/vnode.js';
15
15
  import { listRowIds, listTableRows, listTableTree, } from '../../../collection.js';
16
16
  import { TICKET_RUN_TABLE, ticketRunRows } from '../../../run/Data/runs.js';
17
- import { ticketUrl } from '../../Data/url.js';
18
17
  import { commentRows } from '../comment-item/index.js';
19
18
  import { TICKET_SECTIONS } from '../sections/index.js';
20
19
  /** Inner header width at the documented 60-column terminal. */
@@ -83,9 +82,8 @@ export function handleTicketCopy(input, context, document) {
83
82
  return undefined;
84
83
  const attributes = document?.data?.attributes;
85
84
  const identifier = typeof attributes?.identifier === 'string' ? attributes.identifier : '';
86
- const id = document?.data?.id ?? context.params?.ticketId;
87
85
  return input === 'Y'
88
- ? copyThrough(context.copyToClipboard, ticketUrl(context.services?.baseUrl, id), `the link to ${identifier}`, `no link to ${identifier} · this session has no base URL`)
86
+ ? copyThrough(context.copyToClipboard, asString(attributes?.url), `the link to ${identifier}`, `no link to ${identifier} · the server sent no URL`)
89
87
  : copyThrough(context.copyToClipboard, identifier, identifier, 'nothing to copy');
90
88
  }
91
89
  export function ticketEditAction(context, document) {
@@ -177,11 +175,11 @@ function pendingReviewResources(document) {
177
175
  .filter((r) => r.type === 'bb_comment--review' && linked.has(r.id ?? ''))
178
176
  .sort(compareCommentsNewestFirst);
179
177
  }
180
- function pendingReviewLines(document, baseUrl) {
178
+ function pendingReviewLines(document) {
181
179
  const pending = pendingReviewResources(document);
182
180
  if (!pending.length)
183
181
  return [];
184
- const web = ticketUrl(baseUrl, document.data?.id);
182
+ const web = asString(document.data?.attributes?.url);
185
183
  return [
186
184
  `${pending.length} review${pending.length === 1 ? '' : 's'} awaiting acceptance`,
187
185
  ...pending.map((r) => {
@@ -664,7 +662,7 @@ function timeLines(a) {
664
662
  * it is optional so every pre-existing caller and fixture is unchanged, and the
665
663
  * kernel passes the real clock.
666
664
  */
667
- export function detailSections(document, labels, nowSeconds = 0, baseUrl) {
665
+ export function detailSections(document, labels, nowSeconds = 0) {
668
666
  const a = document.data?.attributes ?? {};
669
667
  const sections = [];
670
668
  // BB-369 D1/D7: `State` LEADS, and no tab lists it — the same arrangement
@@ -728,7 +726,7 @@ export function detailSections(document, labels, nowSeconds = 0, baseUrl) {
728
726
  heading: 'Assignment',
729
727
  lines: assignmentLines(document, labels),
730
728
  });
731
- const pendingLines = pendingReviewLines(document, baseUrl);
729
+ const pendingLines = pendingReviewLines(document);
732
730
  if (pendingLines.length) {
733
731
  sections.push({ heading: 'Pending reviews', lines: pendingLines });
734
732
  }
@@ -800,15 +798,12 @@ export function detailSections(document, labels, nowSeconds = 0, baseUrl) {
800
798
  return sections;
801
799
  }
802
800
  /** The detailSections that belong to a given (non-comments) tab, in tab order. */
803
- export function sectionsForTab(document, tabIndex, labels, nowSeconds = 0, baseUrl) {
801
+ export function sectionsForTab(document, tabIndex, labels, nowSeconds = 0) {
804
802
  const tab = TICKET_SECTIONS[tabIndex];
805
803
  const headings = tab?.headings ?? [];
806
804
  if (!headings.length)
807
805
  return [];
808
- const byHeading = new Map(detailSections(document, labels, nowSeconds, baseUrl).map((s) => [
809
- s.heading,
810
- s,
811
- ]));
806
+ const byHeading = new Map(detailSections(document, labels, nowSeconds).map((s) => [s.heading, s]));
812
807
  return headings
813
808
  .map((h) => byHeading.get(h))
814
809
  .filter((s) => s !== undefined);
@@ -27,6 +27,8 @@ export interface TicketRow {
27
27
  frozen: boolean;
28
28
  /** Why the ticket is standing still: frozen|blocked|no conductor|failing, else ''. */
29
29
  stallReason: string;
30
+ /** The ticket's web URL as the server serves it; the client never builds it. */
31
+ url?: string | undefined;
30
32
  }
31
33
  /** A `(id) → resource` lookup over a document's sideloaded `included` entries.
32
34
  * JSON:API ids are UUIDs (unique across bundles), so id alone keys uniquely. */
@@ -299,7 +301,7 @@ export declare const CONDUCTOR_TICKET_TABLE: {
299
301
  * down to the bytes on the wire. Column order would emit `title` last (it rides
300
302
  * the trailing TITLE column) instead of second.
301
303
  */
302
- export declare const TICKET_LIST_ATTRIBUTES: readonly ["identifier", "title", "state", "priority", "assignee_initials", "owner_initials", "derived_status", "stall_reason", "workflow", "closed", "frozen"];
304
+ export declare const TICKET_LIST_ATTRIBUTES: readonly ["identifier", "title", "state", "priority", "assignee_initials", "owner_initials", "derived_status", "stall_reason", "workflow", "closed", "frozen", "url"];
303
305
  /** What `addFields('bb_ticket--bb_ticket', …)` takes. */
304
306
  export declare const TICKET_LIST_FIELDS: string[];
305
307
  /** The sideloaded conductor renders one column: its label. */
@@ -49,15 +49,20 @@ export const TICKET_LIST_RELATIONSHIPS = [
49
49
  ];
50
50
  /**
51
51
  * Requested but rendered by NO column: `workflow` feeds `TicketRow.type` (the
52
- * row's workflow mapping, kept after BB-299 dropped the type filter) and
53
- * `closed` the closed predicate, so they are required and cannot be derived
54
- * from the column set.
52
+ * row's workflow mapping, kept after BB-299 dropped the type filter),
53
+ * `closed` the closed predicate and `url` the `Y` copy, so they are required
54
+ * and cannot be derived from the column set.
55
55
  *
56
56
  * This is the declared half of BB-294's fieldset rule: the fieldset is the
57
57
  * columns' union PLUS this list, and this list is an explicit declaration rather
58
58
  * than an unstated remainder.
59
59
  */
60
- const TICKET_PREDICATE_ATTRIBUTES = ['workflow', 'closed', 'frozen'];
60
+ const TICKET_PREDICATE_ATTRIBUTES = [
61
+ 'workflow',
62
+ 'closed',
63
+ 'frozen',
64
+ 'url',
65
+ ];
61
66
  /**
62
67
  * The ticket list's columns — the header, the width, the cell value AND the
63
68
  * fieldset entry of each, in ONE declaration (BB-294 AC 4).
@@ -228,6 +233,7 @@ export const TICKET_LIST_ATTRIBUTES = [
228
233
  'workflow',
229
234
  'closed',
230
235
  'frozen',
236
+ 'url',
231
237
  ];
232
238
  /** What `addFields('bb_ticket--bb_ticket', …)` takes. */
233
239
  export const TICKET_LIST_FIELDS = [
@@ -280,6 +286,7 @@ export function mapTicketData(item, included) {
280
286
  projectId: singleRelId(rel('project_id')),
281
287
  closed: typeof raw('closed') === 'boolean' ? raw('closed') : false,
282
288
  frozen: typeof raw('frozen') === 'boolean' ? raw('frozen') : false,
289
+ url: str('url'),
283
290
  };
284
291
  }
285
292
  /**
@@ -491,7 +491,7 @@ export class TicketContentScreen extends AsyncScreen {
491
491
  memo.labels === this.labels &&
492
492
  memo.now === now)
493
493
  return memo.model;
494
- const model = ticketContentModel(document, this.tab, this.labels, now, context.services?.baseUrl);
494
+ const model = ticketContentModel(document, this.tab, this.labels, now);
495
495
  this.modelMemo = { document, labels: this.labels, now, model };
496
496
  return model;
497
497
  }
@@ -44,8 +44,8 @@ export class TicketDetailScreen extends TicketContentScreen {
44
44
  fullNonInteractive(document, context) {
45
45
  const nowSeconds = context.nowSeconds?.() ?? Math.floor(Date.now() / 1000);
46
46
  return flattenSections([
47
- ...detailSections(document, this.labels, nowSeconds, context.services?.baseUrl).filter((section) => section.heading === 'State' || section.heading === 'Labels'),
48
- ...sectionsForTab(document, 0, this.labels, nowSeconds, context.services?.baseUrl),
47
+ ...detailSections(document, this.labels, nowSeconds).filter((section) => section.heading === 'State' || section.heading === 'Labels'),
48
+ ...sectionsForTab(document, 0, this.labels, nowSeconds),
49
49
  ]).lines;
50
50
  }
51
51
  }
@@ -6,7 +6,6 @@ import { resolveWhoCandidate } from '../../user/Data/users.js';
6
6
  import { loadTicketDetail } from '../Data/detail.js';
7
7
  import { CLOSED_FILTER_VALUES, cycleValue, DEFAULT_TICKET_CRITERIA, STATE_FILTER_VALUES, } from '../Data/query.js';
8
8
  import { countTicketsIgnoringClosed, loadFilteredTickets, mapTicketDocument, TICKET_TABLE, } from '../Data/tickets.js';
9
- import { ticketUrl } from '../Data/url.js';
10
9
  import { TicketFilterBar } from './ticket-filter-bar.js';
11
10
  import { TicketSearch } from './ticket-search.js';
12
11
  export class TicketsScreen extends ListScreen {
@@ -352,7 +351,7 @@ export class TicketsScreen extends ListScreen {
352
351
  if (!row)
353
352
  return 'nothing to copy';
354
353
  return link
355
- ? copyThrough(context.copyToClipboard, ticketUrl(context.services?.baseUrl, row.id), `the link to ${row.identifier}`, `no link to ${row.identifier} · this session has no base URL`)
354
+ ? copyThrough(context.copyToClipboard, row.url, `the link to ${row.identifier}`, `no link to ${row.identifier} · the server sent no URL`)
356
355
  : copyThrough(context.copyToClipboard, row.identifier, row.identifier, 'nothing to copy');
357
356
  }
358
357
  renderLoading() {
@@ -0,0 +1,13 @@
1
+ import type { TicketDetailDocument } from '../types.js';
2
+ import { type StyledRun } from './vnode.js';
3
+ /** `* <href>`; only http(s) gets an OSC 8 target, as in `hyperlink.ts`. */
4
+ export declare const linkRuns: (href: string) => StyledRun[];
5
+ /** One link shown at the top of the ticket and run detail. */
6
+ export interface TopLink {
7
+ readonly key: string;
8
+ readonly href: string;
9
+ readonly pullRequest: boolean;
10
+ }
11
+ export declare function isPullRequest(title: string, url: string): boolean;
12
+ /** The served ticket URL first (when present), then PR/MR links, then the rest in stored order. */
13
+ export declare function ticketTopLinks(document: TicketDetailDocument): TopLink[];
@@ -0,0 +1,51 @@
1
+ import { plainRun } from './vnode.js';
2
+ /** `* <href>`; only http(s) gets an OSC 8 target, as in `hyperlink.ts`. */
3
+ export const linkRuns = (href) => [
4
+ plainRun('* '),
5
+ /^https?:\/\//.test(href)
6
+ ? { ...plainRun(href), link: href }
7
+ : plainRun(href),
8
+ ];
9
+ const PR_URL = /\/pull\/\d+(?:[/?#]|$)/;
10
+ const MR_URL = /\/merge_requests\/\d+(?:[/?#]|$)/;
11
+ export function isPullRequest(title, url) {
12
+ return (PR_URL.test(url) ||
13
+ MR_URL.test(url) ||
14
+ /^(PR|MR)\b|pull request|merge request/i.test(title));
15
+ }
16
+ /** The served ticket URL first (when present), then PR/MR links, then the rest in stored order. */
17
+ export function ticketTopLinks(document) {
18
+ const attributes = document.data?.attributes ?? {};
19
+ const stored = Array.isArray(attributes.links)
20
+ ? attributes.links
21
+ : [];
22
+ const links = stored.flatMap((item) => {
23
+ const link = item;
24
+ const href = link.uri ?? link.url;
25
+ if (typeof href !== 'string' || href === '')
26
+ return [];
27
+ const title = typeof link.title === 'string' ? link.title.trim() : '';
28
+ return [
29
+ {
30
+ key: title === '' ? 'link' : title,
31
+ href,
32
+ pullRequest: isPullRequest(title, href),
33
+ },
34
+ ];
35
+ });
36
+ const ordered = [
37
+ ...links.filter((link) => link.pullRequest),
38
+ ...links.filter((link) => !link.pullRequest),
39
+ ];
40
+ const href = attributes.url;
41
+ if (typeof href !== 'string' || href === '')
42
+ return ordered;
43
+ return [
44
+ {
45
+ key: 'ticket',
46
+ href,
47
+ pullRequest: false,
48
+ },
49
+ ...ordered,
50
+ ];
51
+ }
@@ -52,6 +52,8 @@ export interface StyledRun {
52
52
  readonly text: string;
53
53
  readonly attributes: number;
54
54
  readonly fg?: RGBA;
55
+ /** An OSC 8 target for the run; only {@link paragraphNode} writes it. */
56
+ readonly link?: string;
55
57
  }
56
58
  /**
57
59
  * ONE PHYSICAL ROW that carries per-run styling — BB-372 D11.
@@ -259,7 +261,7 @@ export interface ParagraphInput {
259
261
  readonly fg: RGBA;
260
262
  readonly attributes?: number;
261
263
  readonly width?: number | `${number}%` | 'auto';
262
- readonly wrapMode?: 'word' | 'none';
264
+ readonly wrapMode?: 'word' | 'char' | 'none';
263
265
  readonly flexGrow?: number;
264
266
  readonly flexShrink?: number;
265
267
  readonly onMouseDown?: (() => void) | undefined;
@@ -506,7 +506,7 @@ const PARAGRAPH_CACHE_LIMIT = 4096;
506
506
  const colourKey = (fg) => fg === undefined ? '' : String(fg.buffer);
507
507
  const styledRuns = (id, runs) => {
508
508
  const key = runs
509
- .map((run) => `${run.attributes}\u0001${colourKey(run.fg)}\u0001${run.text}`)
509
+ .map((run) => `${run.attributes}\u0001${colourKey(run.fg)}\u0001${run.link ?? ''}\u0001${run.text}`)
510
510
  .join('\u0002');
511
511
  const cached = paragraphContent.get(id);
512
512
  if (cached?.key === key)
@@ -518,6 +518,7 @@ const styledRuns = (id, runs) => {
518
518
  text: run.text,
519
519
  attributes: run.attributes,
520
520
  ...(run.fg === undefined ? {} : { fg: run.fg }),
521
+ ...(run.link === undefined ? {} : { link: { url: run.link } }),
521
522
  })));
522
523
  paragraphContent.set(id, { key, text });
523
524
  return text;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bakers-build/addon-bakers-ui",
3
- "version": "0.12.1-next.4",
3
+ "version": "0.12.1-next.5",
4
4
  "description": "bakers.build TUI: interactive terminal UI (dashboard, projects, tickets) as a dropsh `tui` renderer plugin.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -32,11 +32,11 @@
32
32
  "zustand": "^5.0.15"
33
33
  },
34
34
  "peerDependencies": {
35
- "@bakers-build/core": "^0.12.1-next.4",
36
- "@bakers-build/message": "^0.12.1-next.4"
35
+ "@bakers-build/core": "^0.12.1-next.5",
36
+ "@bakers-build/message": "^0.12.1-next.5"
37
37
  },
38
38
  "bakersBuild": {
39
- "commit": "d62bf7554e5c69de87a474b8d11e3fc7f83f3512",
39
+ "commit": "4c5079384a3a8f725a85393d8bb68f05b5e7f8f8",
40
40
  "channel": "next"
41
41
  }
42
42
  }
@@ -1,16 +0,0 @@
1
- /**
2
- * BB-326 — a ticket's own page on the connected control plane.
3
- *
4
- * `/admin/bakers/ticket/{bb_ticket}` is the entity's canonical link template
5
- * (`web/modules/custom/bb_core/src/Entity/BbTicket.php`). The slot normally
6
- * takes the integer entity id, and the TUI has never seen one: every id it
7
- * holds is JSON:API's resource id, i.e. the UUID. That path still resolves
8
- * because `BbEntityUuidConverter` is attached to the route — the converter
9
- * exists for exactly this, "JSON:API and the bakers skill address entities by
10
- * UUID, so every UUID-based canonical link is dead" without it.
11
- *
12
- * Built here rather than read off the document: JSON:API's `links.self` names
13
- * the API resource (`/jsonapi/bb_ticket/bb_ticket/<uuid>`), which is not
14
- * something an operator wants to open on a phone.
15
- */
16
- export declare function ticketUrl(baseUrl: string | undefined, ticketId: string | undefined): string | undefined;
@@ -1,20 +0,0 @@
1
- /**
2
- * BB-326 — a ticket's own page on the connected control plane.
3
- *
4
- * `/admin/bakers/ticket/{bb_ticket}` is the entity's canonical link template
5
- * (`web/modules/custom/bb_core/src/Entity/BbTicket.php`). The slot normally
6
- * takes the integer entity id, and the TUI has never seen one: every id it
7
- * holds is JSON:API's resource id, i.e. the UUID. That path still resolves
8
- * because `BbEntityUuidConverter` is attached to the route — the converter
9
- * exists for exactly this, "JSON:API and the bakers skill address entities by
10
- * UUID, so every UUID-based canonical link is dead" without it.
11
- *
12
- * Built here rather than read off the document: JSON:API's `links.self` names
13
- * the API resource (`/jsonapi/bb_ticket/bb_ticket/<uuid>`), which is not
14
- * something an operator wants to open on a phone.
15
- */
16
- export function ticketUrl(baseUrl, ticketId) {
17
- if (!baseUrl || !ticketId)
18
- return undefined;
19
- return `${baseUrl.replace(/\/+$/, '')}/admin/bakers/ticket/${ticketId}`;
20
- }