MCPcopy
hub / github.com/Doorman11991/smallcode / _renderStatus

Method _renderStatus

src/tui/fullscreen.js:601–712  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

599 }
600
601 _renderStatus() {
602 let buf = '';
603 const row = this.height;
604 const t = this.theme;
605
606 buf += ANSI.moveTo(row, 1);
607 buf += t.statusBg;
608
609 // 1. Left: Action/Status
610 let actionStr;
611 if (this.isStreaming) {
612 actionStr = ' Streaming...';
613 } else if (this.statusMsg) {
614 actionStr = ` ${this.statusMsg}`;
615 } else {
616 actionStr = ' enter send │ /help commands';
617 }
618
619 // 2. Middle: Scroll & Token info
620 let scrollStr = this.chatScroll < 0 ? '↑ scrolled' : '';
621 let tokenStr = this.tokenInfo ? `${this.tokenInfo}` : '';
622 let middleStr = '';
623 if (scrollStr && tokenStr) {
624 middleStr = `${scrollStr} │ ${tokenStr}`;
625 } else {
626 middleStr = scrollStr || tokenStr || '';
627 }
628
629 // 3. Right: Brand, Model, and Indicator
630 const modelTrunc = this.model.length > 20 ? this.model.slice(0, 17) + '...' : this.model;
631 const indicatorText = this.isStreaming ? '⟳ streaming' : '● idle';
632 const statusIndicator = this.isStreaming
633 ? t.success + '⟳ streaming' + t.brandDim
634 : t.muted + '● idle' + t.brandDim;
635
636 // Compute raw lengths to adjust layout
637 let rawAction = this._stripAnsi(actionStr);
638 let rawMiddle = this._stripAnsi(middleStr);
639
640 // Dynamically adjust segments based on total terminal width
641 const totalWidth = this.width;
642
643 if (totalWidth < 45) {
644 // Tiny terminal: only left and indicator
645 const rightPart = ` ${indicatorText} `;
646 const maxLeft = Math.max(0, totalWidth - rightPart.length);
647 const leftPart = rawAction.length > maxLeft ? rawAction.slice(0, Math.max(0, maxLeft - 3)) + '...' : rawAction.padEnd(maxLeft);
648
649 const leftColored = (this.isStreaming ? t.success : t.accent) + leftPart + t.brandDim;
650 const rightColored = this.isStreaming ? t.success + rightPart : t.muted + rightPart;
651
652 const lineBuf = leftColored + rightColored;
653 buf += this._truncate(lineBuf, totalWidth) + ANSI.reset;
654 return buf;
655 }
656
657 // Moderate/Large terminal: Left, Middle (if fits), and Right
658 let showMiddle = true;

Callers 2

renderMethod · 0.95
tui_layout.test.jsFile · 0.80

Calls 2

_stripAnsiMethod · 0.95
_truncateMethod · 0.95

Tested by

no test coverage detected