知了 Cicada · 任何会议和直播的实时字幕、同声传译、AI 会议纪要,Mac、Windows、Linux、Android 免费开源。Live subtitles, interpreting and meeting notes for any call or stream, on Mac, Windows, Linux and Android.
Swift androidlinuxlive-captionsmacosmeeting-notesmenubar-appsimultaneous-interpretationspeech-recognitionsubtitlesswiftswiftuitranslationwindows
fix(windows): keep Mac records intact, ask before ending a meeting, and show when notes fail
wquguruced28259520e
diff --git a/windows/scripts/cicadactl.ps1 b/windows/scripts/cicadactl.ps1index 6342a1c..19baa00 100644--- a/windows/scripts/cicadactl.ps1+++ b/windows/scripts/cicadactl.ps1@@ -1,5 +1,5 @@# Sends one debug command to a running dev build (Cicada.exe --dev) and prints its JSON state.-# .\cicadactl.ps1 state | start | stop | sample | feed C:\clip.wav | view subtitles | capture on | show records | quit+# .\cicadactl.ps1 state | start | stop | end | notesproblem failed | sample | feed C:\clip.wav | view subtitles | capture on | show records | quit# 结束会议: calls zoom.exe=Zoom|none|real | realcalls | endtimes <silence> <countdown> <grace>|off | endkeepparam([Parameter(ValueFromRemainingArguments = $true)][string[]]$Command)$pipe = New-Object System.IO.Pipes.NamedPipeClientStream(".", "cicada-dev", [System.IO.Pipes.PipeDirection]::InOut)diff --git a/windows/src/Cicada.Core/Models.cs b/windows/src/Cicada.Core/Models.csindex 9860b88..c7756c1 100644--- a/windows/src/Cicada.Core/Models.cs+++ b/windows/src/Cicada.Core/Models.cs@@ -35,14 +35,25 @@ public sealed class Session[JsonPropertyName("endedAt")] public DateTimeOffset? EndedAt { get; set; }[JsonPropertyName("hasAudio")] public bool HasAudio { get; set; }[JsonPropertyName("id")] public string Id { get; set; } = "";+ /// Mac: an imported file still being transcribed. Kept so a Mac record round-trips.+ [JsonPropertyName("importing")] public bool? Importing { get; set; }[JsonPropertyName("lines")] public List<TranscriptLine> Lines { get; set; } = [];[JsonPropertyName("notes")] public MeetingNotes? Notes { get; set; }[JsonPropertyName("renamed")] public bool? Renamed { get; set; }+ /// Mac: heard through the microphone (会议室模式). Windows doesn't record rooms yet.+ [JsonPropertyName("room")] public bool? Room { get; set; }+ /// Mac: the imported file's name, and where its audio is; Windows doesn't import yet.+ [JsonPropertyName("sourceFile")] public string? SourceFile { get; set; }+ [JsonPropertyName("sourcePath")] public string? SourcePath { get; set; }[JsonPropertyName("startedAt")] public DateTimeOffset StartedAt { get; set; }[JsonPropertyName("title")] public string Title { get; set; } = "";[JsonPropertyName("voiceGuesses")] public Dictionary<string, VoiceGuess>? VoiceGuesses { get; set; }[JsonPropertyName("voiceNames")] public Dictionary<string, string>? VoiceNames { get; set; }+ /// Keys a newer Mac (or port) added that this version doesn't know: written back as read, so+ /// opening a record here never loses them. They go after the known keys rather than in order.+ [JsonExtensionData] public Dictionary<string, System.Text.Json.JsonElement>? Unknown { get; set; }+[JsonIgnore] public TimeSpan Duration => (EndedAt ?? DateTimeOffset.Now) - StartedAt;}diff --git a/windows/src/Cicada.Core/Notes.cs b/windows/src/Cicada.Core/Notes.csindex fef4fea..9abfd9c 100644--- a/windows/src/Cicada.Core/Notes.cs+++ b/windows/src/Cicada.Core/Notes.cs@@ -25,6 +25,8 @@ public sealed class NotesEnginepublic MeetingNotes Notes { get; private set; } = new();public State Status { get; private set; } = State.Idle;+ /// cicadactl notesproblem failed|ratelimited|idle: shows what a failed round looks like.+ public void SimulateStatus(string state) { Status = Enum.TryParse<State>(state, true, out var s) ? s : State.Idle; Changed?.Invoke(); }/// While a meeting runs and has notes: when the next live update is due.public DateTime? NextUpdate { get { lock (gate) return sessionId is null || Notes.IsEmpty || inFlight ? null : lastAttempt.AddSeconds(Interval); } }/// The session the notes belong to (stays set after the meeting ends).@@ -113,7 +115,7 @@ public sealed class NotesEngine// (The script check can't tell Chinese from Japanese, so extending them would keep the old.)if (!final && writtenIn is not null && writtenIn != lang) { baseNotes = new MeetingNotes(); Log.Debug($"notes: language now {lang}, rewriting"); }int from = final ? 0 : Math.Min(baseNotes.Covered, lines.Count);- var prompt = Prompt(baseNotes, lines, from, lang, final);+ var prompt = Prompt(baseNotes, lines, from, lang, final, SpeakerLabels.Voices ? SpeakerLabels.Names(session) : null);MeetingNotes? next = null;for (int attempt = 1; attempt <= (final ? 2 : 1); attempt++){@@ -184,14 +186,16 @@ public sealed class NotesEngine// MARK: Prompt (Notes.swift › prompt, word for word)- public static string Prompt(MeetingNotes notes, IReadOnlyList<TranscriptLine> lines, int from, string language, bool final)+ public static string Prompt(MeetingNotes notes, IReadOnlyList<TranscriptLine> lines, int from, string language, bool final,+ IReadOnlyDictionary<int, string>? names = null){- var numbers = SpeakerLabels.Numbers(lines);+ var numbers = SpeakerLabels.Voices ? SpeakerLabels.Numbers(lines) : [];string Line(int i){var l = lines[i];- // As Notes.swift: 说话人N once voices are told apart, 未识别 for a voice not on show.- var who = l.Speaker == "me" ? "你" : numbers.TryGetValue(l.Id, out var n) ? $"说话人{n}" : numbers.Count == 0 ? "对方" : "未识别";+ // As Notes.swift: a named voice as its name, else 说话人N once voices are told apart,+ // 未识别 for a voice not on show.+ var who = l.Speaker == "me" ? "你" : numbers.TryGetValue(l.Id, out var n) ? names?.GetValueOrDefault(n) ?? $"说话人{n}" : numbers.Count == 0 ? "对方" : "未识别";return $"[L{i + 1} {Languages.Clock(l.T)} {who}] {l.Src}";}var current = notes.IsEmpty ? "{}" : CompactJson(notes);diff --git a/windows/src/Cicada.Core/SessionStore.cs b/windows/src/Cicada.Core/SessionStore.csindex 92766b8..86740f5 100644--- a/windows/src/Cicada.Core/SessionStore.cs+++ b/windows/src/Cicada.Core/SessionStore.cs@@ -31,7 +31,10 @@ public sealed class SessionStoreif (!File.Exists(file)) continue;try{- if (Json.Read<Session>(File.ReadAllText(file)) is { } s) sessions[s.Id] = s;+ if (Json.Read<Session>(File.ReadAllText(file)) is not { } s) continue;+ // The app quit mid-meeting: it ended just after its last line (SessionStore.swift › load).+ s.EndedAt ??= s.Lines.Count > 0 ? s.StartedAt.AddSeconds(s.Lines[^1].T + 5) : s.StartedAt;+ sessions[s.Id] = s;}catch (Exception e) { Log.Debug($"store: skipped {Path.GetFileName(dir)}: {e.GetType().Name}"); }}@@ -96,7 +99,15 @@ public sealed class SessionStorepublic void SetNotes(string id, MeetingNotes notes) => Mutate(id, s => s.Notes = notes);- public void Rename(string id, string title) => Mutate(id, s => { s.Title = title.Trim(); s.Renamed = true; });+ /// An empty title, or the one shown already, goes back to / stays on the automatic one+ /// (SessionStore.swift › rename): saving the dialog unchanged mustn't freeze the notes' name.+ public void Rename(string id, string title)+ {+ var t = title.Trim();+ if (Get(id) is not { } current || t == DisplayTitle(current)) return;+ if (t.Length == 0) { ResetTitle(id); return; }+ Mutate(id, s => { s.Title = t; s.Renamed = true; });+ }/// Back to the default title, so the name the notes give the meeting shows again.public void ResetTitle(string id) => Mutate(id, s => { s.Title = DefaultTitle(s.StartedAt); s.Renamed = false; });@@ -176,10 +187,11 @@ public sealed class SessionStoreb.AppendLine(s.StartedAt.ToLocalTime().ToString("yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture)).AppendLine();if (s.Notes is { IsEmpty: false } n) b.AppendLine($"## {Strings.L("纪要")}").AppendLine().Append(NotesBody(n));b.AppendLine($"## {Strings.L("文字记录")}").AppendLine();- var numbers = SpeakerLabels.Numbers(s.Lines);+ var numbers = SpeakerLabels.Voices ? SpeakerLabels.Numbers(s.Lines) : [];+ var names = SpeakerLabels.Names(s);foreach (var l in s.Lines.OrderBy(x => x.T)){- var who = l.Speaker == "me" ? Strings.L("你") : numbers.TryGetValue(l.Id, out var num) ? Strings.LF("说话人 %lld", num) : null;+ var who = l.Speaker == "me" ? Strings.L("你") : numbers.TryGetValue(l.Id, out var num) ? names.GetValueOrDefault(num) ?? Strings.LF("说话人 %lld", num) : null;b.AppendLine($"**{Languages.Clock(l.T)}**{(who is null ? "" : $" {who}:")} {l.Src} ");if (!string.IsNullOrEmpty(l.Dst) && l.Dst != l.Src) b.AppendLine($"{l.Dst}");b.AppendLine();diff --git a/windows/src/Cicada.Core/Speak.cs b/windows/src/Cicada.Core/Speak.csindex 808084d..ced5935 100644--- a/windows/src/Cicada.Core/Speak.cs+++ b/windows/src/Cicada.Core/Speak.cs@@ -134,13 +134,13 @@ public sealed class SpeakEngineState = Phase.Translating; Said = Heard = Problem = null;Changed?.Invoke();Heard? heard = null;- try { heard = await translator.Hear(wav, to, MyLanguage); }+ try { heard = await translator.Hear(wav, to, MyLanguage, Priority.Speak); }catch (LingException e) { Log.Debug($"speak: hear failed {e.Message}"); return Fail(e.Failure is LingException.Kind.Network or LingException.Kind.Timeout ? Strings.L("连不上 Ling,没有发出去") : Strings.L("没翻译成功,没有发出去")); }if (heard is null) return Fail(Strings.L("没听清,没有发出去"));Said = heard.Original;var text = heard.Translation;// Ming didn't translate it: the text translator gets one try; failing that, silence.- if (text is null && heard.Lang != to) text = await translator.Translate(heard.Original, heard.Lang, to, Translator.Kind.Sentence);+ if (text is null && heard.Lang != to) text = await translator.Translate(heard.Original, heard.Lang, to, Translator.Kind.Sentence, Priority.Speak);if (string.IsNullOrWhiteSpace(text)) return Fail(Strings.L("没翻译成功,没有发出去"));var translatedAt = DateTime.UtcNow;Heard = text;diff --git a/windows/src/Cicada.Core/Translator.cs b/windows/src/Cicada.Core/Translator.csindex 91a5aea..ee5dbc0 100644--- a/windows/src/Cicada.Core/Translator.cs+++ b/windows/src/Cicada.Core/Translator.cs@@ -32,10 +32,11 @@ public sealed class Translator(LingClient ling, HttpMessageHandler? google = nul/// One stretch of speech (16 kHz mono WAV) heard and interpreted. `hint` is the language the/// meeting has been in, which keeps Ming from flipping on a short or accented stretch. Null/// when there was no speech or the reply wasn't in the three-line form; never a guess.- public async Task<Heard?> Hear(byte[] wav, string target, string? hint, CancellationToken cancel = default)+ /// `priority` is Speak for what the user says, so it goes ahead of the meeting's lines.+ public async Task<Heard?> Hear(byte[] wav, string target, string? hint, Priority priority = Priority.Translate, CancellationToken cancel = default){var prompt = HearPrompt(target, hint, Glossary());- var reply = await ling.Chat(prompt, HearInstruction(target), Priority.Translate, maxTokens: 800, timeout: 12,+ var reply = await ling.Chat(prompt, HearInstruction(target), priority, maxTokens: 800, timeout: 12,model: LingClient.AudioModel, audio: wav, cancel: cancel);return ParseHeard(reply, target, hint);}@@ -102,7 +103,7 @@ public sealed class Translator(LingClient ling, HttpMessageHandler? google = nulpublic enum Kind { Draft, Sentence }/// Ling (finished sentences only) → Google. Null when both fail.- public async Task<string?> Translate(string text, string source, string target, Kind kind)+ public async Task<string?> Translate(string text, string source, string target, Kind kind, Priority priority = Priority.Translate){if (source == target) return text;if (kind != Kind.Draft && ling.Usable)@@ -115,7 +116,7 @@ public sealed class Translator(LingClient ling, HttpMessageHandler? google = nulvar names = Glossary();if (names.Count > 0) prompt += "\nKnown names and terms (use these spellings): " + string.Join("; ", names);prompt += "\nSubtitle: " + text;- var out_ = await ling.Chat(prompt, "Translate.", Priority.Translate, maxTokens: 400, timeout: 6);+ var out_ = await ling.Chat(prompt, "Translate.", priority, maxTokens: 400, timeout: 6);if (CleanTranslation(out_, target) is { } clean) return clean;}catch (LingException e) { Log.Debug($"translate ling failed: {e.Message}"); }diff --git a/windows/src/Cicada.Core/Voices.cs b/windows/src/Cicada.Core/Voices.csindex 5b2a146..7f18840 100644--- a/windows/src/Cicada.Core/Voices.cs+++ b/windows/src/Cicada.Core/Voices.cs@@ -155,6 +155,25 @@ public static class SpeakerLabels{public const int ShownAfter = 5;+ /// 说话人识别 is on (AppSettings.SpeakerVoices; TranscriptExport.voices on the Mac): when off,+ /// notes and exports name no speakers. Kept in step by the app.+ public static bool Voices { get; set; } = true;++ /// Speaker number → the name the user gave it, else Ling's guess (SpeakerLabels.names); an+ /// empty name the user set clears the guess.+ public static Dictionary<int, string> Names(Session s)+ {+ var outp = new Dictionary<int, string>();+ if (s.VoiceNames is null && s.VoiceGuesses is null) return outp;+ foreach (var (v, n) in VoiceNumbers(s.Lines))+ {+ var key = v.ToString(System.Globalization.CultureInfo.InvariantCulture);+ if (s.VoiceNames?.TryGetValue(key, out var mine) == true) { if (mine.Length > 0) outp[n] = mine; }+ else if (s.VoiceGuesses?.TryGetValue(key, out var g) == true) outp[n] = g.Name;+ }+ return outp;+ }+/// Long enough to say whose voice it is: three words, or four characters of CJK.public static bool Substantive(string text){diff --git a/windows/src/Cicada/App.cs b/windows/src/Cicada/App.csindex b87b786..2ad6a2b 100644--- a/windows/src/Cicada/App.cs+++ b/windows/src/Cicada/App.cs@@ -65,6 +65,8 @@ sealed class ControllerMeetingEndWatch? endWatch;public MeetingEndWatch.Pending? Ending { get; private set; }public bool AutoEnded { get; private set; }+ /// 结束这场会议? is showing in the notes window or subtitle bar (AppModel.requestStop).+ public bool ConfirmingEnd { get; private set; }/// Dev: meeting apps pretending to be in a call, and (silence, countdown, grace) in seconds.public Dictionary<string, string>? FakeCalls;public (double Silence, double Countdown, double Grace)? EndTimes;@@ -76,6 +78,7 @@ sealed class Controllervar ui = Settings.UiLanguage == "system" ? null : Settings.UiLanguage;Strings.Load(Path.Combine(AppContext.BaseDirectory, "Resources"), ui);Ling = new LingClient(Key) { Model = Settings.Model };+ SpeakerLabels.Voices = Settings.SpeakerVoices;Notes = new NotesEngine(Ling, Store);Translator = new Translator(Ling);Listen = new ListenEngine(Ling, Translator, Store, Notes, Settings);@@ -193,7 +196,7 @@ sealed class Controllerreturn item;}menu.Items.Add(Listen.Listening- ? Item(L("结束"), Icons.Stop, () => _ = StopListening(), Hotkey.Label, fill: true)+ ? Item(L("结束"), Icons.Stop, RequestStop, Hotkey.Label, fill: true): Item(L("开始听"), Icons.Wave, () => _ = ToggleListening(), Hotkey.Label));menu.Items.Add(new Separator());menu.Items.Add(Item(L("显示纪要"), Icons.Notes, ShowNotes));@@ -222,8 +225,27 @@ sealed class Controllerpublic async Task ToggleListening(){- if (Listen.Listening) await StopListening();+ if (Listen.Listening) RequestStop();else StartListening(new SystemAudioTap());+ await Task.CompletedTask;+ }++ /// The user's 结束 (buttons, menu, hotkey): a meeting with lines ends only after asking, in the+ /// notes window or subtitle bar, which never take focus, so no modal dialog fights them for it.+ /// An empty one just stops.+ public void RequestStop()+ {+ if (!Listen.Listening) return;+ if (Listen.SessionId is not { } id || Store.Get(id) is not { Lines.Count: > 0 }) { _ = StopListening(); return; }+ ConfirmingEnd = true;+ ShowNotes();+ Changed();+ }++ public void CancelStop()+ {+ ConfirmingEnd = false;+ Changed();}public void StartListening(IAudioSource source)@@ -248,6 +270,7 @@ sealed class Controllervar id = Listen.SessionId;endWatch = null;Ending = null;+ ConfirmingEnd = false;AutoEnded = auto;await Listen.Stop(endedAt);Changed();@@ -481,7 +504,11 @@ sealed class Controller}public bool HotkeyRegistered => hotkey?.Registered ?? false;- public void SettingsChanged() => Changed();+ public void SettingsChanged()+ {+ SpeakerLabels.Voices = Settings.SpeakerVoices;+ Changed();+ }public async Task Quit(){@@ -512,6 +539,7 @@ sealed class Controller["sessions"] = Store.All().Count,["hotkey"] = HotkeyRegistered,["speakerVoices"] = Settings.SpeakerVoices,+ ["confirmingEnd"] = ConfirmingEnd,["voices"] = Listen.SessionId is { } vid && Store.Get(vid) is { } vs ? string.Join(",", vs.Lines.Where(l => l.Speaker == "them").Select(l => SpeakerLabels.Numbers(vs.Lines).TryGetValue(l.Id, out var n) ? n.ToString() : l.Voice is { } v ? $"v{v}" : "-")) : "",["speak"] = Settings.Speak,["speakState"] = Speak.State.ToString(),@@ -571,6 +599,8 @@ static class DebugServer{case "start": app.StartListening(new SystemAudioTap()); break;case "stop": _ = app.StopListening(); break;+ case "end": app.RequestStop(); break; // the user's 结束: asks first when anything was said+ case "notesproblem": app.Notes.SimulateStatus(arg); break;case "feed": app.StartListening(new FileAudioSource(arg)); break;case "sample": _ = app.PlaySample(); break;case "view": app.SetView(arg == "subtitles" ? "subtitles" : "notes"); break;diff --git a/windows/src/Cicada/MainWindow.cs b/windows/src/Cicada/MainWindow.csindex 45bd300..474ea6a 100644--- a/windows/src/Cicada/MainWindow.cs+++ b/windows/src/Cicada/MainWindow.cs@@ -193,7 +193,16 @@ sealed class MainWindow : Windowvar top = new StackPanel { Margin = new Thickness(32, 24, 32, 0) };var title = Ui.Text(SessionStore.DisplayTitle(s), 26, Palette.Ink, FontWeights.Bold);- top.Children.Add(Ui.Row(6, title, Ui.IconButton(Icons.Pencil, L("重命名"), () => Rename(s), Palette.Secondary, 32, 16)));+ var titleRow = Ui.Row(6, title, Ui.IconButton(Icons.Pencil, L("重命名"), () => Rename(s), Palette.Secondary, 32, 16));+ // As the Mac's context menu: only when the notes have a name to go back to.+ if ((s.Renamed ?? !s.Title.StartsWith("会议 ")) && !string.IsNullOrEmpty(s.Notes?.Title))+ {+ var reset = Ui.LinkText(L("恢复自动标题"), () => app.Store.ResetTitle(s.Id));+ reset.VerticalAlignment = VerticalAlignment.Center;+ reset.Margin = new Thickness(6, 0, 0, 0);+ titleRow.Children.Add(reset);+ }+ top.Children.Add(titleRow);var spoken = s.Lines.Select(l => l.SrcLang).FirstOrDefault(x => x is not null);var into = s.Lines.Select(l => l.DstLang).FirstOrDefault(x => x is not null);var meta = new List<string> { Records.Meta(s, app), LF("%@ 句", s.Lines.Count) };@@ -243,7 +252,7 @@ sealed class MainWindow : WindowFrameworkElement Notes(Session s, bool live){if (s.Notes is not { IsEmpty: false } n)- return Empty(live ? L("纪要会在开会几分钟后出现") : L("生成纪要"), "");+ return Empty(live ? L("纪要会在会议进行中自动生成") : L("生成纪要"), "");var article = new StackPanel { MaxWidth = 680, HorizontalAlignment = HorizontalAlignment.Left };if (n.Summary.Length > 0) article.Children.Add(Ui.Text(n.Summary, 15, Palette.Body));foreach (var t in n.Topics)diff --git a/windows/src/Cicada/NotesWindow.cs b/windows/src/Cicada/NotesWindow.csindex 5d6cb47..aebabc7 100644--- a/windows/src/Cicada/NotesWindow.cs+++ b/windows/src/Cicada/NotesWindow.cs@@ -126,7 +126,9 @@ sealed class NotesWindow : Window/// The window never takes focus, so a click lands on the buttons at once.FrameworkElement EndingStrip(){- if (!app.Listen.Listening || app.Ending is not { } p) return new Border();+ if (!app.Listen.Listening) return new Border();+ if (app.ConfirmingEnd) return ConfirmEnd();+ if (app.Ending is not { } p) return new Border();Detach(endingDetail);var buttons = Ui.Row(8, Ui.Button(L("继续记录"), app.KeepRecording, Ui.Kind.Primary, height: 32),Ui.Button(L("现在结束"), () => _ = app.StopListening(), height: 32));@@ -137,6 +139,25 @@ sealed class NotesWindow : Windowreturn new Border { Background = Palette.AccentPale, CornerRadius = new CornerRadius(12), Padding = new Thickness(14), Margin = new Thickness(12, 0, 12, 8), Child = stack };}+ /// 结束这场会议? (NotesWindow.swift › meetingBar): below the header, away from the 结束 button,+ /// so a double click can't confirm it; no timeout, so it never vanishes under the pointer.+ FrameworkElement ConfirmEnd()+ {+ var stack = Ui.Stack(3, Ui.Text(L("结束这场会议?"), 14, Palette.Ink, FontWeights.Bold), Ui.Text(ConfirmEndDetail(), 12, Palette.Secondary));+ var buttons = Ui.Row(8, Ui.Button(L("继续记录"), app.CancelStop, height: 32),+ Ui.Button(L("结束会议"), () => _ = app.StopListening(), Ui.Kind.Primary, height: 32));+ buttons.Margin = new Thickness(0, 10, 0, 0);+ stack.Children.Add(buttons);+ return new Border { Background = Palette.AccentPale, CornerRadius = new CornerRadius(12), Padding = new Thickness(14), Margin = new Thickness(12, 0, 12, 8), Child = stack };+ }++ string ConfirmEndDetail()+ {+ var s = app.Listen.SessionId is { } id ? app.Store.Get(id) : null;+ return LF("已记录 %@ · %lld 句。结束后停止收听,并整理一份完整版纪要。",+ Languages.Clock(s is null ? 0 : (DateTimeOffset.Now - s.StartedAt).TotalSeconds), s?.Lines.Count ?? 0);+ }+static void Detach(FrameworkElement e) { if (e.Parent is Panel p) p.Children.Remove(e); }void Render()@@ -153,9 +174,9 @@ sealed class NotesWindow : Windowif (key != headerKey) { headerKey = key; header.Content = Header(); }Tick();if (Subtitles) { live.Content = SubtitleLine(); return; }- var ek = app.Listen.Listening && app.Ending is { } p ? p.Reason.ToString() : null;+ var ek = !app.Listen.Listening ? null : app.ConfirmingEnd ? "confirm" : app.Ending is { } p ? p.Reason.ToString() : null;if (ek != endingKey) { endingKey = ek; ending.Content = EndingStrip(); }- var bk = $"{app.Listen.Problem}|{app.Settings.ShowInCapture}|{hiddenFromCapture}";+ var bk = $"{app.Listen.Problem}|{(app.Listen.Listening && app.Notes.Status is NotesEngine.State.Failed or NotesEngine.State.RateLimited ? app.Notes.Status : null)}|{app.Settings.ShowInCapture}|{hiddenFromCapture}";if (bk != barsKey) { barsKey = bk; bars.Content = Bars(); }live.Content = LiveCard();var count = app.Listen.SessionId is { } sid ? app.Store.Get(sid)?.Lines.Count ?? 0 : 0;@@ -195,7 +216,7 @@ sealed class NotesWindow : Window{var buttons = new StackPanel { Orientation = Orientation.Horizontal };buttons.Children.Add(Ui.IconButton(Icons.Notes, L("换成纪要"), () => app.SetView("notes"), Brushes.White, 40, 18, onDark: true));- if (listen.Listening) buttons.Children.Add(Ui.IconButton(Icons.Stop, L("结束"), () => _ = app.StopListening(), new SolidColorBrush(Color.FromRgb(0xFF, 0x9B, 0x78)), 40, 16, fill: true, onDark: true));+ if (listen.Listening) buttons.Children.Add(Ui.IconButton(Icons.Stop, L("结束"), app.RequestStop, new SolidColorBrush(Color.FromRgb(0xFF, 0x9B, 0x78)), 40, 16, fill: true, onDark: true));buttons.Children.Add(Ui.IconButton(Icons.Close, L("收起(继续听)"), Collapse, Brushes.White, 40, 14, onDark: true));return buttons;}@@ -218,7 +239,7 @@ sealed class NotesWindow : Windowvar right = new StackPanel { Orientation = Orientation.Horizontal };right.Children.Add(Ui.IconButton(Icons.Subtitles, L("换成字幕条"), () => app.SetView("subtitles"), Palette.Body, 40, 18));right.Children.Add(listen.Listening- ? Gap(Ui.Button(L("结束"), () => _ = app.StopListening(), Ui.Kind.Pale, Icons.Stop, 36, iconFill: true), 2)+ ? Gap(Ui.Button(L("结束"), app.RequestStop, Ui.Kind.Pale, Icons.Stop, 36, iconFill: true), 2): Gap(Ui.Button(L("开始听"), () => _ = app.ToggleListening(), Ui.Kind.Accent, Icons.Wave, 36), 2));right.Children.Add(Gap(Ui.IconButton(Icons.Close, L("收起(继续听)"), Collapse, Palette.Body, 40, 14), 2));var row = Ui.Spread(left, right);@@ -245,6 +266,17 @@ sealed class NotesWindow : WindowAdd(Ui.InfoBar(Ui.Severity.Error, L("Ling key 无效"), L("去设置里换一个 key。"), Ui.Button(L("打开设置"), app.ShowSettings, height: 32)));break;}+ // The notes' own trouble (NotesWindow.swift › banner): the last round didn't land.+ if (app.Listen.Listening)+ switch (app.Notes.Status)+ {+ case NotesEngine.State.RateLimited:+ Add(Ui.InfoBar(Ui.Severity.Warning, null, LF("请求过于频繁,稍后会自动重试。纪要停留在 %@。", NotesCoveredUntil())));+ break;+ case NotesEngine.State.Failed:+ Add(Ui.InfoBar(Ui.Severity.Warning, null, L("这轮没整理好,下一轮会自动重试。")));+ break;+ }if (app.Settings.ShowInCapture)Add(Ui.InfoBar(Ui.Severity.Warning, null, L("共享屏幕时,对方能看到这个窗口。"),Ui.LinkText(L("改回只有我看得到"), () => app.SetShowInCapture(false))));@@ -253,6 +285,14 @@ sealed class NotesWindow : Windowreturn stack;}+ /// When the last line the notes cover was said, as mm:ss.+ string NotesCoveredUntil()+ {+ var lines = app.Listen.SessionId is { } id ? app.Store.Get(id)?.Lines : null;+ var covered = app.Notes.Notes.Covered;+ return Languages.Clock(lines is not null && covered > 0 && covered <= lines.Count ? lines[covered - 1].T : 0);+ }+/// The newest line: the original small, its translation large, then "在听下一句" while Ming works.FrameworkElement LiveCard(){@@ -310,7 +350,7 @@ sealed class NotesWindow : WindowNotesEngine.State.Updating => (L("正在整理纪要…"), ""),NotesEngine.State.NoKey => (L("生成纪要需要 API key"), ""),NotesEngine.State.InvalidKey => (L("这个 key 无效,请检查是否复制完整,或重新创建一个"), ""),- _ => app.Listen.Listening ? (L("纪要会在开会几分钟后出现"), L("之后每 45 秒更新一次")) : ("", ""),+ _ => app.Listen.Listening ? (L("纪要会在会议进行中自动生成"), "") : ("", ""),};var empty = new StackPanel { HorizontalAlignment = HorizontalAlignment.Center, Margin = new Thickness(0, 48, 0, 0) };if (title.Length > 0) { var t = Ui.Text(title, 14, Palette.Body, FontWeights.SemiBold); t.TextAlignment = TextAlignment.Center; empty.Children.Add(t); }@@ -442,6 +482,20 @@ sealed class NotesWindow : Windowleft.Children.Add(clockText);}var text = new StackPanel { VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(8, 0, 12, 0) };+ // Asked to end: the one time the bar carries buttons, as the panel's card does.+ if (listen.Listening && app.ConfirmingEnd)+ {+ text.Children.Add(Ui.Text(L("结束这场会议?"), 15, Brushes.White, FontWeights.Bold));+ text.Children.Add(Gap(Ui.Text(ConfirmEndDetail(), 12, Palette.NightText), 2, top: true));+ // On the dark bar the ink button would vanish: 结束会议 takes the 结束 button's pale look.+ var buttons = Ui.Row(8, Ui.Button(L("继续记录"), app.CancelStop, height: 32), Ui.Button(L("结束会议"), () => _ = app.StopListening(), Ui.Kind.Pale, Icons.Stop, 32, iconFill: true));+ buttons.Margin = new Thickness(0, 8, 0, 0);+ text.Children.Add(buttons);+ var bar = new DockPanel();+ DockPanel.SetDock(left, Dock.Left);+ bar.Children.Add(left); bar.Children.Add(text);+ return bar;+ }// The subtitle bar has no room for buttons: it says what will happen (the Mac's notice).if (listen.Listening && app.Ending is not null){diff --git a/windows/src/Cicada/Strings/en.lproj/Windows.strings b/windows/src/Cicada/Strings/en.lproj/Windows.stringsindex 58c7aa6..c0855e2 100644--- a/windows/src/Cicada/Strings/en.lproj/Windows.strings+++ b/windows/src/Cicada/Strings/en.lproj/Windows.strings@@ -18,7 +18,6 @@"一段 9 秒的英文会议" = "A 9-second meeting in English";"下载到的安装包和预期的不一样,为了安全没有安装。" = "The downloaded installer didn't match what we expected, so it wasn't installed for your safety.";"下载失败,检查网络后再试。" = "Download failed. Check your connection and try again.";-"之后每 45 秒更新一次" = "Updated every 45 seconds after that";"会议" = "Meeting";"会议记录存放位置" = "Meeting records folder";"共享屏幕时,对方能看到这个窗口。" = "Others can see this window when you share your screen.";@@ -104,7 +103,6 @@"稍后会自动重试。" = "We'll try again automatically in a moment.";"等有人说话" = "Waiting for speech";"系统声音" = "System audio";-"纪要会在开会几分钟后出现" = "Notes will appear a few minutes into the meeting";"纪要停留在 %@。" = "Notes stop at %@.";"纪要和翻译用的模型" = "Model for notes and translation";"纪要整理好了" = "Meeting notes are ready";diff --git a/windows/src/Cicada/Strings/ja.lproj/Windows.strings b/windows/src/Cicada/Strings/ja.lproj/Windows.stringsindex f32084a..ba11b56 100644--- a/windows/src/Cicada/Strings/ja.lproj/Windows.strings+++ b/windows/src/Cicada/Strings/ja.lproj/Windows.strings@@ -18,7 +18,6 @@"一段 9 秒的英文会议" = "9 秒の英語の会議";"下载到的安装包和预期的不一样,为了安全没有安装。" = "ダウンロードしたインストーラーが想定と異なるため、安全のためインストールを中止しました。";"下载失败,检查网络后再试。" = "ダウンロードできませんでした。ネットワークを確認してもう一度お試しください。";-"之后每 45 秒更新一次" = "その後は 45 秒ごとに更新されます";"会议" = "会議";"会议记录存放位置" = "会議の記録の保存先";"共享屏幕时,对方能看到这个窗口。" = "画面共有中、このウィンドウは相手にも見えています。";@@ -104,7 +103,6 @@"稍后会自动重试。" = "しばらくすると自動的に再試行します。";"等有人说话" = "音声を待っています";"系统声音" = "システム音声";-"纪要会在开会几分钟后出现" = "メモは開始から数分後に表示されます";"纪要停留在 %@。" = "メモは %@ までです。";"纪要和翻译用的模型" = "メモと翻訳に使用するモデル";"纪要整理好了" = "メモがまとまりました";diff --git a/windows/src/Cicada/Strings/ko.lproj/Windows.strings b/windows/src/Cicada/Strings/ko.lproj/Windows.stringsindex 2b44731..377985c 100644--- a/windows/src/Cicada/Strings/ko.lproj/Windows.strings+++ b/windows/src/Cicada/Strings/ko.lproj/Windows.strings@@ -18,7 +18,6 @@"一段 9 秒的英文会议" = "9초 분량의 영어 회의";"下载到的安装包和预期的不一样,为了安全没有安装。" = "다운로드한 설치 파일이 예상과 달라 안전을 위해 설치하지 않았습니다.";"下载失败,检查网络后再试。" = "다운로드하지 못했습니다. 네트워크를 확인한 후 다시 시도해 주세요.";-"之后每 45 秒更新一次" = "이후 45초마다 업데이트됩니다";"会议" = "회의";"会议记录存放位置" = "회의 기록 저장 위치";"共享屏幕时,对方能看到这个窗口。" = "화면을 공유할 때 상대방이 이 창을 볼 수 있습니다.";@@ -104,7 +103,6 @@"稍后会自动重试。" = "잠시 후 자동으로 다시 시도합니다.";"等有人说话" = "음성 대기 중";"系统声音" = "시스템 소리";-"纪要会在开会几分钟后出现" = "회의록은 회의 시작 몇 분 후에 나타납니다";"纪要停留在 %@。" = "노트는 %@에서 멈춰 있습니다.";"纪要和翻译用的模型" = "회의록 및 번역 모델";"纪要整理好了" = "회의록 정리 완료";diff --git a/windows/src/Cicada/TrayFlyout.cs b/windows/src/Cicada/TrayFlyout.csindex fabb71c..186da60 100644--- a/windows/src/Cicada/TrayFlyout.cs+++ b/windows/src/Cicada/TrayFlyout.cs@@ -88,7 +88,7 @@ sealed class TrayFlyout : Windowgrid.ColumnDefinitions.Add(new ColumnDefinition());grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(8) });grid.ColumnDefinitions.Add(new ColumnDefinition());- var end = Ui.Button(L("结束"), () => { Hide(); _ = app.StopListening(); }, Ui.Kind.Pale, Icons.Stop, 44, iconFill: true);+ var end = Ui.Button(L("结束"), () => { Hide(); app.RequestStop(); }, Ui.Kind.Pale, Icons.Stop, 44, iconFill: true);var show = Ui.Button(L("显示纪要"), () => { Hide(); app.ShowNotes(); }, Ui.Kind.Standard, Icons.Notes, 44);Grid.SetColumn(show, 2);grid.Children.Add(end); grid.Children.Add(show);diff --git a/windows/tests/Cicada.Tests/Program.cs b/windows/tests/Cicada.Tests/Program.csindex b40a540..c8398bf 100644--- a/windows/tests/Cicada.Tests/Program.cs+++ b/windows/tests/Cicada.Tests/Program.cs@@ -254,6 +254,49 @@ static class TestsCheck(SessionStore.Markdown(s).Split('\n')[0].TrimEnd() == "# 我的会", "the export is headed by the shown title");}+ public static void KeepsTheMacsImportAndRoomFields()+ {+ // A Mac record of an imported room recording, plus a key no version knows yet.+ const string mac = """+ {"endedAt":"2026-01-01T02:10:00Z","futureKey":{"a":[1,2]},"hasAudio":true,"id":"20260101-100000","importing":false,"lines":[],"room":true,"sourceFile":"周会.m4a","sourcePath":"/Users/x/周会.m4a","startedAt":"2026-01-01T02:00:00Z","title":"会议 1月1日 10:00"}+ """;+ var s = Json.Read<Session>(mac)!;+ Equal(true, s.Room, "room");+ Equal("周会.m4a", s.SourceFile, "sourceFile");+ Check(JsonNode.DeepEquals(JsonNode.Parse(mac), JsonNode.Parse(Json.Write(s))), "written back with every key: " + Json.Write(s));+ }++ public static void RenameLikeTheMac()+ {+ var store = new SessionStore();+ var id = store.Begin(DateTimeOffset.Parse("2026-01-02T02:00:00Z")).Id;+ store.Append(id, new TranscriptLine { Id = "h1-1", Src = "hi", SrcLang = "en", DstLang = "zh-CN" });+ store.SetNotes(id, new MeetingNotes { Title = "路线评审", Summary = "x" });+ var shown = SessionStore.DisplayTitle(store.Get(id)!);+ store.Rename(id, " " + shown + " ");+ Equal(null, store.Get(id)!.Renamed, "saving the shown title unchanged isn't a rename");+ store.SetNotes(id, new MeetingNotes { Title = "预算", Summary = "y" });+ Check(SessionStore.DisplayTitle(store.Get(id)!).EndsWith(" 预算"), "so a later name from the notes still shows");+ store.Rename(id, "我的会");+ Equal(true, store.Get(id)!.Renamed, "renamed");+ store.Rename(id, " ");+ Equal(false, store.Get(id)!.Renamed, "an empty title goes back to the automatic one");+ Check(SessionStore.DisplayTitle(store.Get(id)!).EndsWith(" 预算"), "the notes' name again");+ store.Delete(id);+ }++ public static void MeetingCutShortEndsAfterItsLastLine()+ {+ var start = DateTimeOffset.Parse("2026-01-03T02:00:00Z");+ var dir = Path.Combine(Paths.Sessions, "20260103-crash");+ Directory.CreateDirectory(dir);+ var s = new Session { Id = "20260103-crash", Title = "会议", StartedAt = start, Lines = [new() { Id = "h1-1", Src = "a", T = 3 }, new() { Id = "h1-2", Src = "b", T = 70 }] };+ File.WriteAllText(Path.Combine(dir, "session.json"), Json.Write(s));+ var store = new SessionStore();+ Equal(start.AddSeconds(75), store.Get(s.Id)!.EndedAt, "last line + 5 s");+ store.Delete(s.Id);+ }+// MARK: Hearingpublic static void ParsesMingReplies()@@ -411,6 +454,27 @@ static class TestsEqual(2.0, next.Todos[0].T, "to-dos too");}+ public static void NotesAndExportNameSpeakersLikeTheMac()+ {+ // Two voices, five substantive lines each: 说话人 1 (voice 7) and 说话人 2 (voice 9).+ var lines = Enumerable.Range(0, 10).Select(i => new TranscriptLine { Id = $"h{i}-1", T = i * 10, Src = $"we will ship line {i}", Voice = i % 2 == 0 ? 7 : 9, SrcLang = "en", DstLang = "zh-CN" }).ToList();+ var s = new Session { Title = "会议 1月1日 10:00", StartedAt = DateTimeOffset.Now, Lines = lines,+ VoiceNames = new() { ["7"] = "George" }, VoiceGuesses = new() { ["9"] = new VoiceGuess { Name = "Anna" } } };+ var names = SpeakerLabels.Names(s);+ Equal("George,Anna", $"{names[1]},{names[2]}", "the user's name, else Ling's guess");+ var p = NotesEngine.Prompt(new MeetingNotes(), lines, 0, "English", final: true, names);+ Check(p.Contains("[L1 00:00 George]") && p.Contains("[L2 00:10 Anna]"), "named in the notes prompt");+ Check(SessionStore.Markdown(s).Contains("George:"), "and in the export");+ try+ {+ SpeakerLabels.Voices = false;+ Check(NotesEngine.Prompt(new MeetingNotes(), lines, 0, "English", final: true).Contains("[L1 00:00 对方]"), "说话人识别 off: no speakers in the notes");+ var md = SessionStore.Markdown(s);+ Check(!md.Contains("George") && !md.Contains("说话人"), "nor in the export");+ }+ finally { SpeakerLabels.Voices = true; }+ }+public static void NotesPromptIsTheMacs(){var lines = new List<TranscriptLine> { new() { T = 1, Src = "你好", Speaker = "them" }, new() { T = 65, Src = "我来说", Speaker = "me" } };@@ -708,6 +772,28 @@ static class Testsfinally { LingClient.Spacing = old; }}+ public static async Task WhatISayGoesAheadOfTheMeeting()+ {+ var old = LingClient.Spacing;+ LingClient.Spacing = 0.2;+ try+ {+ var fake = new Fake(body => body.Contains(LingClient.AudioModel)+ ? Reply("LANG: zh-CN\nORIGINAL: 好的\nTRANSLATION: OK")+ : body.Contains(LingClient.VoiceModel) ? new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent("data:{\"type\":\"speech.audio.done\"}\n\n") } : Reply("ok"));+ var ling = Client(fake);+ var first = ling.Chat("meeting 1", "i", Priority.Translate);+ await Task.Delay(20);+ var queued = ling.Chat("meeting 2", "i", Priority.Translate);+ await Task.Delay(20);+ var said = Speaker(ling, new NoVoice(), new AppSettings { SpeakFrom = "zh-CN" }).Speak(Wav.Bytes(Tone(1)), new Sink());+ await Task.WhenAll(first, queued, (Task)said);+ var order = fake.Calls.Select(c => c.body.Contains(LingClient.AudioModel) ? "hear" : c.body.Contains("meeting 2") ? "meeting 2" : c.body.Contains("meeting 1") ? "meeting 1" : "other").ToList();+ Equal("meeting 1,hear,meeting 2", string.Join(",", order.Where(o => o != "other")), "my words jump the queue");+ }+ finally { LingClient.Spacing = old; }+ }+public static async Task ListenEngineEndToEndWithAFakeMing(){// Two stretches of "speech", told apart by length (1 s, then 1.6 s); the fake Ming