feat(forge): pluggable forge abstraction + GitLab and Gitea/Forgejo/Codeberg (#1913)
* refactor(forge): forge-neutral foundation (GitHub-only) Decouple git-hosting from GitHub behind a neutral abstraction (issue #1616), GitHub-only for now; existing GitHub behaviour is unchanged. - Forge manifest, neutral ForgeService contract, forge registry + resolver, and a client forge-module registry. - GitHub code renamed to the neutral shape; PR/Issue attachment wording preserved. - forge.search.response enums parse tolerantly (unknown kind/auth state degrade instead of breaking the client). - createPullRequest reports typed CLI/auth errors instead of a generic message. - forge-resolver host/remote caches are LRU-bounded. - Forge host trust is explicit: only a known cloud host or a CLI-authenticated host is ever talked to; an unauthenticated GitHub Enterprise host fails resolution instead of routing to github.com. - Docs: forge-providers guide, glossary and i18n forge-copy conventions, architecture and rpc-namespacing terminology. - Vitest React Native mocks (unistyles, svg, linking, lucide) consolidated into shared aliased test-stubs. * feat(forge): GitLab adapter, forge-aware UI, pipelines and approvals GitLab adapter over the glab CLI on the neutral contracts: MR status, forge-aware UI, pipeline tree, and N-of-M approvals. - threadIsResolved is part of the neutral timeline item. - Pipeline load failures show an error instead of an empty section. - Manual pipeline jobs render as pending. - Fork/detached MR head pipelines are fetched by MR iid (glab ci get --merge-request). * feat(forge): Gitea family adapter (Gitea, Forgejo, Codeberg) One adapter over the tea CLI serving Gitea, Forgejo, and Codeberg on the neutral contracts. - CI status aggregates commit statuses and Actions runs together. - Gitea's terminal "warning" state maps to failure on server and client. - Gitea Actions check details are reachable from the PR pane by workflowRunId. * refactor(forge): localize compatibility handling * test(forge): expect normalized GitLab facts --------- Co-authored-by: Mohamed Boudra <boudra.moha@gmail.com>
This commit is contained in:
co-authored by
Mohamed Boudra
parent
04d1ebdce0
commit
a8ebd390fa
@@ -21,7 +21,10 @@ import {
|
||||
import { Composer } from "@/composer";
|
||||
import { FileDropZone } from "@/components/file-drop/file-drop-zone";
|
||||
import { DraftAgentModeControl } from "@/composer/agent-controls/mode-control";
|
||||
import { splitComposerAttachmentsForSubmit } from "@/composer/attachments/submit";
|
||||
import {
|
||||
resolveComposerAttachmentSubmitFormat,
|
||||
splitComposerAttachmentsForSubmit,
|
||||
} from "@/composer/attachments/submit";
|
||||
import { HostStatusDot } from "@/components/host-status-dot";
|
||||
import { HostPicker } from "@/components/hosts/host-picker";
|
||||
import { ProjectIconView } from "@/components/project-icon-view";
|
||||
@@ -36,7 +39,7 @@ import { ScreenHeader } from "@/components/headers/screen-header";
|
||||
import { HEADER_INNER_HEIGHT, MAX_CONTENT_WIDTH, useIsCompactFormFactor } from "@/constants/layout";
|
||||
import { useToast } from "@/contexts/toast-context";
|
||||
import { useAgentInputDraft } from "@/composer/draft/input-draft";
|
||||
import { useGithubSearchQuery } from "@/git/use-github-search-query";
|
||||
import { useForgeSearchQuery } from "@/git/use-forge-search-query";
|
||||
import {
|
||||
useHostRuntimeClient,
|
||||
useHostRuntimeConnectionStatuses,
|
||||
@@ -63,6 +66,7 @@ import {
|
||||
import { useKeyboardShiftStyle } from "@/hooks/use-keyboard-shift-style";
|
||||
import { useFormPreferences } from "@/hooks/use-form-preferences";
|
||||
import { useShortcutKeys } from "@/hooks/use-shortcut-keys";
|
||||
import { getForgePresentation } from "@/git/forge";
|
||||
import type { CreateAgentInitialValues } from "@/hooks/use-agent-form-state";
|
||||
import { generateMessageId } from "@/types/stream";
|
||||
import { toErrorMessage } from "@/utils/error-messages";
|
||||
@@ -79,7 +83,7 @@ import { ICON_SIZE, type Theme } from "@/styles/theme";
|
||||
import type { ComposerAttachment, UserComposerAttachment } from "@/attachments/types";
|
||||
import { useDraftWorkspaceAttachmentScopeKey } from "@/attachments/workspace-attachments-store";
|
||||
import type { MessagePayload } from "@/composer/types";
|
||||
import type { AgentAttachment, GitHubSearchItem } from "@getpaseo/protocol/messages";
|
||||
import type { AgentAttachment, ForgeSearchItem } from "@getpaseo/protocol/messages";
|
||||
import type { CreatePaseoWorktreeInput } from "@getpaseo/client/internal/daemon-client";
|
||||
import type { AgentProvider } from "@getpaseo/protocol/agent-types";
|
||||
import type { WorkspaceDraftTabSetup, WorkspaceTabTarget } from "@/stores/workspace-tabs-store";
|
||||
@@ -637,8 +641,17 @@ function AddProjectPickerAction({ onPress }: { onPress: () => void }) {
|
||||
);
|
||||
}
|
||||
|
||||
function formatPrLabel(item: { number: number; title: string }): string {
|
||||
return `#${item.number} ${item.title}`;
|
||||
function formatPrLabel(item: Pick<ForgeSearchItem, "forge" | "number" | "title">): string {
|
||||
const presentation = getForgePresentation(item.forge ?? "github");
|
||||
return `${presentation.numberPrefix}${item.number} ${item.title}`;
|
||||
}
|
||||
|
||||
function getCheckoutHintPresentation(item: ForgeSearchItem) {
|
||||
const presentation = getForgePresentation(item.forge ?? "github");
|
||||
return {
|
||||
noun: presentation.changeRequestAbbrev,
|
||||
numberPrefix: presentation.numberPrefix,
|
||||
};
|
||||
}
|
||||
|
||||
function pickerItemLabel(item: PickerItem): string {
|
||||
@@ -655,7 +668,7 @@ function newWorkspaceHostOptionTestID(serverId: string): string {
|
||||
|
||||
function computePickerOptionData(
|
||||
branchDetails: ReadonlyArray<{ name: string; committerDate: number }>,
|
||||
prItems: ReadonlyArray<GitHubSearchItem>,
|
||||
prItems: ReadonlyArray<ForgeSearchItem>,
|
||||
): PickerOptionData {
|
||||
const idMap = new Map<string, PickerItem>();
|
||||
|
||||
@@ -817,6 +830,7 @@ interface SubmitDraftInput {
|
||||
attachments: ComposerAttachment[];
|
||||
provider: AgentProvider;
|
||||
composerState: NewWorkspaceComposerState;
|
||||
supportsForgeSearch: boolean;
|
||||
}
|
||||
|
||||
type NewWorkspaceComposerState = NonNullable<
|
||||
@@ -922,6 +936,7 @@ interface CreateChatAgentInput {
|
||||
serverId: string;
|
||||
draftKey: string;
|
||||
draftId?: string;
|
||||
supportsForgeSearch: boolean;
|
||||
labels: {
|
||||
composerStateRequired: string;
|
||||
selectModel: string;
|
||||
@@ -992,7 +1007,12 @@ async function runCreateChatAgent(input: CreateChatAgentInput): Promise<void> {
|
||||
if (!provider) {
|
||||
throw new Error(input.labels.selectModel);
|
||||
}
|
||||
const { attachments: reviewAttachments } = splitComposerAttachmentsForSubmit(attachments);
|
||||
const attachmentSubmitFormat = resolveComposerAttachmentSubmitFormat({
|
||||
supportsForgeAttachments: input.supportsForgeSearch,
|
||||
});
|
||||
const { attachments: reviewAttachments } = splitComposerAttachmentsForSubmit(attachments, {
|
||||
format: attachmentSubmitFormat,
|
||||
});
|
||||
const workspaceNamingAttachments = getWorkspaceNamingAttachments(reviewAttachments);
|
||||
const ensuredWorkspace = await ensureWorkspace({
|
||||
cwd,
|
||||
@@ -1017,6 +1037,7 @@ async function runCreateChatAgent(input: CreateChatAgentInput): Promise<void> {
|
||||
attachments,
|
||||
provider,
|
||||
composerState,
|
||||
supportsForgeSearch: input.supportsForgeSearch,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1138,7 +1159,11 @@ function submitWorkspaceDraft(input: SubmitDraftInput): void {
|
||||
const draftId = draftIdInput?.trim() || generateDraftId();
|
||||
const clientMessageId = generateMessageId();
|
||||
const timestamp = Date.now();
|
||||
const wirePayload = splitComposerAttachmentsForSubmit(attachments);
|
||||
const wirePayload = splitComposerAttachmentsForSubmit(attachments, {
|
||||
format: resolveComposerAttachmentSubmitFormat({
|
||||
supportsForgeAttachments: input.supportsForgeSearch,
|
||||
}),
|
||||
});
|
||||
const submission = resolveWorkspaceDraftSubmissionConfig({
|
||||
draftId,
|
||||
workspaceDirectory,
|
||||
@@ -1616,6 +1641,7 @@ export function NewWorkspaceScreen({
|
||||
});
|
||||
// COMPAT(workspaceMultiplicity): added in v0.1.97, drop the gate when floor >= v0.1.97
|
||||
const supportsWorkspaceMultiplicity = useHostFeature(selectedServerId, "workspaceMultiplicity");
|
||||
const supportsForgeSearch = useHostFeature(selectedServerId, "forgeSearch");
|
||||
const [errorMessage, setErrorMessage] = useState<string | null>(null);
|
||||
const [createdWorkspace, setCreatedWorkspace] = useState<ReturnType<
|
||||
typeof normalizeWorkspaceDescriptor
|
||||
@@ -1753,12 +1779,13 @@ export function NewWorkspaceScreen({
|
||||
staleTime: 15_000,
|
||||
});
|
||||
|
||||
const githubPrSearchQuery = useGithubSearchQuery({
|
||||
const githubPrSearchQuery = useForgeSearchQuery({
|
||||
client,
|
||||
serverId: selectedServerId,
|
||||
cwd: selectedSourceDirectory ?? "",
|
||||
query: debouncedPickerSearchQuery,
|
||||
kinds: ["github-pr"],
|
||||
kinds: ["change_request"],
|
||||
supportsForgeSearch,
|
||||
enabled: pickerQueryEnabled,
|
||||
});
|
||||
|
||||
@@ -1766,11 +1793,12 @@ export function NewWorkspaceScreen({
|
||||
() => normalizeBranchDetails(branchSuggestionsQuery.data),
|
||||
[branchSuggestionsQuery.data],
|
||||
);
|
||||
const githubFeaturesEnabled = githubPrSearchQuery.data?.githubFeaturesEnabled !== false;
|
||||
const prItems: GitHubSearchItem[] = useMemo(() => {
|
||||
if (!githubFeaturesEnabled) return [];
|
||||
const forgeSearchAuthenticated =
|
||||
!githubPrSearchQuery.data || githubPrSearchQuery.data.authState === "authenticated";
|
||||
const prItems: ForgeSearchItem[] = useMemo(() => {
|
||||
if (!forgeSearchAuthenticated) return [];
|
||||
return githubPrSearchQuery.data?.items ?? [];
|
||||
}, [githubFeaturesEnabled, githubPrSearchQuery.data?.items]);
|
||||
}, [forgeSearchAuthenticated, githubPrSearchQuery.data?.items]);
|
||||
|
||||
const { options, itemById }: PickerOptionData = useMemo(
|
||||
() => computePickerOptionData(branchDetails, prItems),
|
||||
@@ -2059,6 +2087,7 @@ export function NewWorkspaceScreen({
|
||||
serverId: selectedServerId,
|
||||
draftKey,
|
||||
draftId,
|
||||
supportsForgeSearch,
|
||||
labels: {
|
||||
composerStateRequired: t("newWorkspace.errors.composerStateRequired"),
|
||||
selectModel: t("newWorkspace.errors.selectModel"),
|
||||
@@ -2071,7 +2100,17 @@ export function NewWorkspaceScreen({
|
||||
toast.error(message);
|
||||
}
|
||||
},
|
||||
[composerState, draftId, draftKey, ensureWorkspace, forkDraftSetup, selectedServerId, t, toast],
|
||||
[
|
||||
composerState,
|
||||
draftId,
|
||||
draftKey,
|
||||
ensureWorkspace,
|
||||
forkDraftSetup,
|
||||
selectedServerId,
|
||||
supportsForgeSearch,
|
||||
t,
|
||||
toast,
|
||||
],
|
||||
);
|
||||
|
||||
const renderPickerOption = useCallback(
|
||||
@@ -2204,12 +2243,15 @@ export function NewWorkspaceScreen({
|
||||
<CheckoutHintBadge
|
||||
label={t("newWorkspace.refPicker.checkoutHint", {
|
||||
number: checkoutHintPrAttachment.item.number,
|
||||
...getCheckoutHintPresentation(checkoutHintPrAttachment.item),
|
||||
})}
|
||||
acceptLabel={t("newWorkspace.refPicker.checkoutPr", {
|
||||
number: checkoutHintPrAttachment.item.number,
|
||||
...getCheckoutHintPresentation(checkoutHintPrAttachment.item),
|
||||
})}
|
||||
dismissLabel={t("newWorkspace.refPicker.dismissCheckoutHint", {
|
||||
number: checkoutHintPrAttachment.item.number,
|
||||
...getCheckoutHintPresentation(checkoutHintPrAttachment.item),
|
||||
})}
|
||||
onAccept={acceptCheckoutHint}
|
||||
onDismiss={dismissCheckoutHint}
|
||||
|
||||
Reference in New Issue
Block a user