Skip to content

Supportgemma4#232

Open
dishit-wednesday wants to merge 3 commits into
mainfrom
supportgemma4
Open

Supportgemma4#232
dishit-wednesday wants to merge 3 commits into
mainfrom
supportgemma4

Conversation

@dishit-wednesday
Copy link
Copy Markdown
Collaborator

Summary

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (code change that neither fixes a bug nor adds a feature)
  • Chore (build process, CI, dependency updates, etc.)

Screenshots / Screen Recordings

Android

Before After

iOS

Before After

Checklist

General

  • My code follows the project's coding style and conventions
  • I have performed a self-review of my code
  • I have added/updated comments where the logic isn't self-evident
  • My changes generate no new warnings or errors

Testing

  • I have tested on Android (physical device or emulator)
  • I have tested on iOS (physical device or simulator)
  • I have tested in light mode and dark mode
  • Existing tests pass locally (npm test)
  • I have added tests that prove my fix is effective or my feature works

React Native Specific

  • No new native module without corresponding platform implementation (Android + iOS)
  • New native modules are added to the Xcode project build target (project.pbxproj)
  • No hardcoded pixel values — uses SPACING / TYPOGRAPHY constants from the theme
  • Styles use useThemedStyles pattern (not inline or static StyleSheet.create)
  • Animations/gestures work smoothly on both platforms
  • Large lists use FlatList / FlashList (not .map() inside ScrollView)
  • No unnecessary re-renders introduced (check with React DevTools Profiler if unsure)

Performance & Models

  • Downloads / long-running tasks report progress to the UI
  • File paths are resolved correctly on both platforms (no hardcoded / vs \\)
  • Large files (models, assets) are not committed to the repository

Security

  • No secrets, API keys, or credentials are included in the code
  • User input is validated/sanitized where applicable

Related Issues

Additional Notes

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

@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 introduces support for Gemma 4 models, updating the llama.rn dependency and implementing specialized parsing for thinking mode and tool-calling tokens. The model import process is also improved to address iOS temporary file eviction and URI resolution. Feedback focuses on ensuring proper URI decoding for file checks, aborting imports when files are missing, and maintaining UI consistency with project-specific alert utilities. Additionally, the reviewer suggests removing the heartbeat interval to reduce production overhead and scoping tool-usage heuristic changes specifically to Gemma 4 to avoid regressions in other models.

Comment on lines +76 to +77
const file1ExistsBefore = await RNFS.exists(file1.uri.replace('file://', ''));
const file2ExistsBefore = await RNFS.exists(file2.uri.replace('file://', ''));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The RNFS.exists check is performed on an encoded URI string. This will fail for file paths containing spaces or special characters (e.g., %20). The path should be decoded before checking for existence to prevent silent failures during the import process.

Suggested change
const file1ExistsBefore = await RNFS.exists(file1.uri.replace('file://', ''));
const file2ExistsBefore = await RNFS.exists(file2.uri.replace('file://', ''));
const file1ExistsBefore = await RNFS.exists(decodeURIComponent(file1.uri.replace('file://', '')));
const file2ExistsBefore = await RNFS.exists(decodeURIComponent(file2.uri.replace('file://', '')));
References
  1. To prevent silent failures, ensure a directory exists (creating it if necessary) before performing operations on it.

Comment on lines +115 to +118
if (!mainExistsAfter || !mmProjExistsAfter) {
console.log('[IMPORT] ⚠️ FILES GONE after dialog! iOS deleted temp inbox files during the', dialogDurationMs, 'ms dialog wait.');
console.log('[IMPORT] This confirms the temp file eviction bug. Need keepLocalCopy() before dialog.');
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The code detects that files might be missing after the dialog (likely due to iOS temp file eviction) but only logs the issue. To prevent silent failures, the process should be aborted with a user-friendly error message if the files are no longer available, rather than proceeding to a guaranteed failure in importLocalModel.

Suggested change
if (!mainExistsAfter || !mmProjExistsAfter) {
console.log('[IMPORT] ⚠️ FILES GONE after dialog! iOS deleted temp inbox files during the', dialogDurationMs, 'ms dialog wait.');
console.log('[IMPORT] This confirms the temp file eviction bug. Need keepLocalCopy() before dialog.');
}
if (!mainExistsAfter || !mmProjExistsAfter) {
setAlertState(showAlert('Import Failed', 'The selected files are no longer available. This can happen on iOS if the system clears temporary files while waiting for confirmation. Please try again.'));
return;
}
References
  1. To prevent silent failures, ensure a directory exists (creating it if necessary) before performing operations on it.

Comment on lines +89 to 97
Alert.alert(
'Import Vision Model?',
`Main model: ${mainFile.name}\nProjector: ${mmProjFile.name}\n\nIf these look wrong, cancel and rename your files.`,
[
{ text: 'Cancel', style: 'cancel', onPress: () => resolve(false) },
{ text: 'Import', onPress: () => resolve(true) },
],
{ cancelable: false },
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

This code uses the native Alert.alert instead of the project's showAlert utility. For UI consistency and to adhere to the project's established patterns, please use setAlertState(showAlert(...)) as was done in the previous implementation.

const heuristicMatch = shouldUseToolsForMessage(messageText, enabledTools);
const activeTools = (isRemote || heuristicMatch) ? enabledTools : [];
const systemPrompt = (!isRemote && activeTools.length > 0) ? `${basePrompt}${buildToolSystemPromptHint(activeTools)}` : basePrompt;
const activeTools = enabledTools;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The removal of the shouldUseToolsForMessage heuristic means all enabled tools are now passed to the model for every message. This increases prompt size and can lead to hallucinations. If this change is required specifically for Gemma 4, it should be scoped to that model to avoid regressions in efficiency for other models.

Comment on lines +239 to +241
const heartbeat = setInterval(() => {
console.log(`[IMPORT][scan] ⏱ HEARTBEAT — still running at ${elapsed()}, current step: ${heartbeatStep}`);
}, 3000);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The 'heartbeat' interval adds unnecessary noise and overhead in production. It should be removed or guarded by a debug flag.

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