Repository navigation
Take the suggested name from the line after a lead-in, without its label [patch] - #242
Merged
Merged
Conversation
…bel [patch] Chat-tuned models often answer "Here is a suggested filename:" and put the name on the next line, or write "**Filename:** `sunset-beach`". The first line was kept, so the lead-in or the label became the stored suggestion. SanitizeFileName now skips a line ending in a colon when another line follows, and strips a leading label and a heading, bullet or list marker. Fixes #237 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW55AnQ5psSyMDKg84G
Resolve the SanitizeFileName conflict with #232 by keeping its formatting and extension handling and taking the line from SelectNameLine. The #232 test row for "Suggested filename: **sunset-beach.png**" pinned the label surviving, which #237 fixes, so it now expects sunset-beach.png. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW55AnQ5psSyMDKg84G
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



Fixes #237
What changed
SanitizeFileNamekept the first non-empty line of the model's answer. When a chat-tuned model wrote a lead-in first, such as "Here is a suggested filename:", the lead-in was stored as the suggestion, and suggestions are never re-requested for a hash. A label on the same line as the name ("Filename:sunset-beach") stayed in the result too.The line choice now lives in a new helper,
Scan.SelectNameLine::when another content line follows. Emphasis around the colon counts, as in**Here is the filename:**. If the lead-in is the only line, it is still used.#,-,*,1.).label:prefix when text follows it. The label may be wrapped in*/_. A label is only letters, spaces and apostrophes followed by whitespace, so a name likesunset-at-5:30pmis left alone.The rest of the sanitizing (quotes, extension, portable characters, length cap, device names) is unchanged. I left the default prompt alone, because it already asks for "only the filename … without … explanation".
Tests
SanitizeFileNameSkipsALeadInAndStripsALabelOrMarkdownMarkercovers every row of the issue's table, plus an emphasised lead-in, a lead-in followed by a fenced name,_Filename_:,-and1..SanitizeFileNameKeepsANameThatOnlyLooksLikeALabelOrLeadIncoverssunset-at-5:30pm, a loneFilename:, and**sunset-beach**.Scan.csreverted, 9 of the new cases fail. With the fix, the full suite passes: 158 passed, 1 skipped because it runs as root.Note on #232
Open PR #232 (for #225) rewrites the lines right after the line-selection statement, so whichever PR lands second gets a small conflict in
SanitizeFileName. To resolve it, take #232's version of the function and replace its openingstring name = rawSuggestion.Split('\n')…FirstOrDefault(…)statement withstring name = SelectNameLine(rawSuggestion);.Generated by Claude Code