Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ describe("PromptSkillTextarea", () => {
expect(screen.getByTestId("prompt-skill-suggestions")).not.toHaveAttribute("role");
expect(input).toHaveAttribute("aria-autocomplete", "list");
expect(input).not.toHaveAttribute("aria-expanded");
expect(screen.getByRole("status")).toHaveTextContent("2 managed skill suggestions available.");

await user.keyboard("{ArrowDown}{Enter}");
expect(input).toHaveValue("$release-notes ");
Expand Down Expand Up @@ -110,15 +111,18 @@ describe("PromptSkillTextarea", () => {
"true"
);
expect(screen.getByText("Loading managed skills...")).toBeInTheDocument();
expect(screen.getByRole("status")).toHaveTextContent("Loading managed skill suggestions.");

rerender(<Harness availableSkills={[]} />);
expect(screen.getByText("No managed skills match this session.")).toBeInTheDocument();
expect(screen.getByRole("status")).toHaveTextContent("No managed skill suggestions available.");
expect(screen.getByTestId("prompt-skill-suggestions")).toHaveClass("bottom-full");

rerender(<Harness loadState="error" availableSkills={[]} />);
expect(
screen.getByText("Managed skills could not be loaded. Try again shortly.")
).toBeInTheDocument();
expect(screen.getByRole("status")).toHaveTextContent("Managed skill suggestions unavailable.");
});

it("does not insert a completion beyond the prompt limit", async () => {
Expand Down
12 changes: 12 additions & 0 deletions packages/web/src/components/prompt-skill-autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ export const PromptSkillTextarea = forwardRef<HTMLTextAreaElement, PromptSkillTe
cursor !== null &&
sameCursor(dismissedAt.cursor, cursor);
const open = completion !== null && !dismissed;
const suggestionStatus = !open
? ""
: suggestionSource.status === "loading"
? "Loading managed skill suggestions."
: suggestionSource.status === "error"
? "Managed skill suggestions unavailable."
: matchingSkills.length === 0
? "No managed skill suggestions available."
: `${matchingSkills.length} managed skill suggestion${matchingSkills.length === 1 ? "" : "s"} available.`;

const setInputRef = useCallback(
(input: HTMLTextAreaElement | null) => {
Expand Down Expand Up @@ -217,6 +226,9 @@ export const PromptSkillTextarea = forwardRef<HTMLTextAreaElement, PromptSkillTe
onSelect?.(event);
}}
/>
<span role="status" className="sr-only">
{suggestionStatus}
</span>
{open && completion && (
<PromptSkillSuggestionPanel
id={listboxId}
Expand Down
Loading