-
-
Notifications
You must be signed in to change notification settings - Fork 95
Fix project automation Qodo follow-ups #166
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
Open
friuns2
wants to merge
3
commits into
main
Choose a base branch
from
codex/project-automation-qodo-followups
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3275,21 +3275,60 @@ function serializeTomlString(value: string): string { | |
| function parseTomlStringArray(value: string): string[] { | ||
| const trimmed = value.trim() | ||
| if (!trimmed.startsWith('[') || !trimmed.endsWith(']')) return [] | ||
| try { | ||
| const parsed = JSON.parse(trimmed) | ||
| return Array.isArray(parsed) | ||
| ? parsed.filter((item): item is string => typeof item === 'string' && item.trim().length > 0) | ||
| : [] | ||
| } catch { | ||
| return [] | ||
| const values: string[] = [] | ||
| let index = 1 | ||
| const endIndex = trimmed.length - 1 | ||
|
|
||
| while (index < endIndex) { | ||
| while (index < endIndex && /[\s,]/u.test(trimmed[index] ?? '')) index += 1 | ||
| if (index >= endIndex) break | ||
|
|
||
| const quote = trimmed[index] | ||
| if (quote !== '"' && quote !== "'") return [] | ||
| const start = index | ||
| index += 1 | ||
| let valueText = '' | ||
|
|
||
| if (quote === "'") { | ||
| const closeIndex = trimmed.indexOf("'", index) | ||
| if (closeIndex < 0 || closeIndex > endIndex) return [] | ||
| valueText = trimmed.slice(index, closeIndex) | ||
| index = closeIndex + 1 | ||
| } else { | ||
| let escaped = false | ||
| while (index < endIndex) { | ||
| const char = trimmed[index] ?? '' | ||
| if (escaped) { | ||
| escaped = false | ||
| } else if (char === '\\') { | ||
| escaped = true | ||
| } else if (char === '"') { | ||
| break | ||
| } | ||
| index += 1 | ||
| } | ||
| if (index >= endIndex || trimmed[index] !== '"') return [] | ||
| try { | ||
| valueText = JSON.parse(trimmed.slice(start, index + 1)) as string | ||
| } catch { | ||
| return [] | ||
| } | ||
| index += 1 | ||
| } | ||
|
|
||
| if (valueText.trim().length > 0) values.push(valueText) | ||
| while (index < endIndex && /\s/u.test(trimmed[index] ?? '')) index += 1 | ||
| if (index < endIndex && trimmed[index] !== ',') return [] | ||
| } | ||
|
|
||
| return values | ||
|
Comment on lines
3275
to
+3324
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1. No performance audit documented This PR introduces behavior changes (new TOML array parsing and automation API response shaping) without an accompanying measurement- or analysis-grounded performance audit. This risks unnoticed regressions (e.g., payload bloat, extra requests, or slower routes) in the affected automation flows. Agent Prompt
|
||
| } | ||
|
|
||
| function serializeTomlStringArray(values: string[]): string { | ||
| return `[${values.map((value) => serializeTomlString(value)).join(', ')}]` | ||
| } | ||
|
|
||
| function parseAutomationToml(raw: string): ThreadAutomationRecord | null { | ||
| export function parseAutomationToml(raw: string): ThreadAutomationRecord | null { | ||
| const values: Record<string, string> = {} | ||
| const extraTomlLines: string[] = [] | ||
| const knownKeys = new Set([ | ||
|
|
@@ -3388,6 +3427,29 @@ function serializeAutomationToml(record: ThreadAutomationRecord): string { | |
| return `${lines.join('\n')}\n` | ||
| } | ||
|
|
||
| export function toAutomationApiRecord(record: ThreadAutomationRecord): Omit<ThreadAutomationRecord, 'extraTomlLines'> { | ||
| const { extraTomlLines: _extraTomlLines, ...apiRecord } = record | ||
| return apiRecord | ||
| } | ||
|
|
||
| function toAutomationApiMap( | ||
| automationsByTarget: Record<string, ThreadAutomationRecord[]>, | ||
| ): Record<string, Array<Omit<ThreadAutomationRecord, 'extraTomlLines'>>> { | ||
| return Object.fromEntries( | ||
| Object.entries(automationsByTarget).map(([target, automations]) => [ | ||
| target, | ||
| automations.map(toAutomationApiRecord), | ||
| ]), | ||
| ) | ||
| } | ||
|
|
||
| function toAutomationApiData( | ||
| automation: ThreadAutomationRecord | ThreadAutomationRecord[] | null, | ||
| ): Omit<ThreadAutomationRecord, 'extraTomlLines'> | Array<Omit<ThreadAutomationRecord, 'extraTomlLines'>> | null { | ||
| if (Array.isArray(automation)) return automation.map(toAutomationApiRecord) | ||
| return automation ? toAutomationApiRecord(automation) : null | ||
| } | ||
|
|
||
| function slugifyAutomationId(threadId: string, name: string): string { | ||
| const preferred = name.trim().toLowerCase().replace(/[^a-z0-9]+/gu, '-').replace(/^-+|-+$/gu, '') | ||
| if (preferred) return preferred.slice(0, 48) | ||
|
|
@@ -7255,13 +7317,13 @@ export function createCodexBridgeMiddleware(): CodexBridgeMiddleware { | |
|
|
||
| if (req.method === 'GET' && url.pathname === '/codex-api/thread-automations') { | ||
| const automationsByThreadId = await listThreadHeartbeatAutomations() | ||
| setJson(res, 200, { data: automationsByThreadId }) | ||
| setJson(res, 200, { data: toAutomationApiMap(automationsByThreadId) }) | ||
| return | ||
| } | ||
|
|
||
| if (req.method === 'GET' && url.pathname === '/codex-api/project-automations') { | ||
| const automationsByProjectName = await listProjectCronAutomations() | ||
| setJson(res, 200, { data: automationsByProjectName }) | ||
| setJson(res, 200, { data: toAutomationApiMap(automationsByProjectName) }) | ||
| return | ||
| } | ||
|
|
||
|
|
@@ -7275,7 +7337,7 @@ export function createCodexBridgeMiddleware(): CodexBridgeMiddleware { | |
| const automation = automationId | ||
| ? await readThreadHeartbeatAutomation(threadId, automationId) | ||
| : await readThreadHeartbeatAutomations(threadId) | ||
| setJson(res, 200, { data: automation }) | ||
| setJson(res, 200, { data: toAutomationApiData(automation) }) | ||
| return | ||
| } | ||
|
|
||
|
|
@@ -7289,7 +7351,7 @@ export function createCodexBridgeMiddleware(): CodexBridgeMiddleware { | |
| const automation = automationId | ||
| ? await readProjectCronAutomation(projectName, automationId) | ||
| : await readProjectCronAutomations(projectName) | ||
| setJson(res, 200, { data: automation }) | ||
| setJson(res, 200, { data: toAutomationApiData(automation) }) | ||
| return | ||
| } | ||
|
|
||
|
|
@@ -7357,7 +7419,7 @@ export function createCodexBridgeMiddleware(): CodexBridgeMiddleware { | |
| return | ||
| } | ||
| const automation = await writeThreadHeartbeatAutomation({ threadId, id, name, prompt, rrule, status }) | ||
| setJson(res, 200, { data: automation }) | ||
| setJson(res, 200, { data: toAutomationApiRecord(automation) }) | ||
| return | ||
| } | ||
|
|
||
|
|
@@ -7378,7 +7440,7 @@ export function createCodexBridgeMiddleware(): CodexBridgeMiddleware { | |
| return | ||
| } | ||
| const automation = await writeProjectCronAutomation({ projectName, id, name, prompt, rrule, status }) | ||
| setJson(res, 200, { data: automation }) | ||
| setJson(res, 200, { data: toAutomationApiRecord(automation) }) | ||
| return | ||
| } | ||
|
|
||
|
|
||
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
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.
Uh oh!
There was an error while loading. Please reload this page.