Merge branch 'calculator' of https://github.com/kalanihelekunihi/faceclaw into calculator

This commit is contained in:
James Babcock committed 2026-08-26 00:49:20 -07:00
commit f3ad55ca3d
126 files changed
+22253 -58

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
import { NavigatedData, Page } from "@nativescript/core";
import { AskViewModel } from "./ask-view-model";
export function navigatingTo(args: NavigatedData): void {
const page = args.object as Page;
if (!page.bindingContext) {
page.bindingContext = new AskViewModel();
}
}
export function unloaded(args: NavigatedData): void {
const page = args.object as Page;
(page.bindingContext as AskViewModel | undefined)?.cancel();
}
+20
View File
@@ -0,0 +1,20 @@
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" unloaded="unloaded">
<ActionBar title="Ask about conversations" />
<GridLayout rows="auto,auto,auto,*" class="p-8">
<TextField
row="0"
hint="e.g. What did Alice say about the budget last week?"
text="{{ question }}"
returnKeyType="go"
returnPress="{{ onAskTap }}" />
<Button row="1" text="{{ askLabel }}" tap="{{ onAskTap }}" isEnabled="{{ askEnabled }}" class="m-t-4" />
<Label row="2" text="{{ statusText }}" class="conversation-meta m-t-4" textWrap="true" visibility="{{ statusVisibility }}" />
<ScrollView row="3" class="m-t-8">
<StackLayout>
<Label text="{{ answer }}" class="ask-answer" textWrap="true" visibility="{{ answerVisibility }}" />
<Label text="{{ contextNote }}" class="conversation-meta m-t-8" textWrap="true" visibility="{{ noteVisibility }}" />
</StackLayout>
</ScrollView>
</GridLayout>
</Page>
+84
View File
@@ -0,0 +1,84 @@
import { Observable } from "@nativescript/core";
import {
askConversations,
conversationQaAvailable,
} from "../apps/microphones/conversation-qa";
import type { LlmStreamHandle } from "../assistant/llm-protocol";
/**
* "Ask about conversations": free-form questions over the saved transcripts,
* speakers, tags, and metadata, answered entirely on-device by the local
* assistant model. The answer streams in as it generates.
*/
export class AskViewModel extends Observable {
private stream: LlmStreamHandle | null = null;
private busy = false;
constructor() {
super();
this.set("question", "");
this.set("answer", "");
this.set("contextNote", "");
this.set("askLabel", "Ask");
this.set("askEnabled", true);
this.set("answerVisibility", "collapsed");
this.set("noteVisibility", "collapsed");
if (!conversationQaAvailable()) {
this.set(
"statusText",
"The on-phone model isn't downloaded yet. Enable it on the glasses under Settings > Assistant, then come back — questions are answered entirely on-device.",
);
this.set("statusVisibility", "visible");
} else {
this.set("statusText", "");
this.set("statusVisibility", "collapsed");
}
}
onAskTap = (): void => {
const question = String(this.get("question") ?? "").trim();
if (!question || this.busy) return;
this.cancel();
this.busy = true;
this.set("askLabel", "Thinking...");
this.set("askEnabled", false);
this.set("answer", "");
this.set("answerVisibility", "collapsed");
this.set("noteVisibility", "collapsed");
this.set("statusText", "Reading your conversations...");
this.set("statusVisibility", "visible");
this.stream = askConversations(question, {
onDelta: (textSoFar) => {
this.set("answer", textSoFar);
this.set("answerVisibility", "visible");
this.set("statusVisibility", "collapsed");
},
onDone: (answer, contextNote) => {
this.finish();
this.set("answer", answer || "(no answer)");
this.set("answerVisibility", "visible");
this.set("contextNote", contextNote);
this.set("noteVisibility", "visible");
},
onError: (message) => {
this.finish();
this.set("statusText", message);
this.set("statusVisibility", "visible");
},
});
};
cancel(): void {
this.stream?.cancel();
this.stream = null;
if (this.busy) this.finish();
}
private finish(): void {
this.busy = false;
this.stream = null;
this.set("askLabel", "Ask");
this.set("askEnabled", true);
}
}
+100
View File
@@ -0,0 +1,100 @@
import { Utils } from "@nativescript/core";
import type { EmotionLabel, SentimentBucket } from "../apps/microphones/sentiment";
declare const com: any;
/**
* Shared plumbing for the conversation review pages: access to the Java
* conversation store, the row shapes it returns, and the small formatting/
* color helpers every page needs. Callers must guard store access with
* `global.isAndroid`.
*/
export type SessionSpeakerRef = { id: number; name: string; color: string };
export type SessionRow = {
id: number;
startedAt: number;
endedAt: number;
title: string;
audioPath: string;
audioCodec: string;
avgSentiment: number;
segmentCount: number;
speakers: SessionSpeakerRef[];
};
export type SegmentRow = {
id: number;
speakerId: number | null;
startedAt: number;
endedAt: number;
audioOffsetMs: number | null;
text: string;
lang: string;
translation: string;
translationLang: string;
sentiment: number;
emotion: string;
angle: number | null;
};
export function conversationStore(): any {
const context = Utils.android.getApplicationContext();
return com.faceclaw.app.FaceclawConversationStore.getInstance(context);
}
export const NO_CONVERSATIONS_MESSAGE =
"No conversations yet — enable Captions + Save captions in the Microphones app on the glasses.";
/** "Mar 4, 2026, 2:15 PM" in the phone's locale. */
export function formatDateTime(ms: number): string {
if (!Number.isFinite(ms) || ms <= 0) return "";
const date = new Date(ms);
return `${date.toLocaleDateString()} ${date.toLocaleTimeString([], { hour: "numeric", minute: "2-digit" })}`;
}
/** Time-of-day only, e.g. "2:15 PM" — used for per-line timestamps. */
export function formatTime(ms: number): string {
if (!Number.isFinite(ms) || ms <= 0) return "";
return new Date(ms).toLocaleTimeString([], { hour: "numeric", minute: "2-digit", second: "2-digit" });
}
/** mm:ss (hours spill into minutes: 90 min -> "90:00"). */
export function formatDuration(ms: number): string {
const totalSeconds = Math.max(0, Math.round(ms / 1000));
const minutes = Math.floor(totalSeconds / 60);
const seconds = totalSeconds % 60;
return `${minutes}:${seconds < 10 ? "0" : ""}${seconds}`;
}
export const SENTIMENT_BUCKET_COLORS: Record<SentimentBucket, string> = {
veryPositive: "#2E7D32",
positive: "#66BB6A",
neutral: "#9E9E9E",
negative: "#EF6C00",
veryNegative: "#C62828",
};
export const EMOTION_COLORS: Record<EmotionLabel, string> = {
happy: "#81C784",
excited: "#AED581",
calm: "#4DB6AC",
relieved: "#66BB6A",
confident: "#4FC3F7",
surprised: "#BA68C8",
confused: "#FFB74D",
bored: "#90A4AE",
anxious: "#FFA726",
embarrassed: "#F06292",
frustrated: "#FF8A65",
sad: "#7986CB",
angry: "#E57373",
disgusted: "#A1887F",
neutral: "#BDBDBD",
};
export function emotionColor(emotion: string): string {
return EMOTION_COLORS[emotion as EmotionLabel] ?? EMOTION_COLORS.neutral;
}
+24
View File
@@ -0,0 +1,24 @@
import { EventData, NavigatedData, Page } from "@nativescript/core";
import { ConversationViewModel } from "./conversation-view-model";
type ConversationContext = { sessionId?: number } | undefined;
export function navigatingTo(args: NavigatedData): void {
const page = args.object as Page;
let model = page.bindingContext as ConversationViewModel | undefined;
if (!model) {
const context = args.context as ConversationContext;
model = new ConversationViewModel(context?.sessionId ?? 0);
page.bindingContext = model;
}
model.reload();
}
export function unloaded(args: EventData): void {
const page = args.object as Page;
const model = page.bindingContext as ConversationViewModel | undefined;
// The page has no forward navigation, so unloaded means it's going away:
// stop playback and release the MediaPlayer.
model?.dispose();
}
+49
View File
@@ -0,0 +1,49 @@
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" unloaded="unloaded">
<ActionBar title="{{ pageTitle }}">
<ActionItem text="Re-diarize" tap="{{ onRediarizeTap }}" android.position="popup" />
<ActionItem text="Split speaker..." tap="{{ onSplitSpeakerTap }}" android.position="popup" />
<ActionItem text="Delete conversation" tap="{{ onDeleteTap }}" android.position="popup" />
</ActionBar>
<GridLayout rows="auto,auto,auto,*" class="p-8">
<StackLayout row="0">
<Label text="{{ headerDate }}" class="conversation-meta" />
<Label text="{{ headerMeta }}" class="conversation-meta" textWrap="true" />
</StackLayout>
<Image row="1" src="{{ graphSource }}" height="120" stretch="fill" class="m-t-8" visibility="{{ graphVisibility }}" />
<Label row="2" text="{{ status }}" class="conversation-status m-t-4" textWrap="true" visibility="{{ statusVisibility }}" />
<ScrollView row="3" class="m-t-8">
<StackLayout>
<Label text="{{ emptyMessage }}" class="conversation-empty" textWrap="true" visibility="{{ emptyVisibility }}" />
<Repeater items="{{ transcriptRows }}">
<Repeater.itemsLayout>
<StackLayout />
</Repeater.itemsLayout>
<Repeater.itemTemplate>
<StackLayout class="{{ rowClass }}" tap="{{ onRowTap }}" longPress="{{ onRowLongPress }}">
<GridLayout columns="*,auto">
<Label col="0" textWrap="true">
<Label.formattedText>
<FormattedString>
<Span text="{{ speakerPrefix }}" color="{{ speakerColor }}" fontWeight="bold" />
<Span text="{{ text }}" />
</FormattedString>
</Label.formattedText>
</Label>
<Label col="1" text="{{ playIndicator }}" class="transcript-play" verticalAlignment="top" />
</GridLayout>
<Label text="{{ translation }}" class="transcript-translation" textWrap="true" visibility="{{ translationVisibility }}" />
<StackLayout orientation="horizontal" class="m-t-4">
<Label text="{{ timeLabel }}" class="transcript-time" />
<Label text="{{ emotionLabel }}" class="transcript-emotion m-l-6" backgroundColor="{{ emotionColor }}" visibility="{{ emotionVisibility }}" />
</StackLayout>
</StackLayout>
</Repeater.itemTemplate>
</Repeater>
</StackLayout>
</ScrollView>
</GridLayout>
</Page>
+159
View File
@@ -0,0 +1,159 @@
import { inferredEmotionFilter, type EmotionLabel } from "../apps/microphones/sentiment";
import { NON_WORD_RUN } from "../util/unicode-class";
/**
* Natural-language search parsing for the conversations list. The grammar is
* deliberately small and lossy-safe: recognized phrases become structured
* filters and are stripped from the query; everything left over is passed on
* as a plain text query.
*
* Recognized date phrases (case-insensitive):
* - "past/last N hours/days/weeks/months" (N as digits, "one".."twelve",
* "a"/"an", "couple (of)", "few"; N omitted means 1), with optional
* leading "in/over/during/from" and "the" -> sinceMs
* - "today", "this week", "this month" -> sinceMs at the period start
* - "yesterday" -> sinceMs/untilMs bracketing
* that day (untilMs is dropped when combined with an open-ended phrase)
*
* Emotion: `inferredEmotionFilter` over the date-stripped query; when it
* names exactly one emotion, that becomes the filter and the tokens that
* triggered it (checked as unigrams and bigrams, so "fed up" works) are
* stripped. When any filter was recognized, connective filler words
* ("conversations where the speaker was ...") are stripped too, so the
* residual text query is only the meaningful content words.
*/
export type ParsedConversationQuery = {
sinceMs: number | null;
untilMs: number | null;
emotion: EmotionLabel | null;
text: string;
};
const NUMBER_WORDS: Record<string, number> = {
a: 1,
an: 1,
one: 1,
two: 2,
three: 3,
four: 4,
five: 5,
six: 6,
seven: 7,
eight: 8,
nine: 9,
ten: 10,
eleven: 11,
twelve: 12,
couple: 2,
few: 3,
};
const UNIT_MS: Record<string, number> = {
hour: 3_600_000,
day: 86_400_000,
week: 7 * 86_400_000,
month: 30 * 86_400_000,
};
const RELATIVE_RANGE_PATTERN =
/\b(?:(?:in|over|during|from)\s+)?(?:the\s+)?(?:past|last)\s+(?:(\d+|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|couple(?:\s+of)?|few|a|an)\s+)?(hour|day|week|month)s?\b/g;
/**
* Filler words that carry no search content once the query has been
* understood as a filter request ("conversations where the speaker was
* angry"). Only stripped when an emotion or date filter matched, so ordinary
* text queries pass through untouched.
*/
const FILLER_WORDS = new Set<string>([
"conversations", "conversation", "chats", "chat", "sessions", "session",
"where", "when", "which", "who", "that", "whose",
"the", "a", "an", "was", "were", "is", "are", "be", "being", "been",
"speaker", "speakers", "someone", "anybody", "anyone", "people", "person",
"sounded", "sounds", "felt", "feels", "feeling", "seemed", "seems",
"show", "me", "find", "search", "list", "get", "all", "any",
"i", "we", "they", "he", "she", "it", "you",
"in", "of", "with", "about", "on", "at", "and", "or", "to",
"talked", "talking", "talks", "said", "saying",
]);
function parseCount(word: string | undefined): number {
if (!word) return 1;
const normalized = word.replace(/\s+of$/, "").trim();
if (/^\d+$/.test(normalized)) return Math.max(1, parseInt(normalized, 10));
return NUMBER_WORDS[normalized] ?? 1;
}
function startOfDay(nowMs: number): number {
const date = new Date(nowMs);
date.setHours(0, 0, 0, 0);
return date.getTime();
}
function tokenize(text: string): string[] {
return text.split(NON_WORD_RUN).filter((token) => token.length > 0);
}
export function parseConversationQuery(raw: string, nowMs: number = Date.now()): ParsedConversationQuery {
let working = raw.toLowerCase();
const sinceCandidates: number[] = [];
let untilMs: number | null = null;
let openEndedRange = false;
working = working.replace(RELATIVE_RANGE_PATTERN, (_match, count: string | undefined, unit: string) => {
sinceCandidates.push(nowMs - parseCount(count) * UNIT_MS[unit]!);
openEndedRange = true;
return " ";
});
if (/\byesterday\b/.test(working)) {
const todayStart = startOfDay(nowMs);
sinceCandidates.push(todayStart - UNIT_MS.day!);
untilMs = todayStart;
working = working.replace(/\byesterday\b/g, " ");
}
if (/\btoday\b/.test(working)) {
sinceCandidates.push(startOfDay(nowMs));
openEndedRange = true;
working = working.replace(/\btoday\b/g, " ");
}
if (/\bthis\s+week\b/.test(working)) {
const now = new Date(nowMs);
sinceCandidates.push(startOfDay(nowMs) - now.getDay() * UNIT_MS.day!);
openEndedRange = true;
working = working.replace(/\bthis\s+week\b/g, " ");
}
if (/\bthis\s+month\b/.test(working)) {
const now = new Date(nowMs);
sinceCandidates.push(new Date(now.getFullYear(), now.getMonth(), 1).getTime());
openEndedRange = true;
working = working.replace(/\bthis\s+month\b/g, " ");
}
// "yesterday" alone brackets that day, but combined with an open-ended
// phrase ("yesterday and the past week") the upper bound would silently
// hide results the other phrase asked for.
if (openEndedRange) untilMs = null;
const sinceMs = sinceCandidates.length > 0 ? Math.min(...sinceCandidates) : null;
const emotion = inferredEmotionFilter(working);
let tokens = tokenize(working);
if (emotion) {
const kept: string[] = [];
for (let i = 0; i < tokens.length; i++) {
if (i + 1 < tokens.length && inferredEmotionFilter(`${tokens[i]} ${tokens[i + 1]}`) === emotion) {
i++;
continue;
}
if (inferredEmotionFilter(tokens[i]!) === emotion) continue;
kept.push(tokens[i]!);
}
tokens = kept;
}
if (emotion || sinceMs !== null) {
tokens = tokens.filter((token) => !FILLER_WORDS.has(token));
}
return { sinceMs, untilMs, emotion, text: tokens.join(" ") };
}
+467
View File
@@ -0,0 +1,467 @@
import { Frame, ImageSource, Observable, Screen, Utils, action, confirm, fromObject } from "@nativescript/core";
import { rediarizeSession } from "../apps/microphones/rediarize";
import { summarize, type AnalyzedLine, type EmotionLabel } from "../apps/microphones/sentiment";
import { speakerRegistry } from "../apps/microphones/speakers";
import {
conversationStore,
emotionColor,
formatDateTime,
formatDuration,
formatTime,
type SegmentRow,
type SessionRow,
} from "./conversation-format";
declare const android: any;
/**
* One transcript line. Rows are Observables so playback highlighting can
* update just the affected rows instead of rebuilding the whole Repeater.
*/
export type TranscriptRow = Observable;
const UNKNOWN_SPEAKER_COLOR = "#90A4AE";
const GRAPH_HEIGHT_DIP = 120;
export class ConversationViewModel extends Observable {
private readonly sessionId: number;
private session: SessionRow | null = null;
private segments: SegmentRow[] = [];
private rows: TranscriptRow[] = [];
private player: any = null; // android.media.MediaPlayer
private activeRowIndex = -1;
private playing = false;
private rediarizeRunning = false;
private _pageTitle = "Conversation";
private _headerDate = "";
private _headerMeta = "";
private _status = "";
private _emptyMessage = "";
private _graphSource: ImageSource | null = null;
constructor(sessionId: number) {
super();
this.sessionId = sessionId;
}
// --- bound properties ------------------------------------------------------
get pageTitle(): string {
return this._pageTitle;
}
get headerDate(): string {
return this._headerDate;
}
get headerMeta(): string {
return this._headerMeta;
}
get status(): string {
return this._status;
}
set status(value: string) {
if (this._status !== value) {
this._status = value;
this.notifyPropertyChange("status", value);
this.notifyPropertyChange("statusVisibility", this.statusVisibility);
}
}
get statusVisibility(): "visible" | "collapse" {
return this._status ? "visible" : "collapse";
}
get emptyMessage(): string {
return this._emptyMessage;
}
get emptyVisibility(): "visible" | "collapse" {
return this._emptyMessage ? "visible" : "collapse";
}
get graphSource(): ImageSource | null {
return this._graphSource;
}
get graphVisibility(): "visible" | "collapse" {
return this._graphSource ? "visible" : "collapse";
}
get transcriptRows(): TranscriptRow[] {
return this.rows;
}
// --- lifecycle -------------------------------------------------------------
reload(): void {
if (!global.isAndroid) {
this._emptyMessage = "Conversation review is only available on Android.";
this.notifyPropertyChange("emptyMessage", this._emptyMessage);
this.notifyPropertyChange("emptyVisibility", this.emptyVisibility);
return;
}
this.stopPlaybackHighlight();
try {
const sessions = JSON.parse(String(conversationStore().querySessions("{}"))) as SessionRow[];
this.session = sessions.find((row) => row.id === this.sessionId) ?? null;
this.segments = JSON.parse(String(conversationStore().querySegments(this.sessionId))) as SegmentRow[];
} catch (error) {
console.error(`conversation load failed: ${String(error)}`);
this.session = null;
this.segments = [];
}
this.refreshHeader();
this.rebuildRows();
this.rebuildGraph();
}
/** Release the MediaPlayer when the page goes away. */
dispose(): void {
this.stopPlaybackHighlight();
if (this.player) {
try {
this.player.release();
} catch {
// already released
}
this.player = null;
}
}
// --- header / rows ---------------------------------------------------------
private refreshHeader(): void {
const session = this.session;
this._pageTitle = session?.title || (session ? formatDateTime(session.startedAt) : "Conversation");
this._headerDate = session ? formatDateTime(session.startedAt) : "";
if (session) {
const durationMs = session.endedAt > session.startedAt ? session.endedAt - session.startedAt : 0;
const speakerNames = (session.speakers ?? []).map((speaker) => speaker.name).join(", ");
const parts = [formatDuration(durationMs), `${session.segmentCount} lines`];
if (speakerNames) parts.push(speakerNames);
if (!session.audioPath) parts.push("no recording");
this._headerMeta = parts.join(" · ");
} else {
this._headerMeta = "";
}
this._emptyMessage = !session
? "This conversation is no longer in the store."
: this.segments.length === 0
? "No transcript lines were saved for this conversation."
: "";
this.notifyPropertyChange("pageTitle", this._pageTitle);
this.notifyPropertyChange("headerDate", this._headerDate);
this.notifyPropertyChange("headerMeta", this._headerMeta);
this.notifyPropertyChange("emptyMessage", this._emptyMessage);
this.notifyPropertyChange("emptyVisibility", this.emptyVisibility);
}
private rebuildRows(): void {
const speakerById = new Map<number, { name: string; color: string }>();
for (const speaker of this.session?.speakers ?? []) {
speakerById.set(speaker.id, speaker);
}
// Session speakers only cover voices heard in this session; a reassignment
// to a brand-new speaker still needs a name, so fall back to the registry.
for (const profile of speakerRegistry.all()) {
if (!speakerById.has(profile.id)) {
speakerById.set(profile.id, { name: profile.name, color: profile.color });
}
}
this.rows = this.segments.map((segment, index) => {
const speaker = segment.speakerId !== null ? speakerById.get(segment.speakerId) : undefined;
const emotion = (segment.emotion || "neutral") as string;
const row = fromObject({
speakerPrefix: `${speaker?.name ?? "Unknown"}: `,
speakerColor: speaker?.color || UNKNOWN_SPEAKER_COLOR,
text: segment.text ?? "",
translation: segment.translation ?? "",
translationVisibility: segment.translation ? "visible" : "collapse",
emotionLabel: emotion,
emotionColor: emotionColor(emotion),
emotionVisibility: emotion !== "neutral" ? "visible" : "collapse",
timeLabel: formatTime(segment.startedAt),
playIndicator: "",
rowClass: "transcript-row",
onRowTap: () => this.onRowTapped(index),
onRowLongPress: () => {
void this.onRowLongPressed(index);
},
});
return row;
});
this.notifyPropertyChange("transcriptRows", this.rows);
}
// --- sentiment graph -------------------------------------------------------
/**
* Renders the per-line sentiment trend into a Bitmap: a horizontal zero
* line, a polyline of scores over the conversation, and a dot per trend
* point colored by the dominant emotion of that stretch.
*/
private rebuildGraph(): void {
this._graphSource = null;
if (global.isAndroid && this.segments.length > 1) {
try {
this._graphSource = this.drawGraph();
} catch (error) {
console.error(`sentiment graph failed: ${String(error)}`);
}
}
this.notifyPropertyChange("graphSource", this._graphSource);
this.notifyPropertyChange("graphVisibility", this.graphVisibility);
}
private drawGraph(): ImageSource | null {
const lines: AnalyzedLine[] = this.segments.map((segment) => ({
score: segment.sentiment ?? 0,
emotion: (segment.emotion || "neutral") as EmotionLabel,
emotionConfidence: 1,
}));
const trend = summarize(lines).trend;
if (trend.length < 2) return null;
const scale = Screen.mainScreen.scale;
const width = Math.max(320, Math.round(Screen.mainScreen.widthDIPs * scale));
const height = Math.round(GRAPH_HEIGHT_DIP * scale);
const padding = Math.round(10 * scale);
const bitmap = android.graphics.Bitmap.createBitmap(width, height, android.graphics.Bitmap.Config.ARGB_8888);
const canvas = new android.graphics.Canvas(bitmap);
canvas.drawColor(android.graphics.Color.parseColor("#26909090"));
const xAt = (i: number): number => padding + (i / (trend.length - 1)) * (width - 2 * padding);
const yAt = (score: number): number => {
const clamped = Math.max(-1, Math.min(1, score));
return height / 2 - clamped * (height / 2 - padding);
};
const paint = new android.graphics.Paint(android.graphics.Paint.ANTI_ALIAS_FLAG);
// Zero line.
paint.setStyle(android.graphics.Paint.Style.STROKE);
paint.setStrokeWidth(1 * scale);
paint.setColor(android.graphics.Color.parseColor("#80909090"));
canvas.drawLine(padding, height / 2, width - padding, height / 2, paint);
// Score polyline.
const path = new android.graphics.Path();
path.moveTo(xAt(0), yAt(trend[0].score));
for (let i = 1; i < trend.length; i++) {
path.lineTo(xAt(i), yAt(trend[i].score));
}
paint.setStrokeWidth(2 * scale);
paint.setColor(android.graphics.Color.parseColor("#78909C"));
canvas.drawPath(path, paint);
// Emotion dots.
paint.setStyle(android.graphics.Paint.Style.FILL);
for (let i = 0; i < trend.length; i++) {
paint.setColor(android.graphics.Color.parseColor(emotionColor(trend[i].emotion)));
canvas.drawCircle(xAt(i), yAt(trend[i].score), 3.5 * scale, paint);
}
return new ImageSource(bitmap);
}
// --- playback --------------------------------------------------------------
private onRowTapped(index: number): void {
if (!global.isAndroid) return;
const session = this.session;
const segment = this.segments[index];
if (!session?.audioPath || !segment) return;
// Lines predating the recording (or a mid-session codec restart) may miss
// an offset; fall back to the wall-clock delta from the session start.
const offsetMs =
segment.audioOffsetMs !== null && segment.audioOffsetMs !== undefined
? segment.audioOffsetMs
: Math.max(0, segment.startedAt - session.startedAt);
if (index === this.activeRowIndex && this.player) {
if (this.playing) {
try {
this.player.pause();
} catch {
// fall through to state update; a dead player just loses the toggle
}
this.playing = false;
} else {
try {
this.player.start();
this.playing = true;
} catch {
this.playing = false;
}
}
this.updateRowPlayback();
return;
}
if (!this.ensurePlayer(session.audioPath)) return;
try {
this.player.seekTo(offsetMs);
this.player.start();
this.playing = true;
this.activeRowIndex = index;
} catch (error) {
this.status = `Playback failed: ${String(error)}`;
this.playing = false;
this.activeRowIndex = -1;
}
this.updateRowPlayback();
}
private ensurePlayer(audioPath: string): boolean {
if (this.player) return true;
try {
const player = new android.media.MediaPlayer();
player.setDataSource(audioPath);
player.prepare();
player.setOnCompletionListener(
new android.media.MediaPlayer.OnCompletionListener({
onCompletion: () => {
Utils.executeOnMainThread(() => {
this.playing = false;
this.updateRowPlayback();
});
},
}),
);
this.player = player;
return true;
} catch (error) {
this.status = `Could not open the recording: ${String(error)}`;
return false;
}
}
private stopPlaybackHighlight(): void {
if (this.player && this.playing) {
try {
this.player.pause();
} catch {
// ignore; the player may already be gone
}
}
this.playing = false;
this.activeRowIndex = -1;
}
private updateRowPlayback(): void {
for (let i = 0; i < this.rows.length; i++) {
const row = this.rows[i];
const isActive = i === this.activeRowIndex;
const rowClass = isActive ? "transcript-row transcript-row-playing" : "transcript-row";
const indicator = isActive ? (this.playing ? "⏸" : "▶") : "";
if (row.get("rowClass") !== rowClass) row.set("rowClass", rowClass);
if (row.get("playIndicator") !== indicator) row.set("playIndicator", indicator);
}
}
// --- actions ---------------------------------------------------------------
onRediarizeTap(): void {
if (!global.isAndroid || this.rediarizeRunning) return;
this.rediarizeRunning = true;
this.status = "Re-diarizing… 0%";
rediarizeSession(this.sessionId, {}, {
onProgress: (fraction) => {
Utils.executeOnMainThread(() => {
this.status = `Re-diarizing… ${Math.round(fraction * 100)}%`;
});
},
onDone: (result) => {
Utils.executeOnMainThread(() => {
this.rediarizeRunning = false;
this.status =
`Re-diarization done: ${result.clusters} voices, ` +
`${result.reassignedSegments} lines reassigned, ${result.newSpeakers} new speakers.`;
this.reload();
});
},
onError: (message) => {
Utils.executeOnMainThread(() => {
this.rediarizeRunning = false;
this.status = message;
});
},
});
}
async onSplitSpeakerTap(): Promise<void> {
if (!global.isAndroid) return;
const speakers = this.session?.speakers ?? [];
if (speakers.length === 0) {
this.status = "This conversation has no speakers to split.";
return;
}
const picked = await action({
title: "Split speaker",
message: "Move one speaker's lines in this conversation to a new profile.",
cancelButtonText: "Cancel",
actions: speakers.map((speaker) => speaker.name),
});
const chosen = speakers.find((speaker) => speaker.name === picked);
if (!chosen) return;
const confirmed = await confirm({
title: "Split speaker",
message: `Move ${chosen.name}'s lines in this conversation to a new speaker?`,
okButtonText: "Split",
cancelButtonText: "Cancel",
});
if (!confirmed) return;
speakerRegistry.splitFromSession(this.sessionId, chosen.id);
this.status = "";
this.reload();
}
async onDeleteTap(): Promise<void> {
if (!global.isAndroid) return;
const confirmed = await confirm({
title: "Delete conversation",
message: "Delete this conversation, its transcript, and its recording link? This cannot be undone.",
okButtonText: "Delete",
cancelButtonText: "Cancel",
});
if (!confirmed) return;
this.dispose();
try {
conversationStore().deleteSession(this.sessionId);
} catch (error) {
this.status = `Delete failed: ${String(error)}`;
return;
}
Frame.topmost()?.goBack();
}
private async onRowLongPressed(index: number): Promise<void> {
if (!global.isAndroid) return;
const segment = this.segments[index];
if (!segment) return;
const profiles = speakerRegistry.all();
if (profiles.length === 0) return;
const picked = await action({
title: "Reassign speaker",
message: "Whose line is this?",
cancelButtonText: "Cancel",
actions: profiles.map((profile) => profile.name),
});
const chosen = profiles.find((profile) => profile.name === picked);
if (!chosen || chosen.id === segment.speakerId) return;
try {
conversationStore().reassignSegmentSpeaker(segment.id, chosen.id);
} catch (error) {
this.status = `Reassign failed: ${String(error)}`;
return;
}
speakerRegistry.reload();
this.reload();
}
}
+19
View File
@@ -0,0 +1,19 @@
import { NavigatedData, Page } from "@nativescript/core";
import { ConversationsViewModel } from "./conversations-view-model";
type ConversationsContext = { speakerId?: number } | undefined;
export function navigatingTo(args: NavigatedData): void {
const page = args.object as Page;
// Preserve the model across back-navigation (returning from a conversation
// or the speakers page) so the search and filters aren't lost; reload every
// time so deletions, merges, and renames made elsewhere show up.
let model = page.bindingContext as ConversationsViewModel | undefined;
if (!model) {
const context = args.context as ConversationsContext;
model = new ConversationsViewModel({ speakerId: context?.speakerId });
page.bindingContext = model;
}
model.reload();
}
+56
View File
@@ -0,0 +1,56 @@
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo">
<ActionBar title="Conversations">
<ActionItem text="Ask AI" tap="{{ onAskTap }}" android.position="actionBar" />
<ActionItem text="Speakers" tap="{{ onSpeakersTap }}" android.position="actionBar" />
</ActionBar>
<GridLayout rows="auto,auto,*" class="p-8">
<SearchBar
row="0"
hint="Search (e.g. lunch past 2 days, angry)"
text="{{ searchText }}"
submit="{{ onSearchSubmit }}"
clear="{{ onSearchClear }}" />
<ScrollView row="1" orientation="horizontal" class="m-t-8" visibility="{{ filterChipsVisibility }}">
<StackLayout orientation="horizontal">
<Repeater items="{{ speakerChips }}">
<Repeater.itemsLayout>
<StackLayout orientation="horizontal" />
</Repeater.itemsLayout>
<Repeater.itemTemplate>
<Label text="{{ name }}" class="{{ chipClass }}" backgroundColor="{{ chipBackground }}" tap="{{ onChipTap }}" />
</Repeater.itemTemplate>
</Repeater>
</StackLayout>
</ScrollView>
<ScrollView row="2" class="m-t-8">
<StackLayout>
<Label text="{{ emptyMessage }}" class="conversation-empty" textWrap="true" visibility="{{ emptyVisibility }}" />
<Repeater items="{{ sessionRows }}">
<Repeater.itemsLayout>
<StackLayout />
</Repeater.itemsLayout>
<Repeater.itemTemplate>
<StackLayout class="conversation-row" tap="{{ onRowTap }}">
<GridLayout columns="*,auto">
<Label col="0" text="{{ title }}" class="conversation-title" textWrap="true" />
<Label col="1" text="" width="12" height="12" borderRadius="6" backgroundColor="{{ sentimentColor }}" verticalAlignment="center" />
</GridLayout>
<Label text="{{ meta }}" class="conversation-meta" />
<Repeater items="{{ speakerChips }}" visibility="{{ chipsVisibility }}" class="m-t-4">
<Repeater.itemsLayout>
<WrapLayout />
</Repeater.itemsLayout>
<Repeater.itemTemplate>
<Label text="{{ name }}" class="speaker-chip" backgroundColor="{{ chipBackground }}" />
</Repeater.itemTemplate>
</Repeater>
</StackLayout>
</Repeater.itemTemplate>
</Repeater>
</StackLayout>
</ScrollView>
</GridLayout>
</Page>
+175
View File
@@ -0,0 +1,175 @@
import { EventData, Frame, Observable, SearchBar } from "@nativescript/core";
import { sentimentBucket } from "../apps/microphones/sentiment";
import { speakerRegistry } from "../apps/microphones/speakers";
import {
conversationStore,
formatDateTime,
formatDuration,
NO_CONVERSATIONS_MESSAGE,
SENTIMENT_BUCKET_COLORS,
type SessionRow,
} from "./conversation-format";
import { parseConversationQuery } from "./conversation-search";
/** One session row in the Repeater; tap handler rides on the item itself (see pairing-view-model). */
export type SessionRowItem = {
title: string;
meta: string;
sentimentColor: string;
speakerChips: Array<{ name: string; chipBackground: string }>;
chipsVisibility: "visible" | "collapse";
onRowTap: () => void;
};
export type SpeakerChipItem = {
name: string;
chipBackground: string;
chipClass: string;
onChipTap: () => void;
};
export class ConversationsViewModel extends Observable {
private _searchText = "";
private _sessionRows: SessionRowItem[] = [];
private _speakerChips: SpeakerChipItem[] = [];
private _emptyMessage = "";
private selectedSpeakerId: number | null = null;
constructor(options?: { speakerId?: number }) {
super();
this.selectedSpeakerId = options?.speakerId ?? null;
}
get searchText(): string {
return this._searchText;
}
set searchText(value: string) {
if (this._searchText !== value) {
this._searchText = value;
this.notifyPropertyChange("searchText", value);
}
}
get sessionRows(): SessionRowItem[] {
return this._sessionRows;
}
get speakerChips(): SpeakerChipItem[] {
return this._speakerChips;
}
get emptyMessage(): string {
return this._emptyMessage;
}
get emptyVisibility(): "visible" | "collapse" {
return this._emptyMessage ? "visible" : "collapse";
}
get filterChipsVisibility(): "visible" | "collapse" {
return this._speakerChips.length > 0 ? "visible" : "collapse";
}
/** Called on every navigatingTo so edits made on other pages show up on the way back. */
reload(): void {
this.refreshSpeakerChips();
this.refreshSessions();
}
onSpeakersTap(): void {
Frame.topmost()?.navigate("phone-ui/speakers-page");
}
onAskTap(): void {
Frame.topmost()?.navigate("phone-ui/ask-page");
}
onSearchSubmit(args: EventData): void {
const bar = args.object as SearchBar;
this._searchText = bar.text ?? "";
this.refreshSessions();
}
onSearchClear(): void {
if (!this._searchText) return;
this._searchText = "";
this.notifyPropertyChange("searchText", "");
this.refreshSessions();
}
private refreshSpeakerChips(): void {
const profiles = global.isAndroid ? speakerRegistry.all() : [];
this._speakerChips = profiles.map((profile) => ({
name: profile.name,
chipBackground: profile.color || "#90A4AE",
chipClass: profile.id === this.selectedSpeakerId ? "speaker-chip speaker-chip-selected" : "speaker-chip",
onChipTap: () => {
this.selectedSpeakerId = this.selectedSpeakerId === profile.id ? null : profile.id;
this.refreshSpeakerChips();
this.refreshSessions();
},
}));
this.notifyPropertyChange("speakerChips", this._speakerChips);
this.notifyPropertyChange("filterChipsVisibility", this.filterChipsVisibility);
}
private refreshSessions(): void {
if (!global.isAndroid) {
this.setSessions([], "Conversation review is only available on Android.");
return;
}
const parsed = parseConversationQuery(this._searchText);
const filter: Record<string, unknown> = {};
if (parsed.sinceMs !== null) filter.sinceMs = parsed.sinceMs;
if (parsed.untilMs !== null) filter.untilMs = parsed.untilMs;
if (parsed.emotion !== null) filter.emotion = parsed.emotion;
if (parsed.text) filter.query = parsed.text;
if (this.selectedSpeakerId !== null) filter.speakerId = this.selectedSpeakerId;
const filtered = Object.keys(filter).length > 0;
let rows: SessionRow[] = [];
try {
rows = JSON.parse(String(conversationStore().querySessions(JSON.stringify(filter)))) as SessionRow[];
} catch (error) {
console.error(`conversations query failed: ${String(error)}`);
this.setSessions([], "Could not read saved conversations.");
return;
}
this.setSessions(
rows.map((row) => this.toRowItem(row)),
rows.length > 0 ? "" : filtered ? "No conversations match this search." : NO_CONVERSATIONS_MESSAGE,
);
}
private setSessions(rows: SessionRowItem[], emptyMessage: string): void {
this._sessionRows = rows;
this._emptyMessage = emptyMessage;
this.notifyPropertyChange("sessionRows", rows);
this.notifyPropertyChange("emptyMessage", emptyMessage);
this.notifyPropertyChange("emptyVisibility", this.emptyVisibility);
}
private toRowItem(row: SessionRow): SessionRowItem {
const durationMs = row.endedAt > row.startedAt ? row.endedAt - row.startedAt : 0;
const metaParts = [formatDateTime(row.startedAt), formatDuration(durationMs), `${row.segmentCount} lines`];
const chips = (row.speakers ?? []).map((speaker) => ({
name: speaker.name,
chipBackground: speaker.color || "#90A4AE",
}));
return {
title: row.title || formatDateTime(row.startedAt),
meta: metaParts.filter((part) => part.length > 0).join(" · "),
sentimentColor: SENTIMENT_BUCKET_COLORS[sentimentBucket(row.avgSentiment ?? 0)],
speakerChips: chips,
chipsVisibility: chips.length > 0 ? "visible" : "collapse",
onRowTap: () => {
Frame.topmost()?.navigate({
moduleName: "phone-ui/conversation-page",
context: { sessionId: row.id },
});
},
};
}
}
+1
View File
@@ -11,6 +11,7 @@
<ActionItem text="Pair glasses" tap="{{ onPairGlassesTap }}" isEnabled="{{ canRun }}" android.position="popup" />
<ActionItem text="Configure devices" tap="{{ onConfigureTap }}" isEnabled="{{ canRun }}" android.position="popup" />
<ActionItem text="Permissions" tap="{{ onPermissionsTap }}" android.position="popup" />
<ActionItem text="Conversations" tap="{{ onConversationsTap }}" android.position="popup" />
<ActionItem text="Take screenshot" tap="{{ onTakeScreenshotTap }}" android.position="popup" />
<ActionItem text="Record screen" tap="{{ onRecordScreenTap }}" android.position="popup" />
<ActionItem text="Uninstall custom firmware" tap="{{ onUninstallFirmwareTap }}" isEnabled="{{ canRun }}" android.position="popup" />
+5
View File
@@ -646,6 +646,11 @@ export class MainViewModel extends Observable {
});
}
/** Review saved caption sessions; works without a glasses connection. */
onConversationsTap(): void {
Frame.topmost()?.navigate("phone-ui/conversations-page");
}
/**
* Live scan that names each nearby pair by model, colour, and serial and
* checks both arms belong together. A connected arm stops advertising, so
+2 -2
View File
@@ -46,8 +46,8 @@ const NO_RESULTS_HINT_AFTER_MS = 10_000;
* re-renders the pair/ring lists at a calm cadence, and saves the chosen
* addresses plus the decoded identity when the user continues.
*
* Selection is always a deliberate tap (no auto-select on a single result),
* mirroring SybilSight's pairing flow: a strong signal is a hint, not consent.
* Selection is always a deliberate tap (no auto-select on a single result):
* a strong signal is a hint, not consent.
*/
export class PairingViewModel extends Observable {
private readonly onboarding: boolean;
+15
View File
@@ -0,0 +1,15 @@
import { NavigatedData, Page } from "@nativescript/core";
import { SpeakersViewModel } from "./speakers-view-model";
export function navigatingTo(args: NavigatedData): void {
const page = args.object as Page;
let model = page.bindingContext as SpeakersViewModel | undefined;
if (!model) {
model = new SpeakersViewModel();
page.bindingContext = model;
}
// Reload every time so edits made from a conversation page (re-diarize,
// split, reassign) show up on the way back.
model.reload();
}
+27
View File
@@ -0,0 +1,27 @@
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo">
<ActionBar title="Speakers" />
<ScrollView class="p-8">
<StackLayout>
<Label text="{{ emptyMessage }}" class="conversation-empty" textWrap="true" visibility="{{ emptyVisibility }}" />
<Repeater items="{{ speakerRows }}">
<Repeater.itemsLayout>
<StackLayout />
</Repeater.itemsLayout>
<Repeater.itemTemplate>
<GridLayout columns="auto,*" class="conversation-row" tap="{{ onRowTap }}">
<Label col="0" text="" width="18" height="18" borderRadius="9" backgroundColor="{{ swatchColor }}" verticalAlignment="center" />
<StackLayout col="1" class="m-l-8">
<StackLayout orientation="horizontal">
<Label text="{{ name }}" class="conversation-title" />
<Label text="{{ tag }}" class="speaker-tag m-l-6" visibility="{{ tagVisibility }}" />
<Label text="my voice" class="speaker-wearer-badge m-l-6" visibility="{{ wearerVisibility }}" />
</StackLayout>
<Label text="{{ meta }}" class="conversation-meta" />
</StackLayout>
</GridLayout>
</Repeater.itemTemplate>
</Repeater>
</StackLayout>
</ScrollView>
</Page>
+230
View File
@@ -0,0 +1,230 @@
import { Frame, Observable, action, alert, confirm, prompt } from "@nativescript/core";
import { speakerRegistry, type SpeakerProfile } from "../apps/microphones/speakers";
import { formatDateTime } from "./conversation-format";
/** One speaker row; tap handler rides on the item itself (see pairing-view-model). */
export type SpeakerRowItem = {
name: string;
tag: string;
tagVisibility: "visible" | "collapse";
wearerVisibility: "visible" | "collapse";
swatchColor: string;
meta: string;
onRowTap: () => void;
};
const PRESET_COLORS: Array<{ label: string; hex: string }> = [
{ label: "Sky", hex: "#4FC3F7" },
{ label: "Amber", hex: "#FFB74D" },
{ label: "Green", hex: "#81C784" },
{ label: "Red", hex: "#E57373" },
{ label: "Purple", hex: "#BA68C8" },
{ label: "Yellow", hex: "#FFD54F" },
{ label: "Teal", hex: "#4DB6AC" },
{ label: "Pink", hex: "#F06292" },
{ label: "Brown", hex: "#A1887F" },
{ label: "Gray", hex: "#90A4AE" },
];
export class SpeakersViewModel extends Observable {
private _speakerRows: SpeakerRowItem[] = [];
private _emptyMessage = "";
get speakerRows(): SpeakerRowItem[] {
return this._speakerRows;
}
get emptyMessage(): string {
return this._emptyMessage;
}
get emptyVisibility(): "visible" | "collapse" {
return this._emptyMessage ? "visible" : "collapse";
}
reload(): void {
if (!global.isAndroid) {
this.setRows([], "Speaker management is only available on Android.");
return;
}
speakerRegistry.reload();
const profiles = speakerRegistry.all();
this.setRows(
profiles.map((profile) => this.toRowItem(profile)),
profiles.length > 0
? ""
: "No speakers yet — voices are enrolled automatically while Captions + Save captions run in the Microphones app on the glasses.",
);
}
private setRows(rows: SpeakerRowItem[], emptyMessage: string): void {
this._speakerRows = rows;
this._emptyMessage = emptyMessage;
this.notifyPropertyChange("speakerRows", rows);
this.notifyPropertyChange("emptyMessage", emptyMessage);
this.notifyPropertyChange("emptyVisibility", this.emptyVisibility);
}
private toRowItem(profile: SpeakerProfile): SpeakerRowItem {
const metaParts: string[] = [];
if (profile.lastHeardAt > 0) metaParts.push(`Last heard ${formatDateTime(profile.lastHeardAt)}`);
metaParts.push(`${profile.segmentCount} lines`);
return {
name: profile.name,
tag: profile.tag,
tagVisibility: profile.tag ? "visible" : "collapse",
wearerVisibility: profile.isWearer ? "visible" : "collapse",
swatchColor: profile.color || "#90A4AE",
meta: metaParts.join(" · "),
onRowTap: () => {
void this.onSpeakerTap(profile.id);
},
};
}
private async onSpeakerTap(speakerId: number): Promise<void> {
const profile = speakerRegistry.byId(speakerId);
if (!profile) return;
const choice = await action({
title: profile.name,
cancelButtonText: "Cancel",
actions: [
"View insights",
"Rename",
"Set tag",
"Set color",
"Set as my voice",
"Merge into...",
"View conversations",
"Delete",
],
});
switch (choice) {
case "View insights":
await this.viewInsights(profile);
break;
case "Rename":
await this.renameSpeaker(profile);
break;
case "Set tag":
await this.setSpeakerTag(profile);
break;
case "Set color":
await this.setSpeakerColor(profile);
break;
case "Set as my voice":
speakerRegistry.setWearer(profile.id, true);
this.reload();
break;
case "Merge into...":
await this.mergeSpeaker(profile);
break;
case "View conversations":
Frame.topmost()?.navigate({
moduleName: "phone-ui/conversations-page",
context: { speakerId: profile.id },
});
break;
case "Delete":
await this.deleteSpeaker(profile);
break;
}
}
/** The contact's conversation memory: last heard, recap, action items, facts. */
private async viewInsights(profile: SpeakerProfile): Promise<void> {
const parts: string[] = [];
if (profile.lastHeardAt > 0) parts.push(`Last heard ${formatDateTime(profile.lastHeardAt)}.`);
if (profile.lastRecap) parts.push(`Last conversation: ${profile.lastRecap}`);
if (profile.actionItems.length) {
parts.push(`Action items:\n${profile.actionItems.map((item) => `• ${item}`).join("\n")}`);
}
if (profile.facts.length) {
parts.push(`Facts:\n${profile.facts.map((fact) => `• ${fact}`).join("\n")}`);
}
if (!profile.lastRecap && !profile.actionItems.length && !profile.facts.length) {
parts.push(
"No conversation insights yet — they are generated on-device when a captioned " +
"conversation with this person ends (requires the downloaded assistant model).",
);
}
await alert({
title: profile.name,
message: parts.join("\n\n"),
okButtonText: "Close",
});
}
private async renameSpeaker(profile: SpeakerProfile): Promise<void> {
const result = await prompt({
title: "Rename speaker",
defaultText: profile.name,
okButtonText: "Rename",
cancelButtonText: "Cancel",
});
const name = result.result ? result.text.trim() : "";
if (!name || name === profile.name) return;
speakerRegistry.rename(profile.id, name);
this.reload();
}
private async setSpeakerTag(profile: SpeakerProfile): Promise<void> {
const result = await prompt({
title: "Set tag",
message: "A short label like \"work\", \"family\", or \"neighbor\".",
defaultText: profile.tag,
okButtonText: "Save",
cancelButtonText: "Cancel",
});
if (!result.result) return;
speakerRegistry.setTag(profile.id, result.text.trim());
this.reload();
}
private async setSpeakerColor(profile: SpeakerProfile): Promise<void> {
const picked = await action({
title: "Set color",
cancelButtonText: "Cancel",
actions: PRESET_COLORS.map((color) => `${color.label} (${color.hex})`),
});
const chosen = PRESET_COLORS.find((color) => `${color.label} (${color.hex})` === picked);
if (!chosen) return;
speakerRegistry.setColor(profile.id, chosen.hex);
this.reload();
}
private async mergeSpeaker(profile: SpeakerProfile): Promise<void> {
const others = speakerRegistry.all().filter((candidate) => candidate.id !== profile.id);
if (others.length === 0) return;
const picked = await action({
title: "Merge into...",
message: `${profile.name}'s lines and voice-print will move to the speaker you pick.`,
cancelButtonText: "Cancel",
actions: others.map((candidate) => candidate.name),
});
const target = others.find((candidate) => candidate.name === picked);
if (!target) return;
const confirmed = await confirm({
title: "Merge speakers",
message: `Merge ${profile.name} into ${target.name}? This cannot be undone.`,
okButtonText: "Merge",
cancelButtonText: "Cancel",
});
if (!confirmed) return;
speakerRegistry.merge(profile.id, target.id);
this.reload();
}
private async deleteSpeaker(profile: SpeakerProfile): Promise<void> {
const confirmed = await confirm({
title: "Delete speaker",
message: `Delete ${profile.name}? Their transcript lines stay but lose the speaker label.`,
okButtonText: "Delete",
cancelButtonText: "Cancel",
});
if (!confirmed) return;
speakerRegistry.remove(profile.id);
this.reload();
}
}