Skip to content

refactor(forge): forge reads and edits route by the repo's owner or the task source - #27276

Merged
OrcaWin merged 1 commit into
mainfrom
OrcaWin/d4-g1-forge
Oct 10, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
OrcaWin/d4-g1-forge

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 15 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​255 $\color{#cf222e}{\Huge{\mathbf{−}}}$​90 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​165
Prod 65 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​475 $\color{#cf222e}{\Huge{\mathbf{−}}}$​567 $\color{#cf222e}{\Huge{\mathbf{−}}}$​92

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

  • Before (user): with a paired server picked as Active Server, some forge actions went to that server even when the repository lives on this computer. Examples: the GitHub filter dropdowns on the Tasks page, the GitHub/GitLab API budget panels in Settings, slug-addressed edits on a Project row whose repository Orca doesn't track, and PR creation for a repo row that has no owner stamp.
  • After (user): each action goes to the host that owns the thing it acts on:
    • PR/issue dialogs and task-page cells (merge, state, reviewers, assignees) use the repository's owner, or the GitHub task source when it names a server.
    • Project boards, the picker and slug dialogs use the board's task-source host. A row's edits use the host the row was loaded from (read back from its cache key), unless the row's owner/repo matches a tracked repository. In that case the edit goes to that repository's owner.
    • Tasks-page filter metadata (labels and assignees for the primary slug) is read from the host that owns the repository the slug came from.
    • The API budget panels in Settings read from the host chosen at the top of Settings (the V7a host picker). Their "Budget scope" label names that host.
    • Hosted-review eligibility, create and create-stacked use the repository row's owner. A repo row with no owner stamp is local. A repo the store doesn't know also stays on this computer instead of going to the focused server.
    • Repo slug resolution (the slug index and its cache keys) is keyed by each repository's owner, so it no longer rebuilds when the Active Server setting changes.
    • GitLab MR base resolution uses the MR repository's owner.
  • Mechanism:
    • Function and prop signatures change from settings-shaped sourceSettings / settings to RuntimeClientTarget (ownerTarget, sourceTarget, target), so the compiler found every caller.
    • New: runtimeTargetForRepoOwner (repo row → transport, or null when no single row names the repo), taskSourceRuntimeTarget, projectViewCacheKeyTarget, hostedReviewRepoOwnerTarget, runtimeTargetForProjectRowOwner, getGitHubMutationTarget and getGitHubRepoRoutingTarget.
    • Deleted settings fabrication: getGitHubRepoRoutingSettings, getGitHubMutationSettings, settingsForProjectViewCacheKey, settingsForProjectRowOwner, settingsForHostedReviewActionOwner, settingsForRepoOwner (in repo-slug-cache), and the ProjectSourceSettings type.
    • Cache keys stay byte-identical (runtime:<env>:… / local:…), so existing caches keep their entries.
    • Ratchets: owner-routing 209 → 165, focus-read 401 → 352.

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 RuntimeClientTarget makes 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.ts and the fetchHostedReviewForBranch path 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

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

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, focused pnpm test (77 files, 780 tests), oxlint, oxfmt, pnpm run check:code-quality:changed, and pnpm check:owner-routing-ratchet (both OK).

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

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

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@OrcaWin
OrcaWin force-pushed the OrcaWin/d4-g1-forge branch from 70499f1 to 33da579 Compare October 10, 2026 16:47
@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 89ad99d3-2b55-4e87-bb04-d59680b42c5a



📥 Commits

Reviewing files that changed from the base of the PR and between 33da5797d79b26ebf4c99d464e035d66be0e9ed1 and 6a50a2c955fc5e1a33af9cbeb448a25016c9cb79.




📒 Files selected for processing (3)
  • config/focus-setting-read-baseline.txt
  • config/scripts/check-owner-routing-ratchet.mjs
  • config/scripts/check-owner-routing-ratchet.test.mjs



Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.





📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

The change adds helpers that resolve runtime targets from task sources and repository or workspace ownership. Renderer operations pass those targets through project views, GitHub and GitLab actions, hosted reviews, metadata hooks, and provider rate-limit panels. The ratchet script now checks owner-routing calls and Active Server setting reads against separate baselines.





Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to 6a50a

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 | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 11.96% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 92 functions across 50 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly summarizes the main change: forge reads and edits now route by repository ownership or task source instead of the app-wide setting.
Description check Passed The description is detailed and covers the required ELI5, changes, rationale, testing, visual proof, review, notes, and checklist sections. It states that no linked issue exists and leaves the full li…

Full details: Docstring Coverage

Explanation

Docstring coverage is 11.96% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 92 functions across 50 files. (1 skipped: 1 unsupported.)


  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR





  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.txt
  • config/owner-routing-baseline.txt
  • config/scripts/check-owner-routing-ratchet.mjs
  • config/scripts/check-owner-routing-ratchet.test.mjs
  • src/renderer/src/components/github-item-dialog/edit-item-fields/gh-edit-section.tsx
  • src/renderer/src/components/github-item-dialog/land-pull-request/pr-actions-panel.tsx
  • src/renderer/src/components/github-item-dialog/land-pull-request/pr-reviewers-panel.tsx
  • src/renderer/src/components/github-item-dialog/land-pull-request/pr-reviewers-request-actions.ts
  • src/renderer/src/components/github-project/ProjectCell.tsx
  • src/renderer/src/components/github-project/ProjectCellIdentity.tsx
  • src/renderer/src/components/github-project/ProjectCellIssueType.tsx
  • src/renderer/src/components/github-project/ProjectCellRepositoryEditors.tsx
  • src/renderer/src/components/github-project/ProjectItemSlugDialog.tsx
  • src/renderer/src/components/github-project/ProjectPicker.tsx
  • src/renderer/src/components/github-project/ProjectRow.tsx
  • src/renderer/src/components/github-project/ProjectViewList.tsx
  • src/renderer/src/components/github-project/ProjectViewToolbar.tsx
  • src/renderer/src/components/github-project/ProjectViewWrapper.tsx
  • src/renderer/src/components/github-project/project-picker-runtime.ts
  • src/renderer/src/components/github-project/slug-dialog/AssigneesEditor.tsx
  • src/renderer/src/components/github-project/slug-dialog/Comments.tsx
  • src/renderer/src/components/github-project/slug-dialog/LabelsEditor.tsx
  • src/renderer/src/components/github-project/slug-dialog/SlugDialogBody.tsx
  • src/renderer/src/components/github-project/useProjectPickerBrowse.ts
  • src/renderer/src/components/github-project/useProjectViewTable.ts
  • src/renderer/src/components/github/PRAssigneesPanel.tsx
  • src/renderer/src/components/github/PRFilterDropdowns.tsx
  • src/renderer/src/components/github/github-rate-limit-display.tsx
  • src/renderer/src/components/github/github-work-item-edit-mutations.ts
  • src/renderer/src/components/github/github-work-item-mutation-target.test.ts
  • src/renderer/src/components/gitlab/gitlab-rate-limit-display.tsx
  • src/renderer/src/components/pull-request-page/actions/panel.tsx
  • src/renderer/src/components/pull-request-page/conversation/tab.tsx
  • src/renderer/src/components/pull-request-page/edit/section.tsx
  • src/renderer/src/components/pull-request-page/reviewers/panel.tsx
  • src/renderer/src/components/pull-request-page/reviewers/request-actions.ts
  • src/renderer/src/components/settings/GitProviderApiBudgetPane.tsx
  • src/renderer/src/components/settings/provider-account-scope.test.ts
  • src/renderer/src/components/settings/provider-account-scope.ts
  • src/renderer/src/components/settings/provider-rate-limit-scope-panels.test.tsx
  • src/renderer/src/components/settings/repository-github-account.ts
  • src/renderer/src/components/settings/repository-icon-github.ts
  • src/renderer/src/components/settings/settings-git-task-section-renderers.tsx
  • src/renderer/src/components/task-page-github-reviewer-actions.ts
  • src/renderer/src/components/task-page/github/AssigneesCell.tsx
  • src/renderer/src/components/task-page/github/Filters.tsx
  • src/renderer/src/components/task-page/github/MergeCell.tsx
  • src/renderer/src/components/task-page/github/ReviewCell.tsx
  • src/renderer/src/components/task-page/github/StatusCell.tsx
  • src/renderer/src/components/use-task-page-github-issue-draft.ts
  • src/renderer/src/hooks/composer-state/composer-source-state.ts
  • src/renderer/src/hooks/composer-state/gitlab-provider-selection.ts
  • src/renderer/src/hooks/useGitHubRepoMetadata.ts
  • src/renderer/src/hooks/useGitHubSlugMetadata.test.tsx
  • src/renderer/src/hooks/useGitHubSlugMetadata.ts
  • src/renderer/src/hooks/useIssueMetadata.test.tsx
  • src/renderer/src/lib/default-creation-host.test.ts
  • src/renderer/src/lib/default-creation-host.ts
  • src/renderer/src/lib/github-source-runtime-context.test.ts
  • src/renderer/src/lib/github-source-runtime-context.ts
  • src/renderer/src/lib/hosted-review-repo-read.ts
  • src/renderer/src/lib/repo-runtime-owner.test.ts
  • src/renderer/src/lib/repo-runtime-owner.ts
  • src/renderer/src/lib/repo-slug-cache.test.ts
  • src/renderer/src/lib/repo-slug-cache.ts
  • src/renderer/src/lib/repo-slug-index.ts
  • src/renderer/src/lib/resolve-owner.test.ts
  • src/renderer/src/lib/resolve-owner.ts
  • src/renderer/src/lib/task-source-runtime-target.test.ts
  • src/renderer/src/lib/task-source-runtime-target.ts
  • src/renderer/src/runtime/runtime-client-target.test.ts
  • src/renderer/src/runtime/runtime-client-target.ts
  • src/renderer/src/store/github/cache-identity.ts
  • src/renderer/src/store/github/project-actions.ts
  • src/renderer/src/store/github/project-field-mutations.ts
  • src/renderer/src/store/github/project-row-actions.ts
  • src/renderer/src/store/github/provider-request-coalescing.test.ts
  • src/renderer/src/store/github/slice-types.ts
  • src/renderer/src/store/github/work-item-mutation-actions.ts
  • src/renderer/src/store/slices/github-project-request-coordination.test.ts
  • src/renderer/src/store/slices/github-project-row-owner.test.ts
  • src/renderer/src/store/slices/github-project-row-owner.ts
  • src/renderer/src/store/slices/github-project-view-tables.test.ts
  • src/renderer/src/store/slices/github-provider-request-concurrency.test.ts
  • src/renderer/src/store/slices/hosted-review-cache-state.ts
  • src/renderer/src/store/slices/hosted-review.test.ts
  • src/renderer/src/store/slices/hosted-review.ts
  • src/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.

Comment on lines +30 to +31
const SETTING_MEMBER_READ =
/\??\.\s*activeRuntimeEnvironmentId\b|(?<!(?:\b[A-Z][\w$]*|>)\s*)\[\s*['"]activeRuntimeEnvironmentId['"]\s*\]/g

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.

Comment on lines +35 to +36
const SETTING_DESTRUCTURE_READ =
/\{[^{}]*\bactiveRuntimeEnvironmentId\b[^{}]*\}(?:\s*\})*\s*(?::[^=;{}]*)?=(?![=>])/g

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.

Comment on lines +85 to +86
seedUse.lastIndex = 0
if (exported && (countSettingReads(body) > 0 || seedUse.test(body))) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ 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-project

Repository: 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/src

Repository: 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.

Comment on lines 47 to +49
args.sourceContext?.provider === 'github'
? getTaskSourceRuntimeSettings(args.sourceContext)
: getGitHubMutationSettings(args.repoId)
const target = getActiveRuntimeTarget(targetSettings)
? taskSourceRuntimeTarget(args.sourceContext)
: getGitHubMutationTarget(args.repoId, args.projectOrigin)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ 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 before taskSourceRuntimeTarget in 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' }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ 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/github

Repository: 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 -400

Repository: 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
done

Repository: 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]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ 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 from matchedRepo.
  • src/renderer/src/components/github-project/ProjectCellIssueType.tsx#L39-L39: derive the issue-type metadata target directly from matchedRepo.
📍 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

@OrcaWin
OrcaWin force-pushed the OrcaWin/d4-g1-forge branch 2 times, most recently from 6cf17c8 to 6a50a2c Compare October 10, 2026 17:09
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant