refactor: move git generation to session structured output
- Use active session prompts for commit/PR generation and drop backend git generation routes. - Improve tool activity UX with Structured Output rendering, description styling tweaks, and detailed-mode expansion fixes.
This commit is contained in:
@@ -62,6 +62,7 @@ import type { GitRemote } from '@/lib/gitApi';
|
||||
import { BranchPickerDialog } from '@/components/session/BranchPickerDialog';
|
||||
import { getRootBranch } from '@/lib/worktrees/worktreeStatus';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { generateCommitMessage as generateSessionCommitMessage } from '@/lib/gitApi';
|
||||
|
||||
type SyncAction = 'fetch' | 'pull' | 'push' | null;
|
||||
type CommitAction = 'commit' | 'commitAndPush' | null;
|
||||
@@ -820,25 +821,14 @@ export const GitView: React.FC<GitViewProps> = ({ mode = 'full' }) => {
|
||||
return;
|
||||
}
|
||||
|
||||
console.error('[git-generation][browser] generate button clicked', {
|
||||
directory: currentDirectory,
|
||||
selectedFiles: selectedPaths.size,
|
||||
});
|
||||
|
||||
setIsGeneratingMessage(true);
|
||||
try {
|
||||
const { getResolvedGitGenerationModel, settingsZenModel } = useConfigStore.getState();
|
||||
const resolvedModel = getResolvedGitGenerationModel();
|
||||
const options: { zenModel?: string; providerId?: string; modelId?: string } = {};
|
||||
if (resolvedModel) {
|
||||
options.providerId = resolvedModel.providerId;
|
||||
options.modelId = resolvedModel.modelId;
|
||||
if (resolvedModel.providerId === 'zen') {
|
||||
options.zenModel = resolvedModel.modelId;
|
||||
}
|
||||
} else if (settingsZenModel) {
|
||||
options.zenModel = settingsZenModel;
|
||||
}
|
||||
const { message } = await git.generateCommitMessage(
|
||||
currentDirectory,
|
||||
Array.from(selectedPaths),
|
||||
Object.keys(options).length > 0 ? options : undefined
|
||||
);
|
||||
const { message } = await generateSessionCommitMessage(currentDirectory, Array.from(selectedPaths));
|
||||
const subject = message.subject?.trim() ?? '';
|
||||
const highlights = Array.isArray(message.highlights) ? message.highlights : [];
|
||||
|
||||
@@ -859,13 +849,17 @@ export const GitView: React.FC<GitViewProps> = ({ mode = 'full' }) => {
|
||||
|
||||
scrollActionPanelToBottom();
|
||||
} catch (error) {
|
||||
console.error('[git-generation][browser] GitView generate handler failed', {
|
||||
message: error instanceof Error ? error.message : String(error),
|
||||
error,
|
||||
});
|
||||
const message =
|
||||
error instanceof Error ? error.message : 'Failed to generate commit message';
|
||||
toast.error(message);
|
||||
} finally {
|
||||
setIsGeneratingMessage(false);
|
||||
}
|
||||
}, [currentDirectory, selectedPaths, git, settingsGitmojiEnabled, gitmojiEmojis, scrollActionPanelToBottom]);
|
||||
}, [currentDirectory, selectedPaths, settingsGitmojiEnabled, gitmojiEmojis, scrollActionPanelToBottom]);
|
||||
|
||||
const handleCreateBranch = async (branchName: string, remote?: GitRemote) => {
|
||||
if (!currentDirectory || !status) return;
|
||||
|
||||
@@ -1128,24 +1128,13 @@ export const PullRequestSection: React.FC<{
|
||||
if (!directory) return;
|
||||
setIsGenerating(true);
|
||||
try {
|
||||
const { getResolvedGitGenerationModel, settingsZenModel } = useConfigStore.getState();
|
||||
const resolvedModel = getResolvedGitGenerationModel();
|
||||
const payload: { base: string; head: string; context?: string; zenModel?: string; providerId?: string; modelId?: string } = {
|
||||
const payload: { base: string; head: string; context?: string; files?: string[] } = {
|
||||
base: targetBaseBranch,
|
||||
head: branch,
|
||||
};
|
||||
if (additionalContext) {
|
||||
payload.context = additionalContext;
|
||||
}
|
||||
if (resolvedModel) {
|
||||
payload.providerId = resolvedModel.providerId;
|
||||
payload.modelId = resolvedModel.modelId;
|
||||
if (resolvedModel.providerId === 'zen') {
|
||||
payload.zenModel = resolvedModel.modelId;
|
||||
}
|
||||
} else if (settingsZenModel) {
|
||||
payload.zenModel = settingsZenModel;
|
||||
}
|
||||
const generated = await generatePullRequestDescription(directory, payload);
|
||||
|
||||
if (generated.title?.trim()) {
|
||||
@@ -1161,7 +1150,7 @@ export const PullRequestSection: React.FC<{
|
||||
} finally {
|
||||
setIsGenerating(false);
|
||||
}
|
||||
}, [branch, directory, isGenerating, additionalContext, onGeneratedDescription, targetBaseBranch]);
|
||||
}, [additionalContext, branch, directory, isGenerating, onGeneratedDescription, targetBaseBranch]);
|
||||
|
||||
const createPr = React.useCallback(async () => {
|
||||
if (!github?.prCreate) {
|
||||
|
||||
Reference in New Issue
Block a user