Repository navigation
feat(tui): error dismiss, quick question selection, contextual Blue footer, UI cleanup #1039
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9a59038
feat(tui): error dismiss, quick question selection, contextual Blue f…
2fe9463
docs(changelog): record PR 1039 (error recovery polish) under Unreleased
8d70472
fix(tui): finish blue notification i18n + align test expectations
424480f
Merge remote-tracking branch 'origin/main' into feat/tui-error-polish
d5d5596
fix(tui): let the number keys reach the Other entry in QuestionPicker
ff6806d
Merge remote-tracking branch 'origin/main' into feat/tui-error-polish
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
64 changes: 64 additions & 0 deletions
64
clients/cli/src/components/QuestionPicker.numbers.test.tsx
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 |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| // @vitest-environment jsdom | ||
| import React from "react"; | ||
| import { act, cleanup, render } from "@testing-library/react"; | ||
| import { afterEach, expect, it, vi } from "vitest"; | ||
| import { QuestionPicker } from "./QuestionPicker.js"; | ||
| import type { ActiveQuestion } from "../types.js"; | ||
|
|
||
| const keyboard = vi.hoisted<{ | ||
| handler: null | ((input: string, key: Record<string, boolean>) => void); | ||
| }>(() => ({ handler: null })); | ||
| vi.mock("ink", async () => { | ||
| const React = await import("react"); | ||
| return { | ||
| Box: ({ children }: { children: React.ReactNode }) => React.createElement("div", null, children), | ||
| Text: ({ children }: { children: React.ReactNode }) => React.createElement("span", null, children), | ||
| useInput: (handler: typeof keyboard.handler) => { keyboard.handler = handler; }, | ||
| }; | ||
| }); | ||
| vi.mock("../hooks/useTerminalSize.js", () => ({ useTerminalSize: () => ({ columns: 80, rows: 24 }) })); | ||
| vi.mock("@inkjs/ui", () => ({ | ||
| TextInput: ({ placeholder }: { placeholder: string }) => React.createElement("div", null, placeholder), | ||
| })); | ||
|
|
||
| afterEach(() => cleanup()); | ||
|
|
||
| const question: ActiveQuestion = { | ||
| sourceId: "q-1", | ||
| question: "Pick one", | ||
| header: "Q", | ||
| options: [ | ||
| { label: "alpha" }, | ||
| { label: "beta" }, | ||
| { label: "gamma" }, | ||
| ], | ||
| multiSelect: false, | ||
| allowOther: true, | ||
| }; | ||
|
|
||
| function picker(onSubmit = () => {}) { | ||
| const view = render(<QuestionPicker question={question} onSubmit={onSubmit} onCancel={() => {}} />); | ||
| if (!keyboard.handler) throw new Error("QuestionPicker did not register input"); | ||
| return view; | ||
| } | ||
|
|
||
| it("submits an option by its number key", () => { | ||
| const onSubmit = vi.fn(); | ||
| picker(onSubmit); | ||
| act(() => keyboard.handler?.("2", {})); | ||
| expect(onSubmit).toHaveBeenCalledWith("beta"); | ||
| }); | ||
|
|
||
| it("opens the Other text input by its number key", () => { | ||
| const view = picker(); | ||
| act(() => keyboard.handler?.("4", {})); | ||
| expect(view.container.textContent).toContain("esc: back"); | ||
| }); | ||
|
|
||
| it("ignores number keys past the last entry", () => { | ||
| const onSubmit = vi.fn(); | ||
| const view = picker(onSubmit); | ||
| act(() => keyboard.handler?.("9", {})); | ||
| expect(onSubmit).not.toHaveBeenCalled(); | ||
| expect(view.container.textContent).not.toContain("esc: back"); | ||
| }); |
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
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
Oops, something went wrong.
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.
When a server error is displayed while
runStateis stillstreaming, pressing the advertised Escape key invokes this handler and the non-modal global handler, whose streaming Escape path callsonInterrupt; in transcript mode it also exits the transcript. Thus following the new dismissal hint can unexpectedly pause the live run or navigate away. Give error dismissal priority in the global keybinding flow or otherwise suppress the conflicting handler.Useful? React with 👍 / 👎.