native macOS codings agent orchestrator
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore(terminal): drop CommandDetect verification logging

The detector's [live]/[immediate]/[skip]/[done] log lines served
their purpose during the title-pattern shakeout and would just be
noise for everyone else. Removes the dedicated logger, the log-only
local variables (durationMs / parked / candidate / surface tags /
elapsedMs / iconSummary), and the `iconLogTag` helper. The two icon
appliers now return Void; `noteCommandFinishedForCommandDetection`
no longer needs the surrounding tabId lookup.

onevcat 5e526b1c 75a8531a

+17 -97
+17 -97
supacode/Features/Terminal/Models/WorktreeTerminalState.swift
··· 6 6 import Sharing 7 7 8 8 private let terminalStateLogger = SupaLogger("TerminalState") 9 - private let commandDetectLogger = SupaLogger("CommandDetect") 10 9 11 10 @MainActor 12 11 @Observable ··· 1418 1417 continuation.finish() 1419 1418 } 1420 1419 1421 - if let tabId = tabId(containing: surfaceId) { 1422 - noteCommandFinishedForCommandDetection( 1423 - durationNs: durationNs, 1424 - surfaceId: surfaceId, 1425 - tabId: tabId 1426 - ) 1427 - } 1420 + noteCommandFinishedForCommandDetection(surfaceId: surfaceId) 1428 1421 1429 1422 // Custom command success toast. One-shot: removed regardless of outcome. 1430 1423 if let commandName = pendingCustomCommands.removeValue(forKey: surfaceId), exitCode == 0 { ··· 1505 1498 // and they bypass the per-cycle `reportedRunning` guard so they 1506 1499 // can refine an icon already set by the initial command name. 1507 1500 if let immediateIcon = CommandIconMap.iconForSubstring(title) { 1508 - let summary = applyResolvedIcon(immediateIcon, surfaceId: surfaceId, tabId: tabId) 1509 - let surfaceTag = surfaceId.uuidString.prefix(8) 1510 - let tabTag = tabId.rawValue.uuidString.prefix(8) 1511 - commandDetectLogger.info( 1512 - "[immediate] tui title matched: title=\"\(title)\" " 1513 - + "tab=\(tabTag) surface=\(surfaceTag) \(summary)" 1514 - ) 1501 + applyResolvedIcon(immediateIcon, surfaceId: surfaceId, tabId: tabId) 1515 1502 return 1516 1503 } 1517 1504 // Decide whether this title should arm a debounce timer. Skip when: ··· 1549 1536 ) 1550 1537 } 1551 1538 1552 - func noteCommandFinishedForCommandDetection( 1553 - durationNs: UInt64, 1554 - surfaceId: UUID, 1555 - tabId: TerminalTabID 1556 - ) { 1557 - let durationMs = Int(durationNs / 1_000_000) 1558 - // Prefer the parked previous candidate (the `preexec`-set command 1559 - // title) over the live one, which `precmd` will already have 1560 - // rewritten to the idle prompt by the time this event lands. 1561 - let parked = lastObservedTitleBySurface.removeValue(forKey: surfaceId) 1562 - let candidate = commandDetectorPendingBySurface[surfaceId] 1563 - let resolvedTitle = parked ?? candidate?.title 1539 + func noteCommandFinishedForCommandDetection(surfaceId: UUID) { 1540 + // Drop transient pending/parked state, reset the per-cycle 1541 + // "already reported" guard, and arm the idle-prompt learner so 1542 + // the next title (the precmd-set prompt) gets memorised. 1564 1543 cancelCommandDetectionTimer(forSurfaceId: surfaceId) 1565 - // Reset the per-cycle "already reported" guard, and arm the 1566 - // idle-prompt learner so the next title (the precmd-set prompt) 1567 - // gets memorised. 1568 1544 reportedRunningCommandBySurface.removeValue(forKey: surfaceId) 1569 1545 awaitingIdleTitleLearningBySurface.insert(surfaceId) 1570 - let surfaceTag = surfaceId.uuidString.prefix(8) 1571 - let tabTag = tabId.rawValue.uuidString.prefix(8) 1572 - if durationMs >= Self.commandDetectThresholdMs { 1573 - let title = resolvedTitle ?? "<title not captured>" 1574 - commandDetectLogger.info( 1575 - "[done] long-running cmd: title=\"\(title)\" duration=\(durationMs)ms " 1576 - + "tab=\(tabTag) surface=\(surfaceTag)" 1577 - ) 1578 - } else if let resolvedTitle { 1579 - commandDetectLogger.debug( 1580 - "[skip] short cmd: title=\"\(resolvedTitle)\" duration=\(durationMs)ms " 1581 - + "tab=\(tabTag) surface=\(surfaceTag)" 1582 - ) 1583 - } 1584 1546 } 1585 1547 1586 1548 /// Cancel the in-flight debounce timer and discard the transient ··· 1627 1589 1628 1590 private func commandDetectionTimerFired(forSurfaceId surfaceId: UUID, tabId: TerminalTabID) { 1629 1591 guard let pending = commandDetectorPendingBySurface[surfaceId] else { return } 1630 - let parts = (ContinuousClock.now - pending.startedAt).components 1631 - let elapsedMs = Int(parts.seconds * 1000 + parts.attoseconds / 1_000_000_000_000_000) 1632 1592 // Mark this command as already reported so subsequent title 1633 1593 // mutations within the same run (claude's spinner, vim's mode 1634 - // line, …) don't fire additional `[live]` entries until 1594 + // line, …) don't fire additional debounce passes until 1635 1595 // `command_finished` clears the guard. 1636 1596 reportedRunningCommandBySurface[surfaceId] = pending.title 1637 - let iconSummary = applyDetectedIcon(forCommand: pending.title, surfaceId: surfaceId, tabId: tabId) 1638 - let surfaceTag = surfaceId.uuidString.prefix(8) 1639 - let tabTag = tabId.rawValue.uuidString.prefix(8) 1640 - commandDetectLogger.info( 1641 - "[live] running cmd detected: title=\"\(pending.title)\" elapsed=\(elapsedMs)ms " 1642 - + "tab=\(tabTag) surface=\(surfaceTag) \(iconSummary)" 1643 - ) 1644 - } 1645 - 1646 - /// Side-effect of `[live]` detection: apply the icon picked by 1647 - /// first-token mapping. Selection-2 semantics — the icon stays 1648 - /// after the command exits, so the tab carries a long-lived "what 1649 - /// is this for" hint. Returns a short tag string so the log line 1650 - /// can explain *why* (or why not) the icon changed. 1651 - private func applyDetectedIcon( 1652 - forCommand title: String, 1653 - surfaceId: UUID, 1654 - tabId: TerminalTabID 1655 - ) -> String { 1656 - guard let icon = CommandIconMap.iconForFirstToken(title) else { 1657 - return "icon=<no-mapping>" 1597 + if let icon = CommandIconMap.iconForFirstToken(pending.title) { 1598 + applyResolvedIcon(icon, surfaceId: surfaceId, tabId: tabId) 1658 1599 } 1659 - return applyResolvedIcon(icon, surfaceId: surfaceId, tabId: tabId) 1660 1600 } 1661 1601 1662 1602 /// Apply an already-resolved icon to the tab. Shared between the 1663 - /// debounce-driven `[live]` path and the substring-driven 1664 - /// `[immediate]` path so focus / lock / unchanged checks stay in 1665 - /// one place. 1603 + /// debounce-driven first-token path and the substring-driven 1604 + /// immediate path so focus / lock / unchanged checks stay in one 1605 + /// place. 1666 1606 private func applyResolvedIcon( 1667 1607 _ icon: TabIconSource, 1668 1608 surfaceId: UUID, 1669 1609 tabId: TerminalTabID 1670 - ) -> String { 1610 + ) { 1671 1611 // Per-tab UI is single-headed: only the focused surface in a 1672 1612 // multi-split tab gets to drive its tab's icon. Stops a 1673 1613 // background split's command from silently overriding what the 1674 1614 // user is currently looking at. 1675 - guard focusedSurfaceIdByTab[tabId] == surfaceId else { 1676 - return "icon=<not-focused>" 1677 - } 1678 - guard let tab = tabManager.tabs.first(where: { $0.id == tabId }) else { 1679 - return "icon=<tab-missing>" 1680 - } 1681 - if tab.isIconLocked { 1682 - return "icon=<user-locked>" 1683 - } 1615 + guard focusedSurfaceIdByTab[tabId] == surfaceId else { return } 1616 + guard let tab = tabManager.tabs.first(where: { $0.id == tabId }) else { return } 1617 + guard !tab.isIconLocked else { return } 1684 1618 // `tab.icon` storage is the SF Symbol string; the asset variant 1685 1619 // (when set) is the real branding, but rendering hasn't been 1686 1620 // wired yet so we still write the symbol. See `TabIconSource` 1687 1621 // docs for the three-step recipe to enable asset rendering. 1688 1622 let symbol = icon.systemSymbol 1689 - if tab.icon == symbol { 1690 - return iconLogTag(icon: icon, suffix: "(unchanged)") 1691 - } 1623 + guard tab.icon != symbol else { return } 1692 1624 tabManager.updateIcon(tabId, icon: symbol) 1693 - return iconLogTag(icon: icon, suffix: nil) 1694 - } 1695 - 1696 - private func iconLogTag(icon: TabIconSource, suffix: String?) -> String { 1697 - var tag = "icon=sf:\(icon.systemSymbol)" 1698 - if let asset = icon.assetName { 1699 - tag += " (asset:\(asset))" 1700 - } 1701 - if let suffix { 1702 - tag += " \(suffix)" 1703 - } 1704 - return tag 1705 1625 } 1706 1626 1707 1627 static func formatDuration(_ seconds: Int) -> String {