mirror of
https://github.com/murashit/codex-panel.git
synced 2026-07-22 06:57:10 +00:00
Merge sparse rate limit updates
This commit is contained in:
parent
2598ee1327
commit
0389f86f93
5 changed files with 17 additions and 10 deletions
|
|
@ -14,6 +14,7 @@ import { planChatNotification, type ChatNotificationEffect } from "./chat-notifi
|
|||
|
||||
export interface ChatControllerActions {
|
||||
refreshThreads: () => void;
|
||||
refreshRateLimits: () => void;
|
||||
refreshSkills: (forceReload?: boolean) => void;
|
||||
publishAppServerMetadata: () => void;
|
||||
maybeNameThread: (threadId: string, turn: Turn) => void;
|
||||
|
|
@ -151,6 +152,9 @@ export class ChatController {
|
|||
case "refresh-threads":
|
||||
this.actions.refreshThreads();
|
||||
return;
|
||||
case "refresh-rate-limits":
|
||||
this.actions.refreshRateLimits();
|
||||
return;
|
||||
case "refresh-skills":
|
||||
this.actions.refreshSkills(effect.forceReload);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import { routeServerNotification } from "./inbound-routing";
|
|||
|
||||
export type ChatNotificationEffect =
|
||||
| { type: "refresh-threads" }
|
||||
| { type: "refresh-rate-limits" }
|
||||
| { type: "refresh-skills"; forceReload: boolean }
|
||||
| { type: "publish-app-server-metadata" }
|
||||
| { type: "maybe-name-thread"; threadId: string; turn: Turn }
|
||||
|
|
@ -255,8 +256,8 @@ function planDiagnosticStatus(notification: ServerNotification): ChatNotificatio
|
|||
}
|
||||
if (method === "account/rateLimits/updated") {
|
||||
return {
|
||||
actions: [{ type: "thread/list-applied", rateLimit: params.rateLimits }],
|
||||
effects: [{ type: "publish-app-server-metadata" }],
|
||||
actions: [],
|
||||
effects: [{ type: "refresh-rate-limits" }],
|
||||
};
|
||||
}
|
||||
if (method === "skills/changed") {
|
||||
|
|
|
|||
|
|
@ -354,6 +354,9 @@ export function createChatViewControllerAssembly(host: ChatViewControllerAssembl
|
|||
refreshThreads: () => {
|
||||
void host.refreshThreads();
|
||||
},
|
||||
refreshRateLimits: () => {
|
||||
void appServer.refreshRateLimits();
|
||||
},
|
||||
refreshSkills: (forceReload) => void host.refreshSkills(forceReload),
|
||||
publishAppServerMetadata: host.publishAppServerMetadataSnapshot,
|
||||
maybeNameThread: (threadId, turn) => {
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ function controllerForState(
|
|||
): ChatController {
|
||||
return new ChatController(testStoreForState(state), {
|
||||
refreshThreads: vi.fn(),
|
||||
refreshRateLimits: vi.fn(),
|
||||
refreshSkills: vi.fn(),
|
||||
publishAppServerMetadata: vi.fn(),
|
||||
maybeNameThread: vi.fn(),
|
||||
|
|
@ -641,10 +642,10 @@ describe("ChatController", () => {
|
|||
expect(refreshThreads).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("stores account rate limit updates outside thread scope", () => {
|
||||
it("refreshes account rate limits after sparse update notifications", () => {
|
||||
const state = createChatState();
|
||||
const publishAppServerMetadata = vi.fn();
|
||||
const controller = controllerForState(state, { publishAppServerMetadata });
|
||||
const refreshRateLimits = vi.fn();
|
||||
const controller = controllerForState(state, { refreshRateLimits });
|
||||
|
||||
controller.handleNotification({
|
||||
method: "account/rateLimits/updated",
|
||||
|
|
@ -662,11 +663,8 @@ describe("ChatController", () => {
|
|||
},
|
||||
} satisfies Extract<ServerNotification, { method: "account/rateLimits/updated" }>);
|
||||
|
||||
expect(state.rateLimit).toMatchObject({
|
||||
limitId: "codex",
|
||||
primary: { usedPercent: 64 },
|
||||
});
|
||||
expect(publishAppServerMetadata).toHaveBeenCalledOnce();
|
||||
expect(state.rateLimit).toBeNull();
|
||||
expect(refreshRateLimits).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it("records MCP startup status for diagnostics without a chat system message", () => {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ describe("PendingRequestController", () => {
|
|||
const render = vi.fn();
|
||||
const controller = new ChatController(stateStore, {
|
||||
refreshThreads: vi.fn(),
|
||||
refreshRateLimits: vi.fn(),
|
||||
refreshSkills: vi.fn(),
|
||||
publishAppServerMetadata: vi.fn(),
|
||||
maybeNameThread: vi.fn(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue