Skip to content

feat: trigger git commit on approval in ChatScreen#108

Merged
jbdevprimary merged 2 commits into
mainfrom
chat-approve-commit-12982100548334997176
Feb 12, 2026
Merged

feat: trigger git commit on approval in ChatScreen#108
jbdevprimary merged 2 commits into
mainfrom
chat-approve-commit-12982100548334997176

Conversation

@jbdevprimary
Copy link
Copy Markdown
Contributor

Implemented real git commit functionality in the ChatScreen approval flow. When a user approves a 'commit' action request, the application now stages all changes in the project's repository and creates a commit using the provided description and user profile. Added robust error handling and user feedback.


PR created automatically by Jules for task 12982100548334997176 started by @jbdevprimary

@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 27, 2026

Warning

Rate limit exceeded

@jbdevprimary has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 7 minutes and 22 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chat-approve-commit-12982100548334997176

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @jbdevprimary, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the ChatScreen by integrating direct Git commit capabilities. It allows users to approve 'commit' action requests, which then trigger a real Git commit operation, staging all current changes and creating a commit with a specified message and author details. This streamlines the development workflow by enabling version control actions directly from the chat interface.

Highlights

  • Git Commit Integration: Implemented real Git commit functionality directly within the ChatScreen's approval flow, allowing users to trigger commits from chat.
  • Automated Staging and Committing: Upon approval of a 'commit' action request, the application now automatically stages all changes in the project's repository and creates a commit.
  • Enhanced Error Handling: Added robust error handling and user feedback (via Alert messages) for potential issues during Git operations.
  • User Profile for Commits: Commits are now attributed to the user's profile, using their name and email for the Git author.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds functionality to trigger a real git commit when a user approves a 'commit' action in the chat screen. The implementation in handleApprovalResponse is a good start, but it contains a critical error handling issue with GitService calls and a high-severity issue regarding commit author information. I've provided a detailed comment with a code suggestion to address both problems, ensuring that git operations are handled robustly and commits have correct authorship. The other changes, including refactoring for activeThread, are well done.

Comment thread app/(tabs)/chat.tsx Outdated
Comment on lines +72 to +103
try {
// Find project path
const projectId = activeThread?.projectId;
const project = projectId ? projects.find((p) => p.id === projectId) : undefined;
const repoDir = project?.localPath;

if (!repoDir) {
Alert.alert('Error', 'No repository path found for project');
return;
}

// Stage all changes
await GitService.stage({ dir: repoDir, filepath: '.' });

// Commit
const author = {
name: userProfile?.name || userProfile?.login || 'User',
email: userProfile?.email || 'user@example.com',
};

await GitService.commit({
dir: repoDir,
message: approvalMsg.metadata.actionDescription || 'Commit from chat',
author,
});

// Only mark as approved if commit succeeded
respondToApproval(messageId, activeThreadId, approved);
} catch (error) {
console.error('Failed to commit:', error);
Alert.alert('Commit Failed', error instanceof Error ? error.message : 'Unknown error');
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This block has a couple of significant issues:

  1. Incorrect Error Handling (Critical): GitService methods like stage and commit do not throw exceptions on failure. They return a result object like { success: boolean, error?: string }. The current try...catch block will not handle errors from these services, potentially leading to unexpected behavior where a failed stage or commit is treated as a success.

  2. Risky Commit Author (High): The code falls back to generic values like 'User' and 'user@example.com' if the user's profile isn't fully loaded. This can lead to commits with incorrect or anonymous author information in the repository history, which is highly undesirable.

I've provided a suggestion that refactors this block to correctly handle GitService results and ensures a valid user profile exists before attempting to commit.

          try {
            // Find project path
            const projectId = activeThread?.projectId;
            const project = projectId ? projects.find((p) => p.id === projectId) : undefined;
            const repoDir = project?.localPath;

            if (!repoDir) {
              Alert.alert('Error', 'No repository path found for project');
              return;
            }

            if (!userProfile) {
              Alert.alert('Error', 'User profile not loaded. Cannot create commit.');
              return;
            }

            // Stage all changes
            const stageResult = await GitService.stage({ dir: repoDir, filepath: '.' });
            if (!stageResult.success) {
              console.error('Failed to stage changes:', stageResult.error);
              Alert.alert('Stage Failed', stageResult.error || 'An unknown error occurred.');
              return;
            }

            // Commit
            const author = {
              name: userProfile.name || userProfile.login,
              email: userProfile.email || `${userProfile.id}+${userProfile.login}@users.noreply.github.com`,
            };

            const commitResult = await GitService.commit({
              dir: repoDir,
              message: approvalMsg.metadata.actionDescription || 'Commit from chat',
              author,
            });

            if (!commitResult.success) {
              console.error('Failed to commit:', commitResult.error);
              Alert.alert('Commit Failed', commitResult.error || 'An unknown error occurred.');
              return;
            }

            // Only mark as approved if commit succeeded
            respondToApproval(messageId, activeThreadId, approved);
          } catch (error) {
            console.error('An unexpected error occurred during commit process:', error);
            Alert.alert('Error', error instanceof Error ? error.message : 'An unexpected error occurred.');
          }

@jbdevprimary jbdevprimary force-pushed the chat-approve-commit-12982100548334997176 branch 2 times, most recently from b772669 to 35d6634 Compare February 12, 2026 03:31
google-labs-jules Bot and others added 2 commits February 11, 2026 21:35
- Replaced mocked 'Approve' action with `GitService` integration
- Implemented `handleApprovalResponse` to handle commit approvals
- Added staging and commit logic using `GitService`
- Added error handling and user feedback via `Alert`
- Updated imports to include `GitService` and `Alert`

Co-authored-by: jbdevprimary <2650679+jbdevprimary@users.noreply.github.com>
@jbdevprimary jbdevprimary force-pushed the chat-approve-commit-12982100548334997176 branch from 35d6634 to 932df96 Compare February 12, 2026 03:35
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@jbdevprimary jbdevprimary merged commit da1f613 into main Feb 12, 2026
13 of 17 checks passed
@jbdevprimary jbdevprimary deleted the chat-approve-commit-12982100548334997176 branch February 12, 2026 03:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant