mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-20 00:02:11 +00:00
cheers
This commit is contained in:
parent
73734a23a1
commit
09d1b099b7
3 changed files with 30 additions and 2 deletions
|
|
@ -42,6 +42,7 @@ export class FooterDataProvider {
|
||||||
private cachedBranch: string | null | undefined = undefined;
|
private cachedBranch: string | null | undefined = undefined;
|
||||||
private gitWatcher: FSWatcher | null = null;
|
private gitWatcher: FSWatcher | null = null;
|
||||||
private branchChangeCallbacks = new Set<() => void>();
|
private branchChangeCallbacks = new Set<() => void>();
|
||||||
|
private availableProviderCount = 0;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.setupGitWatcher();
|
this.setupGitWatcher();
|
||||||
|
|
@ -90,6 +91,16 @@ export class FooterDataProvider {
|
||||||
this.extensionStatuses.clear();
|
this.extensionStatuses.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Number of unique providers with available models (for footer display) */
|
||||||
|
getAvailableProviderCount(): number {
|
||||||
|
return this.availableProviderCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Internal: update available provider count */
|
||||||
|
setAvailableProviderCount(count: number): void {
|
||||||
|
this.availableProviderCount = count;
|
||||||
|
}
|
||||||
|
|
||||||
/** Internal: cleanup */
|
/** Internal: cleanup */
|
||||||
dispose(): void {
|
dispose(): void {
|
||||||
if (this.gitWatcher) {
|
if (this.gitWatcher) {
|
||||||
|
|
@ -126,8 +137,8 @@ export class FooterDataProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Read-only view for extensions - excludes setExtensionStatus and dispose */
|
/** Read-only view for extensions - excludes setExtensionStatus, setAvailableProviderCount and dispose */
|
||||||
export type ReadonlyFooterDataProvider = Pick<
|
export type ReadonlyFooterDataProvider = Pick<
|
||||||
FooterDataProvider,
|
FooterDataProvider,
|
||||||
"getGitBranch" | "getExtensionStatuses" | "onBranchChange"
|
"getGitBranch" | "getExtensionStatuses" | "getAvailableProviderCount" | "onBranchChange"
|
||||||
>;
|
>;
|
||||||
|
|
|
||||||
|
|
@ -168,6 +168,11 @@ export class FooterComponent implements Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prepend the provider in parenthesis to the right side if there's multiple providers
|
||||||
|
if (this.footerData.getAvailableProviderCount() > 1 && state.model) {
|
||||||
|
rightSide = `(${state.model.provider}) ${rightSide}`;
|
||||||
|
}
|
||||||
|
|
||||||
let statsLeftWidth = visibleWidth(statsLeft);
|
let statsLeftWidth = visibleWidth(statsLeft);
|
||||||
const rightSideWidth = visibleWidth(rightSide);
|
const rightSideWidth = visibleWidth(rightSide);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -476,6 +476,9 @@ export class InteractiveMode {
|
||||||
this.footerDataProvider.onBranchChange(() => {
|
this.footerDataProvider.onBranchChange(() => {
|
||||||
this.ui.requestRender();
|
this.ui.requestRender();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Initialize available provider count for footer display
|
||||||
|
await this.updateAvailableProviderCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2781,6 +2784,13 @@ export class InteractiveMode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Update the footer's available provider count from current model candidates */
|
||||||
|
private async updateAvailableProviderCount(): Promise<void> {
|
||||||
|
const models = await this.getModelCandidates();
|
||||||
|
const uniqueProviders = new Set(models.map((m) => m.provider));
|
||||||
|
this.footerDataProvider.setAvailableProviderCount(uniqueProviders.size);
|
||||||
|
}
|
||||||
|
|
||||||
private showModelSelector(initialSearchInput?: string): void {
|
private showModelSelector(initialSearchInput?: string): void {
|
||||||
this.showSelector((done) => {
|
this.showSelector((done) => {
|
||||||
const selector = new ModelSelectorComponent(
|
const selector = new ModelSelectorComponent(
|
||||||
|
|
@ -3173,6 +3183,7 @@ export class InteractiveMode {
|
||||||
try {
|
try {
|
||||||
this.session.modelRegistry.authStorage.logout(providerId);
|
this.session.modelRegistry.authStorage.logout(providerId);
|
||||||
this.session.modelRegistry.refresh();
|
this.session.modelRegistry.refresh();
|
||||||
|
await this.updateAvailableProviderCount();
|
||||||
this.showStatus(`Logged out of ${providerName}`);
|
this.showStatus(`Logged out of ${providerName}`);
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
this.showError(`Logout failed: ${error instanceof Error ? error.message : String(error)}`);
|
this.showError(`Logout failed: ${error instanceof Error ? error.message : String(error)}`);
|
||||||
|
|
@ -3267,6 +3278,7 @@ export class InteractiveMode {
|
||||||
// Success
|
// Success
|
||||||
restoreEditor();
|
restoreEditor();
|
||||||
this.session.modelRegistry.refresh();
|
this.session.modelRegistry.refresh();
|
||||||
|
await this.updateAvailableProviderCount();
|
||||||
this.showStatus(`Logged in to ${providerName}. Credentials saved to ${getAuthPath()}`);
|
this.showStatus(`Logged in to ${providerName}. Credentials saved to ${getAuthPath()}`);
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
restoreEditor();
|
restoreEditor();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue