Skip to content

fix(prompts): include command in prompt group list projections - #16880

Closed
aniketkrs wants to merge 2 commits into
LibreChat-AI:devfrom
aniketkrs:fix/prompt-list-command
Closed

aniketkrs wants to merge 2 commits into
LibreChat-AI:devfrom
aniketkrs:fix/prompt-list-command

Conversation

@aniketkrs

Copy link
Copy Markdown
Contributor

Impact

A prompt saved with a slash command (e.g. weather) never reaches the browser through the two prompt-group list endpoints, so:

  • the / popover lists the prompt by name only, without the /weather - prefix,
  • typing /weather does not match the prompt that owns that command,
  • nothing downstream of the popover can know which command was picked.

The prompt's own page shows the command correctly because GET /api/prompts/groups/:groupId returns it. Only the list responses lose it.

Cause

getListPromptGroupsByAccess (serving GET /api/prompts/all) and getPromptGroups (serving GET /api/prompts/groups) project list fields with Mongoose .select() but omit command:

.select(
  'name numberOfGenerations oneliner category productionId author authorName createdAt updatedAt',
)

The sibling getAllPromptGroups selects command, so the field exists on the model. The client expects it (client/src/Providers/PromptGroupsContext.tsx builds each popover option as value: group.command ?? group.name with a /${group.command} - label prefix), so group.command is always undefined in the popover today.

Fix

Add command to the .select() projection in both list queries (packages/data-schemas/src/methods/prompt.ts). One focused change, no schema or type changes needed (command is already projected elsewhere and the list responses are Record<string, unknown>[]).

Fixes #16874.

Copilot AI balanced review requested due to automatic review settings October 8, 2026 03:54
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions
github-actions Bot changed the base branch from main to dev October 8, 2026 03:54
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

👋 Thanks for the contribution! LibreChat merges all changes into dev first — main only moves at release time — so this pull request's base branch was switched from main to dev automatically.

Nothing is needed from you; your commits, reviews and discussion are unchanged. If the diff now shows files you did not touch, rebase onto dev:

git remote add upstream https://github.com/LibreChat-AI/LibreChat.git
git fetch upstream dev
git rebase upstream/dev
git push --force-with-lease

Maintainers: apply the target: main label and restore the base branch if this one genuinely belongs on main.

@AtefBellaaj
AtefBellaaj self-requested a review October 9, 2026 14:42

@AtefBellaaj AtefBellaaj left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for working on this. can you please add some tests for this?

@aniketkrs

Copy link
Copy Markdown
Contributor Author

Done, added regression tests in packages/data-schemas/src/methods/prompt.spec.ts covering both list endpoints (getPromptGroups and getListPromptGroupsByAccess). Each creates a group with a command value and asserts the returned projection carries it, so either projection dropping command fails the test.

@AtefBellaaj

Copy link
Copy Markdown
Collaborator

@aniketkrs much appreciated 🙏

can you please check the failing tests and static checks? I would appreciated it also if you rebase with the dev branch. Thank you 😊

@aniketkrs aniketkrs closed this Oct 12, 2026
@aniketkrs
aniketkrs deleted the fix/prompt-list-command branch October 12, 2026 04:28
@aniketkrs

Copy link
Copy Markdown
Contributor Author

Thanks for the review. I looked at the three failing checks and both problems trace back to the test file I added.

The TypeScript type check failed because the new test read result.promptGroups off the union return type without narrowing it first. I replaced that with an explicit in check that throws a clear error if the error shape comes back instead.

The static check failure was formatting in the same block. I cleaned that up.

The data schemas test failure came from the same TypeScript error breaking compilation of the spec.

I also rebased the branch onto the latest dev as requested. The branch now sits at upstream dev 5ee091e9 with the same changes across two files: the command projection fix in prompt.ts plus the corrected regression tests in prompt.spec.ts.

CI is rerunning on the new head. Let me know if anything else needs attention.

@AtefBellaaj

Copy link
Copy Markdown
Collaborator

I see that you closed the PR. Was this a mistake?

@aniketkrs

Copy link
Copy Markdown
Contributor Author

Yes, that close was a mistake on my side. While rebasing onto dev I deleted and recreated the branch, which auto closed this PR, and GitHub does not allow reopening a PR whose branch was recreated.

I have opened #17046 with the same fix on the rebased head. It addresses your review: regression tests for both list projections are included, the TS2339 union error is fixed by narrowing on promptGroups, and the spec file passes the repo Prettier config. Continuing the review there; this one can stay closed.

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.

[Bug]: Prompt group lists omit command, so the / popover never shows or matches a prompt's command

3 participants