tickets
All repositories: gitoria
6.1 KB
// lib/mdview.hl — THE MARKDOWN READ VIEW FOR LLM READERS (ticket #6, mission 014; CONCEPT.md "Data// formats": a Markdown read view for LLM readers). The ticket GET endpoints answer// `Accept: text/markdown` with a compact Markdown document instead of JSON (lib/api-helpers.hl// `wantsMarkdown`, `markdownReply`); JSON stays the default and is unchanged. Statics only.//// one ticket → # <project> #<n>: <subject>// state · opened (by) · updated · formerly · URL// the summary as written (it IS Markdown)// ## History — one `### <seq> · <when> · <author> <what>` per event, its text below// a list → # Tickets (<filters>): <count>// one line per ticket: `- <project> #<n> [<state>] <subject> · updated <when> · <url>`// Texts are embedded as written (they are Markdown already), so a text's own headings sit// inside the document — readers should take the `### <seq> ·` lines as the event boundaries.import { publicUrl } from './users.hl'static NL = ""// one line: line breaks and runs of spaces become one spacestatic oneLine = (s) => {if (s == null) { return '' }parts = []for (w of ('' + s).replaceAll(NL, ' ').split(' ')) { if (w != '') { parts.push(w) } }return parts.join(' ')}// `> ` in front of every line (a previous summary inside an edit event)static quoted = (s) => {out = []for (l of ('' + s).split(NL)) { out.push(l == '' ? '>' : '> ' + l) }return out.join(NL)}static ticketLine = (row) => {return '- ' + row.project + ' ' + row.ref + ' [' + row.state + '] ' + oneLine(row.subject) + ' · updated ' + row.updated + ' · ' + publicUrl + row.href + relationTail(row)}// ---- relations (ticket #4, mission 017) --------------------------------------------------------// one ticket's document gets "Parent:", "Children (k of n done):", "Blocked by:", "Blocks:"// blocks under its URL; a list line gets ` · parent … · children n, k done · blocked by … · blocks …`static refName = (r) => { return r.project + ' ' + r.ref }static refLine = (r) => { return '- ' + refName(r) + ' [' + r.state + '] ' + oneLine(r.subject) + ' · ' + publicUrl + r.href }static confirmedOf = (refs) => {let n = 0for (r of refs) { if (r.state == 'done') { n = n + 1 } }return n}static relationTail = (row) => {parts = []if (row.parent != null) { parts.push('parent ' + refName(row.parent)) }total = row.children.lengthif (total > 0) { parts.push('children ' + total + (row.allChildrenConfirmed ? ', all done' : ', ' + confirmedOf(row.children) + ' done')) }if (row.blockedBy.length > 0) {bs = []for (r of row.blockedBy) { bs.push(refName(r) + ' [' + r.state + ']') }parts.push('blocked by ' + bs.join(', '))}if (row.blocks.length > 0) {bs = []for (r of row.blocks) { bs.push(refName(r)) }parts.push('blocks ' + bs.join(', '))}return parts.length == 0 ? '' : ' · ' + parts.join(' · ')}static relationLines = (t) => {lines = []if (t.parent != null) {lines.push('')lines.push('Parent: ' + refName(t.parent) + ' [' + t.parent.state + '] ' + oneLine(t.parent.subject) + ' · ' + publicUrl + t.parent.href)}total = t.children.lengthif (total > 0) {lines.push('')lines.push('Children (' + (t.allChildrenConfirmed ? 'all ' + total + ' done' : confirmedOf(t.children) + ' of ' + total + ' done') + '):')for (r of t.children) { lines.push(refLine(r)) }}if (t.blockedBy.length > 0) {lines.push('')lines.push('Blocked by:')for (r of t.blockedBy) { lines.push(refLine(r)) }}if (t.blocks.length > 0) {lines.push('')lines.push('Blocks:')for (r of t.blocks) { lines.push(refLine(r)) }}return lines}// a list: { tickets } (rows, as the JSON answer) + a label of its filters ('' = all)static listDocument = (rows, filters) => {lines = []lines.push('# Tickets' + (filters != '' ? ' (' + filters + ')' : '') + ': ' + rows.length)lines.push('')for (r of rows) { lines.push(ticketLine(r)) }return lines.join(NL) + NL}static eventHeadline = (e) => {let what = e.labelif (e.kind == 'state') { what = 'changed the state: ' + (e.from != '' ? e.from : '?') + ' → ' + e.to }// mission 016: an edited comment shows its newest text, the headline says since when (a deleted one: its label)if (e.edited == true) { what = 'commented (edited ' + e.editedWhen + ')' }if (e.kind == 'edit') {parts = []if (e.subjectChanged) { parts.push('subject') }if (e.summaryChanged) { parts.push('summary') }what = 'edited the ' + parts.join(' and ')}return '### ' + e.seq + ' · ' + e.when + ' · ' + oneLine(e.author) + ' ' + what}// one ticket: { ticket (row), events (rows, oldest first) } as the JSON answerstatic ticketDocument = (data) => {t = data.ticketlet opener = ''for (e of data.events) { if (e.kind == 'created' && opener == '') { opener = oneLine(e.author) } }lines = []lines.push('# ' + t.project + ' ' + t.ref + ': ' + oneLine(t.subject))lines.push('')let meta = 'state: ' + t.state + ' · opened ' + t.created + (opener != '' ? ' by ' + opener : '') + ' · updated ' + t.updatedif (t.hasOld) { meta = meta + ' · formerly ' + t.oldRef }lines.push(meta)lines.push(publicUrl + t.href)for (l of relationLines(t)) { lines.push(l) }lines.push('')lines.push(t.summary != '' ? t.summary : '(no summary)')lines.push('')lines.push('## History')for (e of data.events) {lines.push('')lines.push(eventHeadline(e))if (e.kind == 'edit') {if (e.subjectChanged) {lines.push('')lines.push('Subject before: ' + oneLine(e.oldSubject))}if (e.summaryChanged) {lines.push('')lines.push('Summary before:')lines.push('')lines.push(e.oldSummary != '' ? quoted(e.oldSummary) : '> (empty)')}}if (e.hasText) {lines.push('')lines.push(e.text)}// tickets#27: a comment's files, one line each (the address needs a member's login or token)if (e.attachments != null) {lines.push('')lines.push('Attachments:')for (a of e.attachments) { lines.push('- [' + oneLine(a.name).replaceAll('[', '(').replaceAll(']', ')') + '](' + publicUrl + a.url + ') · ' + a.type + ' · ' + a.size + ' bytes') }}}return lines.join(NL) + NL}
Branches
Latest commits
- 18d2df60md-editor.hl: verbatim copy of components f3-mdvalue (an outside value change is shown by the editor)mre
- f6764bedreports/H1-hydrate.mdmre
- 1bbbf0edtests/browser.mjs: wait for hydration before clicking the login button on / (device B)mre
- 6f503cfctests/cdp.mjs: HL_CPU_THROTTLE=<rate> optional CPU throttling for gate runsmre
- e17e2855re-vendor Hybriel 5406d146 (hl:web batches 9+10: #72 emits while the socket is closed delivered after reconnect, browser boot linear, faster list appends; contains int 6–14 + m406)mre
- a6ddccd2re-vendor Hybriel 6f8a0689 (int 6–11: streaming cursors, #203 index heal + close() fix, fd403 listDir/cursor fds, hl:time browser side, hl:web batches 5+6)mre
- 81e036b7docker-compose: nofile 65536 (Hybriel int 6+ boot opened >1024 files in the tracker)mre
- 5d8d2cf6deploy: backup copies index files first and *.mpack data last (hot-copy skew, hybriel #203)mre
- 58e8c02cmission 024: report, LOG, STATUS, e2e fixmre
- 50778073tests/e2e-route-marker.mjs: first paint marker, comments post/edit redrawmre
- c5203298mission 024: MainMenu marks the page from the route (layouts 0bcc629 main-menu.hl); browser-side marker removed; gate: marker in the server HTMLmre
- b1a4c270re-vendor Hybriel master f9614007: bin/ (git-ignored) and plugins wholemre
- 866397a0mission 023: theme from layouts 76f99f6 (current marker, menu count badge), components from 3794c59 (MdEditor keys); Inbox count as badge, current by address; gates and E2E; reportmre
- 7ed2e5e5deploy.sh: a gate without a 'passed,' line (check-theme) no longer ends the script silently (grep under pipefail), as gitoria/layoutsmre
- bf9064a3mission 022: tickets on the layouts theme (step 1): shell, styles, gates, audit, E2E; reportmre
- f3d61711mission 022 WIP: tickets on the layouts theme (dbe3de7): AppHeader/MainMenu/UserMenu/Sidebar/ContentFirst shell, styles reduced to the app's own, check-theme in the gates, 390 audit + real-Chrome walk scriptmre
- 31cabfccmission 021: E2E script, report, LOG, STATUSmre
- 6aea8683editor look: .empty rule only for p.empty, files off where tickets has no upload, state note one line, events test scrolls the editor into view; synced md-editor (components d702d76+6f27ad3); gate 377/0, events 52/0mre
- dce6ffa6Merge branch 'w28-deflake'mre
- 536092a1tickets (mission 019): de-flake the m016 comment clicks (B: unliked) — calmClick waits until the button stops moving; test only, no app changemre