Skip to content

fix(code): show user skills in / popup and drop the autofill#2229

Merged
adboio merged 4 commits into
mainfrom
posthog-code/fix-slash-command-popup-skills
Jun 8, 2026
Merged

fix(code): show user skills in / popup and drop the autofill#2229
adboio merged 4 commits into
mainfrom
posthog-code/fix-slash-command-popup-skills

Conversation

@richardsolomou

@richardsolomou richardsolomou commented May 19, 2026

Copy link
Copy Markdown
Member

Problem

In running tasks, the / popup only showed /good /bad /feedback until the agent's available_commands_update arrived. And / mid-prompt opened an inline autocomplete instead of the popover.

Changes

  • Running tasks fall back to the trpc-fetched skills list while session commands are empty. Loader moved to PromptInput so 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.
  • An explicit empty available_commands_update from the agent now suppresses the draft-store fallback, so the agent stays authoritative.

How did you test this?

  • pnpm --filter code typecheck
  • pnpm --filter code exec vitest run src/renderer/features/message-editor/ (70 tests pass, 6 in the new getSuggestions.test.ts)

Publish to changelog?

no

@richardsolomou richardsolomou requested a review from a team May 19, 2026 16:51
@richardsolomou richardsolomou marked this pull request as ready for review May 19, 2026 16:51
@greptile-apps

greptile-apps Bot commented May 19, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
Fix 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

Comment thread apps/code/src/renderer/features/message-editor/suggestions/getSuggestions.test.ts Outdated
@adboio

adboio commented May 19, 2026

Copy link
Copy Markdown
Contributor

this is a regression, i'm gonna take a peek in case there's a smaller/simpler bug here we can fix!

@adboio adboio self-assigned this May 19, 2026
@adboio

adboio commented May 22, 2026

Copy link
Copy Markdown
Contributor

@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?

@richardsolomou

Copy link
Copy Markdown
Member Author

@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

@richardsolomou richardsolomou force-pushed the posthog-code/fix-slash-command-popup-skills branch from 72e84a3 to c3969bc Compare May 25, 2026 05:35
@greptile-apps

greptile-apps Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
Fix 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

Comment thread apps/code/src/renderer/features/message-editor/suggestions/getSuggestions.ts Outdated
@richardsolomou richardsolomou changed the title fix(code): show user skills in running tasks and trigger / after spaces fix(code): show user skills in / popup and drop the autofill May 25, 2026
@richardsolomou richardsolomou requested review from a team and removed request for a team May 30, 2026 13:47
@k11kirky

k11kirky commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Sorry @richardsolomou

Still got one remaining this

pr_fetched_at is written but never read

updatePrCache still stamps prFetchedAt: now(), but a repo-wide grep confirms nothing reads it (only schema/migration/mock/write sites). getTaskPrStatus still fires void this.revalidateTaskPrStatus(...) unconditionally on every call:

const cachedPrState = (cached?.prState ?? null) as SidebarPrState;
void this.revalidateTaskPrStatus(taskId, cloudPrUrl); // no staleness gate
if (cachedPrState) return { prState: cachedPrState, hasDiff: false };
So the headline cold-start scenario — every visible card spawning a gh subprocess at once on restart — is made non-blocking but not suppressed. The react-query staleTime: 60_000 only dedupes within a live session; it resets on restart, which is precisely when the column was meant to help. Still a "wire it in or drop it" call. A two-line gate closes it:

const TTL = 60_000;
const fetchedAt = cached?.prFetchedAt ? Date.parse(cached.prFetchedAt) : 0;
if (Date.now() - fetchedAt > TTL) void this.revalidateTaskPrStatus(taskId, cloudPrUrl);

we don't want the TTL, instead delete the column + its migration line so you're not shipping a written-but-unread field

@richardsolomou

Copy link
Copy Markdown
Member Author

@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

@adboio what do you think about this?

adboio commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

@richardsolomou sorry for the delay, i think you're right! testing now, will merge shortly :) thank you!

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
`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
@adboio adboio force-pushed the posthog-code/fix-slash-command-popup-skills branch from 538db06 to 5745292 Compare June 8, 2026 18:28

adboio commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit c98a106.

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
@adboio adboio force-pushed the posthog-code/fix-slash-command-popup-skills branch from 5745292 to c98a106 Compare June 8, 2026 18:39
@adboio adboio merged commit 1a83b8b into main Jun 8, 2026
20 checks passed

adboio commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Merge activity

@adboio adboio deleted the posthog-code/fix-slash-command-popup-skills branch June 8, 2026 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants