The AI-native screen recorder. Record your screen and talk; the people you share it with and your AI agents both get it.
Rust agent-readableai-agentsarecclaude-codecodexcursorlocal-firstmacosprivacyrustscreen-recorderscreen-recordingtauritranscriptiontypescriptwindows
/**
* The meeting notes as the viewer shows them: the Markdown the model wrote,
* split into headings, list items and paragraphs. Which lines are action
* items, and their order, comes from Rust (`noteLines`, from `notes::parse`
* in `crates/clipy-local-meetings`), so the checkbox the user ticks is always
* the one `set_meeting_action_done` changes. This file only finds each
* Markdown line's place in that list, by its text, in order.
*/
import type { MeetingNoteLineDto } from "./bridge";
export type NotesBlock =
| { kind: "section"; text: string }
| { kind: "topic"; text: string }
| {
kind: "item" | "paragraph";
text: string;
/** Index into `noteLines`, or null when the line is not one of them. */
line: number | null;
/** Its index among action items, when Rust says it is one. */
action: number | null;
done: boolean;
};
// The `s` flag on the patterns below: without it `.` stops at U+2028 and
// U+2029, which JavaScript counts as line ends but Rust's `lines()` does not,
// so an item holding one lost its checkbox (#913).
/** The same list markers as `bullet` in notes.rs: "- ", "* ", "• ", "1. ". */
function bulletText(line: string): string | null {
const match = /^(?:[-*•] |\d+\. )(.*)$/s.exec(line.trimStart());
return match ? match[1].trim() : null;
}
/** The same checkboxes as `strip_checkbox` in notes.rs. */
function withoutCheckbox(text: string): string {
const match = /^\[[ xX]\] (.*)$/s.exec(text);
return match ? match[1].trim() : text;
}
export function notesBlocks(markdown: string, noteLines: readonly MeetingNoteLineDto[]): NotesBlock[] {
const blocks: NotesBlock[] = [];
let next = 0;
for (const raw of markdown.split("\n")) {
const line = raw.trim();
if (!line) continue;
if (line.startsWith("## ")) {
blocks.push({ kind: "section", text: line.slice(3).trim() });
continue;
}
if (line.startsWith("### ")) {
blocks.push({ kind: "topic", text: line.slice(4).trim() });
continue;
}
if (line.startsWith("#")) continue;
const bullet = bulletText(line);
const text = withoutCheckbox(bullet ?? line);
const kind = bullet === null ? "paragraph" : "item";
let index: number | null = null;
for (let i = next; i < noteLines.length; i++) {
if (noteLines[i].text === text) {
index = i;
next = i + 1;
break;
}
}
const found = index === null ? null : noteLines[index];
blocks.push({ kind, text, line: index, action: found?.action ?? null, done: found?.done ?? false });
}
return blocks;
}
/** `**bold**` spans, the one inline style the notes use. */
export function boldSpans(text: string): { text: string; bold: boolean }[] {
const parts = text.split("**");
// An odd count means every ** was paired.
if (parts.length % 2 === 0) return [{ text, bold: false }];
const out: { text: string; bold: boolean }[] = [];
parts.forEach((part, index) => {
if (part) out.push({ text: part, bold: index % 2 === 1 });
});
return out;
}
const SPEAKER_COLOURS = ["#2563eb", "#b45309", "#7c3aed", "#0f766e", "#be185d", "#4d7c0f", "#c2410c", "#0369a1"];
/** A stable colour per speaker id: "you" first, then p1, p2... in order. */
export function speakerColour(id: string): string {
if (id === "you") return "#15803d";
if (id === "others") return "#6b7280";
const n = Number.parseInt(id.replace(/^p/, ""), 10);
if (Number.isFinite(n) && n > 0) return SPEAKER_COLOURS[(n - 1) % SPEAKER_COLOURS.length];
let hash = 0;
for (const ch of id) hash = (hash * 31 + ch.charCodeAt(0)) >>> 0;
return SPEAKER_COLOURS[hash % SPEAKER_COLOURS.length];
}