-
Notifications
You must be signed in to change notification settings - Fork 36
bug: fix onboarding softlock / add dynamic input accepting. Fix grammatical issues. #439
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
nolan-at-pieces
wants to merge
1
commit into
main
Choose a base branch
from
fix_onboarding
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -67,21 +67,26 @@ def run(self): | |||||||||
|
|
||||||||||
|
|
||||||||||
| class OnboardingCommandStep(BasedOnboardingStep): | ||||||||||
| def __init__(self, text, predicted_text: str) -> None: | ||||||||||
| def __init__(self, text, predicted_text: str, prefix_match: bool = False) -> None: | ||||||||||
| self.text = text | ||||||||||
| self.predicted_text = predicted_text | ||||||||||
| self.prefix_match = prefix_match | ||||||||||
|
|
||||||||||
| def _is_valid(self, user_input: str) -> bool: | ||||||||||
| if self.prefix_match: | ||||||||||
| s = user_input.strip() | ||||||||||
| return s.startswith(self.predicted_text) and len(s) > len(self.predicted_text) | ||||||||||
| return user_input == self.predicted_text | ||||||||||
|
|
||||||||||
| def run(self): | ||||||||||
| Settings.logger.print(Markdown(self.text)) | ||||||||||
| # self.click_to_continue(console) | ||||||||||
|
|
||||||||||
| user_input = input(get_prompt()).strip() | ||||||||||
| while user_input != self.predicted_text: | ||||||||||
| while not self._is_valid(user_input): | ||||||||||
| if user_input == "exit": | ||||||||||
| sys.exit(1) | ||||||||||
| Settings.logger.print( | ||||||||||
| Markdown(f"❌ Wrong command. Please use: `{self.predicted_text}`") | ||||||||||
| ) | ||||||||||
| hint = "e.g. `pieces ask 'your question'`" if self.prefix_match else f"Please use: `{self.predicted_text}`" | ||||||||||
| Settings.logger.print(Markdown(f"❌ Wrong command. {hint}")) | ||||||||||
| user_input = input(get_prompt()).strip() | ||||||||||
|
|
||||||||||
| run_command(*extract_text(user_input.removeprefix("pieces "))) | ||||||||||
|
|
@@ -200,7 +205,7 @@ def onboarding_command(**kwargs): | |||||||||
| "Step 2: Save a Material": [ | ||||||||||
| OnboardingStep( | ||||||||||
| "Let's get started by saving a material to Pieces.\n" | ||||||||||
| "Copy the following python material: \n" | ||||||||||
| "Copy the following Python material:\n" | ||||||||||
| f"```python\n{demo_snippet}\n```", | ||||||||||
| create_snippet_one_validation, | ||||||||||
| ), | ||||||||||
|
|
@@ -216,18 +221,19 @@ def onboarding_command(**kwargs): | |||||||||
| ], | ||||||||||
| "Step 4: Start a Session": [ | ||||||||||
| OnboardingCommandStep( | ||||||||||
| "Starting a session allows you to run multiple commands without having to start the Pieces CLI every time." | ||||||||||
| "Starting a session allows you to run multiple commands without having to start the Pieces CLI every time. " | ||||||||||
| "Start a session with `pieces run`. To exit your session, use `exit`.", | ||||||||||
|
Comment on lines
+224
to
225
|
||||||||||
| "Starting a session allows you to run multiple commands without having to start the Pieces CLI every time. " | |
| "Start a session with `pieces run`. To exit your session, use `exit`.", | |
| "Starting a session allows you to run multiple commands without having to start the Pieces CLI every time." | |
| " Start a session with `pieces run`. To exit your session, use `exit`.", |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
In prefix_match mode,
_is_validrequireslen(s) > len(self.predicted_text), which rejectspieces ask(no query) even though the CLI supports runningaskwithout args and then prompting for a query. This can still leave users stuck if they try the shorter valid command; consider allowing an exact match as valid (and/or validating based on parsed tokens rather than a raw string prefix).