Skip to content

Integrate IntroScreen and Improve AI Generation Cleanup#7

Open
Godzilla675 wants to merge 25 commits intore-writefrom
integrate-intro-screen-and-improve-cleanup-12681402008920270218
Open

Integrate IntroScreen and Improve AI Generation Cleanup#7
Godzilla675 wants to merge 25 commits intore-writefrom
integrate-intro-screen-and-improve-cleanup-12681402008920270218

Conversation

@Godzilla675
Copy link
Owner

This PR integrates the IntroScreen as a startup splash screen and improves the resource management of the AI engines by ensuring that generation tasks are correctly cancelled when their associated flows are closed.

Key changes:

  1. IntroScreen Integration: The IntroScreen now accepts an onFinished callback which is invoked after its internal progress animation completes. MainActivity was updated to show this screen first and manage the transition to the rest of the application.
  2. State Management: In MainActivity, rememberSaveable is used for the showIntro state to prevent the splash screen from re-triggering on device rotation or other configuration changes.
  3. Engine Reliability: LlmModelWorker now properly calls ggufStopGeneration() and stopDiffusionGeneration() within the awaitClose block of their respective streaming flows. This prevents the underlying engines from continuing to process tokens or image steps after the UI has cancelled the request.

PR created automatically by Jules for task 12681402008920270218 started by @Godzilla675

Copilot AI and others added 25 commits January 17, 2026 12:32
Co-authored-by: Godzilla675 <131464726+Godzilla675@users.noreply.github.com>
…ovements

Co-authored-by: Godzilla675 <131464726+Godzilla675@users.noreply.github.com>
Co-authored-by: Godzilla675 <131464726+Godzilla675@users.noreply.github.com>
Co-authored-by: Godzilla675 <131464726+Godzilla675@users.noreply.github.com>
Co-authored-by: Godzilla675 <131464726+Godzilla675@users.noreply.github.com>
Co-authored-by: Godzilla675 <131464726+Godzilla675@users.noreply.github.com>
Co-authored-by: Godzilla675 <131464726+Godzilla675@users.noreply.github.com>
Co-authored-by: Godzilla675 <131464726+Godzilla675@users.noreply.github.com>
Co-authored-by: Godzilla675 <131464726+Godzilla675@users.noreply.github.com>
…support

Add remote MCP server support with settings UI
Co-authored-by: Godzilla675 <131464726+Godzilla675@users.noreply.github.com>
Enable BuildConfig generation for memory-vault debug build
Co-authored-by: Godzilla675 <131464726+Godzilla675@users.noreply.github.com>
Co-authored-by: Godzilla675 <131464726+Godzilla675@users.noreply.github.com>
[WIP] Check AI models access to MCP servers and fix any issues
Co-authored-by: Godzilla675 <131464726+Godzilla675@users.noreply.github.com>
…ns field

Co-authored-by: Godzilla675 <131464726+Godzilla675@users.noreply.github.com>
- Fix parseResponse() to always try SSE parsing regardless of transport type
- Rename test class from McpServerIntegrationTest to McpServerTest
- Use exact assertions instead of permissive contains() checks
- Add helper function documentation and UUID format validation
- Reduce UUID test iterations from 100 to 10 for efficiency

Co-authored-by: Godzilla675 <131464726+Godzilla675@users.noreply.github.com>
…p-server

Add MCP server integration tests
- Added an onFinished callback to IntroScreen to allow navigation after initialization.
- Integrated IntroScreen as the initial splash screen in MainActivity, using rememberSaveable to maintain state across configuration changes.
- Enhanced LlmModelWorker by adding proper stop generation calls in awaitClose blocks for both text (GGUF) and image (Diffusion) generation flows, ensuring resources are freed when flows are cancelled.

Co-authored-by: Godzilla675 <131464726+Godzilla675@users.noreply.github.com>
@google-labs-jules
Copy link

👋 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.

@gemini-code-assist
Copy link

Summary of Changes

Hello @Godzilla675, 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 introduces a new IntroScreen to serve as a startup splash screen, enhancing the initial user experience by providing a visual introduction. Concurrently, it significantly improves the reliability and resource management of the application's AI generation engines by implementing robust cancellation mechanisms, ensuring that computational tasks are properly terminated when no longer needed.

Highlights

  • IntroScreen Integration: The IntroScreen now accepts an onFinished callback, which is invoked upon completion of its animation. MainActivity has been updated to display this IntroScreen as a splash screen during startup, managing the transition to the main application content once the intro animation finishes.
  • State Management for IntroScreen: In MainActivity, the showIntro state, which controls the visibility of the IntroScreen, is now managed using rememberSaveable. This ensures that the splash screen does not reappear unexpectedly on configuration changes, such as device rotation, providing a smoother user experience.
  • Improved AI Engine Resource Management: The LlmModelWorker has been enhanced to ensure proper resource cleanup for AI generation tasks. Specifically, ggufStopGeneration() and stopDiffusionGeneration() are now explicitly called within the awaitClose blocks of their respective streaming flows. This guarantees that underlying AI engines cease processing tokens or image steps when their associated UI requests are cancelled, preventing orphaned processes and improving system stability.
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

@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 successfully integrates an intro screen and improves resource management for AI generation tasks. The use of rememberSaveable for the intro screen state is appropriate for handling configuration changes. The updates to LlmModelWorker to cancel generation tasks when flows are closed are a significant improvement for resource efficiency. I've identified a potential medium-severity issue in MainActivity.kt where the new navigation logic could lead to UI flicker due to a race condition with state loading. My review includes a specific comment on how to resolve this by handling the loading state more explicitly.

Comment on lines +94 to 114
if (showIntro) {
IntroScreen(onFinished = { showIntro = false })
} else {
val chatViewModel: ChatViewModel = hiltViewModel()
val llmModelViewModel: LLMModelViewModel = hiltViewModel()

AppNavigation(
chatViewModel = chatViewModel,
llmModelViewModel = llmModelViewModel
)
if (!hasAcceptedTerms) {
TermsAndConditionsScreen(
onAccept = {
scope.launch {
termsDataStore.acceptTerms()
}
}
)
} else {
val chatViewModel: ChatViewModel = hiltViewModel()
val llmModelViewModel: LLMModelViewModel = hiltViewModel()

AppNavigation(
chatViewModel = chatViewModel,
llmModelViewModel = llmModelViewModel
)
}
}

Choose a reason for hiding this comment

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

medium

This new navigation logic can cause a UI flicker due to a race condition with loading the hasAcceptedTerms state. On line 80, hasAcceptedTerms is initialized to true. If the DataStore is slow to emit the actual value (e.g., false), the app may briefly show AppNavigation after the intro screen before jumping to TermsAndConditionsScreen once the state updates.

To prevent this, you should handle the loading state explicitly. A robust approach is:

  1. Initialize hasAcceptedTerms to null on line 80: collectAsState(initial = null).
  2. Use a when statement here to handle the null (loading), false (not accepted), and true (accepted) states. This will prevent the flicker and provide a smoother user experience.

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.

2 participants