Skip to content

refactor: extract experimental settings entry wrapper#297

Open
ndycode wants to merge 2 commits intorefactor/pr2-backend-category-entry-wrapperfrom
refactor/pr2-experimental-settings-entry-wrapper
Open

refactor: extract experimental settings entry wrapper#297
ndycode wants to merge 2 commits intorefactor/pr2-backend-category-entry-wrapperfrom
refactor/pr2-experimental-settings-entry-wrapper

Conversation

@ndycode
Copy link
Owner

@ndycode ndycode commented Mar 22, 2026

Summary

  • extract the promptExperimentalSettings entry wrapper out of settings-hub on top of the latest settings leaf
  • keep experimental settings prompt behavior unchanged while slimming the settings facade
  • add a focused test for the new experimental settings entry helper

Validation

  • npm run typecheck
  • npm run lint -- lib/codex-manager/experimental-settings-entry.ts lib/codex-manager/settings-hub.ts test/experimental-settings-entry.test.ts
  • npm run test -- test/experimental-settings-entry.test.ts

note: greptile review for oc-chatgpt-multi-auth. cite files like lib/foo.ts:123. confirm regression tests + windows concurrency/token redaction coverage.

Greptile Summary

this pr extracts the promptExperimentalSettingsEntry wrapper out of settings-hub into its own module, slimming the facade and making the entry point independently testable. it also tightens types across experimental-settings-prompt.ts — replacing all as never casts with concrete oc-chatgpt-orchestrator and storage types and exporting ExperimentalSettingsCopy / ExperimentalSettingsPromptDeps as named types that other modules can reference directly.

  • lib/codex-manager/experimental-settings-entry.ts — new thin wrapper; delegates all deps to promptExperimentalSettingsMenu with no added logic
  • lib/codex-manager/experimental-settings-prompt.ts — all TAction / TPlan / TApplied free type params collapsed into concrete types; ExperimentalSettingsPromptDeps<TTargetState> extracted and exported; minor indentation regression introduced in the inline hotkey callback (~line 320)
  • lib/codex-manager/settings-hub.ts — call site updated; as never casts fully removed; getTargetDestination now correctly defaults destination to null instead of undefined
  • test/experimental-settings-entry.test.ts — focused passthrough test verifies all deps are forwarded; only the non-null return path is covered (null path missing)

Confidence Score: 5/5

  • safe to merge — pure refactor with no behavioral change and improved type safety
  • all as never casts are gone, types are tighter, and the extracted module has a focused test. the two remaining items (indentation nit, missing null test case) are non-blocking p2s that don't affect runtime behavior or coverage thresholds in a meaningful way.
  • no files require special attention

Important Files Changed

Filename Overview
lib/codex-manager/experimental-settings-entry.ts new thin entry wrapper that delegates to promptExperimentalSettingsMenu; types are sound, no logic of its own
lib/codex-manager/experimental-settings-prompt.ts type params tightened (removes as never, concrete oc-chatgpt types), ExperimentalSettingsPromptDeps exported as named type — one indentation inconsistency introduced around the inline hotkey callback at line 320
lib/codex-manager/settings-hub.ts call site updated to use promptExperimentalSettingsEntry; all as never casts replaced with properly-typed lambdas; no behavioral change
test/experimental-settings-entry.test.ts focused passthrough test covers the non-null path; missing a null-return case to hit the remaining branch and satisfy the 80% coverage threshold

Sequence Diagram

sequenceDiagram
    participant SH as settings-hub
    participant EE as experimental-settings-entry
    participant EP as experimental-settings-prompt

    SH->>EE: promptExperimentalSettingsEntry({ initialConfig, promptExperimentalSettingsMenu, ...deps })
    EE->>EP: promptExperimentalSettingsMenu({ initialConfig, ...deps })
    EP-->>EE: PluginConfig | null
    EE-->>SH: PluginConfig | null
Loading

Fix All in Codex

Prompt To Fix All With AI
This is a comment left during a code review.
Path: lib/codex-manager/experimental-settings-prompt.ts
Line: 320-329

Comment:
**Inconsistent indentation in `getExperimentalSelectOptions` call**

`copy.experimentalHelpPreview` and the hotkey callback are indented one extra tab compared to `params.ui` in the same argument list. every other `getExperimentalSelectOptions` call in this file aligns all three arguments at the same level. this is a formatting regression introduced by removing the `as TAction` casts.

```suggestion
		params.getExperimentalSelectOptions(
			params.ui,
			copy.experimentalHelpPreview,
			(raw) => {
				const lower = raw.toLowerCase();
				if (lower === "q") return { type: "back" };
				if (lower === "a") return { type: "apply" };
				return undefined;
			},
		),
	);
```

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: test/experimental-settings-entry.test.ts
Line: 5-63

Comment:
**Missing `null`-return path test**

only the happy path is tested (menu resolves to a config). there's no case asserting that when `promptExperimentalSettingsMenu` resolves to `null`, the entry wrapper also returns `null`. given the 80% coverage threshold in this repo, add a second `it` block — it's a two-liner:

```typescript
it("returns null when the menu returns null", async () => {
    const promptExperimentalSettingsMenu = vi.fn(async () => null);
    const result = await promptExperimentalSettingsEntry({
        initialConfig: { fetchTimeoutMs: 2000 },
        promptExperimentalSettingsMenu,
        ...minimalDeps, // extract shared deps to a helper
    });
    expect(result).toBeNull();
});
```

How can I resolve this? If you propose a fix, please make it concise.

Last reviewed commit: "Preserve experimenta..."

@chatgpt-codex-connector
Copy link

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 22, 2026

📝 Walkthrough

Walkthrough

introduces a new wrapper entry point promptExperimentalSettingsEntry in lib/codex-manager/experimental-settings-entry.ts:1-114 that delegates directly to promptExperimentalSettingsMenu callback. updates lib/codex-manager/settings-hub.ts:1-3 to call the new wrapper instead of the callback directly. adds test coverage in test/experimental-settings-entry.test.ts:1-42.

Changes

Cohort / File(s) Summary
New experimental settings entry wrapper
lib/codex-manager/experimental-settings-entry.ts
exports promptExperimentalSettingsEntry accepting a params object with initialConfig, promptExperimentalSettingsMenu callback, and various UI/sync utilities. function immediately delegates to the callback with initialConfig and returns its result unchanged.
Settings hub integration
lib/codex-manager/settings-hub.ts
imports new promptExperimentalSettingsEntry and updates promptExperimentalSettings to call the wrapper instead of directly invoking promptExperimentalSettingsMenu.
Test coverage
test/experimental-settings-entry.test.ts
adds vitest test verifying promptExperimentalSettingsEntry forwards all dependencies to promptExperimentalSettingsMenu and returns the callback result correctly.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

the wrapper pattern is straightforward delegation with no complex logic, but parameter density in lib/codex-manager/experimental-settings-entry.ts and understanding the full parameter surface requires careful attention. test coverage test/experimental-settings-entry.test.ts:1-42 validates the delegation path adequately. note: test could strengthen regression coverage by verifying at least one parameter error case (e.g., missing required property in params object) to catch accidental signature drift; also verify behavior on windows paths in any downstream consumers relying on this entry point.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed title follows conventional commit format with type 'refactor' and accurately describes the main change: extracting experimental settings entry wrapper.
Description check ✅ Passed pr description covers summary, what changed, and validation steps; includes greptile review with identified issues.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/pr2-experimental-settings-entry-wrapper
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch refactor/pr2-experimental-settings-entry-wrapper

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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@lib/codex-manager/experimental-settings-entry.ts`:
- Around line 3-86: The wrapper function promptExperimentalSettingsEntry
currently erases precise types (hotkeyMapper, copy, and the inner callback)
forcing callers to use as never; fix by preserving the original generic/compound
type: either import and re-export the exact prompt params/type from
experimental-settings-prompt (the promptExperimentalSettingsMenu signature and
its generic action type) and use that imported type for the inner callback and
outer params, or make promptExperimentalSettingsEntry generic over the same
action/type parameter(s) so type information flows through (and extract the
duplicated 14-property callback shape into a shared type alias used by both
promptExperimentalSettingsMenu and promptExperimentalSettingsEntry to avoid
duplication). Ensure references to promptExperimentalSettingsMenu,
promptExperimentalSettingsEntry, hotkeyMapper, copy and the duplicated inner
callback shape are updated to use the shared/imported type so call sites no
longer need as never casts.

In `@test/experimental-settings-entry.test.ts`:
- Around line 39-40: The test currently only checks that
promptExperimentalSettingsMenu was called but not that the forwarded args
contain the expected initial config; update the assertion for
promptExperimentalSettingsMenu (the mock) to use toHaveBeenCalledWith and assert
it was called with an object containing initialConfig: { fetchTimeoutMs: 2000 }
(e.g. toHaveBeenCalledWith(expect.objectContaining({ initialConfig: {
fetchTimeoutMs: 2000 } }))) so the test verifies the delegation actually
forwards the expected value while keeping the existing result assertion.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 2eadd62a-879b-4b9b-a7b6-b2e30605e713

📥 Commits

Reviewing files that changed from the base of the PR and between 0606240 and 5e3562c.

📒 Files selected for processing (3)
  • lib/codex-manager/experimental-settings-entry.ts
  • lib/codex-manager/settings-hub.ts
  • test/experimental-settings-entry.test.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Greptile Review
🧰 Additional context used
📓 Path-based instructions (2)
lib/**

⚙️ CodeRabbit configuration file

focus on auth rotation, windows filesystem IO, and concurrency. verify every change cites affected tests (vitest) and that new queues handle EBUSY/429 scenarios. check for logging that leaks tokens or emails.

Files:

  • lib/codex-manager/settings-hub.ts
  • lib/codex-manager/experimental-settings-entry.ts
test/**

⚙️ CodeRabbit configuration file

tests must stay deterministic and use vitest. demand regression cases that reproduce concurrency bugs, token refresh races, and windows filesystem behavior. reject changes that mock real secrets or skip assertions.

Files:

  • test/experimental-settings-entry.test.ts
🔇 Additional comments (3)
lib/codex-manager/experimental-settings-entry.ts (1)

87-114: delegation logic looks correct.

the pass-through is straightforward and preserves the return type. no side effects or logging concerns.

lib/codex-manager/settings-hub.ts (2)

67-67: import looks good.

correctly imports the new entry wrapper alongside the existing promptExperimentalSettingsMenu import at line 68.


667-669: refactor looks correct, but as never casts highlight the type mismatch.

the delegation to promptExperimentalSettingsEntry preserves behavior. the as never casts at lines 669, 673-676, 684-685 are required because the wrapper's type declarations erased the generics from promptExperimentalSettingsMenu.

if you address the type safety suggestion in lib/codex-manager/experimental-settings-entry.ts:3-86, these casts can be removed.

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