Skip to content

Conversation

@ryoppippi
Copy link
Owner

@ryoppippi ryoppippi commented Jun 22, 2025

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

  • Extract rendering logic: Move all display logic from `commands/_blocks.live.ts` to new `src/_live-rendering.ts` module
  • Thin CLI layer: Reduce command file from ~520 lines to ~95 lines, keeping only process lifecycle management
  • Better separation of concerns: Commands now act as orchestration layers, business logic is isolated and testable

🔧 Code Quality Improvements

  • Fix terminal buffer management: Ensure buffer is always cleared after flush to prevent duplicate content
  • Replace hardcoded ANSI sequences: Add named constants for line wrap control and color reset
  • Improve comment clarity: Replace informal language with precise technical descriptions

📝 Comment Improvements

  • Update technical comments to be more specific and educational
  • Add frame rate limiting explanations (60fps, flicker prevention)
  • Document DEC synchronized output mode with double-buffering concepts
  • Clarify terminal buffering and alternate screen functionality

🧪 Testing

  • Add comprehensive in-source tests for all extracted functions
  • Frame rate limiting tests with AbortSignal handling
  • Display formatting helper function tests
  • Delay and abort signal integration tests

📁 File Changes

  • `src/_live-rendering.ts` (NEW): 483 lines of extracted rendering logic with tests
  • `src/commands/_blocks.live.ts`: Simplified to 95 lines (was 520+ lines)
  • `src/_consts.ts`: Improved frame rate limiting comment
  • `src/_terminal-utils.ts`: Enhanced technical comments, fixed buffer management, added ANSI constants

Benefits

  1. Better maintainability: Logic is separated from CLI concerns
  2. Improved testability: Rendering functions are now independently testable
  3. Reusable components: Display logic can be reused by other parts of the system
  4. Cleaner architecture: Commands focus on process management, modules handle business logic
  5. More robust terminal handling: Fixed buffer clearing and standardized ANSI sequences

Test Results

All 212 tests pass, including 6 new tests for the extracted functionality.

Behavior

⚠️ No functional changes - the live monitoring behavior remains identical. This is purely a structural refactoring with code quality improvements.

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.

Documents the strategy for separating CLI and business logic to improve maintainability and testability
@coderabbitai
Copy link

coderabbitai bot commented Jun 22, 2025

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

📥 Commits

Reviewing files that changed from the base of the PR and between e83edf84941321e16b2bded608df500e236ac069 and 184a114.

📒 Files selected for processing (1)
  • src/_terminal-utils.ts (5 hunks)

Walkthrough

This change refactors live rendering logic for the blocks command by moving all rendering and formatting code from src/commands/_blocks.live.ts into a new src/_live-rendering.ts module. The command file now focuses on orchestration, while the new module handles all aspects of live terminal display.

Changes

File(s) Summary
refactoring-plan.txt Adds a detailed refactoring plan outlining separation of rendering logic and migration steps.
src/_live-rendering.ts New module implementing all live rendering functions, types, and tests for terminal dashboard display.
src/commands/_blocks.live.ts Removes rendering logic, delegates to _live-rendering.ts, and focuses on command orchestration.
src/_consts.ts Updates comment for MIN_RENDER_INTERVAL_MS to clarify its purpose; no code changes.
src/_terminal-utils.ts Improves and clarifies comments and documentation; no code or API 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
Loading

Possibly related PRs

  • #168: Refactors the live monitoring loop in src/commands/_blocks.live.ts by adding a call to monitor.clearCache(), directly modifying the same loop affected by this PR.
  • #126: Implements the original live monitoring feature and rendering logic, which this PR now restructures and isolates into a dedicated module.
  • #167: Introduces terminal buffering, alternate screen, sync mode, and frame rate limiting to the live monitoring command, which are now reorganized in this refactor.

Poem

A rabbit hopped through code so vast,
Splitting logic, clean at last!
Rendering moved to its own domain,
The terminal dashboard shines again.
With flicker gone and colors bright,
This bunny cheers the refactor’s might!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ryoppippi ryoppippi requested a review from Copilot June 22, 2025 21:22
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jun 22, 2025

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
ccusage-guide 184a114 Jun 22 2025, 09:49 PM

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jun 22, 2025

Open in StackBlitz

npm i https://pkg.pr.new/ryoppippi/ccusage@170

commit: 184a114

This comment was marked as outdated.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.ts to a new, dedicated module: src/_live-rendering.ts.
  • CLI Layer Thinning: The src/commands/_blocks.live.ts file 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.ts and src/_terminal-utils.ts have 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

  1. 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.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.ts to reduce duplicated code within conditional blocks, which would enhance maintainability.
  • Code Clarity: Some try/catch blocks 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.

Comment on lines 41 to 46
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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;
	}

Comment on lines 63 to 68
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Similar to delayWithAbort, this catch block has a redundant if statement. Both logical paths result in throw error. Simplifying this will improve code clarity.

		catch (error) {
			// Propagate any error, including AbortError for graceful shutdown.
			throw error;
		}

Comment on lines 242 to 277
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

This comment was marked as outdated.

- 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.
@ryoppippi ryoppippi requested a review from Copilot June 22, 2025 21:38

This comment was marked as outdated.

@ryoppippi ryoppippi requested a review from Copilot June 22, 2025 21:44
Copy link
Contributor

Copilot AI left a 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 = [];

Copy link

@coderabbitai coderabbitai bot left a 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.ts creates 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
@ryoppippi ryoppippi changed the title Refactor live monitoring: extract rendering logic for better code organization refactor: extract live monitoring rendering logic for better code organization Jun 22, 2025
@ryoppippi ryoppippi merged commit 9c661e3 into main Jun 22, 2025
11 checks passed
@ryoppippi ryoppippi deleted the block-test branch June 22, 2025 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants