Skip to content

feat: prompt inject condition for api key, close #1202#1210

Merged
looplj merged 1 commit intorelease/v0.9.xfrom
dev-tmp
Mar 28, 2026
Merged

feat: prompt inject condition for api key, close #1202#1210
looplj merged 1 commit intorelease/v0.9.xfrom
dev-tmp

Conversation

@looplj
Copy link
Copy Markdown
Owner

@looplj looplj commented Mar 28, 2026

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new prompt activation condition based on API keys, allowing prompts to be triggered for specific keys. The changes span the frontend UI for prompt configuration, GraphQL schema updates, and backend matching logic in the PromptMatcher. Feedback on the PR identifies critical compilation errors in the test suite due to invalid Go syntax (new(1)) and suggests a user experience improvement for displaying API key labels in the frontend dialog.

conditions: []objects.PromptActivationConditionComposite{
{
Conditions: []objects.PromptActivationCondition{
{Type: objects.PromptActivationConditionTypeAPIKey, APIKeyID: new(1)},
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.

critical

The syntax new(1) is invalid in Go as the built-in new function expects a type, not a value. This will cause a compilation error. To get a pointer to an integer literal, you should use the lo.ToPtr() helper function, which is already being used in this test file.

Suggested change
{Type: objects.PromptActivationConditionTypeAPIKey, APIKeyID: new(1)},
{Type: objects.PromptActivationConditionTypeAPIKey, APIKeyID: lo.ToPtr(1)},

conditions: []objects.PromptActivationConditionComposite{
{
Conditions: []objects.PromptActivationCondition{
{Type: objects.PromptActivationConditionTypeAPIKey, APIKeyID: new(1)},
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.

critical

The syntax new(1) is invalid in Go as the built-in new function expects a type, not a value. This will cause a compilation error. To get a pointer to an integer literal, you should use the lo.ToPtr() helper function, which is already being used in this test file.

Suggested change
{Type: objects.PromptActivationConditionTypeAPIKey, APIKeyID: new(1)},
{Type: objects.PromptActivationConditionTypeAPIKey, APIKeyID: lo.ToPtr(1)},

if (!apiKeysData?.edges) return [];
return apiKeysData.edges.map((edge) => ({
value: String(edge.node.id),
label: edge.node.name || `API Key #${edge.node.id}`,
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.

medium

For a better user experience, the API key label should display the numeric ID (e.g., "API Key #123") instead of the full GUID (e.g., "API Key #APIKey_123"). You can use the extractNumberIDAsNumber function, which is already imported, to extract the numeric part of the ID.

Suggested change
label: edge.node.name || `API Key #${edge.node.id}`,
label: edge.node.name || "API Key #" + extractNumberIDAsNumber(edge.node.id),

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

@looplj looplj merged commit bb23c59 into release/v0.9.x Mar 28, 2026
3 checks passed
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.

1 participant