Repository navigation
refactor(forge): forge reads and edits route by the repo's owner or the task source - #27276
Conversation
70499f1 to
33da579
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to Several earlier concerns are still open: project-row edits could be routed to the wrong host when hosts differ, cache-key parsing could mishandle environment IDs containing a colon, and the new focus-read ratchet could miscount or miss readers. Resolve or explicitly accept these before merging. Pre-merge checks |
|
There was a problem hiding this comment.
Actionable comments posted: 8
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
bed527db-55b2-433e-9158-cd135bf46c80
📥 Commits
Reviewing files that changed from the base of the PR and between 5c7c493 and 33da5797d79b26ebf4c99d464e035d66be0e9ed1.
📒 Files selected for processing (88)
config/focus-setting-read-baseline.txtconfig/owner-routing-baseline.txtconfig/scripts/check-owner-routing-ratchet.mjsconfig/scripts/check-owner-routing-ratchet.test.mjssrc/renderer/src/components/github-item-dialog/edit-item-fields/gh-edit-section.tsxsrc/renderer/src/components/github-item-dialog/land-pull-request/pr-actions-panel.tsxsrc/renderer/src/components/github-item-dialog/land-pull-request/pr-reviewers-panel.tsxsrc/renderer/src/components/github-item-dialog/land-pull-request/pr-reviewers-request-actions.tssrc/renderer/src/components/github-project/ProjectCell.tsxsrc/renderer/src/components/github-project/ProjectCellIdentity.tsxsrc/renderer/src/components/github-project/ProjectCellIssueType.tsxsrc/renderer/src/components/github-project/ProjectCellRepositoryEditors.tsxsrc/renderer/src/components/github-project/ProjectItemSlugDialog.tsxsrc/renderer/src/components/github-project/ProjectPicker.tsxsrc/renderer/src/components/github-project/ProjectRow.tsxsrc/renderer/src/components/github-project/ProjectViewList.tsxsrc/renderer/src/components/github-project/ProjectViewToolbar.tsxsrc/renderer/src/components/github-project/ProjectViewWrapper.tsxsrc/renderer/src/components/github-project/project-picker-runtime.tssrc/renderer/src/components/github-project/slug-dialog/AssigneesEditor.tsxsrc/renderer/src/components/github-project/slug-dialog/Comments.tsxsrc/renderer/src/components/github-project/slug-dialog/LabelsEditor.tsxsrc/renderer/src/components/github-project/slug-dialog/SlugDialogBody.tsxsrc/renderer/src/components/github-project/useProjectPickerBrowse.tssrc/renderer/src/components/github-project/useProjectViewTable.tssrc/renderer/src/components/github/PRAssigneesPanel.tsxsrc/renderer/src/components/github/PRFilterDropdowns.tsxsrc/renderer/src/components/github/github-rate-limit-display.tsxsrc/renderer/src/components/github/github-work-item-edit-mutations.tssrc/renderer/src/components/github/github-work-item-mutation-target.test.tssrc/renderer/src/components/gitlab/gitlab-rate-limit-display.tsxsrc/renderer/src/components/pull-request-page/actions/panel.tsxsrc/renderer/src/components/pull-request-page/conversation/tab.tsxsrc/renderer/src/components/pull-request-page/edit/section.tsxsrc/renderer/src/components/pull-request-page/reviewers/panel.tsxsrc/renderer/src/components/pull-request-page/reviewers/request-actions.tssrc/renderer/src/components/settings/GitProviderApiBudgetPane.tsxsrc/renderer/src/components/settings/provider-account-scope.test.tssrc/renderer/src/components/settings/provider-account-scope.tssrc/renderer/src/components/settings/provider-rate-limit-scope-panels.test.tsxsrc/renderer/src/components/settings/repository-github-account.tssrc/renderer/src/components/settings/repository-icon-github.tssrc/renderer/src/components/settings/settings-git-task-section-renderers.tsxsrc/renderer/src/components/task-page-github-reviewer-actions.tssrc/renderer/src/components/task-page/github/AssigneesCell.tsxsrc/renderer/src/components/task-page/github/Filters.tsxsrc/renderer/src/components/task-page/github/MergeCell.tsxsrc/renderer/src/components/task-page/github/ReviewCell.tsxsrc/renderer/src/components/task-page/github/StatusCell.tsxsrc/renderer/src/components/use-task-page-github-issue-draft.tssrc/renderer/src/hooks/composer-state/composer-source-state.tssrc/renderer/src/hooks/composer-state/gitlab-provider-selection.tssrc/renderer/src/hooks/useGitHubRepoMetadata.tssrc/renderer/src/hooks/useGitHubSlugMetadata.test.tsxsrc/renderer/src/hooks/useGitHubSlugMetadata.tssrc/renderer/src/hooks/useIssueMetadata.test.tsxsrc/renderer/src/lib/default-creation-host.test.tssrc/renderer/src/lib/default-creation-host.tssrc/renderer/src/lib/github-source-runtime-context.test.tssrc/renderer/src/lib/github-source-runtime-context.tssrc/renderer/src/lib/hosted-review-repo-read.tssrc/renderer/src/lib/repo-runtime-owner.test.tssrc/renderer/src/lib/repo-runtime-owner.tssrc/renderer/src/lib/repo-slug-cache.test.tssrc/renderer/src/lib/repo-slug-cache.tssrc/renderer/src/lib/repo-slug-index.tssrc/renderer/src/lib/resolve-owner.test.tssrc/renderer/src/lib/resolve-owner.tssrc/renderer/src/lib/task-source-runtime-target.test.tssrc/renderer/src/lib/task-source-runtime-target.tssrc/renderer/src/runtime/runtime-client-target.test.tssrc/renderer/src/runtime/runtime-client-target.tssrc/renderer/src/store/github/cache-identity.tssrc/renderer/src/store/github/project-actions.tssrc/renderer/src/store/github/project-field-mutations.tssrc/renderer/src/store/github/project-row-actions.tssrc/renderer/src/store/github/provider-request-coalescing.test.tssrc/renderer/src/store/github/slice-types.tssrc/renderer/src/store/github/work-item-mutation-actions.tssrc/renderer/src/store/slices/github-project-request-coordination.test.tssrc/renderer/src/store/slices/github-project-row-owner.test.tssrc/renderer/src/store/slices/github-project-row-owner.tssrc/renderer/src/store/slices/github-project-view-tables.test.tssrc/renderer/src/store/slices/github-provider-request-concurrency.test.tssrc/renderer/src/store/slices/hosted-review-cache-state.tssrc/renderer/src/store/slices/hosted-review.test.tssrc/renderer/src/store/slices/hosted-review.tssrc/renderer/src/store/slices/worktrees/session/worktree-terminal-reference.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
| const SETTING_MEMBER_READ = | ||
| /\??\.\s*activeRuntimeEnvironmentId\b|(?<!(?:\b[A-Z][\w$]*|>)\s*)\[\s*['"]activeRuntimeEnvironmentId['"]\s*\]/g |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Exclude property assignments from the read count.
If source code contains settings.activeRuntimeEnvironmentId = id, SETTING_MEMBER_READ counts the assignment as a read. A new assignment can therefore fail the focus-read ratchet even though it adds no setting read. Exclude simple assignments while retaining accesses that read the previous value.
| const SETTING_DESTRUCTURE_READ = | ||
| /\{[^{}]*\bactiveRuntimeEnvironmentId\b[^{}]*\}(?:\s*\})*\s*(?::[^=;{}]*)?=(?![=>])/g |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Count destructured setting parameters.
If an exported function accepts ({ activeRuntimeEnvironmentId }) and uses that value to select a host, this pattern finds no read because the parameter has no =. discoverFocusReaders then misses the function, and calls to it pass the ratchet. Count setting destructuring in function parameters as well as assignments.
| seedUse.lastIndex = 0 | ||
| if (exported && (countSettingReads(body) > 0 || seedUse.test(body))) { |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Recognize functions exported by a separate declaration.
If a function reads the setting and the module later uses export { focusHost }, topLevelDeclarations marks the function as unexported. This condition omits focusHost from the reader set, so calls in other files add no focus-read count. Resolve named export lists against the declarations before filtering readers.
| @@ -38,7 +38,7 @@ export function ProjectAssigneesCell({ | |||
| open ? owner : null, | |||
| open ? repo : null, | |||
| seedKey ? seedKey.split(',') : [], | |||
| sourceSettings, | |||
| sourceTarget, | |||
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
# Locate the hooks and inspect their target selection and transport branches.
fd -i 'useGitHubSlugMetadata' src/renderer/src/hooks
rg -n -C 8 'useRepoAssigneesBySlug|useRepoLabelsBySlug|callRuntimeRpc|sourceTarget|runtimeTargetForRepoOwner' src/renderer/src/hooks src/renderer/src/components/github-projectRepository: stablyai/orca
Length of output: 42472
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- ProjectCellRepositoryEditors.tsx ---'
nl -ba src/renderer/src/components/github-project/ProjectCellRepositoryEditors.tsx
printf '%s\n' '--- ProjectRow.tsx relevant wiring ---'
nl -ba src/renderer/src/components/github-project/ProjectRow.tsx | sed -n '1,180p'
printf '%s\n' '--- ProjectCellField.tsx references ---'
rg -n -C 12 --glob '*.tsx' 'ProjectAssigneesCell|ProjectLabelsCell|runtimeTargetForRepoOwner|onEditAssignees|onEditLabels|sourceTarget' src/renderer/src/components/github-project
printf '%s\n' '--- runtimeTargetForRepoOwner ---'
rg -n -C 20 --glob '*.ts' --glob '*.tsx' 'export function runtimeTargetForRepoOwner|function runtimeTargetForRepoOwner' src/renderer/srcRepository: stablyai/orca
Length of output: 41960
Route repository metadata through the matched repository owner.
The metadata hooks use sourceTarget directly. A row with a matched repository owner on another host can therefore load assignees and labels from the board host, while its edit action targets the repository owner. Resolve the matched owner for these hooks and keep sourceTarget for unmatched rows.
| args.sourceContext?.provider === 'github' | ||
| ? getTaskSourceRuntimeSettings(args.sourceContext) | ||
| : getGitHubMutationSettings(args.repoId) | ||
| const target = getActiveRuntimeTarget(targetSettings) | ||
| ? taskSourceRuntimeTarget(args.sourceContext) | ||
| : getGitHubMutationTarget(args.repoId, args.projectOrigin) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Use the tracked Project-row repository owner before the source host. When a tracked row repository belongs to a different host from its GitHub source or board, these paths can send repository operations to the source host. Use the source or cache-key target only when the row repository has no known owner.
src/renderer/src/components/github/github-work-item-edit-mutations.ts#L47-L49: check the tracked repository owner beforetaskSourceRuntimeTargetin this issue-update branch and the corresponding PR body and state branches.src/renderer/src/components/github-project/slug-dialog/SlugDialogBody.tsx#L59-L59: resolve the tracked row owner before requesting details, and pass that target to the dialog’s metadata and comment components; preserve the cache-key target for untracked rows.
📍 Affects 2 files
src/renderer/src/components/github/github-work-item-edit-mutations.ts#L47-L49(this comment)src/renderer/src/components/github-project/slug-dialog/SlugDialogBody.tsx#L59-L59
| return runtimeMatch | ||
| ? { ...settings, activeRuntimeEnvironmentId: runtimeMatch[1] } | ||
| : { ...settings, activeRuntimeEnvironmentId: null } | ||
| return runtimeMatch ? { kind: 'environment', environmentId: runtimeMatch[1] } : { kind: 'local' } |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
# Inspect environment-ID creation and validation, then compare cache-key writers and readers.
rg -n -C 3 'environmentId:|environmentId\s*=|projectViewSourceScope|projectViewCacheKeyTarget' src/shared src/renderer/src/runtime src/renderer/src/store/githubRepository: stablyai/orca
Length of output: 45667
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- cache identity and direct consumers ---'
nl -ba src/renderer/src/store/github/cache-identity.ts | sed -n '1,110p'
nl -ba src/renderer/src/store/github/project-row-actions.ts | sed -n '70,115p;205,240p'
nl -ba src/renderer/src/store/github/project-field-mutations.ts | sed -n '45,75p;115,140p'
printf '%s\n' '--- runtime environment ID declarations and normalization ---'
rg -n -F --glob '*.{ts,d.ts}' -- 'environment.id' src/shared src/renderer/src | head -200
rg -n -F --glob '*.{ts,d.ts}' -- 'runtimeEnvironments' src/shared src/renderer/src | head -200
rg -n -E --glob '*.{ts,d.ts}' '(normalize.*Environment|EnvironmentId|environment.*id.*(valid|parse|normalize)|id.*environment)' src/shared src/renderer/src | head -300
printf '%s\n' '--- environment creation and persistence ---'
rg -n -E --glob '*.{ts,d.ts}' '(create.*Environment|environment.*(create|register|save|persist)|KnownRuntimeEnvironment|RuntimeEnvironment)' src/shared src/renderer/src | head -400Repository: stablyai/orca
Length of output: 40398
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- candidate runtime-environment files ---'
rg --files src/shared src/renderer/src | rg 'runtime-environment|global-settings|execution-host'
printf '%s\n' '--- environment schemas/types and ID normalization ---'
rg -n -F --glob '*.{ts,d.ts}' -- 'KnownRuntimeEnvironment' src/shared src/renderer/src || true
rg -n -F --glob '*.{ts,d.ts}' -- 'PublicKnownRuntimeEnvironment' src/shared src/renderer/src || true
rg -n -F --glob '*.{ts,d.ts}' -- 'runtimeEnvironmentSchema' src/shared src/renderer/src || true
rg -n -F --glob '*.{ts,d.ts}' -- 'environmentIdSchema' src/shared src/renderer/src || true
rg -n -F --glob '*.{ts,d.ts}' -- 'updateEnvironmentFromPairingCode' src/shared src/renderer/src || true
rg -n -F --glob '*.{ts,d.ts}' -- 'addRuntimeEnvironment' src/shared src/renderer/src || true
rg -n -F --glob '*.{ts,d.ts}' -- 'toRuntimeExecutionHostId' src/shared src/renderer/src || true
printf '%s\n' '--- likely type/schema excerpts ---'
for f in $(rg --files src/shared src/renderer/src | rg 'runtime-environment|execution-host' | head -80); do
if rg -q -E 'KnownRuntimeEnvironment|PublicKnownRuntimeEnvironment|environment.*id|Environment.*id|z\.object|interface .*Environment' "$f"; then
echo "### $f"
nl -ba "$f" | sed -n '1,260p'
fi
doneRepository: stablyai/orca
Length of output: 41186
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- shared/runtime-environments.ts ---'
nl -ba src/shared/runtime-environments.ts | sed -n '1,230p'
printf '%s\n' '--- shared/execution-host.ts ---'
nl -ba src/shared/execution-host.ts | sed -n '1,120p'
printf '%s\n' '--- shared/runtime-environment-store.ts ---'
nl -ba src/shared/runtime-environment-store.ts | sed -n '1,190p'
printf '%s\n' '--- shared/runtime-environment-store-file.ts ---'
nl -ba src/shared/runtime-environment-store-file.ts | sed -n '1,120p'Repository: stablyai/orca
Length of output: 28183
Encode runtime environment IDs in project-view cache scopes.
PersistedRuntimeEnvironmentSchema permits : in id. The writer stores the complete ID, but projectViewCacheKeyTarget captures only the text before the first :. Field edits, and row edits that use the cache-source fallback, can therefore route to the wrong environment.
🐛 Suggested fix
export function projectViewSourceScope(target: RuntimeClientTarget): string {
- return target.kind === 'environment' ? `runtime:${target.environmentId}` : 'local'
+ return target.kind === 'environment'
+ ? `runtime:${encodeURIComponent(target.environmentId)}`
+ : 'local'
}
/** The host a board row was loaded from, read back from the scope written into its cache key. */
export function projectViewCacheKeyTarget(cacheKey: string): RuntimeClientTarget {
const runtimeMatch = /^github-project:runtime:([^:]+):/.exec(cacheKey)
- return runtimeMatch ? { kind: 'environment', environmentId: runtimeMatch[1] } : { kind: 'local' }
+ if (!runtimeMatch) {
+ return { kind: 'local' }
+ }
+ try {
+ return { kind: 'environment', environmentId: decodeURIComponent(runtimeMatch[1]) }
+ } catch {
+ return { kind: 'local' }
+ }
}| host: string | undefined, | ||
| rowSource: RuntimeClientTarget | ||
| ): RuntimeClientTarget { | ||
| const matchedRepo = lookupReposBySlugFromCache(state.repos, `${owner}/${repo}`, host)[0] |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Do not select the first repository when multiple hosts match a slug. If the same GitHub repository is tracked on two hosts, lookupReposBySlugFromCache returns both rows. This line always chooses repository order, even when the Project row was loaded from the other host. A row edit can therefore use the wrong host's credentials. Select a unique match for rowSource, or leave an ambiguous match on rowSource rather than choosing an unrelated host.
| rowSource: RuntimeClientTarget | ||
| ): RuntimeClientTarget { | ||
| const matchedRepo = lookupReposBySlugFromCache(state.repos, `${owner}/${repo}`, host)[0] | ||
| return (matchedRepo ? runtimeTargetForRepoOwner(state, matchedRepo.id) : null) ?? rowSource |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Derive owner targets from the matched repository row. Both sites find a repository row and then search again by its bare ID. When IDs collide across hosts, the second search can choose the focused host or fail to resolve the row.
src/renderer/src/store/slices/github-project-row-owner.ts#L23-L23: derive the mutation target directly frommatchedRepo.src/renderer/src/components/github-project/ProjectCellIssueType.tsx#L39-L39: derive the issue-type metadata target directly frommatchedRepo.
📍 Affects 2 files
src/renderer/src/store/slices/github-project-row-owner.ts#L23-L23(this comment)src/renderer/src/components/github-project/ProjectCellIssueType.tsx#L39-L39
6cf17c8 to
6a50a2c
Compare
…he task source GitHub PR and issue dialogs, task-page cells, Project boards, slug metadata, the repo slug index, hosted-review actions, GitLab MR base resolution and the Settings API-budget panels now carry a RuntimeClientTarget derived from the repo row, the row-less task source, the board row's cache key or the Settings host scope, instead of settings-shaped objects resolved through getActiveRuntimeTarget. A repo row with no owner stamp is local; an untracked Project row edits on the host that loaded it. Owner-routing ratchet 209 -> 165; focus-read ratchet 401 -> 352.
6a50a2c to
33b0017
Compare
ELI5
When you act on a GitHub or GitLab item in Orca, the action has to run on the machine that owns that repository. Many forge screens instead asked the app-wide "Active Server" setting. This PR makes them ask the repository row, the task source, or the board row instead. For anyone who only uses this computer, nothing changes.
Builds on #27275 (owner transports and the focus-read ratchet), now merged.
What Changed
owner/repomatches a tracked repository. In that case the edit goes to that repository's owner.sourceSettings/settingstoRuntimeClientTarget(ownerTarget,sourceTarget,target), so the compiler found every caller.runtimeTargetForRepoOwner(repo row → transport, ornullwhen no single row names the repo),taskSourceRuntimeTarget,projectViewCacheKeyTarget,hostedReviewRepoOwnerTarget,runtimeTargetForProjectRowOwner,getGitHubMutationTargetandgetGitHubRepoRoutingTarget.getGitHubRepoRoutingSettings,getGitHubMutationSettings,settingsForProjectViewCacheKey,settingsForProjectRowOwner,settingsForHostedReviewActionOwner,settingsForRepoOwner(in repo-slug-cache), and theProjectSourceSettingstype.runtime:<env>:…/local:…), so existing caches keep their entries.Why
Each of these screens already knows the resource it acts on (a repository row, a task source, a board row) or has an explicit host choice (Settings). Routing by that resource is the ownership rule from the design, and the forge rows of the ownership table already describe it. We considered keeping a settings-shaped object built from the owner. That is how the bug crept in: raw settings type-check in the same slot and quietly route by focus. Passing a
RuntimeClientTargetmakes that mistake a compile error.Left for a follow-up (6 sites): Linear/Jira (
runtime-linear-client,runtime-jira-target,useIssueMetadata,linear-api-key-dialog) still pass the default-host settings. Their connection status is tracked only for that one host, so moving them needs the per-host task-source scope.store/github/repository-routing.tsand thefetchHostedReviewForBranchpath still take owner-fabricated settings, because those settings also feed the PR and hosted-review cache-key helpers. Migrating those keys is a separate change.Linked Issue
None. This is part of the host-ownership routing stack (D4 G1).
Visual Proof
N/A. The only visible change is the "Budget scope" label in Settings → Git, which now names the Settings host. Unit tests cover it, and the app isn't launched on this load-capped machine.
Testing
New or changed tests that prove the old answer was wrong:
repo-runtime-owner.test.ts: a repo row with no owner stamp is local while a server is focused, and an unknown repo has no transport.github-work-item-mutation-target.test.ts: an untracked Project row edits on the host that loaded it, not the focused server.hosted-review.test.ts: creating a review for an unstamped local repo uses local IPC while a server is focused. The runtime-creation tests now stamp the repo as server-owned, which is what ingest does.provider-rate-limit-scope-panels.test.tsx: the budget scope follows the Settings host, not focus.github-project-row-owner.test.ts,task-source-runtime-target.test.ts,repo-slug-cache.test.ts.Ran:
pnpm tc, focusedpnpm test(77 files, 780 tests),oxlint,oxfmt,pnpm run check:code-quality:changed, andpnpm check:owner-routing-ratchet(both OK).Review
Agent skill upstream boundary
Notes
No wire change; renderer only. SSH: SSH repos keep using this computer's credentials over local IPC. GitLab and other providers: hosted-review creation is provider-neutral, and GitLab MR base resolution moved to the owner.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)