Skip to content

Add useExitOnCtrlC hook #5924

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

Open
wants to merge 1 commit into
base: shauns/06-02-add_loadingbar_ui_component
Choose a base branch
from

Conversation

shauns
Copy link
Contributor

@shauns shauns commented Jun 2, 2025

WHY are these changes introduced?

To improve code organization and maintainability by extracting the Ctrl+C handling logic into a reusable hook.

WHAT is this pull request doing?

Creates a new useExitOnCtrlC hook that encapsulates the logic for handling Ctrl+C keyboard input to exit the process. This hook:

  • Extracts the Ctrl+C handling logic from the Tasks component
  • Provides a reusable implementation that can be used across different components
  • Includes comprehensive test coverage for the new hook

The Tasks component has been updated to use this new hook, simplifying its implementation.

How to test your changes?

  1. Run any CLI command that uses the Tasks component
  2. Press Ctrl+C during execution
  3. Verify that the process exits correctly

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

Copy link
Contributor Author

shauns commented Jun 2, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@shauns shauns marked this pull request as ready for review June 2, 2025 14:06
@shauns shauns requested a review from a team as a code owner June 2, 2025 14:06
Copy link
Contributor

github-actions bot commented Jun 2, 2025

We detected some changes at packages/*/src and there are no updates in the .changeset.
If the changes are user-facing, run pnpm changeset add to track your changes and include them in the next release CHANGELOG.

Caution

DO NOT create changesets for features which you do not wish to be included in the public changelog of the next CLI release.

Copy link
Contributor

github-actions bot commented Jun 2, 2025

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
78.09% (+0.08% 🔼)
12527/16042
🟡 Branches
72.27% (+0.1% 🔼)
6076/8407
🟡 Functions
78.23% (-0.01% 🔻)
3281/4194
🟡 Lines
78.53% (+0.09% 🔼)
11855/15097
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🟢
... / use-exit-on-ctrl-c.ts
80% 50% 100% 80%
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟢
... / app.test-data.ts
91.54% (-0.5% 🔻)
93.75%
81.4% (-1.16% 🔻)
90.91% (-0.53% 🔻)
🔴
... / dev.ts
11.57% (-7.09% 🔻)
12.33% (-1.37% 🔻)
12.12% (-12.88% 🔻)
12.39% (-6.81% 🔻)
🟢
... / handlers.ts
91.8% (-5.49% 🔻)
75% (+8.33% 🔼)
88.89% (-11.11% 🔻)
91.67% (-5.56% 🔻)
🔴
... / app-management-client.ts
46.56% (+0.36% 🔼)
41.43%
43.64% (-0.05% 🔻)
45.45% (+0.4% 🔼)
🟢
... / ExtensionServerProvider.tsx
81.82% (-3.9% 🔻)
0%
71.43% (-5.49% 🔻)
88.24% (-5.51% 🔻)

Test suite run success

2901 tests passing in 1260 suites.

Report generated by 🧪jest coverage report action from 1f9a01f

@shauns shauns force-pushed the shauns/06-02-add_useexitonctrlc_hook branch from 3ab608e to 72137d9 Compare June 4, 2025 11:16
@shauns shauns force-pushed the shauns/06-02-add_loadingbar_ui_component branch 2 times, most recently from 6805c2f to dcc143a Compare June 5, 2025 11:28
@shauns shauns force-pushed the shauns/06-02-add_useexitonctrlc_hook branch from 72137d9 to d4750fa Compare June 5, 2025 11:28
@shauns shauns force-pushed the shauns/06-02-add_loadingbar_ui_component branch from dcc143a to 8f34fe9 Compare June 5, 2025 12:09
@shauns shauns force-pushed the shauns/06-02-add_useexitonctrlc_hook branch from d4750fa to 1f9a01f Compare June 5, 2025 12:09
Copy link
Contributor

github-actions bot commented Jun 5, 2025

Differences in type declarations

We detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:

  • Some seemingly private modules might be re-exported through public modules.
  • If the branch is behind main you might see odd diffs, rebase main into this branch.

New type declarations

packages/cli-kit/dist/private/node/ui/components/LoadingBar.d.ts
import React from 'react';
interface LoadingBarProps {
    title: string;
    noColor?: boolean;
}
declare const LoadingBar: ({ title, noColor }: React.PropsWithChildren<LoadingBarProps>) => JSX.Element;
export { LoadingBar };
packages/cli-kit/dist/private/node/ui/hooks/use-exit-on-ctrl-c.d.ts
/**
 * This hook will cause the process to exit when the user presses Ctrl+C.
 */
export declare function useExitOnCtrlC(): void;

Existing type declarations

We found no diffs with existing type declarations

Copy link
Contributor

@gonzaloriestra gonzaloriestra left a comment

Choose a reason for hiding this comment

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

👌

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