Skip to content

Commit af11599

Browse files
committed
refactor: route runtime ui resolver helper
1 parent c610acc commit af11599

1 file changed

Lines changed: 40 additions & 17 deletions

File tree

index.ts

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -410,13 +410,6 @@ export const OpenAIOAuthPlugin: Plugin = async ({ client }: PluginInput) => {
410410
});
411411
};
412412

413-
const resolveUiRuntime = (): UiRuntimeOptions => {
414-
return resolveRuntimeUiOptions({
415-
loadPluginConfig,
416-
applyUiRuntimeFromConfig,
417-
});
418-
};
419-
420413
const getStatusMarker = (
421414
ui: UiRuntimeOptions,
422415
status: "ok" | "warning" | "error",
@@ -570,7 +563,10 @@ export const OpenAIOAuthPlugin: Plugin = async ({ client }: PluginInput) => {
570563
};
571564

572565
// Initialize runtime UI settings once on plugin load; auth/tools refresh this dynamically.
573-
resolveUiRuntime();
566+
resolveRuntimeUiOptions({
567+
loadPluginConfig,
568+
applyUiRuntimeFromConfig,
569+
});
574570

575571
return {
576572
event: eventHandler,
@@ -3689,7 +3685,10 @@ export const OpenAIOAuthPlugin: Plugin = async ({ client }: PluginInput) => {
36893685
"List all Codex OAuth accounts and the current active index.",
36903686
args: {},
36913687
async execute() {
3692-
const ui = resolveUiRuntime();
3688+
const ui = resolveRuntimeUiOptions({
3689+
loadPluginConfig,
3690+
applyUiRuntimeFromConfig,
3691+
});
36933692
const storage = await loadAccounts();
36943693
const storePath = getStoragePath();
36953694

@@ -3825,7 +3824,10 @@ export const OpenAIOAuthPlugin: Plugin = async ({ client }: PluginInput) => {
38253824
),
38263825
},
38273826
async execute({ index }) {
3828-
const ui = resolveUiRuntime();
3827+
const ui = resolveRuntimeUiOptions({
3828+
loadPluginConfig,
3829+
applyUiRuntimeFromConfig,
3830+
});
38293831
const storage = await loadAccounts();
38303832
if (!storage || storage.accounts.length === 0) {
38313833
if (ui.v2Enabled) {
@@ -3921,7 +3923,10 @@ export const OpenAIOAuthPlugin: Plugin = async ({ client }: PluginInput) => {
39213923
description: "Show detailed status of Codex accounts and rate limits.",
39223924
args: {},
39233925
async execute() {
3924-
const ui = resolveUiRuntime();
3926+
const ui = resolveRuntimeUiOptions({
3927+
loadPluginConfig,
3928+
applyUiRuntimeFromConfig,
3929+
});
39253930
const storage = await loadAccounts();
39263931
if (!storage || storage.accounts.length === 0) {
39273932
if (ui.v2Enabled) {
@@ -4092,7 +4097,10 @@ export const OpenAIOAuthPlugin: Plugin = async ({ client }: PluginInput) => {
40924097
"Show runtime request metrics for this plugin process.",
40934098
args: {},
40944099
execute() {
4095-
const ui = resolveUiRuntime();
4100+
const ui = resolveRuntimeUiOptions({
4101+
loadPluginConfig,
4102+
applyUiRuntimeFromConfig,
4103+
});
40964104
const now = Date.now();
40974105
const uptimeMs = Math.max(0, now - runtimeMetrics.startedAt);
40984106
const total = runtimeMetrics.totalRequests;
@@ -4294,7 +4302,10 @@ export const OpenAIOAuthPlugin: Plugin = async ({ client }: PluginInput) => {
42944302
"Check health of all Codex accounts by validating refresh tokens.",
42954303
args: {},
42964304
async execute() {
4297-
const ui = resolveUiRuntime();
4305+
const ui = resolveRuntimeUiOptions({
4306+
loadPluginConfig,
4307+
applyUiRuntimeFromConfig,
4308+
});
42984309
const storage = await loadAccounts();
42994310
if (!storage || storage.accounts.length === 0) {
43004311
if (ui.v2Enabled) {
@@ -4372,7 +4383,10 @@ export const OpenAIOAuthPlugin: Plugin = async ({ client }: PluginInput) => {
43724383
),
43734384
},
43744385
async execute({ index }) {
4375-
const ui = resolveUiRuntime();
4386+
const ui = resolveRuntimeUiOptions({
4387+
loadPluginConfig,
4388+
applyUiRuntimeFromConfig,
4389+
});
43764390
const storage = await loadAccounts();
43774391
if (!storage || storage.accounts.length === 0) {
43784392
if (ui.v2Enabled) {
@@ -4516,7 +4530,10 @@ export const OpenAIOAuthPlugin: Plugin = async ({ client }: PluginInput) => {
45164530
"Manually refresh OAuth tokens for all accounts to verify they're still valid.",
45174531
args: {},
45184532
async execute() {
4519-
const ui = resolveUiRuntime();
4533+
const ui = resolveRuntimeUiOptions({
4534+
loadPluginConfig,
4535+
applyUiRuntimeFromConfig,
4536+
});
45204537
const storage = await loadAccounts();
45214538
if (!storage || storage.accounts.length === 0) {
45224539
if (ui.v2Enabled) {
@@ -4604,7 +4621,10 @@ export const OpenAIOAuthPlugin: Plugin = async ({ client }: PluginInput) => {
46044621
.describe("Overwrite existing file (default: true)"),
46054622
},
46064623
async execute({ path: filePath, force }) {
4607-
const ui = resolveUiRuntime();
4624+
const ui = resolveRuntimeUiOptions({
4625+
loadPluginConfig,
4626+
applyUiRuntimeFromConfig,
4627+
});
46084628
try {
46094629
await exportAccounts(filePath, force ?? true);
46104630
const storage = await loadAccounts();
@@ -4653,7 +4673,10 @@ export const OpenAIOAuthPlugin: Plugin = async ({ client }: PluginInput) => {
46534673
),
46544674
},
46554675
async execute({ path: filePath }) {
4656-
const ui = resolveUiRuntime();
4676+
const ui = resolveRuntimeUiOptions({
4677+
loadPluginConfig,
4678+
applyUiRuntimeFromConfig,
4679+
});
46574680
try {
46584681
const result = await importAccounts(filePath);
46594682
invalidateAccountManagerCache();

0 commit comments

Comments
 (0)