Repository navigation
feat(combos): add editable per-combo description field persisted via /api/combos (#5005) #5011
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| /** | ||
| * #5005 — Per-combo editable `description` field. | ||
| * | ||
| * The routing-combo API historically had NO `description` field: the Zod | ||
| * `createComboSchema` / `updateComboSchema` stripped any `description` on save. | ||
| * This proves the schema now ACCEPTS and PRESERVES `description`, and that the | ||
| * value round-trips through the DB layer (persisted in the `data` JSON blob and | ||
| * surfaced back by GET-style reads), with no new DB column. | ||
| */ | ||
| import test from "node:test"; | ||
| import assert from "node:assert/strict"; | ||
| import fs from "node:fs"; | ||
| import os from "node:os"; | ||
| import path from "node:path"; | ||
|
|
||
| const TEST_DATA_DIR = fs.mkdtempSync(path.join(os.tmpdir(), "omniroute-combo-desc-5005-")); | ||
| process.env.DATA_DIR = TEST_DATA_DIR; | ||
|
|
||
| const { createComboSchema, updateComboSchema } = await import( | ||
| "../../src/shared/validation/schemas.ts" | ||
| ); | ||
| const core = await import("../../src/lib/db/core.ts"); | ||
| const combosDb = await import("../../src/lib/db/combos.ts"); | ||
|
|
||
| async function resetStorage() { | ||
| core.resetDbInstance(); | ||
| if (fs.existsSync(TEST_DATA_DIR)) { | ||
| fs.rmSync(TEST_DATA_DIR, { recursive: true, force: true }); | ||
| } | ||
| fs.mkdirSync(TEST_DATA_DIR, { recursive: true }); | ||
| } | ||
|
|
||
| test.beforeEach(async () => { | ||
| await resetStorage(); | ||
| }); | ||
|
|
||
| test.after(async () => { | ||
| core.resetDbInstance(); | ||
| fs.rmSync(TEST_DATA_DIR, { recursive: true, force: true }); | ||
| }); | ||
|
|
||
| test("createComboSchema preserves description instead of stripping it", () => { | ||
| const parsed = createComboSchema.parse({ | ||
| name: "Described Combo", | ||
| models: [{ provider: "openai", model: "gpt-4.1" }], | ||
| description: "Routes premium traffic to GPT-4.1", | ||
| }); | ||
| assert.equal(parsed.description, "Routes premium traffic to GPT-4.1"); | ||
| }); | ||
|
|
||
| test("updateComboSchema preserves description instead of stripping it", () => { | ||
| const parsed = updateComboSchema.parse({ | ||
| description: "Updated description text", | ||
| }); | ||
| assert.equal(parsed.description, "Updated description text"); | ||
| }); | ||
|
|
||
| test("description round-trips through createCombo and getComboById/getComboByName", async () => { | ||
| const created = await combosDb.createCombo({ | ||
| name: "Desc Combo", | ||
| models: [{ provider: "openai", model: "gpt-4.1" }], | ||
| description: "My human-friendly note", | ||
| }); | ||
| assert.equal(created.description, "My human-friendly note"); | ||
|
|
||
| const byId = await combosDb.getComboById(created.id as string); | ||
| assert.ok(byId, "combo should be retrievable by id"); | ||
| assert.equal(byId!.description, "My human-friendly note"); | ||
|
|
||
| const byName = await combosDb.getComboByName("Desc Combo"); | ||
| assert.ok(byName, "combo should be retrievable by name"); | ||
| assert.equal(byName!.description, "My human-friendly note"); | ||
| }); | ||
|
|
||
| test("description survives an updateCombo and is listed by getCombos", async () => { | ||
| const created = await combosDb.createCombo({ | ||
| name: "Update Desc Combo", | ||
| models: [{ provider: "openai", model: "gpt-4.1" }], | ||
| }); | ||
|
|
||
| const updated = await combosDb.updateCombo(created.id as string, { | ||
| description: "Added later via PUT", | ||
| }); | ||
| assert.ok(updated); | ||
| assert.equal(updated!.description, "Added later via PUT"); | ||
|
|
||
| const all = await combosDb.getCombos(); | ||
| const found = all.find((c) => c.id === created.id); | ||
| assert.ok(found, "updated combo should appear in getCombos"); | ||
| assert.equal(found!.description, "Added later via PUT"); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To prevent users from entering descriptions longer than the backend schema limit (2000 characters), we should add the
maxLength={2000}attribute to the<textarea>element. This ensures a better user experience by preventing unexpected API validation failures on form submission.