Skip to content

feat(ai): support unlabeled batch fetch in prompts getAll - #5000

Merged
jurajmajerik merged 2 commits into
mainfrom
prompts-get-all-unlabeled
Sep 17, 2026
Merged

jurajmajerik merged 2 commits into
mainfrom
prompts-get-all-unlabeled

Conversation

@jurajmajerik

Copy link
Copy Markdown
Contributor

Problem

prompts.getAll() requires a label, so there is no way to batch-fetch the latest version of every prompt. The server treats any label value as a filter, so no value a caller could pass produces the unlabeled listing that plain get(name) resolves to. Requested by a customer; mirrors PostHog/posthog-python#966.

Changes

  • label on getAll is now optional. Without it, the request omits the label param and returns the latest version of every prompt, matching plain get(name).
  • Unlabeled results are cached under the undefined cache key that plain get(name) reads, so those calls become cache hits.
  • The label-resolution checks (absent/moved rows) only run when a label was requested.

Release info Sub-libraries affected

Libraries affected

  • @posthog/ai

Checklist

  • Tests for new code
  • Accounted for the impact of any changes across different platforms
  • Accounted for backwards compatibility of any changes (no breaking changes!)
  • Took care not to unnecessarily increase the bundle size

If releasing new changes

  • Changeset file added (.changeset/prompts-get-all-unlabeled.md, minor)

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

  • Written with Claude Code (model: claude-fable-5), driven by @jurajmajerik.
  • One test added to the getAll() block: an unlabeled fetch must omit the label param from the URL, accept rows without labels, and seed the unlabeled get() cache. All 69 prompt tests pass; check-types, oxlint and oxfmt clean.

@greptile-apps

greptile-apps Bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
### Issue 1
packages/ai/src/prompts.ts:106-109
**Misplaced label-state documentation**

The new helper separates `rowLabelState` from the documentation that describes it, making that documentation appear to describe `promptListReference` instead. Move the helper above the label-state documentation, or move the documentation directly above `rowLabelState`, so future changes do not misread the helper's behavior.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "feat(ai): support unlabeled batch fetch ..." | Re-trigger Greptile

Comment thread packages/ai/src/prompts.ts Outdated
Comment on lines +106 to +109
/** Formats a batch-fetch reference for logs and errors. */
function promptListReference(label: string | undefined): string {
return label === undefined ? 'all prompts' : `prompts with label "${label}"`
}

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.

P2 Misplaced label-state documentation

The new helper separates rowLabelState from the documentation that describes it, making that documentation appear to describe promptListReference instead. Move the helper above the label-state documentation, or move the documentation directly above rowLabelState, so future changes do not misread the helper's behavior.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/ai/src/prompts.ts
Line: 106-109

Comment:
**Misplaced label-state documentation**

The new helper separates `rowLabelState` from the documentation that describes it, making that documentation appear to describe `promptListReference` instead. Move the helper above the label-state documentation, or move the documentation directly above `rowLabelState`, so future changes do not misread the helper's behavior.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed in 3e1b4f6

@marandaneto marandaneto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The code looks good; no qualifying findings. Verdict: correct.

@jurajmajerik
jurajmajerik merged commit 1dfde0e into main Sep 17, 2026
64 checks passed
@jurajmajerik
jurajmajerik deleted the prompts-get-all-unlabeled branch September 17, 2026 13:48
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.

2 participants