chore(foundry): workbench action responsiveness (#254)

* wip

* wip
This commit is contained in:
Nathan Flurry 2026-03-14 20:42:18 -07:00 committed by GitHub
parent 400f9a214e
commit 99abb9d42e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
171 changed files with 7260 additions and 7342 deletions

View file

@ -65,7 +65,7 @@ export interface FoundryOrganizationSettings {
export interface FoundryOrganization {
id: string;
workspaceId: string;
organizationId: string;
kind: FoundryOrganizationKind;
settings: FoundryOrganizationSettings;
github: FoundryGithubState;

View file

@ -15,7 +15,7 @@ export const ConfigSchema = z.object({
})
.optional(),
notify: z.array(NotifyBackendSchema).default(["terminal"]),
workspace: z
organization: z
.object({
default: z.string().min(1).default("default"),
})
@ -39,7 +39,7 @@ export const ConfigSchema = z.object({
backup_interval_secs: 3600,
backup_retention_days: 7,
}),
providers: z
sandboxProviders: z
.object({
local: z
.object({

View file

@ -1,14 +1,14 @@
import { z } from "zod";
export const WorkspaceIdSchema = z
export const OrganizationIdSchema = z
.string()
.min(1)
.max(64)
.regex(/^[a-zA-Z0-9._-]+$/);
export type WorkspaceId = z.infer<typeof WorkspaceIdSchema>;
export type OrganizationId = z.infer<typeof OrganizationIdSchema>;
export const ProviderIdSchema = z.enum(["e2b", "local"]);
export type ProviderId = z.infer<typeof ProviderIdSchema>;
export const SandboxProviderIdSchema = z.enum(["e2b", "local"]);
export type SandboxProviderId = z.infer<typeof SandboxProviderIdSchema>;
export const AgentTypeSchema = z.enum(["claude", "codex"]);
export type AgentType = z.infer<typeof AgentTypeSchema>;
@ -39,7 +39,7 @@ export const TaskStatusSchema = z.enum([
export type TaskStatus = z.infer<typeof TaskStatusSchema>;
export const RepoRecordSchema = z.object({
workspaceId: WorkspaceIdSchema,
organizationId: OrganizationIdSchema,
repoId: RepoIdSchema,
remoteUrl: RepoRemoteSchema,
createdAt: z.number().int(),
@ -47,33 +47,27 @@ export const RepoRecordSchema = z.object({
});
export type RepoRecord = z.infer<typeof RepoRecordSchema>;
export const AddRepoInputSchema = z.object({
workspaceId: WorkspaceIdSchema,
remoteUrl: RepoRemoteSchema,
});
export type AddRepoInput = z.infer<typeof AddRepoInputSchema>;
export const CreateTaskInputSchema = z.object({
workspaceId: WorkspaceIdSchema,
organizationId: OrganizationIdSchema,
repoId: RepoIdSchema,
task: z.string().min(1),
explicitTitle: z.string().trim().min(1).optional(),
explicitBranchName: z.string().trim().min(1).optional(),
providerId: ProviderIdSchema.optional(),
sandboxProviderId: SandboxProviderIdSchema.optional(),
agentType: AgentTypeSchema.optional(),
onBranch: z.string().trim().min(1).optional(),
});
export type CreateTaskInput = z.infer<typeof CreateTaskInputSchema>;
export const TaskRecordSchema = z.object({
workspaceId: WorkspaceIdSchema,
organizationId: OrganizationIdSchema,
repoId: z.string().min(1),
repoRemote: RepoRemoteSchema,
taskId: z.string().min(1),
branchName: z.string().min(1).nullable(),
title: z.string().min(1).nullable(),
task: z.string().min(1),
providerId: ProviderIdSchema,
sandboxProviderId: SandboxProviderIdSchema,
status: TaskStatusSchema,
statusMessage: z.string().nullable(),
activeSandboxId: z.string().nullable(),
@ -81,7 +75,7 @@ export const TaskRecordSchema = z.object({
sandboxes: z.array(
z.object({
sandboxId: z.string().min(1),
providerId: ProviderIdSchema,
sandboxProviderId: SandboxProviderIdSchema,
sandboxActorId: z.string().nullable(),
switchTarget: z.string().min(1),
cwd: z.string().nullable(),
@ -106,7 +100,7 @@ export const TaskRecordSchema = z.object({
export type TaskRecord = z.infer<typeof TaskRecordSchema>;
export const TaskSummarySchema = z.object({
workspaceId: WorkspaceIdSchema,
organizationId: OrganizationIdSchema,
repoId: z.string().min(1),
taskId: z.string().min(1),
branchName: z.string().min(1).nullable(),
@ -117,21 +111,21 @@ export const TaskSummarySchema = z.object({
export type TaskSummary = z.infer<typeof TaskSummarySchema>;
export const TaskActionInputSchema = z.object({
workspaceId: WorkspaceIdSchema,
organizationId: OrganizationIdSchema,
taskId: z.string().min(1),
});
export type TaskActionInput = z.infer<typeof TaskActionInputSchema>;
export const SwitchResultSchema = z.object({
workspaceId: WorkspaceIdSchema,
organizationId: OrganizationIdSchema,
taskId: z.string().min(1),
providerId: ProviderIdSchema,
sandboxProviderId: SandboxProviderIdSchema,
switchTarget: z.string().min(1),
});
export type SwitchResult = z.infer<typeof SwitchResultSchema>;
export const ListTasksInputSchema = z.object({
workspaceId: WorkspaceIdSchema,
organizationId: OrganizationIdSchema,
repoId: RepoIdSchema.optional(),
});
export type ListTasksInput = z.infer<typeof ListTasksInputSchema>;
@ -139,11 +133,6 @@ export type ListTasksInput = z.infer<typeof ListTasksInputSchema>;
export const RepoBranchRecordSchema = z.object({
branchName: z.string().min(1),
commitSha: z.string().min(1),
parentBranch: z.string().nullable(),
trackedInStack: z.boolean(),
diffStat: z.string().nullable(),
hasUnpushed: z.boolean(),
conflictsWithMain: z.boolean(),
taskId: z.string().nullable(),
taskTitle: z.string().nullable(),
taskStatus: TaskStatusSchema.nullable(),
@ -153,69 +142,27 @@ export const RepoBranchRecordSchema = z.object({
ciStatus: z.string().nullable(),
reviewStatus: z.string().nullable(),
reviewer: z.string().nullable(),
firstSeenAt: z.number().int().nullable(),
lastSeenAt: z.number().int().nullable(),
updatedAt: z.number().int(),
});
export type RepoBranchRecord = z.infer<typeof RepoBranchRecordSchema>;
export const RepoOverviewSchema = z.object({
workspaceId: WorkspaceIdSchema,
organizationId: OrganizationIdSchema,
repoId: RepoIdSchema,
remoteUrl: RepoRemoteSchema,
baseRef: z.string().nullable(),
stackAvailable: z.boolean(),
fetchedAt: z.number().int(),
branchSyncAt: z.number().int().nullable(),
prSyncAt: z.number().int().nullable(),
branchSyncStatus: z.enum(["pending", "syncing", "synced", "error"]),
prSyncStatus: z.enum(["pending", "syncing", "synced", "error"]),
repoActionJobs: z.array(
z.object({
jobId: z.string().min(1),
action: z.enum(["sync_repo", "restack_repo", "restack_subtree", "rebase_branch", "reparent_branch"]),
branchName: z.string().nullable(),
parentBranch: z.string().nullable(),
status: z.enum(["queued", "running", "completed", "error"]),
message: z.string().min(1),
createdAt: z.number().int(),
updatedAt: z.number().int(),
completedAt: z.number().int().nullable(),
}),
),
branches: z.array(RepoBranchRecordSchema),
});
export type RepoOverview = z.infer<typeof RepoOverviewSchema>;
export const RepoStackActionSchema = z.enum(["sync_repo", "restack_repo", "restack_subtree", "rebase_branch", "reparent_branch"]);
export type RepoStackAction = z.infer<typeof RepoStackActionSchema>;
export const RepoStackActionInputSchema = z.object({
workspaceId: WorkspaceIdSchema,
repoId: RepoIdSchema,
action: RepoStackActionSchema,
branchName: z.string().trim().min(1).optional(),
parentBranch: z.string().trim().min(1).optional(),
export const OrganizationUseInputSchema = z.object({
organizationId: OrganizationIdSchema,
});
export type RepoStackActionInput = z.infer<typeof RepoStackActionInputSchema>;
export const RepoStackActionResultSchema = z.object({
jobId: z.string().min(1).nullable().optional(),
action: RepoStackActionSchema,
executed: z.boolean(),
status: z.enum(["queued", "running", "completed", "error"]).optional(),
message: z.string().min(1),
at: z.number().int(),
});
export type RepoStackActionResult = z.infer<typeof RepoStackActionResultSchema>;
export const WorkspaceUseInputSchema = z.object({
workspaceId: WorkspaceIdSchema,
});
export type WorkspaceUseInput = z.infer<typeof WorkspaceUseInputSchema>;
export type OrganizationUseInput = z.infer<typeof OrganizationUseInputSchema>;
export const StarSandboxAgentRepoInputSchema = z.object({
workspaceId: WorkspaceIdSchema,
organizationId: OrganizationIdSchema,
});
export type StarSandboxAgentRepoInput = z.infer<typeof StarSandboxAgentRepoInputSchema>;
@ -226,7 +173,7 @@ export const StarSandboxAgentRepoResultSchema = z.object({
export type StarSandboxAgentRepoResult = z.infer<typeof StarSandboxAgentRepoResultSchema>;
export const HistoryQueryInputSchema = z.object({
workspaceId: WorkspaceIdSchema,
organizationId: OrganizationIdSchema,
limit: z.number().int().positive().max(500).optional(),
branch: z.string().min(1).optional(),
taskId: z.string().min(1).optional(),
@ -235,7 +182,7 @@ export type HistoryQueryInput = z.infer<typeof HistoryQueryInputSchema>;
export const HistoryEventSchema = z.object({
id: z.number().int(),
workspaceId: WorkspaceIdSchema,
organizationId: OrganizationIdSchema,
repoId: z.string().nullable(),
taskId: z.string().nullable(),
branchName: z.string().nullable(),
@ -246,14 +193,14 @@ export const HistoryEventSchema = z.object({
export type HistoryEvent = z.infer<typeof HistoryEventSchema>;
export const PruneInputSchema = z.object({
workspaceId: WorkspaceIdSchema,
organizationId: OrganizationIdSchema,
dryRun: z.boolean(),
yes: z.boolean(),
});
export type PruneInput = z.infer<typeof PruneInputSchema>;
export const KillInputSchema = z.object({
workspaceId: WorkspaceIdSchema,
organizationId: OrganizationIdSchema,
taskId: z.string().min(1),
deleteBranch: z.boolean(),
abandon: z.boolean(),
@ -261,13 +208,13 @@ export const KillInputSchema = z.object({
export type KillInput = z.infer<typeof KillInputSchema>;
export const StatuslineInputSchema = z.object({
workspaceId: WorkspaceIdSchema,
organizationId: OrganizationIdSchema,
format: z.enum(["table", "claude-code"]),
});
export type StatuslineInput = z.infer<typeof StatuslineInputSchema>;
export const ListInputSchema = z.object({
workspaceId: WorkspaceIdSchema,
organizationId: OrganizationIdSchema,
format: z.enum(["table", "json"]),
full: z.boolean(),
});

View file

@ -4,4 +4,4 @@ export * from "./config.js";
export * from "./logging.js";
export * from "./realtime-events.js";
export * from "./workbench.js";
export * from "./workspace.js";
export * from "./organization.js";

View file

@ -0,0 +1,13 @@
import type { AppConfig } from "./config.js";
export function resolveOrganizationId(flagOrganization: string | undefined, config: AppConfig): string {
if (flagOrganization && flagOrganization.trim().length > 0) {
return flagOrganization.trim();
}
if (config.organization.default.trim().length > 0) {
return config.organization.default.trim();
}
return "default";
}

View file

@ -1,5 +1,5 @@
import type { FoundryAppSnapshot } from "./app-shell.js";
import type { WorkbenchOpenPrSummary, WorkbenchRepoSummary, WorkbenchSessionDetail, WorkbenchTaskDetail, WorkbenchTaskSummary } from "./workbench.js";
import type { WorkbenchOpenPrSummary, WorkbenchRepositorySummary, WorkbenchSessionDetail, WorkbenchTaskDetail, WorkbenchTaskSummary } from "./workbench.js";
export interface SandboxProcessSnapshot {
id: string;
@ -15,12 +15,12 @@ export interface SandboxProcessSnapshot {
tty: boolean;
}
/** Workspace-level events broadcast by the workspace actor. */
export type WorkspaceEvent =
/** Organization-level events broadcast by the organization actor. */
export type OrganizationEvent =
| { type: "taskSummaryUpdated"; taskSummary: WorkbenchTaskSummary }
| { type: "taskRemoved"; taskId: string }
| { type: "repoAdded"; repo: WorkbenchRepoSummary }
| { type: "repoUpdated"; repo: WorkbenchRepoSummary }
| { type: "repoAdded"; repo: WorkbenchRepositorySummary }
| { type: "repoUpdated"; repo: WorkbenchRepositorySummary }
| { type: "repoRemoved"; repoId: string }
| { type: "pullRequestUpdated"; pullRequest: WorkbenchOpenPrSummary }
| { type: "pullRequestRemoved"; prId: string };
@ -31,7 +31,7 @@ export type TaskEvent = { type: "taskDetailUpdated"; detail: WorkbenchTaskDetail
/** Session-level events broadcast by the task actor and filtered by sessionId on the client. */
export type SessionEvent = { type: "sessionUpdated"; session: WorkbenchSessionDetail };
/** App-level events broadcast by the app workspace actor. */
/** App-level events broadcast by the app organization actor. */
export type AppEvent = { type: "appUpdated"; snapshot: FoundryAppSnapshot };
/** Sandbox process events broadcast by the sandbox instance actor. */

View file

@ -1,4 +1,4 @@
import type { AgentType, ProviderId, TaskStatus } from "./contracts.js";
import type { AgentType, SandboxProviderId, TaskStatus } from "./contracts.js";
export type WorkbenchTaskStatus = TaskStatus | "new";
export type WorkbenchAgentKind = "Claude" | "Codex" | "Cursor";
@ -32,7 +32,10 @@ export interface WorkbenchComposerDraft {
/** Session metadata without transcript content. */
export interface WorkbenchSessionSummary {
id: string;
sessionId: string | null;
/** Stable UI session id used for routing and task-local identity. */
sessionId: string;
/** Underlying sandbox session id when provisioning has completed. */
sandboxSessionId?: string | null;
sessionName: string;
agent: WorkbenchAgentKind;
model: WorkbenchModelId;
@ -43,11 +46,10 @@ export interface WorkbenchSessionSummary {
errorMessage?: string | null;
}
/** Full session content — only fetched when viewing a specific session tab. */
/** Full session content — only fetched when viewing a specific session. */
export interface WorkbenchSessionDetail {
/** Stable UI tab id used for the session topic key and routing. */
/** Stable UI session id used for the session topic key and routing. */
sessionId: string;
tabId: string;
sandboxSessionId: string | null;
sessionName: string;
agent: WorkbenchAgentKind;
@ -87,7 +89,7 @@ export interface WorkbenchHistoryEvent {
messageId: string;
preview: string;
sessionName: string;
tabId: string;
sessionId: string;
createdAtMs: number;
detail: string;
}
@ -121,12 +123,12 @@ export interface WorkbenchOpenPrSummary {
}
export interface WorkbenchSandboxSummary {
providerId: ProviderId;
sandboxProviderId: SandboxProviderId;
sandboxId: string;
cwd: string | null;
}
/** Sidebar-level task data. Materialized in the workspace actor's SQLite. */
/** Sidebar-level task data. Materialized in the organization actor's SQLite. */
export interface WorkbenchTaskSummary {
id: string;
repoId: string;
@ -162,8 +164,8 @@ export interface WorkbenchTaskDetail extends WorkbenchTaskSummary {
activeSandboxId: string | null;
}
/** Repo-level summary for workspace sidebar. */
export interface WorkbenchRepoSummary {
/** Repo-level summary for organization sidebar. */
export interface WorkbenchRepositorySummary {
id: string;
label: string;
/** Aggregated branch/task overview state (replaces getRepoOverview polling). */
@ -171,19 +173,15 @@ export interface WorkbenchRepoSummary {
latestActivityMs: number;
}
/** Workspace-level snapshot — initial fetch for the workspace topic. */
export interface WorkspaceSummarySnapshot {
workspaceId: string;
repos: WorkbenchRepoSummary[];
/** Organization-level snapshot — initial fetch for the organization topic. */
export interface OrganizationSummarySnapshot {
organizationId: string;
repos: WorkbenchRepositorySummary[];
taskSummaries: WorkbenchTaskSummary[];
openPullRequests: WorkbenchOpenPrSummary[];
}
/**
* Deprecated compatibility aliases for older mock/view-model code.
* New code should use the summary/detail/topic-specific types above.
*/
export interface WorkbenchAgentTab extends WorkbenchSessionSummary {
export interface WorkbenchSession extends WorkbenchSessionSummary {
draft: WorkbenchComposerDraft;
transcript: WorkbenchTranscriptEvent[];
}
@ -199,7 +197,7 @@ export interface WorkbenchTask {
updatedAtMs: number;
branch: string | null;
pullRequest: WorkbenchPullRequestSummary | null;
tabs: WorkbenchAgentTab[];
sessions: WorkbenchSession[];
fileChanges: WorkbenchFileChange[];
diffs: Record<string, string>;
fileTree: WorkbenchFileTreeNode[];
@ -212,7 +210,7 @@ export interface WorkbenchRepo {
label: string;
}
export interface WorkbenchProjectSection {
export interface WorkbenchRepositorySection {
id: string;
label: string;
updatedAtMs: number;
@ -220,9 +218,9 @@ export interface WorkbenchProjectSection {
}
export interface TaskWorkbenchSnapshot {
workspaceId: string;
organizationId: string;
repos: WorkbenchRepo[];
projects: WorkbenchProjectSection[];
repositories: WorkbenchRepositorySection[];
tasks: WorkbenchTask[];
}
@ -256,30 +254,30 @@ export interface TaskWorkbenchRenameInput {
export interface TaskWorkbenchSendMessageInput {
taskId: string;
tabId: string;
sessionId: string;
text: string;
attachments: WorkbenchLineAttachment[];
}
export interface TaskWorkbenchTabInput {
export interface TaskWorkbenchSessionInput {
taskId: string;
tabId: string;
sessionId: string;
}
export interface TaskWorkbenchRenameSessionInput extends TaskWorkbenchTabInput {
export interface TaskWorkbenchRenameSessionInput extends TaskWorkbenchSessionInput {
title: string;
}
export interface TaskWorkbenchChangeModelInput extends TaskWorkbenchTabInput {
export interface TaskWorkbenchChangeModelInput extends TaskWorkbenchSessionInput {
model: WorkbenchModelId;
}
export interface TaskWorkbenchUpdateDraftInput extends TaskWorkbenchTabInput {
export interface TaskWorkbenchUpdateDraftInput extends TaskWorkbenchSessionInput {
text: string;
attachments: WorkbenchLineAttachment[];
}
export interface TaskWorkbenchSetSessionUnreadInput extends TaskWorkbenchTabInput {
export interface TaskWorkbenchSetSessionUnreadInput extends TaskWorkbenchSessionInput {
unread: boolean;
}
@ -290,9 +288,9 @@ export interface TaskWorkbenchDiffInput {
export interface TaskWorkbenchCreateTaskResponse {
taskId: string;
tabId?: string;
sessionId?: string;
}
export interface TaskWorkbenchAddTabResponse {
tabId: string;
export interface TaskWorkbenchAddSessionResponse {
sessionId: string;
}

View file

@ -1,13 +0,0 @@
import type { AppConfig } from "./config.js";
export function resolveWorkspaceId(flagWorkspace: string | undefined, config: AppConfig): string {
if (flagWorkspace && flagWorkspace.trim().length > 0) {
return flagWorkspace.trim();
}
if (config.workspace.default.trim().length > 0) {
return config.workspace.default.trim();
}
return "default";
}