Skip to content

refactor: extract shared claude session UUID regex #55

Description

@unni-facets

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

  • go test ./... green
  • go vet ./... clean
  • No remaining literal copies of the regex outside internal/claudematch

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions