Skip to content

Commit 21660fc

Browse files
author
DavidQ
committed
BUILD PR: centralize getRuntimeAndRegistry across exact command-pack/preset batch.
1 parent 229a579 commit 21660fc

File tree

9 files changed

+186
-138
lines changed

9 files changed

+186
-138
lines changed

docs/dev/CODEX_COMMANDS.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
MODEL: GPT-5.3-codex
22
REASONING: high
33
COMMAND:
4-
Execute docs/pr/BUILD_PR_SHARED_EXTRACTION_42_CREATE_RESULT_COMMANDPACK_BATCH.md exactly.
4+
Execute docs/pr/BUILD_PR_SHARED_EXTRACTION_43_GET_RUNTIME_AND_REGISTRY_BATCH.md exactly.
55
Edit only these files:
6-
- tools/dev/commandPacks/commandPackResultUtils.js (new file)
6+
- tools/dev/shared/runtimeRegistryUtils.js (new file)
77
- tools/dev/commandPacks/groupCommandPack.js
8-
- tools/dev/commandPacks/macroCommandPack.js
9-
- tools/dev/commandPacks/toggleCommandPack.js
8+
- tools/dev/commandPacks/overlayCommandPack.js
9+
- tools/dev/presets/debugPresetApplier.js
1010
Do not expand scope.
11-
Package the delta output to <project folder>/tmp/BUILD_PR_SHARED_EXTRACTION_42_CREATE_RESULT_COMMANDPACK_BATCH_delta.zip
11+
Package the delta output to <project folder>/tmp/BUILD_PR_SHARED_EXTRACTION_43_GET_RUNTIME_AND_REGISTRY_BATCH_delta.zip

docs/dev/COMMIT_COMMENT.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
BUILD PR: centralize createResult across exact command-pack batch.
1+
BUILD PR: centralize getRuntimeAndRegistry across exact command-pack/preset batch.

docs/dev/NEXT_COMMAND.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Next: run BUILD_PR_SHARED_EXTRACTION_43_GET_RUNTIME_AND_REGISTRY_BATCH after this batch.
1+
Next: continue duplicate-family extraction from the provided duplicate report.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Execution-grade batch for createResult using the exact duplicate-report file list.
1+
Execution-grade batch for getRuntimeAndRegistry using the exact duplicate-report file list.
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# BUILD_PR_SHARED_EXTRACTION_43_GET_RUNTIME_AND_REGISTRY_BATCH
2+
3+
## Purpose
4+
Centralize duplicated `getRuntimeAndRegistry(context)` implementations across the exact command-pack/preset batch identified in the duplicate report.
5+
6+
## Single PR Purpose
7+
Normalize ONLY this helper:
8+
9+
- `getRuntimeAndRegistry(context)`
10+
11+
## Exact Files Allowed
12+
13+
### New shared file
14+
1. `tools/dev/shared/runtimeRegistryUtils.js`
15+
16+
### Consumer files
17+
2. `tools/dev/commandPacks/groupCommandPack.js`
18+
3. `tools/dev/commandPacks/overlayCommandPack.js`
19+
4. `tools/dev/presets/debugPresetApplier.js`
20+
21+
Do not edit any other file.
22+
23+
## Source of Truth
24+
This exact scope comes from the provided duplicate report entry for:
25+
26+
`function getRuntimeAndRegistry(context)`
27+
28+
Only the 3 listed consumer files are in scope.
29+
30+
## Exact Shared Helper Creation
31+
Create:
32+
33+
`tools/dev/shared/runtimeRegistryUtils.js`
34+
35+
Export exactly:
36+
37+
```js
38+
export function getRuntimeAndRegistry(context) {
39+
// copy one existing implementation exactly
40+
}
41+
```
42+
43+
Implementation rules:
44+
- use ONE existing local implementation as source-of-truth
45+
- do NOT merge logic
46+
- do NOT generalize behavior
47+
- preserve the function signature exactly:
48+
- `getRuntimeAndRegistry(context)`
49+
50+
## Exact Consumer Changes
51+
For each of the 3 listed consumer files:
52+
53+
If the file contains a local function definition matching:
54+
```js
55+
function getRuntimeAndRegistry(context)
56+
```
57+
then:
58+
- remove the local `getRuntimeAndRegistry(context)` function definition
59+
- import `getRuntimeAndRegistry` from the correct relative path to:
60+
- `../shared/runtimeRegistryUtils.js` for command pack files
61+
- `../shared/runtimeRegistryUtils.js` for `tools/dev/presets/debugPresetApplier.js`
62+
- if the file already imports from that module, add `getRuntimeAndRegistry` with the minimum safe edit
63+
- do not duplicate imports
64+
- do not touch unrelated helpers
65+
- do not change logic
66+
67+
If a listed file already imports and uses shared `getRuntimeAndRegistry`, leave it unchanged.
68+
69+
## Relative Import Rule
70+
Use exactly:
71+
72+
`../shared/runtimeRegistryUtils.js`
73+
74+
Do not use aliases.
75+
Do not change `.js` extension usage.
76+
77+
## Hard Constraints
78+
- no engine changes
79+
- no files outside the 3 listed consumers plus the one new shared file
80+
- no repo-wide preset/command-pack helper cleanup
81+
- no behavior changes
82+
- keep one PR purpose only
83+
84+
## Validation Checklist
85+
1. Confirm no more than the 4 listed files changed
86+
2. Confirm `tools/dev/shared/runtimeRegistryUtils.js` exists and exports `getRuntimeAndRegistry`
87+
3. Confirm local `function getRuntimeAndRegistry(context)` definitions no longer exist in changed listed consumer files
88+
4. Confirm changed consumer files import `getRuntimeAndRegistry` from `../shared/runtimeRegistryUtils.js`
89+
5. Confirm no unrelated files changed
90+
6. Confirm no behavior changes were made
91+
92+
## Non-Goals
93+
- no cleanup outside the 3 listed consumer files
94+
- no refactor beyond this exact duplicate-removal batch

tools/dev/commandPacks/groupCommandPack.js

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,43 +12,10 @@ import {
1212
requireNoArgs
1313
} from "./packUtils.js";
1414
import { createResult } from "./commandPackResultUtils.js";
15+
import { getRuntimeAndRegistry } from "../shared/runtimeRegistryUtils.js";
1516

1617
import { sanitizeText } from "../../../src/engine/debug/inspectors/shared/inspectorUtils.js";
1718

18-
function getRuntimeAndRegistry(context) {
19-
const runtime = context?.consoleRuntime;
20-
const panelRegistry = runtime?.panelRegistry;
21-
if (!runtime || typeof runtime.getState !== "function") {
22-
return {
23-
status: "failed",
24-
error: createResult(
25-
"failed",
26-
"Group",
27-
["Console runtime is unavailable."],
28-
"MISSING_COMMAND_CONTEXT"
29-
)
30-
};
31-
}
32-
33-
if (!panelRegistry || typeof panelRegistry.getOrderedPanels !== "function" || typeof panelRegistry.setPanelEnabled !== "function") {
34-
return {
35-
status: "failed",
36-
error: createResult(
37-
"failed",
38-
"Group",
39-
["Overlay panel registry is unavailable."],
40-
"MISSING_OVERLAY_REGISTRY"
41-
)
42-
};
43-
}
44-
45-
return {
46-
status: "ready",
47-
runtime,
48-
panelRegistry
49-
};
50-
}
51-
5219
function buildSnapshot(panelRegistry) {
5320
const panels = panelRegistry.getOrderedPanels(true);
5421
const allPanels = Array.isArray(panels) ? panels : [];
@@ -78,7 +45,12 @@ function persistSnapshotIfConfigured(context, panelRegistry) {
7845
function setGroupEnabled(context, groupDescriptor, nextEnabled) {
7946
const runtimeContext = getRuntimeAndRegistry(context);
8047
if (runtimeContext.status !== "ready") {
81-
return runtimeContext.error;
48+
return createResult(
49+
"failed",
50+
"Group",
51+
[runtimeContext.message],
52+
runtimeContext.code
53+
);
8254
}
8355

8456
const panelRegistry = runtimeContext.panelRegistry;
@@ -256,7 +228,12 @@ export function createGroupCommandPack() {
256228

257229
const runtimeContext = getRuntimeAndRegistry(context);
258230
if (runtimeContext.status !== "ready") {
259-
return runtimeContext.error;
231+
return createResult(
232+
"failed",
233+
"Group",
234+
[runtimeContext.message],
235+
runtimeContext.code
236+
);
260237
}
261238

262239
const panelRegistry = runtimeContext.panelRegistry;

0 commit comments

Comments
 (0)