mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-16 20:01:27 +00:00
Add Foundry dev panel
This commit is contained in:
parent
859ad13934
commit
f365342dcc
4 changed files with 397 additions and 0 deletions
|
|
@ -140,6 +140,12 @@ export interface MockFoundryAppClient {
|
|||
resumeSubscription(organizationId: string): Promise<void>;
|
||||
reconnectGithub(organizationId: string): Promise<void>;
|
||||
recordSeatUsage(workspaceId: string): void;
|
||||
setMockDebugOrganizationState(input: {
|
||||
organizationId: string;
|
||||
githubSyncStatus?: MockGithubSyncStatus;
|
||||
githubInstallationStatus?: MockGithubInstallationStatus;
|
||||
runtimeStatus?: MockActorRuntimeStatus;
|
||||
}): Promise<void>;
|
||||
}
|
||||
|
||||
const STORAGE_KEY = "sandbox-agent-foundry:mock-app:v1";
|
||||
|
|
@ -174,6 +180,22 @@ function buildHealthyRuntimeState(): MockFoundryActorRuntimeState {
|
|||
};
|
||||
}
|
||||
|
||||
function buildSampleRuntimeIssue(organization: MockFoundryOrganization): MockFoundryActorRuntimeIssue {
|
||||
return {
|
||||
actorId: `${organization.id}:github-state`,
|
||||
actorType: "organization",
|
||||
scopeId: organization.id,
|
||||
scopeLabel: `${organization.settings.displayName} organization`,
|
||||
message: "GitHub sync failed while refreshing repositories",
|
||||
workflowId: "github-sync",
|
||||
stepName: "full-sync",
|
||||
attempt: 2,
|
||||
willRetry: true,
|
||||
retryDelayMs: 5000,
|
||||
occurredAt: Date.now(),
|
||||
};
|
||||
}
|
||||
|
||||
function buildDefaultSnapshot(): MockFoundryAppSnapshot {
|
||||
return {
|
||||
auth: {
|
||||
|
|
@ -671,6 +693,50 @@ class MockFoundryAppStore implements MockFoundryAppClient {
|
|||
}));
|
||||
}
|
||||
|
||||
async setMockDebugOrganizationState(input: {
|
||||
organizationId: string;
|
||||
githubSyncStatus?: MockGithubSyncStatus;
|
||||
githubInstallationStatus?: MockGithubInstallationStatus;
|
||||
runtimeStatus?: MockActorRuntimeStatus;
|
||||
}): Promise<void> {
|
||||
await this.injectAsyncLatency();
|
||||
this.requireOrganization(input.organizationId);
|
||||
this.updateOrganization(input.organizationId, (organization) => {
|
||||
const nextIssues =
|
||||
input.runtimeStatus === "error" ? (organization.runtime.issues.length > 0 ? organization.runtime.issues : [buildSampleRuntimeIssue(organization)]) : [];
|
||||
const nextRuntime =
|
||||
input.runtimeStatus != null
|
||||
? {
|
||||
...organization.runtime,
|
||||
status: input.runtimeStatus,
|
||||
errorCount: nextIssues.length,
|
||||
lastErrorAt: nextIssues[0]?.occurredAt ?? null,
|
||||
issues: nextIssues,
|
||||
}
|
||||
: organization.runtime;
|
||||
const nextSyncStatus = input.githubSyncStatus ?? organization.github.syncStatus;
|
||||
return {
|
||||
...organization,
|
||||
github: {
|
||||
...organization.github,
|
||||
syncStatus: nextSyncStatus,
|
||||
installationStatus: input.githubInstallationStatus ?? organization.github.installationStatus,
|
||||
importedRepoCount: nextSyncStatus === "synced" ? organization.repoCatalog.length : organization.github.importedRepoCount,
|
||||
lastSyncLabel:
|
||||
nextSyncStatus === "syncing"
|
||||
? "Syncing repositories..."
|
||||
: nextSyncStatus === "error"
|
||||
? "GitHub sync failed"
|
||||
: nextSyncStatus === "pending"
|
||||
? "Waiting to sync"
|
||||
: "Synced just now",
|
||||
lastSyncAt: nextSyncStatus === "synced" ? Date.now() : organization.github.lastSyncAt,
|
||||
},
|
||||
runtime: nextRuntime,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
recordSeatUsage(workspaceId: string): void {
|
||||
const org = this.snapshot.organizations.find((candidate) => candidate.workspaceId === workspaceId);
|
||||
const currentUser = currentMockUser(this.snapshot);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue