39beccf7f4
Root cause of the "4 people → 2 speakers" Meet call: the colored-border detector
read solid camera-off avatar tiles (orange "J", magenta "G") as active speakers
for the ENTIRE call. Those whole-call phantom spans dominated backend name
attribution, collapsing every remote voice onto one name — and the giant filled
bbox also swallowed screen-share text (WERUNBTC.COM ×49) as a speaker.
Validated against 9 real fixtures (harness over the real MeetAdapter):
Detection:
- FrameSampler.thinColoredPoints: coloured counterpart of thinWhitePoints — keeps
thin border/ring/pill edges, drops solid colour fills.
- GridCallAnalyzer.isHollow: reject a highlight component whose interior is filled
(a solid tile) vs a hollow ring (a real border). Config.maxInteriorFill (0.2 default).
- MeetAdapter: detect thin BLUE edges only (hue 180–240°, measured from the
fixtures), maxInteriorFill 0.3 (real Meet rings ≈0.2–0.3, solid tiles ≈0.36).
- Result on fixtures: John Arnold/Grant Gilliam (solid tiles) now NEVER detected;
Matt Odell/Mark detected when their blue cue is present. Sparse but never wrong —
correct for a naming hint over audio diarization.
OCR name hygiene:
- isLikelyName rejects domain-like screen-share text ("WERUNBTC.COM", OCR'd ".GOM").
- cleaned() strips trailing punctuation ("Mark." → "Mark").
- TimelineBuilder.canonicalizeByFrequency folds rare OCR misspellings into a
dominant near-twin name ("Matt Odel"/"MattOdell" → "Matt Odell", "Mare" → "Mark").
Tests: hollow-ring, extended OCR filter, fuzzy-merge. 65 pass.
89 lines
4.0 KiB
Swift
89 lines
4.0 KiB
Swift
import XCTest
|
|
import CoreGraphics
|
|
@testable import Ten31Transcripts
|
|
|
|
/// Window-selection logic: prefer the exact detected window (e.g. the Meet browser
|
|
/// window) by ID, else fall back to the largest owned window. This is the fix for
|
|
/// the "captures the wrong browser window" data-flow bug.
|
|
final class VisualObserverTests: XCTestCase {
|
|
|
|
private func c(_ id: CGWindowID, _ w: CGFloat, _ h: CGFloat) -> (id: CGWindowID, frame: CGRect) {
|
|
(id, CGRect(x: 0, y: 0, width: w, height: h))
|
|
}
|
|
|
|
func testCanonicalizeFoldsOcrMisspellingsIntoDominantName() {
|
|
func seg(_ s: Double, _ e: Double, _ n: String) -> VisualTimeline.Segment {
|
|
.init(start: s, end: e, name: n, confidence: 0.9, source: "vision")
|
|
}
|
|
let segs = [
|
|
seg(0, 1689, "Matt Odell"), // dominant
|
|
seg(1700, 1702, "Matt Odel"), // OCR typo → fold
|
|
seg(1702, 1702.3, "MattOdell"), // dropped-space typo → fold
|
|
seg(0, 1155, "Mark"), // dominant
|
|
seg(1200, 1201, "Mare"), // OCR typo → fold into Mark
|
|
seg(0, 4, "Sidisel"), // screen junk, no near-twin → kept (dropped later, no voice match)
|
|
]
|
|
let names = Set(TimelineBuilder.canonicalizeByFrequency(segs).map { $0.name })
|
|
XCTAssertTrue(names.contains("Matt Odell"))
|
|
XCTAssertTrue(names.contains("Mark"))
|
|
XCTAssertFalse(names.contains("Matt Odel"))
|
|
XCTAssertFalse(names.contains("MattOdell"))
|
|
XCTAssertFalse(names.contains("Mare"))
|
|
XCTAssertTrue(names.contains("Sidisel"))
|
|
}
|
|
|
|
func testPrefersMatchingWindowIDOverLargest() {
|
|
// The Meet window (id 42) is NOT the largest — must still be chosen by ID.
|
|
let candidates = [c(7, 1600, 1000), c(42, 800, 600), c(9, 1200, 900)]
|
|
let idx = VisualObserver.pickWindowIndex(candidates, preferredID: 42)
|
|
XCTAssertEqual(idx, 1)
|
|
}
|
|
|
|
func testFallsBackToLargestWhenNoPreferredID() {
|
|
let candidates = [c(7, 800, 600), c(9, 1600, 1000), c(11, 1200, 900)]
|
|
let idx = VisualObserver.pickWindowIndex(candidates, preferredID: nil)
|
|
XCTAssertEqual(idx, 1) // the 1600x1000 window
|
|
}
|
|
|
|
func testFallsBackToLargestWhenPreferredIDMissing() {
|
|
let candidates = [c(7, 800, 600), c(9, 1600, 1000)]
|
|
let idx = VisualObserver.pickWindowIndex(candidates, preferredID: 999) // gone
|
|
XCTAssertEqual(idx, 1)
|
|
}
|
|
|
|
func testNilWhenNoCandidates() {
|
|
XCTAssertNil(VisualObserver.pickWindowIndex([], preferredID: 42))
|
|
XCTAssertNil(VisualObserver.pickWindowIndex([], preferredID: nil))
|
|
}
|
|
|
|
// MARK: - Duration clamping (visual_timeline.json internal consistency)
|
|
|
|
func testClampSegmentsToDuration() {
|
|
let segs = [
|
|
VisualTimeline.Segment(start: 1, end: 5, name: "A", confidence: 0.9, source: "vision"),
|
|
VisualTimeline.Segment(start: 8, end: 12, name: "B", confidence: 0.8, source: "vision"), // end past 10
|
|
VisualTimeline.Segment(start: 10.5, end: 11, name: "C", confidence: 0.7, source: "vision"), // fully past → dropped
|
|
]
|
|
let out = VisualCapture.clampSegments(segs, to: 10)
|
|
XCTAssertEqual(out.count, 2)
|
|
XCTAssertEqual(out[0].end, 5, accuracy: 0.001)
|
|
XCTAssertEqual(out[1].end, 10, accuracy: 0.001) // clamped
|
|
XCTAssertFalse(out.contains { $0.name == "C" }) // dropped
|
|
}
|
|
|
|
func testClampGapsToDuration() {
|
|
let gaps = [
|
|
VisualTimeline.Gap(start: 2, end: 4, reason: "minimized"),
|
|
VisualTimeline.Gap(start: 9, end: 13, reason: "minimized"), // clamped to 10
|
|
]
|
|
let out = VisualCapture.clampGaps(gaps, to: 10)
|
|
XCTAssertEqual(out.count, 2)
|
|
XCTAssertEqual(out[1].end, 10, accuracy: 0.001)
|
|
}
|
|
|
|
func testClampPassthroughWhenDurationUnknown() {
|
|
let segs = [VisualTimeline.Segment(start: 1, end: 99, name: "A", confidence: 1, source: "vision")]
|
|
XCTAssertEqual(VisualCapture.clampSegments(segs, to: 0), segs) // no duration → unchanged
|
|
}
|
|
}
|