Refactor: unify capture filename assembly into CaptureFilename#9
Merged
Merged
Conversation
The '<prefix><app slug> <timestamp>.<ext>' rule lived in CaptureManager.saveImage and was re-implemented in PreferencesWindow.filenamePreview, so the two could drift (the preview also hardcoded .png regardless of the chosen format). Extract the assembly into a pure CaptureFilename.make(prefix:slug:timestamp:ext:) used by both, and add CaptureFormat.fileExtension to unify the jpg/png derivation. Real save path is behavior-preserving. The settings preview now reflects the selected format's extension (was always .png) and otherwise renders identically. Adds CaptureFilenameTests (6 cases).
GamalAnwar
added a commit
that referenced
this pull request
Jun 18, 2026
Extract the '<prefix><slug> <timestamp>.<ext>' rule (duplicated across CaptureManager.saveImage and PreferencesWindow.filenamePreview) into a pure CaptureFilename.make(...), and add CaptureFormat.fileExtension. Real save path is behavior-preserving; the settings preview now reflects the chosen format's extension (was hardcoded .png). Adds CaptureFilenameTests (6 cases). CI green.
GamalAnwar
added a commit
that referenced
this pull request
Jun 18, 2026
Extract the '<prefix><slug> <timestamp>.<ext>' rule (duplicated across CaptureManager.saveImage and PreferencesWindow.filenamePreview) into a pure CaptureFilename.make(...), and add CaptureFormat.fileExtension. Real save path is behavior-preserving; the settings preview now reflects the chosen format's extension (was hardcoded .png). Adds CaptureFilenameTests (6 cases). CI green.
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.
Summary
The capture filename rule —
<prefix><app slug> <timestamp>.<ext>, withprefixdefaulting toStag_and the slug omitted (with its space) when empty — lived inCaptureManager.saveImageand was re-implemented inPreferencesWindow.filenamePreview. Two copies of the same rule that could (and partly did) drift.This extracts the assembly into a pure helper used by both:
and adds
CaptureFormat.fileExtension(png/jpg) so the extension derivation isn't an inline ternary either.Scope / safety
CaptureManager) is behavior-preserving —fileExtensionreturns exactly what the old== .jpeg ? "jpg" : "png"ternary did, and the prefix/slug assembly is identical.filenamePreviewpreviously hardcoded.pngregardless of the selected format; it now reflectsprefs.defaultFormat.fileExtension. Same example values otherwise (Safari,2026-01-01). Called out because it's a (minor) visible change to the settings label.Tests
CaptureFilenameTests(6 cases): empty-prefix fallback, custom prefix verbatim, slug inserted with separating space, empty-slug omits the space (no double space), extension applied, andCaptureFormat.fileExtensionmapping.🤖 Generated with Claude Code
Generated by Claude Code