The regex matching --session-id <uuid> / --resume <uuid> in a claude argv is duplicated byte-for-byte across 5 files:
internal/app/sessions.go:19 (claudeSessionArgRe)
internal/iterm/iterm.go:107 (claudeSessionRowRe)
internal/terminal/terminal.go:195 (claudeSessionRowRe)
internal/zellij/zellij.go:134 (claudeSessionRowRe)
internal/kitty/kitty.go:163 (claudeSessionRowRe)
All five compile the same pattern:
`(?:--session-id|--resume)[ =]([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})`
Proposed change
Create a new package internal/claudematch exporting:
- the compiled regex
- a small helper like
func ExtractSessionUUID(line string) (string, bool) returning the lowercased UUID if a match is found
Update the 5 call sites to import and use it. Behavior must be identical — drop the duplicate vars in each backend.
Notes
- Pure refactor: no behavior change, no contract change, no test rewrites beyond import paths.
- Existing per-package tests should keep passing unchanged.
- Spec-pattern of mock vars (
PSRunner, RunnerOutput, etc.) is unrelated and must not be touched.
Acceptance
The regex matching
--session-id <uuid>/--resume <uuid>in aclaudeargv is duplicated byte-for-byte across 5 files:internal/app/sessions.go:19(claudeSessionArgRe)internal/iterm/iterm.go:107(claudeSessionRowRe)internal/terminal/terminal.go:195(claudeSessionRowRe)internal/zellij/zellij.go:134(claudeSessionRowRe)internal/kitty/kitty.go:163(claudeSessionRowRe)All five compile the same pattern:
`(?:--session-id|--resume)[ =]([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})`Proposed change
Create a new package
internal/claudematchexporting:func ExtractSessionUUID(line string) (string, bool)returning the lowercased UUID if a match is foundUpdate the 5 call sites to import and use it. Behavior must be identical — drop the duplicate
vars in each backend.Notes
PSRunner,RunnerOutput, etc.) is unrelated and must not be touched.Acceptance
go test ./...greengo vet ./...cleaninternal/claudematch