MCPcopy Create free account
hub / github.com/Noumena-Network/code / createBridgeLogger

Function createBridgeLogger

src/bridge/bridgeUI.ts:43–531  ·  view source on GitHub ↗
(options: {
  verbose: boolean
  write?: (s: string) => void
})

Source from the content-addressed store, hash-verified

41}
42
43export function createBridgeLogger(options: {
44 verbose: boolean
45 write?: (s: string) => void
46}): BridgeLogger {
47 const write = options.write ?? ((s: string) => process.stdout.write(s))
48 const verbose = options.verbose
49
50 // Track how many status lines are currently displayed at the bottom
51 let statusLineCount = 0
52
53 // Status state machine
54 let currentState: StatusState = 'idle'
55 let currentStateText = 'Ready'
56 let repoName = ''
57 let branch = ''
58 let debugLogPath = ''
59
60 // Connect URL (built in printBanner with correct base for staging/prod)
61 let connectUrl = ''
62 let cachedIngressUrl = ''
63 let cachedEnvironmentId = ''
64 let activeSessionUrl: string | null = null
65
66 // QR code lines for the current URL
67 let qrLines: string[] = []
68 let qrVisible = false
69
70 // Tool activity for the second status line
71 let lastToolSummary: string | null = null
72 let lastToolTime = 0
73
74 // Session count indicator (shown when multi-session mode is enabled)
75 let sessionActive = 0
76 let sessionMax = 1
77 // Spawn mode shown in the session-count line + gates the `w` hint
78 let spawnModeDisplay: 'same-dir' | 'worktree' | null = null
79 let spawnMode: SpawnMode = 'single-session'
80
81 // Per-session display info for the multi-session bullet list (keyed by compat sessionId)
82 const sessionDisplayInfo = new Map<
83 string,
84 { title?: string; url: string; activity?: SessionActivity }
85 >()
86
87 // Connecting spinner state
88 let connectingTimer: ReturnType<typeof setInterval> | null = null
89 let connectingTick = 0
90
91 /**
92 * Count how many visual terminal rows a string occupies, accounting for
93 * line wrapping. Each `\n` is one row, and content wider than the terminal
94 * wraps to additional rows.
95 */
96 function countVisualLines(text: string): number {
97 // eslint-disable-next-line custom-rules/prefer-use-terminal-size
98 const cols = process.stdout.columns || 80 // non-React CLI context
99 let count = 0
100 // Split on newlines to get logical lines

Callers 1

bridgeMainFunction · 0.85

Calls 1

writeMethod · 0.45

Tested by

no test coverage detected