Commit Graph

2 Commits

Author SHA1 Message Date
João Salavisa 7be0db04d8 fix(backend): restrict branch/dir name sanitizers to ASCII alphanumerics (#1095)
* fix(backend): strip non-ASCII chars from branch/worktree names

Non-ASCII titles (CJK, Cyrillic, Arabic, emoji) flowed verbatim into git
branch names and worktree directory names because the sanitizers used
unicode.IsLetter/IsDigit, which accept any Unicode letter or digit. The
resulting names broke many downstream tools and left worktrees
effectively inaccessible.

Restrict SanitizeForBranch and SanitizeRepoDirName to ASCII
alphanumerics. Non-ASCII runes now route through the existing
hyphen-replace + collapse + trim pipeline, and the existing fallback
chain (sanitized title -> sanitized task ID -> "task") handles
titles that become empty after stripping. The "Issue #N:" / "PR #N:"
prefix already added by the GitHub ingestion path means a non-ASCII
issue title still produces a recognizable name like "issue-123".

Closes #1081

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* refactor(worktree): fix comment accuracy and harden test assertion

- Remove "emoji" from isASCIIAlphaNum doc — emoji are not Unicode
  letters (unicode.IsLetter returns false), so the prior code never
  admitted bare emoji. Correct examples to CJK, Cyrillic, Arabic.
- Replace hard-coded len(dirName) != 8 with strings.Contains check
  so the assertion stays correct if suffix length ever changes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Kandev Agent <agent@kandev.dev>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 13:36:00 +01:00
João Salavisa b30933240b fix: sanitize multi-repo worktree dirs and polish task-create chip dropdown (#815)
* fix: sanitize multi-repo worktree dirs and polish task-create chip dropdown

Backend: org-prefixed Repository.Name like "owner/repo" was used verbatim
as the worktree subdirectory under the task root, nesting one level too
deep and breaking agentctl's sibling-based multi-repo detection in
scanRepositorySubdirs. Sanitize to a single path-safe segment so all
worktrees land as siblings of the task root.

Web: the multi-repo chip dropdown built its own option list and dropped
the path Badge plus search filtering that the legacy header dropdown
shipped. Restore parity (name + path), widen the popover (288 → 360 px),
stack name and full path on two lines so neither has to truncate
aggressively, hide the Badge for workspace repos without a local clone,
and use a path-aware scorer that floors weak fuzzy matches so unrelated
paths stop surfacing for short queries.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix: address PR review feedback

- Add ErrInvalidRepoName sentinel and use it in createInTaskDir when
  RepoName sanitizes to empty, replacing the misleading reuse of
  ErrTaskDirRequired (Claude/Greptile).
- Reuse repoDirHyphenRun in SanitizeForBranch instead of recompiling the
  regexp per call (CodeRabbit nitpick).
- Document the SanitizeRepoDirName collision edge case in the doc
  comment (Greptile).
- Extract scoreRepo to lib/utils/repo-filter.ts and add unit tests
  pinning the 0.4 fuzzy-match threshold (Claude).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Kandev Agent <agent@kandev.dev>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-04 17:22:28 +01:00