-
-
Notifications
You must be signed in to change notification settings - Fork 317
refactor: extract live monitoring rendering logic for better code organization #170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Documents the strategy for separating CLI and business logic to improve maintainability and testability
|
Warning Rate limit exceeded@ryoppippi has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 23 minutes and 32 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📥 CommitsReviewing files that changed from the base of the PR and between e83edf84941321e16b2bded608df500e236ac069 and 184a114. 📒 Files selected for processing (1)
WalkthroughThis change refactors live rendering logic for the blocks command by moving all rendering and formatting code from Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI_Command as blocks.live.ts
participant Renderer as _live-rendering.ts
participant Terminal
participant Monitor
User->>CLI_Command: Start live monitoring
CLI_Command->>Terminal: Setup terminal (alternate screen, sync mode)
loop Monitoring Loop
CLI_Command->>Monitor: Fetch active block
alt Active block exists
CLI_Command->>Renderer: renderActiveBlock(terminal, block, config)
Renderer->>Terminal: Draw live dashboard
else No active block
CLI_Command->>Renderer: renderWaitingState(terminal, config, signal)
Renderer->>Terminal: Draw waiting message
end
CLI_Command->>Renderer: delayWithAbort(interval, signal)
end
CLI_Command->>Terminal: Cleanup and restore terminal
Possibly related PRs
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
ccusage-guide | 184a114 | Jun 22 2025, 09:49 PM |
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @ryoppippi, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request undertakes a significant refactoring of the live monitoring functionality. The primary goal is to improve code organization and separation of concerns by extracting all rendering and display logic from the command-line interface (CLI) layer into a dedicated module. This structural change enhances maintainability, testability, and reusability of the display components, all while ensuring no functional changes are introduced to the user experience.
Highlights
- Core Logic Extraction: All live monitoring rendering and display functions have been moved from
src/commands/_blocks.live.tsto a new, dedicated module:src/_live-rendering.ts. - CLI Layer Thinning: The
src/commands/_blocks.live.tsfile has been significantly reduced in size (from ~520 lines to ~95 lines), now serving purely as an orchestration layer for the live monitoring process. - Enhanced Documentation: Technical comments across
src/_consts.tsandsrc/_terminal-utils.tshave been updated to provide clearer explanations of concepts like frame rate limiting, DEC synchronized output mode, and terminal buffering. - Increased Test Coverage: Comprehensive in-source tests have been added for the newly extracted rendering functions, including frame rate limiting, display formatting, and abort signal handling.
- No Functional Impact: This entire refactoring is purely structural; the live monitoring behavior and user experience remain identical to before the changes.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request is a well-executed refactoring that successfully separates rendering logic from command orchestration, significantly improving code organization and testability. The new _live-rendering.ts module is comprehensive and the command file _blocks.live.ts is now much cleaner.
My review focuses on a few areas for further improvement:
- Code Duplication: There are opportunities in
_live-rendering.tsto reduce duplicated code within conditional blocks, which would enhance maintainability. - Code Clarity: Some
try/catchblocks can be simplified for better readability without changing functionality. - UX Regression: A minor regression was found where error messages are no longer colored, for which I've suggested a fix.
Overall, this is a great step forward for the codebase's architecture.
src/_live-rendering.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The catch block contains a redundant conditional check. Both the if branch and the statement following it throw error. This can be simplified by removing the conditional, making the code more concise and easier to read.
catch (error) {
// Re-throw any error to be handled by the caller.
// This includes AbortError for graceful shutdown.
throw error;
}
src/_live-rendering.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/_live-rendering.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a good amount of code duplication in the if/else block for rendering the "Usage" section, depending on whether config.tokenLimit is set. Much of the logic for creating and padding strings is repeated.
This same pattern of duplication also appears in the "Projections" section that follows (lines 326-363).
Refactoring these sections to reduce duplication would improve maintainability. For example, you could define variables like usageBarStr and usageDetails inside the conditional blocks and then use a single set of terminal.write calls outside the conditional.
src/commands/_blocks.live.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message written to the terminal is no longer colored red. The previous implementation used pc.red() to highlight errors, which is a good practice for visibility. This appears to be an unintentional regression from the refactoring.
To restore this, apply the code suggestion below.
terminal.write(pc.red(`Error: ${errorMessage}\n`));Update comments in _consts.ts and _terminal-utils.ts to be more specific and technical: - Frame rate limiting explanation (60fps, flicker prevention) - DEC sync mode details with reference to double-buffering concepts - Terminal buffering and alternate screen functionality clarifications - Remove generic comments, add context for complex technical concepts
Create src/_live-rendering.ts with all rendering logic moved from commands: - Frame rate limiting (shouldRenderFrame, delayWithAbort) - Display rendering (renderActiveBlock, renderWaitingState) - Layout functions (renderLiveDisplay, renderCompactLiveDisplay) - Helper functions (formatTokensShort, DETAIL_COLUMN_WIDTHS) - LiveMonitoringConfig type definition - Comprehensive in-source tests for all core functions This separation improves code organization by moving business logic out of the command layer, making it more testable and reusable.
Simplify commands/_blocks.live.ts by moving all rendering logic to _live-rendering module: - Remove 400+ lines of rendering code (renderLiveDisplay, renderCompactLiveDisplay) - Remove helper functions (formatTokensShort, DETAIL_COLUMN_WIDTHS) - Remove redundant function definitions - Keep only process lifecycle, signal management, and terminal setup - Import all rendering functions from _live-rendering module File reduced from ~520 lines to ~95 lines while maintaining identical behavior. Commands now act as thin orchestration layers, following separation of concerns.
- Simplify error handling by removing redundant try/catch wrappers - Reduce code duplication in usage section rendering with const destructuring - Restore red styling for error messages to maintain consistency - Replace let with const for immutable value assignment All changes maintain existing functionality while improving code clarity and reducing side effects.
- Remove overly complex shouldRenderFrame abstraction - Restore inline frame rate limiting from main branch - Ensure proper 1-second refresh intervals instead of 16ms updates - Remove unused imports and tests for deleted function The refresh interval now works correctly: frame rate limiting prevents excessive rendering while maintaining the configured update interval.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the live monitoring feature to extract rendering logic into a dedicated module, thin out the CLI layer, and improve documentation.
- Extracted display logic from the command file into a new rendering module
- Enhanced and clarified comments around buffering, sync mode, and screen handling
- Updated frame rate limiting comments to reference CPU usage and flicker prevention
Reviewed Changes
Copilot reviewed 3 out of 5 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/_terminal-utils.ts | Clarified buffering and sync-mode comments; adjusted flush logic |
| src/_consts.ts | Updated frame rate limiting comment to note CPU and flicker UX |
| refactoring-plan.txt | Added detailed plan for further file structure refactoring |
Comments suppressed due to low confidence (1)
src/_terminal-utils.ts:101
- Resetting the buffer and disabling buffering state outside the conditional may clear state even when buffering wasn't active. Consider moving these resets inside the
if (this.useBuffering && this.buffer.length > 0)block to avoid unintended state changes.
this.buffer = [];
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (2)
src/_terminal-utils.ts (1)
100-102: Good fix for the buffer clearing issue!Adding buffer clearing and resetting the buffering state after flushing prevents duplicate content issues that were previously identified. This ensures clean state management between render cycles.
src/_live-rendering.ts (1)
213-239: Refactor duplicated rendering logic between usage and projections sections.Both sections follow nearly identical patterns for progress bar creation and detail row formatting. Consider extracting helper functions to reduce duplication and improve maintainability.
Example refactoring approach:
+function renderProgressSection( + terminal: TerminalManager, + config: { + label: string, + icon: string, + value: number, + limit?: number, + barWidth: number, + details: Array<{ label: string, value: string }>, + marginStr: string, + boxWidth: number, + labelWidth: number + } +) { + const percent = config.limit ? (config.value / config.limit) * 100 : 0; + const barColor = percent > 100 ? pc.red : percent > 80 ? pc.yellow : pc.green; + + const progressBar = config.limit + ? createProgressBar(config.value, config.limit, config.barWidth, { + showPercentage: false, + fillChar: barColor('█'), + emptyChar: pc.gray('░'), + leftBracket: '[', + rightBracket: ']', + }) + : `[${pc.green('█'.repeat(Math.floor(config.barWidth * 0.1)))}${pc.gray('░'.repeat(config.barWidth - Math.floor(config.barWidth * 0.1)))}]`; + + // Render progress bar + const labelStr = pc.bold(`${config.icon} ${config.label}`); + const labelWidth = stringWidth(labelStr); + const suffix = config.limit + ? `${percent.toFixed(1).padStart(6)}% (${formatTokensShort(config.value)}/${formatTokensShort(config.limit)})` + : `(${formatTokensShort(config.value)} tokens)`; + + const barStr = `${labelStr}${''.padEnd(Math.max(0, config.labelWidth - labelWidth))} ${progressBar} ${suffix}`; + const barPadded = barStr + ' '.repeat(Math.max(0, config.boxWidth - 3 - stringWidth(barStr))); + terminal.write(`${config.marginStr}│ ${barPadded}│\n`); + + // Render details + renderDetailRow(terminal, config.details, config.marginStr, config.boxWidth); +} -// Usage section rendering (lines 213-239) +renderProgressSection(terminal, { + label: 'USAGE', + icon: '🔥', + value: totalTokens, + limit: config.tokenLimit, + barWidth, + details: [ + { label: 'Tokens', value: `${formatNumber(totalTokens)} (${rateDisplay})` }, + ...(config.tokenLimit ? [{ label: 'Limit', value: `${formatNumber(config.tokenLimit)} tokens` }] : []), + { label: 'Cost', value: formatCurrency(block.costUSD) } + ], + marginStr, + boxWidth, + labelWidth +});This would significantly reduce code duplication and make the rendering logic more maintainable.
Also applies to: 287-324
🧹 Nitpick comments (1)
src/commands/_blocks.live.ts (1)
68-68: Address the efficiency TODO comment.The comment suggests there may be performance issues with
LiveMonitor.getActiveBlock()that require investigation. Consider creating a follow-up issue to profile and optimize this if needed.Would you like me to create an issue to track the performance investigation of
LiveMonitor.getActiveBlock()?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 6dbd5a8 and e83edf84941321e16b2bded608df500e236ac069.
📒 Files selected for processing (5)
refactoring-plan.txt(1 hunks)src/_consts.ts(1 hunks)src/_live-rendering.ts(1 hunks)src/_terminal-utils.ts(4 hunks)src/commands/_blocks.live.ts(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/commands/_blocks.live.ts (2)
src/_live-rendering.ts (3)
delayWithAbort(36-38)renderWaitingState(44-54)renderActiveBlock(60-68)src/_consts.ts (1)
MIN_RENDER_INTERVAL_MS(110-110)
🪛 LanguageTool
refactoring-plan.txt
[style] ~5-~5: As an alternative to the over-used intensifier ‘extremely’, consider replacing this phrase.
Context: ...ile 2. data-loader.ts is 3676 lines - extremely large 3. Live rendering logic is mixed into c...
(EN_WEAK_ADJECTIVE)
[uncategorized] ~6-~6: You might be missing the article “the” here.
Context: ...e 3. Live rendering logic is mixed into command layer 4. Commands should be thin CLI la...
(AI_EN_LECTOR_MISSING_DETERMINER_THE)
[uncategorized] ~7-~7: A period might be missing here.
Context: ...e thin CLI layers, not contain business logic ## Proposed Structure ### Option 1: D...
(AI_EN_LECTOR_MISSING_PUNCTUATION_PERIOD)
[uncategorized] ~60-~60: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ...a.vitest != null)` pattern - Test frame rate limiting logic - Test rendering functions with m...
(EN_COMPOUND_ADJECTIVE_INTERNAL)
🪛 ESLint
src/_terminal-utils.ts
[error] 93-93: Unexpected any value in conditional. An explicit comparison or type conversion is required.
(ts/strict-boolean-expressions)
[error] 93-93: Unsafe member access .isTTY on an error typed value.
(ts/no-unsafe-member-access)
[error] 94-94: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 94-94: Unsafe member access .write on an error typed value.
(ts/no-unsafe-member-access)
[error] 97-97: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 97-97: Unsafe member access .write on an error typed value.
(ts/no-unsafe-member-access)
[error] 110-110: Unexpected any value in conditional. An explicit comparison or type conversion is required.
(ts/strict-boolean-expressions)
[error] 110-110: Unsafe member access .isTTY on an error typed value.
(ts/no-unsafe-member-access)
[error] 111-111: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 111-111: Unsafe member access .write on an error typed value.
(ts/no-unsafe-member-access)
[error] 111-111: Unsafe member access .enterAlternativeScreen on an error typed value.
(ts/no-unsafe-member-access)
[error] 113-113: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 113-113: Unsafe member access .write on an error typed value.
(ts/no-unsafe-member-access)
[error] 166-166: Unsafe return of a value of type error.
(ts/no-unsafe-return)
[error] 166-166: Unsafe member access .isTTY on an error typed value.
(ts/no-unsafe-member-access)
src/commands/_blocks.live.ts
[error] 62-62: Unsafe member access .signal on an error typed value.
(ts/no-unsafe-member-access)
[error] 71-71: Unsafe member access .signal on an error typed value.
(ts/no-unsafe-member-access)
[error] 80-80: Unsafe member access .signal on an error typed value.
(ts/no-unsafe-member-access)
src/_live-rendering.ts
[error] 37-37: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 37-37: Unsafe assignment of an error typed value.
(ts/no-unsafe-assignment)
[error] 47-47: Unsafe argument of type error typed assigned to a parameter of type string.
(ts/no-unsafe-argument)
[error] 47-47: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 47-47: Unsafe member access .cursorTo on an error typed value.
(ts/no-unsafe-member-access)
[error] 48-48: Unsafe argument of type error typed assigned to a parameter of type string.
(ts/no-unsafe-argument)
[error] 48-48: Unsafe member access .eraseDown on an error typed value.
(ts/no-unsafe-member-access)
[error] 49-49: Unsafe argument of type error typed assigned to a parameter of type string.
(ts/no-unsafe-argument)
[error] 49-49: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 49-49: Unsafe member access .yellow on an error typed value.
(ts/no-unsafe-member-access)
[error] 50-50: Unsafe argument of type error typed assigned to a parameter of type string.
(ts/no-unsafe-argument)
[error] 50-50: Unsafe member access .cursorHide on an error typed value.
(ts/no-unsafe-member-access)
[error] 63-63: Unsafe argument of type error typed assigned to a parameter of type string.
(ts/no-unsafe-argument)
[error] 63-63: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 63-63: Unsafe member access .cursorTo on an error typed value.
(ts/no-unsafe-member-access)
[error] 64-64: Unsafe argument of type error typed assigned to a parameter of type string.
(ts/no-unsafe-argument)
[error] 64-64: Unsafe member access .eraseDown on an error typed value.
(ts/no-unsafe-member-access)
[error] 66-66: Unsafe argument of type error typed assigned to a parameter of type string.
(ts/no-unsafe-argument)
[error] 66-66: Unsafe member access .cursorHide on an error typed value.
(ts/no-unsafe-member-access)
[error] 126-126: Unsafe assignment of an error typed value.
(ts/no-unsafe-assignment)
[error] 126-126: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 126-126: Unsafe member access .cyan on an error typed value.
(ts/no-unsafe-member-access)
[error] 127-127: Unsafe assignment of an error typed value.
(ts/no-unsafe-assignment)
[error] 127-127: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 127-127: Unsafe member access .gray on an error typed value.
(ts/no-unsafe-member-access)
[error] 139-139: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 139-139: Unsafe member access .bold on an error typed value.
(ts/no-unsafe-member-access)
[error] 144-144: Unsafe assignment of an error typed value.
(ts/no-unsafe-assignment)
[error] 144-144: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 144-144: Unsafe member access .bold on an error typed value.
(ts/no-unsafe-member-access)
[error] 145-145: Unsafe assignment of an error typed value.
(ts/no-unsafe-assignment)
[error] 145-145: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 147-147: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 151-151: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 151-151: Unsafe member access .gray on an error typed value.
(ts/no-unsafe-member-access)
[error] 152-152: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 152-152: Unsafe member access .gray on an error typed value.
(ts/no-unsafe-member-access)
[error] 152-152: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 153-153: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 153-153: Unsafe member access .gray on an error typed value.
(ts/no-unsafe-member-access)
[error] 153-153: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 155-155: Unsafe assignment of an error typed value.
(ts/no-unsafe-assignment)
[error] 155-155: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 156-156: Unsafe assignment of an error typed value.
(ts/no-unsafe-assignment)
[error] 156-156: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 161-161: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 173-173: Unsafe assignment of an error typed value.
(ts/no-unsafe-assignment)
[error] 173-173: Unsafe member access .green on an error typed value.
(ts/no-unsafe-member-access)
[error] 175-175: Unsafe assignment of an error typed value.
(ts/no-unsafe-assignment)
[error] 175-175: Unsafe member access .red on an error typed value.
(ts/no-unsafe-member-access)
[error] 178-178: Unsafe assignment of an error typed value.
(ts/no-unsafe-assignment)
[error] 178-178: Unsafe member access .yellow on an error typed value.
(ts/no-unsafe-member-access)
[error] 189-189: Unsafe assignment of an error typed value.
(ts/no-unsafe-assignment)
[error] 189-189: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 190-190: Unsafe assignment of an error typed value.
(ts/no-unsafe-assignment)
[error] 190-190: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 190-190: Unsafe member access .gray on an error typed value.
(ts/no-unsafe-member-access)
[error] 195-195: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 195-195: Unsafe member access .green on an error typed value.
(ts/no-unsafe-member-access)
[error] 195-195: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 195-195: Unsafe member access .gray on an error typed value.
(ts/no-unsafe-member-access)
[error] 199-201: Unsafe assignment of an error typed value.
(ts/no-unsafe-assignment)
[error] 200-200: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 200-200: Unsafe member access .red on an error typed value.
(ts/no-unsafe-member-access)
[error] 200-200: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 200-200: Unsafe member access .yellow on an error typed value.
(ts/no-unsafe-member-access)
[error] 200-200: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 200-200: Unsafe member access .green on an error typed value.
(ts/no-unsafe-member-access)
[error] 203-203: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 203-203: Unsafe member access .bold on an error typed value.
(ts/no-unsafe-member-access)
[error] 204-204: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 204-204: Unsafe member access .bold on an error typed value.
(ts/no-unsafe-member-access)
[error] 207-207: Unsafe assignment of an error typed value.
(ts/no-unsafe-assignment)
[error] 207-207: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 207-207: Unsafe member access .bold on an error typed value.
(ts/no-unsafe-member-access)
[error] 208-208: Unsafe assignment of an error typed value.
(ts/no-unsafe-assignment)
[error] 208-208: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 216-216: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 216-216: Unsafe member access .gray on an error typed value.
(ts/no-unsafe-member-access)
[error] 217-217: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 217-217: Unsafe member access .gray on an error typed value.
(ts/no-unsafe-member-access)
[error] 218-218: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 218-218: Unsafe member access .gray on an error typed value.
(ts/no-unsafe-member-access)
[error] 222-222: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 222-222: Unsafe member access .gray on an error typed value.
(ts/no-unsafe-member-access)
[error] 224-224: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 224-224: Unsafe member access .gray on an error typed value.
(ts/no-unsafe-member-access)
[error] 228-228: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 232-232: Unsafe assignment of an error typed value.
(ts/no-unsafe-assignment)
[error] 232-232: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 233-233: Unsafe assignment of an error typed value.
(ts/no-unsafe-assignment)
[error] 233-233: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 237-237: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 252-252: Unsafe assignment of an error typed value.
(ts/no-unsafe-assignment)
[error] 252-252: Unsafe member access .green on an error typed value.
(ts/no-unsafe-member-access)
[error] 254-254: Unsafe assignment of an error typed value.
(ts/no-unsafe-assignment)
[error] 254-254: Unsafe member access .red on an error typed value.
(ts/no-unsafe-member-access)
[error] 257-257: Unsafe assignment of an error typed value.
(ts/no-unsafe-assignment)
[error] 257-257: Unsafe member access .yellow on an error typed value.
(ts/no-unsafe-member-access)
[error] 268-268: Unsafe assignment of an error typed value.
(ts/no-unsafe-assignment)
[error] 268-268: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 269-269: Unsafe assignment of an error typed value.
(ts/no-unsafe-assignment)
[error] 269-269: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 269-269: Unsafe member access .gray on an error typed value.
(ts/no-unsafe-member-access)
[error] 274-274: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 274-274: Unsafe member access .green on an error typed value.
(ts/no-unsafe-member-access)
[error] 274-274: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 274-274: Unsafe member access .gray on an error typed value.
(ts/no-unsafe-member-access)
[error] 276-282: Unsafe assignment of an error typed value.
(ts/no-unsafe-assignment)
[error] 278-278: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 278-278: Unsafe member access .red on an error typed value.
(ts/no-unsafe-member-access)
[error] 280-280: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 280-280: Unsafe member access .yellow on an error typed value.
(ts/no-unsafe-member-access)
[error] 281-281: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 281-281: Unsafe member access .green on an error typed value.
(ts/no-unsafe-member-access)
[error] 282-282: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 282-282: Unsafe member access .green on an error typed value.
(ts/no-unsafe-member-access)
[error] 285-285: Unsafe assignment of an error typed value.
(ts/no-unsafe-assignment)
[error] 285-285: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 285-285: Unsafe member access .bold on an error typed value.
(ts/no-unsafe-member-access)
[error] 286-286: Unsafe assignment of an error typed value.
(ts/no-unsafe-assignment)
[error] 286-286: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 289-289: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 293-293: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 293-293: Unsafe member access .gray on an error typed value.
(ts/no-unsafe-member-access)
[error] 294-294: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 294-294: Unsafe member access .gray on an error typed value.
(ts/no-unsafe-member-access)
[error] 295-295: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 295-295: Unsafe member access .gray on an error typed value.
(ts/no-unsafe-member-access)
[error] 297-297: Unsafe assignment of an error typed value.
(ts/no-unsafe-assignment)
[error] 297-297: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 298-298: Unsafe assignment of an error typed value.
(ts/no-unsafe-assignment)
[error] 298-298: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 303-303: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 308-308: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 312-312: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 312-312: Unsafe member access .gray on an error typed value.
(ts/no-unsafe-member-access)
[error] 313-313: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 313-313: Unsafe member access .gray on an error typed value.
(ts/no-unsafe-member-access)
[error] 314-314: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 314-314: Unsafe member access .gray on an error typed value.
(ts/no-unsafe-member-access)
[error] 316-316: Unsafe assignment of an error typed value.
(ts/no-unsafe-assignment)
[error] 316-316: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 317-317: Unsafe assignment of an error typed value.
(ts/no-unsafe-assignment)
[error] 317-317: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 322-322: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 333-333: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 340-340: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 340-340: Unsafe member access .gray on an error typed value.
(ts/no-unsafe-member-access)
[error] 358-358: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 358-358: Unsafe member access .bold on an error typed value.
(ts/no-unsafe-member-access)
[error] 368-368: Unsafe assignment of an error typed value.
(ts/no-unsafe-assignment)
[error] 368-368: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 368-368: Unsafe member access .red on an error typed value.
(ts/no-unsafe-member-access)
[error] 368-368: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 368-368: Unsafe member access .yellow on an error typed value.
(ts/no-unsafe-member-access)
[error] 368-368: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 368-368: Unsafe member access .green on an error typed value.
(ts/no-unsafe-member-access)
[error] 386-386: Unsafe argument of type error typed assigned to a parameter of type string.
(ts/no-unsafe-argument)
[error] 386-386: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 386-386: Unsafe member access .gray on an error typed value.
(ts/no-unsafe-member-access)
[error] 391-391: Unsafe assignment of an error typed value.
(ts/no-unsafe-assignment)
[error] 393-393: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 394-394: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 395-395: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 395-395: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 395-395: Unsafe member access .toBe on an error typed value.
(ts/no-unsafe-member-access)
[error] 396-396: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 396-396: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 396-396: Unsafe member access .toBe on an error typed value.
(ts/no-unsafe-member-access)
[error] 399-399: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 400-400: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 400-400: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 400-400: Unsafe member access .toBe on an error typed value.
(ts/no-unsafe-member-access)
[error] 401-401: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 401-401: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 401-401: Unsafe member access .toBe on an error typed value.
(ts/no-unsafe-member-access)
[error] 402-402: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 402-402: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 402-402: Unsafe member access .toBe on an error typed value.
(ts/no-unsafe-member-access)
[error] 406-406: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 407-407: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 408-408: Unsafe assignment of an error typed value.
(ts/no-unsafe-assignment)
[error] 408-408: Unsafe construction of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 410-410: Unsafe member access .signal on an error typed value.
(ts/no-unsafe-member-access)
[error] 412-412: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 412-412: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 412-412: Unsafe member access .toBeGreaterThanOrEqual on an error typed value.
(ts/no-unsafe-member-access)
[error] 415-415: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 416-416: Unsafe assignment of an error typed value.
(ts/no-unsafe-assignment)
[error] 416-416: Unsafe construction of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 417-417: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 417-417: Unsafe return of a value of type error.
(ts/no-unsafe-return)
[error] 417-417: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 417-417: Unsafe member access .abort on an error typed value.
(ts/no-unsafe-member-access)
[error] 419-421: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 419-419: Unsafe call of a(n) error type typed value.
(ts/no-unsafe-call)
[error] 419-419: Unsafe member access .signal on an error typed value.
(ts/no-unsafe-member-access)
[error] 420-420: Unsafe member access .rejects on an error typed value.
(ts/no-unsafe-member-access)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Workers Builds: ccusage-guide
🔇 Additional comments (5)
src/_consts.ts (1)
107-109: Excellent documentation improvement!The enhanced comment clearly explains the purpose and reasoning behind the 16ms frame rate limit, making it easier for future developers to understand why this value was chosen.
src/_terminal-utils.ts (1)
6-10: Excellent documentation enhancements throughout!The improved comments provide valuable technical context about:
- DEC synchronized output mode and its double-buffering analogy
- Terminal buffering strategy for flicker prevention
- Alternate screen functionality
- The importance of proper cleanup
These changes significantly improve code maintainability.
Also applies to: 78-80, 87-89, 106-108, 112-113, 119-120, 131-133, 162-164, 170-172
refactoring-plan.txt (1)
1-74: Well-structured refactoring plan!This planning document clearly articulates the problems, solutions, and implementation approach. It's valuable to have this documented for future reference and understanding of the architectural decisions made in this PR.
src/commands/_blocks.live.ts (1)
1-98: Excellent refactoring - clean separation of concerns achieved!The command file has been successfully reduced from 520+ lines to a focused ~95 lines that handle only orchestration responsibilities. The extraction of rendering logic to
_live-rendering.tscreates a much cleaner architecture.src/_live-rendering.ts (1)
1-425: Well-structured rendering module with good test coverage!The extraction of rendering logic into this dedicated module successfully implements the separation of concerns outlined in the refactoring plan. The module is well-organized with clear exports, comprehensive documentation, and in-source tests.
- Add DISABLE_LINE_WRAP and ENABLE_LINE_WRAP constants for line wrap control - Add ANSI_RESET constant for color reset sequences - Improve code maintainability and readability
Summary
This PR refactors the live monitoring functionality to improve code organization by separating concerns between the CLI layer and business logic.
Changes Made
🏗️ Code Structure Improvements
🔧 Code Quality Improvements
📝 Comment Improvements
🧪 Testing
📁 File Changes
Benefits
Test Results
All 212 tests pass, including 6 new tests for the extracted functionality.
Behavior
Related
Addresses the file structure concerns noted in the codebase where command files were becoming too large and mixing concerns. Also addresses PR review feedback for code quality improvements.