Skip to content

Commit e1fd88b

Browse files
refactor: address pr comments.
1 parent 7dff17b commit e1fd88b

3 files changed

Lines changed: 13 additions & 17 deletions

File tree

.github/instructions/pr-review.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ You are reviewing changes for @knighted/develop. Be concise, technical, and spec
2424
## What to verify
2525

2626
- No generated artifacts are edited (dist/, coverage/, test-results/).
27+
- Duplicated logic paths are avoided when a shared helper/module already exists; prefer reusing the established implementation.
2728
- CDN import/fallback behavior is not bypassed with ad hoc URLs in feature modules.
2829
- Sensitive values (PAT/token) are not logged or exposed in UI/status output.
2930
- New UI behavior is covered in Playwright where appropriate.

src/modules/app-core/github-workflows.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { toWorkspaceRecordKey } from '../workspace/workspace-tab-helpers.js'
2+
13
const initializeGitHubWorkflows = ({
24
createGitHubPrEditorSyncController,
35
createGitHubChatDrawer,
@@ -120,22 +122,6 @@ const initializeGitHubWorkflows = ({
120122
const toSafeRepositoryFullName = value =>
121123
typeof value === 'string' ? value.trim() : ''
122124

123-
const toWorkspaceIdentitySegment = value => {
124-
const normalized = typeof value === 'string' ? value.trim().toLowerCase() : ''
125-
126-
if (!normalized) {
127-
return ''
128-
}
129-
130-
return normalized.replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '')
131-
}
132-
133-
const toWorkspaceRecordKey = ({ repositoryFullName, headBranch } = {}) => {
134-
const repoSegment = toWorkspaceIdentitySegment(repositoryFullName) || 'local'
135-
const headSegment = toWorkspaceIdentitySegment(headBranch) || 'draft'
136-
return `${repoSegment}::${headSegment}`
137-
}
138-
139125
const shouldApplyActivePrEditorSync = ({ repository, activeContext }) => {
140126
const syncedContextKey = getActivePrContextSyncKey(activeContext)
141127
const currentSyncKey = getActivePrEditorSyncKey()
@@ -258,6 +244,7 @@ const initializeGitHubWorkflows = ({
258244
fileUpdates,
259245
repositoryFullName,
260246
pullRequestNumber,
247+
branch,
261248
}) => {
262249
if (typeof onPrContextStateChange === 'function') {
263250
onPrContextStateChange(githubAiContextState.activePrContext)

src/modules/app-core/pr-context-records.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,19 @@ const persistClosedPrContextRecords = async ({
4444
recordsForContext.map(record => {
4545
const preservedTitle =
4646
toNonEmptyWorkspaceText(record.prTitle) || normalizedFallbackTitle
47+
const preservedPrNumber =
48+
typeof record.prNumber === 'number' && Number.isFinite(record.prNumber)
49+
? record.prNumber
50+
: null
51+
const nextPersistedPrNumber =
52+
typeof nextPrNumber === 'number' && Number.isFinite(nextPrNumber)
53+
? nextPrNumber
54+
: preservedPrNumber
4755

4856
return workspaceStorage.upsertWorkspace({
4957
...record,
5058
prContextState: 'closed',
51-
prNumber: nextPrNumber,
59+
prNumber: nextPersistedPrNumber,
5260
prTitle: preservedTitle,
5361
lastModified: now,
5462
})

0 commit comments

Comments
 (0)