Skip to content

知了 Cicada · 任何会议和直播的实时字幕、同声传译、AI 会议纪要,Mac、Windows、Linux、Android 免费开源。Live subtitles, interpreting and meeting notes for any call or stream, on Mac, Windows, Linux and Android.

feat: Say how far the notes are behind the meeting, and lay out the live notes window to read more easily

wquguru32319e68bf09
diff --git a/Sources/LiveSubs/NotesViews.swift b/Sources/LiveSubs/NotesViews.swift
index 555f066..e4be49e 100644
--- a/Sources/LiveSubs/NotesViews.swift
+++ b/Sources/LiveSubs/NotesViews.swift
@@ -21,6 +21,8 @@ struct NotesContentView: View {
var coveredUntil: Double?
/// Where the last topic ends when the meeting is over (its last line).
var endedAt: Double?
+ /// Lines heard since `coveredUntil` that the notes don't cover yet (shown under the last topic).
+ var behind = 0
var onJump: (Double) -> Void = { _ in }
var body: some View {
@@ -60,11 +62,13 @@ struct NotesContentView: View {
if document { Divider() }
TopicView(topic: topic,
end: i + 1 < notes.topics.count ? notes.topics[i + 1].start : (live ? nil : endedAt),
- current: live && i == notes.topics.count - 1,
- updating: updating && i == notes.topics.count - 1, fresh: fresh, onJump: onJump)
+ current: live && i == notes.topics.count - 1, fresh: fresh, onJump: onJump)
.padding(.vertical, document ? 14 : 0)
.id(Self.topicID(topic))
}
+ if live, behind > 0, let coveredUntil {
+ NotesBehindRow(after: coveredUntil, lines: behind, onJump: onJump)
+ }
}
}
@@ -312,53 +316,46 @@ private struct TopicView: View {
/// The next topic's start, or the meeting's end; nil while it is still being discussed.
let end: Double?
let current: Bool
- let updating: Bool
let fresh: Set<String>
let onJump: (Double) -> Void
var body: some View {
- VStack(alignment: .leading, spacing: 8) {
- HStack(alignment: .firstTextBaseline, spacing: 10) {
+ VStack(alignment: .leading, spacing: 10) {
+ HStack(alignment: .firstTextBaseline, spacing: 8) {
+ Text(topic.title).font(.system(size: 15, weight: .bold)).fixedSize(horizontal: false, vertical: true)
+ if current { Tag(L("正在讲"), live: true) }
+ if fresh.contains(topic.title) && !current { Tag(L("新"), live: true) }
+ Spacer(minLength: 8)
Button { onJump(topic.start) } label: {
Text(range)
.font(.system(size: 12, weight: current ? .semibold : .regular).monospacedDigit())
.foregroundStyle(current ? Palette.accentInk : Palette.tertiary)
- .frame(width: column, alignment: .leading)
+ .fixedSize()
}
.buttonStyle(.plain).help("看原话")
- Text(topic.title).font(.system(size: 15, weight: .bold))
- if current { Tag(L("正在讲"), live: true) }
- if fresh.contains(topic.title) && !current { Tag(L("新"), live: true) }
}
- VStack(alignment: .leading, spacing: 6) {
- if !topic.summary.isEmpty {
- Text(topic.summary).font(.system(size: 13)).foregroundStyle(Palette.secondary).lineSpacing(2)
- .fixedSize(horizontal: false, vertical: true)
- }
- ForEach(Array(topic.points.enumerated()), id: \.offset) { i, p in
- HStack(alignment: .firstTextBaseline, spacing: 8) {
- Circle().fill(fresh.contains(p) ? Palette.accent : Palette.ink.opacity(0.55)).frame(width: 4, height: 4)
- .alignmentGuide(.firstTextBaseline) { $0[.bottom] + 4 }
- Text(p).font(.system(size: 14)).lineSpacing(2).textSelection(.enabled)
- .fixedSize(horizontal: false, vertical: true)
- if fresh.contains(p) { Tag(L("新"), live: true) }
- Spacer(minLength: 4)
- if let t = topic.pointTime(i) { TimeLink(text: NotesEngine.clock(t), t: t, onJump: onJump) }
- }
- .modifier(FadeIn(active: fresh.contains(p)))
- }
- if let fish = topic.fishbone { FishboneView(fishbone: fish, onJump: onJump).padding(.top, 4) }
- if updating {
- VStack(alignment: .leading, spacing: 7) {
- SkeletonBar(fraction: 0.82, height: 10, warm: true)
- SkeletonBar(fraction: 0.56, height: 10, warm: true)
+ if !topic.summary.isEmpty {
+ Text(topic.summary).font(.system(size: 13)).foregroundStyle(Palette.secondary).lineSpacing(2)
+ .fixedSize(horizontal: false, vertical: true)
+ }
+ // Each point's time and 新 sit on a line above it, so the text keeps the column's whole width.
+ ForEach(Array(topic.points.enumerated()), id: \.offset) { i, p in
+ VStack(alignment: .leading, spacing: 3) {
+ if topic.pointTime(i) != nil || fresh.contains(p) {
+ HStack(spacing: 6) {
+ if let t = topic.pointTime(i) { TimeLink(text: NotesEngine.clock(t), t: t, onJump: onJump) }
+ if fresh.contains(p) { Tag(L("新"), live: true) }
+ }
}
- .padding(.top, 2)
+ Text(p).font(.system(size: 14)).lineSpacing(2).textSelection(.enabled)
+ .fixedSize(horizontal: false, vertical: true)
+ .frame(maxWidth: .infinity, alignment: .leading)
}
+ .modifier(FadeIn(active: fresh.contains(p)))
}
- .padding(.leading, column + 10)
+ if let fish = topic.fishbone { FishboneView(fishbone: fish, onJump: onJump).padding(.top, 4) }
}
- .padding(.vertical, current ? 10 : 0).padding(.horizontal, current ? 10 : 0)
+ .padding(.vertical, current ? 12 : 0).padding(.horizontal, current ? 12 : 0)
.background(RoundedRectangle(cornerRadius: 14).fill(current ? Palette.accentWash : .clear))
}
@@ -368,8 +365,33 @@ private struct TopicView: View {
guard let end, end > topic.start + 1 else { return current ? L("\(from) 起") : from }
return "\(from)–\(NotesEngine.clock(end))"
}
+}
- private var column: CGFloat { (end ?? topic.start) >= 3600 ? 104 : 76 }
+/// Under the last topic while the notes are behind the meeting: how much isn't in them yet, and a
+/// way to read it in the transcript meanwhile.
+struct NotesBehindRow: View {
+ let after: Double
+ let lines: Int
+ let onJump: (Double) -> Void
+
+ var body: some View {
+ Button { onJump(after) } label: {
+ VStack(alignment: .leading, spacing: 3) {
+ HStack(spacing: 8) {
+ LiveDot()
+ Text("\(NotesEngine.clock(after)) 之后的 \(lines) 句还在整理").font(.system(size: 13, weight: .semibold))
+ .fixedSize(horizontal: false, vertical: true)
+ }
+ Text("先看原话 →").font(.system(size: 12))
+ }
+ .foregroundStyle(Palette.accentInk)
+ .padding(.horizontal, 14).padding(.vertical, 11)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .overlay(RoundedRectangle(cornerRadius: 12).strokeBorder(Palette.accent.opacity(0.45), style: StrokeStyle(lineWidth: 1, dash: [4, 3])))
+ .contentShape(Rectangle())
+ }
+ .buttonStyle(.plain)
+ }
}
/// A small time that jumps to that moment in the transcript.
@@ -484,7 +506,7 @@ enum UserScroll {
/// newest line; scrolling up pauses that and collects new lines into a "↓ N 句新内容" button.
/// A search highlights matches in place instead of hiding the lines around them.
///
-/// Every row is its own lazy child (a topic's card is drawn a row at a time, `cardSlice`), so a long
+/// Every paragraph is its own lazy child, so a long
/// meeting lays out only what is on screen. What is being said right now is `partial`, a view that
/// watches the speech itself: with `.equatable()` a new word redraws that row, not the list.
struct TranscriptListView<Partial: View>: View, Equatable {
@@ -538,14 +560,14 @@ struct TranscriptListView<Partial: View>: View, Equatable {
return out
}
- /// One lazy child: a topic's title, or one line of its card.
+ /// One lazy child: a topic's title, or a paragraph (one person's lines close together).
private enum Item: Identifiable {
case header(title: String, start: Double, gap: Bool)
- case line(TranscriptLine, first: Bool, last: Bool, label: Bool, gap: Bool)
+ case paragraph([TranscriptLine], label: Bool)
var id: String {
switch self {
case .header(_, let start, _): "group-\(start)"
- case .line(let l, _, _, _, _): l.id
+ case .paragraph(let ls, _): ls[0].id
}
}
}
@@ -556,21 +578,19 @@ struct TranscriptListView<Partial: View>: View, Equatable {
var out: [Item] = []
for (gi, g) in gs.enumerated() {
if !g.title.isEmpty { out.append(.header(title: g.title, start: g.start, gap: gi > 0)) }
- for (i, l) in g.lines.enumerated() {
- // The line being spoken closes the last card when it shows.
- let last = i == g.lines.count - 1 && !(gi == gs.count - 1 && partialShown)
+ for (i, p) in TranscriptParagraphs.group(g.lines, speakers).enumerated() {
// With voices told apart, a name only where the speaker changes (and atop each topic).
- out.append(.line(l, first: i == 0, last: last, label: speakers.isEmpty || i == 0 || starts.contains(l.id),
- gap: gi > 0 && i == 0 && g.title.isEmpty))
+ // Every paragraph carries its name when voices are on: it is also where it's corrected.
+ out.append(.paragraph(p, label: speakers.isEmpty || !voices.isEmpty || i == 0 || starts.contains(p[0].id)))
}
}
return out
}
- private struct Edge: Equatable {
- var distance: CGFloat
- var height: CGFloat
- var container: CGFloat
+ /// The scroll target for a line: the paragraph it is in.
+ private func target(_ line: TranscriptLine) -> String {
+ for item in items { if case .paragraph(let ls, _) = item, ls.contains(where: { $0.id == line.id }) { return item.id } }
+ return line.id
}
var body: some View {
@@ -584,22 +604,12 @@ struct TranscriptListView<Partial: View>: View, Equatable {
Text("\(NotesEngine.clock(start)) · \(title)")
.font(.system(size: 13, weight: .bold)).foregroundStyle(Palette.secondary)
.padding(.top, gap ? 16 : 6).padding(.bottom, 10)
- case .line(let l, let first, let last, let label, let gap):
- VStack(alignment: .leading, spacing: 0) {
- row(l, label: label)
- if !last { Divider() }
- }
- .cardSlice(first: first, last: last)
- .padding(.top, gap ? 10 : 0)
+ case .paragraph(let ls, let label):
+ row(ls, label: label).padding(.bottom, 4)
}
}
if partialShown {
- VStack(alignment: .leading, spacing: 0) {
- if !lines.isEmpty { Divider() }
- partial
- }
- .cardSlice(first: lines.isEmpty, last: true)
- .id("partial")
+ partial.id("partial")
}
if lines.isEmpty && !partialShown {
if live {
@@ -611,12 +621,10 @@ struct TranscriptListView<Partial: View>: View, Equatable {
}
Color.clear.frame(height: 1).id("bottom")
}
- .padding(.bottom, 12)
+ .padding(.top, 8).padding(.bottom, 12)
}
- .onScrollGeometryChange(for: Edge.self) { g in
- Edge(distance: g.contentSize.height - g.contentOffset.y - g.containerSize.height,
- height: g.contentSize.height, container: g.containerSize.height)
- } action: { old, new in
+ .topFade()
+ .onScrollEdgeChange { old, new in
if new.height != old.height || new.container != old.container {
// Not only new lines move the bottom: a translation arriving under its line,
// topic headers from a notes update, rows the lazy stack only now measured,
@@ -663,9 +671,10 @@ struct TranscriptListView<Partial: View>: View, Equatable {
/// A row the lazy stack hasn't drawn yet lands where its height was guessed: jump, then settle
/// once it is measured.
private func reveal(_ line: TranscriptLine, anchor: UnitPoint, _ proxy: ScrollViewProxy) {
- proxy.scrollTo(line.id, anchor: anchor)
+ let id = target(line)
+ proxy.scrollTo(id, anchor: anchor)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) {
- withAnimation { proxy.scrollTo(line.id, anchor: anchor) }
+ withAnimation { proxy.scrollTo(id, anchor: anchor) }
}
}
@@ -723,10 +732,13 @@ struct TranscriptListView<Partial: View>: View, Equatable {
return a
}
- private func row(_ l: TranscriptLine, label: Bool = true) -> some View {
- let isMatch = l.id == currentMatch
- let latest = live && l.id == lines.last?.id
- let dim = searching && !matches(l)
+ private func row(_ ls: [TranscriptLine], label: Bool = true) -> some View {
+ let l = ls[0]
+ let isMatch = ls.contains { $0.id == currentMatch }
+ let latest = live && ls.last?.id == lines.last?.id
+ let dim = searching && !ls.contains(where: matches)
+ let src = TranscriptParagraphs.join(ls.map(\.src))
+ let dst = TranscriptParagraphs.join(ls.compactMap { $0.dst != $0.src ? $0.dst : nil })
return HStack(alignment: .top, spacing: 12) {
Text(NotesEngine.clock(l.t)).font(.system(size: 12, weight: isMatch ? .semibold : .regular).monospacedDigit())
.foregroundStyle(latest || isMatch ? Palette.accentInk : Palette.tertiary)
@@ -748,9 +760,9 @@ struct TranscriptListView<Partial: View>: View, Equatable {
}
else if let n = speakers[l.id] { SpeakerTag(number: n) }
else if !speakers.isEmpty { UnknownSpeakerTag() }
- Text(highlighted(l.src, current: isMatch)).font(.system(size: 14)).lineSpacing(2).textSelection(.enabled)
- if bilingual, let d = l.dst, d != l.src {
- Text(highlighted(d, current: isMatch)).font(.system(size: 13)).foregroundStyle(Palette.secondary)
+ Text(highlighted(src, current: isMatch)).font(.system(size: 14)).lineSpacing(2).textSelection(.enabled)
+ if bilingual, !dst.isEmpty {
+ Text(highlighted(dst, current: isMatch)).font(.system(size: 13)).foregroundStyle(Palette.secondary)
.lineSpacing(2).textSelection(.enabled)
}
if assigning == l.id, let onAssign {
@@ -764,8 +776,12 @@ struct TranscriptListView<Partial: View>: View, Equatable {
}
Spacer(minLength: 0)
}
- .padding(.horizontal, 14).padding(.vertical, 11)
- .background(latest || isMatch ? Palette.accentWash : Color.clear)
+ .padding(.horizontal, 12).padding(.vertical, 9)
+ .background(RoundedRectangle(cornerRadius: 10).fill(
+ assigning == l.id ? Palette.fill
+ : latest || isMatch ? Palette.accentWash
+ : marked != nil && ls.contains(where: { $0.voice == marked }) ? SpeakerColor.ink(voices[marked!] ?? 1).opacity(0.07)
+ : Color.clear))
.opacity(dim ? 0.5 : 1)
}
@@ -850,28 +866,22 @@ struct LivePartialRow: View {
}
Spacer(minLength: 0)
}
- .padding(.horizontal, 14).padding(.vertical, 11)
- .background(Palette.accentWash)
+ .padding(.horizontal, 12).padding(.vertical, 9)
}
}
}
extension View {
- /// One row of a `FramedList` card, drawn on its own so a long card can be lazy: the outline's
- /// top and rounded corners on the first row, its bottom on the last, only the sides between.
- func cardSlice(first: Bool, last: Bool) -> some View {
- let r: CGFloat = 16
- let shape = UnevenRoundedRectangle(topLeadingRadius: first ? r : 0, bottomLeadingRadius: last ? r : 0,
- bottomTrailingRadius: last ? r : 0, topTrailingRadius: first ? r : 0)
- return frame(maxWidth: .infinity, alignment: .leading)
- .clipShape(shape)
- .overlay {
- // Edges between rows are pushed outside the row and masked away; the sides stay whole.
- shape.stroke(Palette.line, lineWidth: 1)
- .padding(.top, first ? 0 : -2).padding(.bottom, last ? 0 : -2)
- .mask { Rectangle().padding(.horizontal, -2).padding(.top, first ? -2 : 0).padding(.bottom, last ? -2 : 0) }
+ /// A scroll view's top edge fades to white, so a line scrolled half out of view doesn't look cut off.
+ func topFade(_ height: CGFloat = 24) -> some View {
+ mask {
+ VStack(spacing: 0) {
+ LinearGradient(colors: [.clear, .black], startPoint: .top, endPoint: .bottom).frame(height: height)
+ Color.black
}
+ }
}
+
}
/// The transcript before anyone has spoken: the start mark, two rows in the bilingual shape
@@ -1280,21 +1290,6 @@ struct NotesGeneratingView: View {
}
}
-/// "正在更新" pill in the header while notes that already exist are being updated.
-struct UpdatingPill: View {
- var body: some View {
- HStack(spacing: 7) {
- Spinner(size: 12, track: Color(red: 0.965, green: 0.847, blue: 0.796))
- Text("正在更新").font(.system(size: 12, weight: .semibold))
- }
- .foregroundStyle(Palette.accentInk)
- .padding(.horizontal, 11).padding(.vertical, 6)
- .background(Capsule().fill(Palette.accentPale))
- .fixedSize()
- }
-}
-
-/// A point that just arrived fades in from slightly below.
struct FadeIn: ViewModifier {
let active: Bool
@State private var shown = false
diff --git a/Sources/LiveSubs/NotesWindow.swift b/Sources/LiveSubs/NotesWindow.swift
index a95edb1..49dc223 100644
--- a/Sources/LiveSubs/NotesWindow.swift
+++ b/Sources/LiveSubs/NotesWindow.swift
@@ -190,6 +190,9 @@ struct NotesWindowView: View {
header(wide: geo.size.width >= 760)
meetingBar.padding(.horizontal, 24).padding(.bottom, 4)
banner.padding(.horizontal, 24).padding(.bottom, 4)
+ if live { LanguageNotice(model: model).padding(.horizontal, 24).padding(.bottom, 8) }
+ // Where the scrolling starts: a hairline, and each column fades in under it (`topFade`).
+ Rectangle().fill(MainWindowView.hairline).frame(height: 1)
if geo.size.width >= 760 {
HStack(alignment: .top, spacing: 0) {
notesPane.frame(maxWidth: .infinity)
@@ -273,11 +276,7 @@ struct NotesWindowView: View {
Text(live || session == nil ? L("实时纪要") : L("会议纪要")).font(.system(size: 24, weight: .bold))
.lineLimit(1).minimumScaleFactor(0.75)
Spacer(minLength: 8)
- if engine.state == .updating, !engine.notes.isEmpty {
- UpdatingPill().padding(.trailing, 4)
- }
if live {
- languageChip.padding(.trailing, 2)
Button(action: askToEnd) {
Text("结束").font(.system(size: 12, weight: .semibold)).foregroundStyle(Palette.ink)
.padding(.horizontal, 12).frame(height: 28)
@@ -291,15 +290,29 @@ struct NotesWindowView: View {
}
iconButton("minus", help: L("收成小卡")) { collapse() }
}
- HStack(spacing: 6) {
- if live { LiveDot() }
- Text(statusLine).font(.system(size: 12)).foregroundStyle(Palette.tertiary).lineLimit(2)
- .fixedSize(horizontal: false, vertical: true)
- // Apart on the right, so turning it on or off doesn't move the text.
+ // State lives here, not in buttons beside 结束: the meeting's languages as a text link
+ // and a small spinner while the notes are being written. The sharing mark sits apart on
+ // the right, so turning it on or off doesn't move the text.
+ HStack(alignment: .top, spacing: 6) {
+ FlowLayout(spacing: 6) {
+ if live { LiveDot().frame(height: 22) }
+ Text(statusLine).font(.system(size: 12)).foregroundStyle(Palette.tertiary).frame(height: 22)
+ if live {
+ dotSeparator
+ languageLink
+ }
+ if live, engine.state == .updating, !engine.notes.isEmpty {
+ dotSeparator
+ HStack(spacing: 5) {
+ Spinner(size: 10)
+ Text("整理中").font(.system(size: 12)).foregroundStyle(Palette.tertiary)
+ }
+ .frame(height: 22)
+ }
+ }
Spacer(minLength: 0)
capturableBadge
}
- .frame(minHeight: 22)
}
if !wide {
HStack(spacing: 0) {
@@ -426,7 +439,6 @@ struct NotesWindowView: View {
if live {
var parts = [(heard == 0 ? L("正在听 · ") : L("正在记录 · ")) + NotesEngine.clock(elapsed)]
if heard > 0 { parts.append(L("\(heard) 句")) }
- if !engine.notes.isEmpty, lastCovered > 0 { parts.append(L("纪要已更新至 \(NotesEngine.clock(lastCovered))")) }
return parts.joined(separator: " · ")
}
let clock = session.map { L("已结束 · ") + TranscriptExport.header($0) } ?? L("没有在记录")
@@ -440,23 +452,22 @@ struct NotesWindowView: View {
/// "EN → 中": what the meeting speaks → what the notes are written in. Opens this meeting's
/// choices below the header (not a popover: the panel never activates the app, and a popover in
/// an inactive app closes as soon as it opens); the defaults live in 设置 › 语言.
- private var languageChip: some View {
+ private var languageLink: some View {
let id = session?.id ?? ""
- let from = model.meetingLanguage(store.liveID).map(Self.short) ?? L("自动")
+ let from = model.meetingLanguage(store.liveID).map(targetName) ?? L("自动")
return Button { languageOpen.toggle() } label: {
- HStack(spacing: 4) {
- Text(from)
- Image(systemName: "arrow.right").font(.system(size: 9, weight: .bold))
- Text(Self.short(model.notesLanguageCode(id)))
- }
- .font(.system(size: 12, weight: .semibold)).foregroundStyle(Palette.accentInk)
- .padding(.horizontal, 9).frame(height: 28)
- .background(RoundedRectangle(cornerRadius: 7).fill(Palette.accentPale))
- .contentShape(Rectangle())
+ Text("\(from) → \(targetName(model.notesLanguageCode(id)))")
+ .font(.system(size: 12)).foregroundStyle(Palette.secondary)
+ .underline(color: Palette.line)
+ .frame(height: 22).contentShape(Rectangle())
}
.buttonStyle(.plain).help("这场会议的语言").accessibilityLabel(L("这场会议的语言"))
}
+ private var dotSeparator: some View {
+ Text("·").font(.system(size: 12)).foregroundStyle(Palette.tertiary).frame(height: 22)
+ }
+
private func languageCard(_ id: String) -> some View {
let source = model.meetingLanguage(store.liveID)
let mine = settings.myLanguage
@@ -496,16 +507,6 @@ struct NotesWindowView: View {
.foregroundStyle(Palette.ink)
}
- static func short(_ code: String) -> String {
- switch code {
- case "zh-CN": L("中")
- case "zh-TW": L("繁")
- case "ja": L("日")
- case "ko": L("韩")
- default: code.prefix(2).uppercased()
- }
- }
-
// MARK: Ending a meeting
/// Nothing heard yet: there is nothing to lose, stop at once. Otherwise ask first, below the
@@ -603,6 +604,13 @@ struct NotesWindowView: View {
}
}
+ /// Lines the notes don't cover yet, once they are two minutes behind the meeting (between
+ /// ordinary 45 s updates there is always a little that isn't in yet).
+ private var behind: Int {
+ guard live, let s = session, lastCovered > 0, elapsed - lastCovered >= 120 else { return 0 }
+ return max(0, s.lines.count - engine.notes.covered)
+ }
+
private var lastCovered: Double {
guard let s = session, engine.notes.covered > 0, engine.notes.covered <= s.lines.count else { return 0 }
return s.lines[engine.notes.covered - 1].t
@@ -687,10 +695,12 @@ struct NotesWindowView: View {
summaryJustChanged: engine.summaryChangedAt.map { now.timeIntervalSince($0) < 20 } ?? false,
coveredUntil: lastCovered > 0 ? lastCovered : nil,
endedAt: session?.lines.last?.t,
+ behind: behind,
onJump: { t in jumpTo = t; tab = "transcript" })
- .padding(.horizontal, 24).padding(.vertical, 12)
+ .padding(.horizontal, 24).padding(.top, 16).padding(.bottom, 12)
}
- .onScrollGeometryChange(for: CGFloat.self) { $0.contentOffset.y } action: { _, _ in
+ .topFade()
+ .onScrolled {
if UserScroll.recent { notesScrolledAt = Date() }
}
// Each live update lands on the topic being discussed now, which is the last one and
diff --git a/Tests/LiveSubsTests/NotesWindowTests.swift b/Tests/LiveSubsTests/NotesWindowTests.swift
new file mode 100644
index 0000000..988c796
--- /dev/null
+++ b/Tests/LiveSubsTests/NotesWindowTests.swift
@@ -0,0 +1,44 @@
+import Foundation
+import Testing
+@testable import LiveSubs
+
+@Suite struct NotesWindowTests {
+ private func line(_ id: String, _ t: Double, _ speaker: String = "them", _ src: String = "a line") -> TranscriptLine {
+ TranscriptLine(id: id, t: t, speaker: speaker, src: src, dst: nil, srcLang: "en", dstLang: "zh-CN")
+ }
+
+ @Test func paragraphsKeepOnePersonWithinThirtySeconds() {
+ let lines = [line("a", 0), line("b", 10), line("c", 29), line("d", 31), line("e", 32, "me"), line("f", 33)]
+ let groups = TranscriptParagraphs.group(lines, ["a": 1, "b": 1, "c": 1, "d": 1, "f": 1])
+ // a–c within 30 s of a; d starts a new one; 你 breaks the run; f is a new paragraph after it.
+ #expect(groups.map { $0.map(\.id) } == [["a", "b", "c"], ["d"], ["e"], ["f"]])
+ }
+
+ @Test func paragraphsSplitBetweenSpeakers() {
+ let lines = [line("a", 0), line("b", 2), line("c", 4)]
+ let groups = TranscriptParagraphs.group(lines, ["a": 1, "b": 2, "c": 2])
+ #expect(groups.map { $0.map(\.id) } == [["a"], ["b", "c"]])
+ }
+
+ @Test func joinSpacesWordsNotChinese() {
+ #expect(TranscriptParagraphs.join(["Hello.", " World. "]) == "Hello. World.")
+ #expect(TranscriptParagraphs.join(["你好。", "再见。"]) == "你好。再见。")
+ #expect(TranscriptParagraphs.join(["", "Only"]) == "Only")
+ }
+
+ @Test func notesShowNamesGivenSince() {
+ var n = MeetingNotes()
+ n.summary = "说话人1和说话人 12 讨论,说话人 2 没说话"
+ n.todos = [NoteItem(text: "说话人 1 跟进", owner: "说话人1", support: 1)]
+ let shown = SpeakerLabels.named(n, [1: "David", 12: "Kenji"])
+ #expect(shown.summary == "David和Kenji 讨论,说话人 2 没说话")
+ #expect(shown.todos[0].text == "David 跟进")
+ #expect(shown.todos[0].owner == "David")
+ }
+
+ @Test func peopleComeFromRoles() {
+ let terms = [NoteTerm(name: "Wai Alamed", note: "BGN 集团首席运营官", heard: []),
+ NoteTerm(name: "ADNOC", note: "阿布扎比国家石油公司", heard: [])]
+ #expect(NoteTerm.people(terms) == ["Wai Alamed"])
+ }
+}
diff --git a/tools/README.md b/tools/README.md
index 2d1abe5..7d2a331 100644
--- a/tools/README.md
+++ b/tools/README.md
@@ -24,7 +24,7 @@
- 显示与字幕:`display:<notes|bar|none>`、`subtitles:<both|translation|original>`、`meetingSubtitles:<…>`、`overlayState`、`overlayToggle`、`pillClick`(等于点主窗口顶部的“正在听”)、`overlayAuto[:off]`、`hideAfter:<秒>`
- 纪要:`notesLang:<mine|source>`、`meetingNotesLang:<…>`、`notesRegenerate:<id>=<mine|source>`、`notesWindow[:x,y,w,h]`、`notesClose`、`notesMinimize`、`notesFrame`、`notesNow`、`notesState`、`notesShow:<id>`、`notesReplay:<id>`、`notesCapturable[:off]`(只改窗口能否被截屏)、`notesShare:<on|off>`(改“共享屏幕时让对方看到”这个设置,等于点图标或开关)
- 结束会议:`endSim:<应用名>[,…]` 假装这些会议应用在通话(`endSim:` 全部挂断,`endSim:off` 回到真实情况),`endTimes:<静默秒>,<倒计时秒>,<挂断宽限秒>` 缩短等待(`endTimes:` 回到设置),`endKeep` 等于点“继续记录”,`endState` 写进日志
- - 渲染(不需要录屏权限):`panelRender:<png>`(菜单栏面板,离屏画)、`windowsRender:<目录>`、`settingsRender:<栏目>=<png>`、`notesRender:<png>`、`mainShow:<id>[,transcript]`、`mainRender:<png>`、`speakTestRender:<png>`
+ - 渲染(不需要录屏权限):`panelRender:<png>`(菜单栏面板,离屏画)、`windowsRender:<目录>`、`settingsRender:<栏目>=<png>`、`notesRender:<png>`、`mainShow:<id>[,transcript]`、`mainWindow:x,y,宽,高`(摆好主窗口并暂时浮在最上层,方便模拟点击;不带参数恢复)、`mainRender:<png>`、`speakTestRender:<png>`
- AI:`aiKeyFile:<路径>`(从 0600 文件读 key,不经过日志;测完就删掉文件)、`aiCheck`、`aiRemove`、`aiHide:<on|off>`(只在内存里当作没有 key,文件不动;用于截图)、`aiState`、`lingSimulate:<429|hijack|timeout|off>`、`translateFail:<n>`(接下来 n 句在所有翻译来源都失败,用来测重试)
- 声音:`voice:<语言>[=<id>]`、`voicePreview:<语言>=<id>`、`voiceCloneFile:<wav>`、`voicePicker:<on|off>`
- 诊断:`diagnostics:<on|off>`、`diagReport`