fix(code): show user skills in / popup and drop the autofill#2229
fix(code): show user skills in / popup and drop the autofill#2229richardsolomou wants to merge 4 commits into
Conversation
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
apps/code/src/renderer/features/message-editor/suggestions/getSuggestions.test.ts:89-148
**Prefer parameterised tests for the fallback/override scenarios**
Tests 2 and 3 share identical setup (`seedSessionContext(TASK_ID)`) and differ only in whether `seedSessionAvailableCommands` is called; likewise tests 3 and 5 both exercise the draft-store fallback path but from different context states. Expressing these as `it.each` suites would satisfy the team's parameterised-test preference and make adding future cases (e.g. empty `availableCommands` from agent) a one-liner rather than a new `it` block.
Reviews (1): Last reviewed commit: "fix(code): show user skills in running t..." | Re-trigger Greptile |
|
this is a regression, i'm gonna take a peek in case there's a smaller/simpler bug here we can fix! |
|
@richardsolomou clarifying - mid-prompt you should still be able to see commands, but they just "autofill" instead of showing the whole popover like you'd see at the start of the task. is that also not working for you? |
|
@adboio that does work, but is that the intended way of doing it? It feels..off. why don't we just reuse the same approach? Similar to Slack mentions, you can @ someone at the beginning or the middle of the message and you have the same behavior |
72e84a3 to
c3969bc
Compare
Two bugs in the slash-command popup, fixed together: 1. Skills popup only showed `/good /bad /feedback` in running tasks. `getCommandSuggestions` ignored the trpc-fetched skills list whenever the session had a `taskId`, so the popup waited on the agent's async `available_commands_update` and only saw the hard-coded session commands until it arrived. Now we fall back to the draft-store skills list whenever the session-command list is empty; agent commands still take over once they arrive. Also moves the trpc skills loader into `PromptInput` so every prompt with commands enabled populates the fallback (previously only `TaskInput` did). 2. Popup only appeared when `/` was at the start of the line. `CommandMention` set `startOfLine: true` (the only mention type to do so), so `please /foo` did not trigger. Dropping the flag restores parity with `@` and `#`, while Tiptap's default `allowedPrefixes: [" "]` still prevents file paths like `abc/foo` from triggering. Tests in `getSuggestions.test.ts` cover the new fallback paths. Generated-By: PostHog Code Task-Id: 300b3a9a-c74e-42a2-9099-5ede198c7570
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
apps/code/src/renderer/features/message-editor/suggestions/getSuggestions.ts:166-169
Draft fallback fires when agent sends an explicit empty command list. `getAvailableCommandsForTask` returns `[]` both when no `available_commands_update` has arrived yet and when the agent sends one with `availableCommands: []`. The `sessionCommands.length > 0` guard cannot distinguish these two cases, so if an agent deliberately clears its command list the UI will still show the draft-store fallback — contrary to the stated invariant that "agent-supplied commands remain authoritative once they arrive." Storing a sentinel (e.g. `null` for "not yet received" vs `[]` for "agent sent empty") would let the guard be precise.
```suggestion
const sessionCommands = taskId ? getAvailableCommandsForTask(taskId) : null;
const draftCommands = store.commands[sessionId] ?? [];
// null → agent hasn't reported yet, use draft fallback
// [] → agent reported an empty list, respect it (no custom commands)
// [...] → agent reported commands, use them
const agentCommands = sessionCommands ?? draftCommands;
```
Reviews (2): Last reviewed commit: "fix(code): show user skills in running t..." | Re-trigger Greptile |
`extractAvailableCommandsFromEvents` returned `[]` both when no `available_commands_update` had arrived and when the agent reported one with `availableCommands: []`. The `getCommandSuggestions` fallback then fired in both cases, which contradicted the invariant that agent-supplied commands are authoritative once they arrive. Return `null` from the extractor (and from `getAvailableCommandsForTask` / `useAvailableCommandsForTask`) to mean "not yet received"; `[]` now means "agent reported empty" and the draft-store fallback is skipped. Adds a parameterised test for the new case. Generated-By: PostHog Code Task-Id: 456f79c0-c95d-4e46-8888-0087ead45124
Mid-prompt `/` was matching the popover behavior advertised for `@` and `#`, but two separate autofill paths kept hijacking the experience: - `autoCommit: true` on `CommandMention` committed the chip as soon as the query exactly matched a label, closing the popover before the user could scan it. - `CommandGhostText` rendered inline ghost text (Tab to accept) whenever a `/query` appeared mid-prompt, instead of surfacing the same suggestion popover used at the start of the line. Remove both. `/` now opens the popover at the start of a line and after a space, with arrow-key/enter selection — matching `@` and `#`. The unused `autoCommit` plumbing in `createSuggestionMention` goes with it. Generated-By: PostHog Code Task-Id: 456f79c0-c95d-4e46-8888-0087ead45124
Reverts the deletions of `CommandGhostText` and the `autoCommit` plumbing on `createSuggestionMention`. The autofill behavior is still disabled — we just don't register the extension or pass the option from `CommandMention` — but the code stays in tree so we can flip it back on later without re-writing it. Generated-By: PostHog Code Task-Id: 456f79c0-c95d-4e46-8888-0087ead45124
Problem
In running tasks, the
/popup only showed/good /bad /feedbackuntil the agent'savailable_commands_updatearrived. And/mid-prompt opened an inline autocomplete instead of the popover.Changes
PromptInputso session views populate it too./opens the popover anywhere in the prompt (matching@and#), instead of the inline ghost-text autofill. The autofill code stays in tree but is no longer wired up.available_commands_updatefrom the agent now suppresses the draft-store fallback, so the agent stays authoritative.How did you test this?
pnpm --filter code typecheckpnpm --filter code exec vitest run src/renderer/features/message-editor/(70 tests pass, 6 in the newgetSuggestions.test.ts)Publish to changelog?
no