feat: prompt inject condition for api key, close #1202#1210
feat: prompt inject condition for api key, close #1202#1210looplj merged 1 commit intorelease/v0.9.xfrom
Conversation
There was a problem hiding this comment.
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)}, |
There was a problem hiding this comment.
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.
| {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)}, |
There was a problem hiding this comment.
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.
| {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}`, |
There was a problem hiding this comment.
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.
| label: edge.node.name || `API Key #${edge.node.id}`, | |
| label: edge.node.name || "API Key #" + extractNumberIDAsNumber(edge.node.id), |
Uh oh!
There was an error while loading. Please reload this page.