-
Notifications
You must be signed in to change notification settings - Fork 0
[WRONG BRANCH] fix(prompt): preserve external TOML escaped paths #396
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -714,22 +714,25 @@ function readToggle(configBytes: string | null, id: ToggleId): ToggleState { | |
|
|
||
| function readModelInstructionsFile(configBytes: string | null): string | null { | ||
| if (configBytes === null) return null; | ||
| const parsed = rootValue(configBytes, "model_instructions_file"); | ||
| if (typeof parsed === "string") return parsed; | ||
| if (parsed === undefined) return null; | ||
| for (const line of rootLines(configBytes)) { | ||
| // Capture the whole literal INCLUDING its quotes and decode it, rather than | ||
| // returning the raw inner text. `setRootString` writes this key through | ||
| // `encodeBasicString`, which escapes backslashes, so on Windows the stored | ||
| // literal is "C:\\Users\\..." while the path is "C:\Users\...". Reading the | ||
| // inner text verbatim returned the doubled form: the round trip did not | ||
| // survive, `baseSelection` compared a doubled path against the real variant | ||
| // path and reported `external` for a variant this code had just selected. | ||
| // literal is "C:\\Users\\..." while the path is "C:\Users\...". | ||
| // | ||
| // `[^"]*` cannot span an escaped quote either. That is not a new limit -- it | ||
| // is the same one the writer's restricted escape set is built around, and | ||
| // `decodeBasicString` refuses anything outside it rather than guessing. | ||
| // Prefer Bun's TOML decoder above so externally-authored standard escapes | ||
| // remain present and external. This restricted scan is only a fallback for | ||
| // documents Bun cannot parse. If its narrow decoder refuses a literal, | ||
| // preserve that literal rather than treating the setting as absent. | ||
| const m = /^\s*model_instructions_file\s*=\s*("[^"]*")\s*(?:#.*)?$/.exec(line); | ||
| if (m) return decodeBasicString(m[1]!); | ||
| if (m) return decodeBasicString(m[1]!) ?? m[1]!; | ||
| } | ||
| return null; | ||
| // A present non-string value or unrecognised spelling fails closed. Only | ||
| // `undefined` above proves that the setting is absent. | ||
| return "<unreadable model_instructions_file>"; | ||
|
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.
When AGENTS.md reference: src/AGENTS.md:L10-L10 Useful? React with 👍 / 👎. |
||
| } | ||
|
|
||
| /** Variant ids are ours to generate, so they stay in one narrow shape. */ | ||
|
|
||
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.
For externally authored basic strings containing valid
\tor\fescapes, this returns Bun's decoded value even though this same module documents that supported Bun versions transpose those escapes relative to Codex's Rust TOML parser. The dashboard therefore reports the wrong path, andcomputePromptProbeStateFingerprintreads and hashes that wrong file, so editing the real external prompt may leave a cached probe result valid; decode these path literals with Codex-compatible TOML escape semantics rather than trusting Bun's parsed string.AGENTS.md reference: src/AGENTS.md:L10-L10
Useful? React with 👍 / 👎.