mirror of
https://github.com/murashit/codex-panel.git
synced 2026-07-22 06:57:10 +00:00
Publish app-server metadata from controller
This commit is contained in:
parent
fd5ccb4598
commit
ad3ce85884
3 changed files with 31 additions and 11 deletions
|
|
@ -21,6 +21,7 @@ export interface ChatAppServerControllerHost {
|
|||
currentClient: () => AppServerClient | null;
|
||||
runtimeSnapshot: () => RuntimeSnapshot;
|
||||
forceMessagesToBottom: () => void;
|
||||
publishAppServerMetadata: (metadata: SharedAppServerMetadata) => void;
|
||||
}
|
||||
|
||||
export interface RefreshCapabilityDiagnosticsOptions {
|
||||
|
|
@ -94,6 +95,16 @@ export class ChatAppServerController {
|
|||
return metadata;
|
||||
}
|
||||
|
||||
async refreshPublishedAppServerMetadata(): Promise<SharedAppServerMetadata | null> {
|
||||
const metadata = await this.refreshAppServerMetadata();
|
||||
if (metadata) this.host.publishAppServerMetadata(metadata);
|
||||
return metadata;
|
||||
}
|
||||
|
||||
publishAppServerMetadataSnapshot(): void {
|
||||
this.host.publishAppServerMetadata(this.appServerMetadataSnapshot());
|
||||
}
|
||||
|
||||
async startThread(): Promise<Awaited<ReturnType<AppServerClient["startThread"]>> | null> {
|
||||
const client = this.host.currentClient();
|
||||
if (!client) return null;
|
||||
|
|
@ -129,6 +140,11 @@ export class ChatAppServerController {
|
|||
this.dispatch({ type: "thread/list-applied", availableSkills: skills.data, appServerDiagnostics: diagnostics });
|
||||
}
|
||||
|
||||
async refreshPublishedSkills(forceReload = false): Promise<void> {
|
||||
await this.refreshSkills(forceReload);
|
||||
this.publishAppServerMetadataSnapshot();
|
||||
}
|
||||
|
||||
async loadSkills(forceReload = false): Promise<{ data: SkillMetadata[]; probe: AppServerDiagnostics["probes"]["skills/list"] }> {
|
||||
const client = this.host.currentClient();
|
||||
if (!client) return { data: [], probe: capabilityProbeError("skills/list", new Error("Codex app-server is not connected.")) };
|
||||
|
|
@ -243,6 +259,11 @@ export class ChatAppServerController {
|
|||
await Promise.all(probes);
|
||||
}
|
||||
|
||||
async refreshPublishedCapabilityDiagnostics(options: RefreshCapabilityDiagnosticsOptions = {}): Promise<void> {
|
||||
await this.refreshCapabilityDiagnostics(options);
|
||||
this.publishAppServerMetadataSnapshot();
|
||||
}
|
||||
|
||||
recordMcpStartupStatus(name: string, startupStatus: "starting" | "ready" | "failed" | "cancelled", message: string | null): void {
|
||||
this.dispatch({
|
||||
type: "thread/list-applied",
|
||||
|
|
|
|||
|
|
@ -237,6 +237,9 @@ export class CodexChatView extends ItemView {
|
|||
forceMessagesToBottom: () => {
|
||||
this.queueMessagesBottomScroll();
|
||||
},
|
||||
publishAppServerMetadata: (metadata) => {
|
||||
this.plugin.publishAppServerMetadata(metadata);
|
||||
},
|
||||
});
|
||||
this.history = new ThreadHistoryLoader({
|
||||
stateStore: this.chatState,
|
||||
|
|
@ -549,9 +552,8 @@ export class CodexChatView extends ItemView {
|
|||
if (this.connectionWork.isStale(connection)) return;
|
||||
this.client = this.connection.currentClient();
|
||||
if (!this.client) throw new Error("Codex app-server connection did not initialize.");
|
||||
const metadata = await this.appServer.refreshAppServerMetadata();
|
||||
await this.appServer.refreshPublishedAppServerMetadata();
|
||||
if (this.connectionWork.isStale(connection)) return;
|
||||
if (metadata) this.plugin.publishAppServerMetadata(metadata);
|
||||
await this.loadSharedThreadList();
|
||||
if (this.connectionWork.isStale(connection)) return;
|
||||
this.scheduleDeferredDiagnostics();
|
||||
|
|
@ -595,8 +597,7 @@ export class CodexChatView extends ItemView {
|
|||
if (!this.client) return;
|
||||
try {
|
||||
await this.loadSharedThreadList();
|
||||
const metadata = await this.appServer.refreshAppServerMetadata();
|
||||
if (metadata) this.plugin.publishAppServerMetadata(metadata);
|
||||
await this.appServer.refreshPublishedAppServerMetadata();
|
||||
this.refreshTabHeader();
|
||||
this.render();
|
||||
} catch (error) {
|
||||
|
|
@ -609,8 +610,7 @@ export class CodexChatView extends ItemView {
|
|||
await this.ensureConnected();
|
||||
if (!this.client) return;
|
||||
this.clearDeferredDiagnostics();
|
||||
await this.appServer.refreshCapabilityDiagnostics();
|
||||
this.publishAppServerMetadataSnapshot();
|
||||
await this.appServer.refreshPublishedCapabilityDiagnostics();
|
||||
this.render();
|
||||
}
|
||||
|
||||
|
|
@ -626,8 +626,7 @@ export class CodexChatView extends ItemView {
|
|||
private async refreshSkills(forceReload = false): Promise<void> {
|
||||
this.client = this.connection.currentClient();
|
||||
if (!this.client) return;
|
||||
await this.appServer.refreshSkills(forceReload);
|
||||
this.publishAppServerMetadataSnapshot();
|
||||
await this.appServer.refreshPublishedSkills(forceReload);
|
||||
this.render();
|
||||
}
|
||||
|
||||
|
|
@ -693,7 +692,7 @@ export class CodexChatView extends ItemView {
|
|||
}
|
||||
|
||||
private publishAppServerMetadataSnapshot(): void {
|
||||
this.plugin.publishAppServerMetadata(this.appServer.appServerMetadataSnapshot());
|
||||
this.appServer.publishAppServerMetadataSnapshot();
|
||||
}
|
||||
|
||||
private applyCachedSharedAppServerState(): void {
|
||||
|
|
@ -1281,8 +1280,7 @@ export class CodexChatView extends ItemView {
|
|||
|
||||
private async refreshDeferredDiagnostics(): Promise<void> {
|
||||
if (!this.connection.isConnected()) return;
|
||||
await this.appServer.refreshCapabilityDiagnostics({ cachedAppServerMetadata: true });
|
||||
this.publishAppServerMetadataSnapshot();
|
||||
await this.appServer.refreshPublishedCapabilityDiagnostics({ cachedAppServerMetadata: true });
|
||||
this.render();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ describe("ChatAppServerController", () => {
|
|||
currentClient: () => client,
|
||||
runtimeSnapshot: () => ({}) as never,
|
||||
forceMessagesToBottom: () => undefined,
|
||||
publishAppServerMetadata: () => undefined,
|
||||
});
|
||||
|
||||
await controller.refreshAppServerMetadata();
|
||||
|
|
|
|||
Loading…
Reference in a new issue