fix: harden linked workspace intent naming (#4686)

- trim prose punctuation from embedded GitHub URLs before smart submit parsing
- avoid treating generated workspace slugs as explicit user intent
- add regression coverage for both edge cases
This commit is contained in:
Jinjing
2026-06-04 23:50:04 -07:00
committed by GitHub
parent 0575b9a8cc
commit 3312bdc285
4 changed files with 56 additions and 10 deletions
@@ -39,6 +39,28 @@ describe('getSmartGitHubSubmitIntent', () => {
})
})
it('finds an embedded GitHub item URL when prose punctuation touches the URL', () => {
expect(
getSmartGitHubSubmitIntent('review (https://github.com/stablyai/orca/pull/2049), please')
).toEqual({
kind: 'link',
owner: 'stablyai',
repo: 'orca',
number: 2049,
type: 'pr'
})
expect(getSmartGitHubSubmitIntent('fix https://github.com/stablyai/orca/issues/2050.')).toEqual(
{
kind: 'link',
owner: 'stablyai',
repo: 'orca',
number: 2050,
type: 'issue'
}
)
})
it('treats #number as source intent but leaves plain numbers as names', () => {
expect(getSmartGitHubSubmitIntent('#2049')).toEqual({
kind: 'hash-number',
+4 -1
View File
@@ -46,6 +46,7 @@ export type SmartGitHubSubmitLookup = {
const SMART_GITHUB_SUBMIT_LOOKUP_TTL_MS = 60_000
const SMART_GITHUB_SUBMIT_LOOKUP_CACHE_MAX_ENTRIES = 128
const GITHUB_ITEM_URL_RE = /https?:\/\/(?:www\.)?github\.com\/\S+/i
const TRAILING_GITHUB_ITEM_URL_PUNCTUATION_RE = /[),.;\]}]+$/
type SmartGitHubSubmitLookupCacheEntry = {
expiresAt: number
@@ -100,7 +101,9 @@ function parseGitHubIssueOrPRLinkFromText(
input: string
): ReturnType<typeof parseGitHubIssueOrPRLink> {
const match = GITHUB_ITEM_URL_RE.exec(input)
return match ? parseGitHubIssueOrPRLink(match[0]) : null
return match
? parseGitHubIssueOrPRLink(match[0].replace(TRAILING_GITHUB_ITEM_URL_PUNCTUATION_RE, ''))
: null
}
function getSmartGitHubSubmitLookupCacheKey({
+16
View File
@@ -90,6 +90,22 @@ describe('getWorkspaceIntentName', () => {
})
})
it('does not treat an auto-generated slug as explicit user intent', () => {
expect(
getWorkspaceIntentName({
sourceText: 'issue-123-fix-navbar',
workItem: {
type: 'issue',
number: 456,
title: 'Make importer handle archived rows'
}
})
).toEqual({
displayName: 'Issue 456 Make Importer Handle',
seedName: 'issue-456-make-importer-handle'
})
})
it('uses external provider identifiers without duplicating them in the subject', () => {
expect(
getWorkspaceIntentName({
+14 -9
View File
@@ -42,16 +42,21 @@ export type WorkspaceIntentName = {
seedName: string
}
// Why: generated workspace seeds are hyphenated; `issue-123-fix-title`
// must not be reinterpreted as the user explicitly asking to fix a new issue.
const ACTION_LABELS: [RegExp, string][] = [
[/\bfix(?:e[sd])?\b|\bresolve\b|\brepair\b/i, 'Fix'],
[/\bdebug\b|\bdiagnose\b/i, 'Debug'],
[/\breview\b|\blook\s+over\b|\binspect\b|\bcheck\b|\bsafe\b|\bsafety\b/i, 'Review'],
[/\bimplement\b|\bbuild\b|\bship\b/i, 'Implement'],
[/\binvestigate\b|\bunderstand\b|\btriage\b/i, 'Investigate'],
[/\badd\b|\bcreate\b/i, 'Add'],
[/\bupdate\b|\bchange\b/i, 'Update'],
[/\brefactor\b|\bsimplify\b/i, 'Refactor'],
[/\btest\b|\bverify\b|\bvalidate\b/i, 'Test']
[/(?:^|[^a-z0-9_-])(?:fix(?:e[sd])?|resolve|repair)(?:$|[^a-z0-9_-])/i, 'Fix'],
[/(?:^|[^a-z0-9_-])(?:debug|diagnose)(?:$|[^a-z0-9_-])/i, 'Debug'],
[
/(?:^|[^a-z0-9_-])(?:review|look\s+over|inspect|check|safe|safety)(?:$|[^a-z0-9_-])/i,
'Review'
],
[/(?:^|[^a-z0-9_-])(?:implement|build|ship)(?:$|[^a-z0-9_-])/i, 'Implement'],
[/(?:^|[^a-z0-9_-])(?:investigate|understand|triage)(?:$|[^a-z0-9_-])/i, 'Investigate'],
[/(?:^|[^a-z0-9_-])(?:add|create)(?:$|[^a-z0-9_-])/i, 'Add'],
[/(?:^|[^a-z0-9_-])(?:update|change)(?:$|[^a-z0-9_-])/i, 'Update'],
[/(?:^|[^a-z0-9_-])(?:refactor|simplify)(?:$|[^a-z0-9_-])/i, 'Refactor'],
[/(?:^|[^a-z0-9_-])(?:test|verify|validate)(?:$|[^a-z0-9_-])/i, 'Test']
]
const STOP_WORDS = new Set([