-
Notifications
You must be signed in to change notification settings - Fork 3
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
Report job status on each prompt #411
Conversation
WalkthroughThe changes introduce a new Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Shell
participant Reporter
participant JobManager
User->>Shell: Input command
Shell->>Reporter: Check job status
Reporter->>JobManager: Get job updates
JobManager-->>Reporter: Return job status
Reporter-->>Shell: Display job status
Shell-->>User: Show prompt
Assessment against linked issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
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 (
|
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: 3
Outside diff range, codebase verification and nitpick comments (3)
yash-cli/CHANGELOG-lib.md (1)
34-36
: Clarify the changelog entry forprepare_input
.The changelog entry for the
prepare_input
function mentions the addition of theReporter
decorator but does not explicitly state the new behavior in interactive mode. It would be beneficial to clarify that this decorator is specifically applied when the shell is in interactive mode to enhance user feedback on job statuses.Consider revising the entry to explicitly mention the interactive mode condition:
- The `startup::input::prepare_input` function now applies the `yash_env::input::Reporter` decorator to the returned source input if the shell is interactive, enhancing user feedback on job statuses.yash-cli/src/startup/input.rs (1)
Line range hint
71-94
: Review the implementation of theprepare_input
function.The
prepare_input
function has been modified to include a conditional check for the interactive mode of the shell. If the shell is interactive, theReporter
decorator is applied. This implementation aligns with the PR objectives to enhance user feedback on job statuses.However, it's important to ensure that the
Reporter
decorator does not interfere with other decorators likeEcho
andPrompter
which are applied based on different conditions. The current implementation seems to handle these concerns separately, which is good.Consider adding a unit test to verify that the
Reporter
decorator is applied correctly in interactive mode and that it behaves as expected with other decorators.yash-cli/tests/scripted_test.rs (1)
268-271
: Review the implementation of thejob_control_ex
test function.The
job_control_ex
function is designed to test thejob-y.sh
script using therun_with_pty
method. This is consistent with the existing testing structure and is a good practice for ensuring that the new job control functionality is tested in an environment that mimics user interaction.However, it would be beneficial to include more details in the test function's documentation or comments about what specific aspects of the
job-y.sh
script are being tested, especially regarding the new job status reporting functionality. This would help maintainers and other developers understand the scope and purpose of the test more clearly.Consider adding comments or documentation within the test function to clarify the specific behaviors being tested:
/// Tests the new job status reporting functionality in `job-y.sh`. /// This test ensures that job statuses are correctly reported at each prompt when running the script.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (10)
- yash-builtin/src/jobs.rs (3 hunks)
- yash-cli/CHANGELOG-bin.md (1 hunks)
- yash-cli/CHANGELOG-lib.md (1 hunks)
- yash-cli/src/startup/input.rs (4 hunks)
- yash-cli/tests/scripted_test.rs (1 hunks)
- yash-cli/tests/scripted_test/job-y.sh (1 hunks)
- yash-env/CHANGELOG.md (2 hunks)
- yash-env/src/input.rs (1 hunks)
- yash-env/src/input/reporter.rs (1 hunks)
- yash-env/src/job/fmt.rs (3 hunks)
Additional context used
Shellcheck
yash-cli/tests/scripted_test/job-y.sh
[warning] 5-5: Use semicolon or linefeed before 'done' (or quote to make it literal).
(SC1010)
[error] 8-8: You need a space after the [ and before the ].
(SC1035)
[error] 8-8: Couldn't parse this test expression. Fix to allow more checks.
(SC1073)
[error] 8-8: You need a space before the ].
(SC1020)
[error] 8-8: Missing space before ]. Fix any mentioned problems and try again.
(SC1072)
Additional comments not posted (7)
yash-cli/tests/scripted_test/job-y.sh (2)
14-23
: Approve job control test setup.The setup for testing job control with background processes and synchronization via a FIFO is correctly implemented and should effectively test the specified behavior.
8-9
: Correct the syntax of the test expression.The test expression on line 8 has multiple syntax errors related to spacing around brackets. Correcting these will ensure the script functions as intended.
Apply this diff to correct the syntax:
-[1] + Done sleep 0 +[1] + Done sleep 0Likely invalid or redundant comment.
Tools
Shellcheck
[error] 8-8: You need a space after the [ and before the ].
(SC1035)
[error] 8-8: Couldn't parse this test expression. Fix to allow more checks.
(SC1073)
[error] 8-8: You need a space before the ].
(SC1020)
[error] 8-8: Missing space before ]. Fix any mentioned problems and try again.
(SC1072)
yash-env/src/input/reporter.rs (1)
25-47
: Well-implementedReporter
struct.The
Reporter
struct is well-designed and appropriately usesRefCell
for mutable access to the environment. This is crucial for its functionality to report job status changes effectively.yash-env/CHANGELOG.md (1)
8-16
: Clear and informative changelog entries.The changelog entries for
job::fmt::Accumulator
andinput::Reporter
are well-written and provide clear information about the new features added to the project.yash-env/src/job/fmt.rs (1)
202-302
: Well-designedAccumulator
struct with effective methods.The
Accumulator
struct is effectively designed to collect and format job reports. The methodsnew
andadd
are well-implemented and documented, providing clear functionality for managing job reports.yash-builtin/src/jobs.rs (1)
151-151
: Review the integration ofaccumulator.add
.The replacement of
accumulator.report
withaccumulator.add
suggests a shift in how job statuses are handled. Ensure that the new method integrates well with the existing job management system and that it correctly updates job statuses as intended.Run the following script to verify the integration of the
accumulator.add
method:Also applies to: 158-158
Verification successful
Integration of
accumulator.add
is verified.The
accumulator.add
method is correctly implemented inyash-env/src/job/fmt.rs
and is integrated across multiple files, aligning with the intended functionality of updating job statuses. The method's usage and implementation confirm its role in the job management system. No issues were found with its integration.
- File:
yash-env/src/job/fmt.rs
- Method Definition:
pub fn add<S: System>(&mut self, index: usize, job: &Job, system: &S)
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the integration of `accumulator.add` method. # Test: Search for the method usage. Expect: Only occurrences of the new method. rg --type rust -A 5 $'accumulator.add'Length of output: 2060
Script:
#!/bin/bash # Description: Find the definition of the `accumulator.add` method to verify its implementation. # Search for the definition of the `add` method in Rust files. ast-grep --lang rust --pattern 'fn add($_, $_, $_) { $$$ }'Length of output: 61
Script:
#!/bin/bash # Description: Search for the `add` method within struct or trait implementations. # Search for the `add` method in the context of a struct or trait. rg --type rust -A 10 'fn add'Length of output: 15469
yash-env/src/input.rs (1)
32-33
: Approve the introduction of thereporter
module.The addition of the
reporter
module and its public exposure viapub use reporter::Reporter;
are well-aligned with the PR's objectives to enhance job status reporting in the interactive shell. This change promotes better modularity and maintainability.Consider verifying the integration of the
Reporter
module with the rest of the system to ensure there are no conflicts or issues:Verification successful
Integration of the
Reporter
module is verified and no issues are found.The
Reporter
module is well-integrated into the system, with its usage inyash-cli/src/startup/input.rs
and thorough testing inyash-env/src/input/reporter.rs
. There are no conflicts or issues detected in the integration.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the integration of the `Reporter` module. # Test: Search for any potential conflicts or issues related to the `Reporter` module. rg --type rust -A 5 $'Reporter'Length of output: 5162
test_e 'interactive shell reports job status before prompt' -im | ||
echo >&2; sleep 0& while kill -0 $! 2>/dev/null; do :; done | ||
echo done >&2; exit |
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.
Fix syntax issue with 'done' placement.
The script contains a syntax warning on line 5. To ensure proper execution and readability, consider adjusting the placement of 'done' or using a semicolon before it as suggested by Shellcheck (SC1010).
Apply this diff to fix the syntax issue:
-echo done >&2; exit
+echo done >&2; exit;
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
test_e 'interactive shell reports job status before prompt' -im | |
echo >&2; sleep 0& while kill -0 $! 2>/dev/null; do :; done | |
echo done >&2; exit | |
test_e 'interactive shell reports job status before prompt' -im | |
echo >&2; sleep 0& while kill -0 $! 2>/dev/null; do :; done | |
echo done >&2; exit; |
Tools
Shellcheck
[warning] 5-5: Use semicolon or linefeed before 'done' (or quote to make it literal).
(SC1010)
Closes #407
Summary by CodeRabbit
New Features
Reporter
decorator for real-time job status feedback in interactive mode.Accumulator
structure for organized job report formatting.Bug Fixes
Tests
Documentation