Skip to content

refactor(instance-settings): streamline modal state and save flow#4

Merged
theguy000 merged 3 commits intomasterfrom
refactor/instance-settings-flow
Mar 18, 2026
Merged

refactor(instance-settings): streamline modal state and save flow#4
theguy000 merged 3 commits intomasterfrom
refactor/instance-settings-flow

Conversation

@theguy000
Copy link
Copy Markdown
Owner

Streamlined instance settings and fingerprint update flow to reduce state mismatch between UI and backend.

Streamlined instance settings and fingerprint update flow to reduce state mismatch between UI and backend.
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, 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 refactors the instance settings and fingerprint update flow to enhance user control over window geometry when auto-fingerprinting is active. The changes aim to reduce state mismatch between the UI and backend by providing explicit options for managing window size and position, thereby improving the overall consistency and user experience of instance configuration.

Highlights

  • Enhanced Auto-Fingerprinting Control: Introduced new settings to control how window size and position are handled when auto-fingerprinting is enabled, allowing users to choose between randomized or deterministic window geometry.
  • Streamlined UI for Instance Settings: Added new user interface elements within the instance settings modal to manage the automatic window size change behavior and select default window size presets, improving the clarity and control for users.
  • Backend Integration for Window Geometry: Updated the backend logic in Rust to accept and process the new window size and position parameters, ensuring that the auto-fingerprinting generation correctly applies the user's preferences.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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.

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 effectively streamlines the instance settings, particularly for handling window size in the automatic fingerprint generation mode. The changes introduce a new option to either randomize the window size on each launch or use a deterministic size, with corresponding updates to the Rust backend and Svelte frontend. The implementation is largely solid, but I've identified a few opportunities to enhance code clarity and maintainability. My review includes suggestions for using named constants instead of magic numbers in the Rust code, refactoring a logic block in the Svelte component to be more concise, and moving inline styles to a dedicated CSS file to improve separation of concerns.

Comment on lines +323 to +337
let (outer_w, outer_h) = if change_window_size {
let pct_w = rng.gen_range(75..=100) as f64 / 100.0;
let pct_h = rng.gen_range(75..=100) as f64 / 100.0;
(
((avail_w as f64 * pct_w) as u32).max(800),
((avail_h as f64 * pct_h) as u32).max(600),
)
} else if let (Some(w), Some(h)) = (default_outer_width, default_outer_height) {
(w.min(avail_w), h.min(avail_h))
} else {
(
((avail_w as f64 * 0.9) as u32).max(800),
((avail_h as f64 * 0.9) as u32).max(600),
)
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This block uses several magic numbers (75..=100, 800, 600, 0.9). To improve readability and maintainability, consider defining them as named constants at the top of the module. This makes the code self-documenting and easier to modify in the future.

For example:

const MIN_WINDOW_DIM_PCT: u8 = 75;
const MAX_WINDOW_DIM_PCT: u8 = 100;
const MIN_OUTER_WIDTH: u32 = 800;
const MIN_OUTER_HEIGHT: u32 = 600;
const DEFAULT_WINDOW_SCALE: f64 = 0.9;

Comment on lines +130 to +142
fp.auto_change_window_size = autoMode ? autoChangeWindowSize : null;
if (autoMode && !autoChangeWindowSize && autoWindowPresetIndex >= 0 && WINDOW_PRESETS[autoWindowPresetIndex]) {
const preset = WINDOW_PRESETS[autoWindowPresetIndex];
fp.outer_width = preset.w;
fp.outer_height = preset.h;
fp.inner_width = null;
fp.inner_height = null;
} else if (autoMode) {
fp.outer_width = null;
fp.outer_height = null;
fp.inner_width = null;
fp.inner_height = null;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This logic for setting window dimensions in AUTO mode can be refactored to be more concise and avoid repetition. The fp.inner_width = null and fp.inner_height = null assignments are made in both branches of the conditional. You can simplify this by checking for autoMode once and then handling the conditional logic for outer_width and outer_height inside that block, setting the inner dimensions just once at the end.

      fp.auto_change_window_size = autoMode ? autoChangeWindowSize : null;
      if (autoMode) {
        const preset = !autoChangeWindowSize && autoWindowPresetIndex >= 0 ? WINDOW_PRESETS[autoWindowPresetIndex] : null;
        if (preset) {
          fp.outer_width = preset.w;
          fp.outer_height = preset.h;
        } else {
          fp.outer_width = null;
          fp.outer_height = null;
        }
        fp.inner_width = null;
        fp.inner_height = null;
      }

Comment on lines +217 to +251
<div style="margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(16, 185, 129, 0.2); display: flex; align-items: center; justify-content: space-between; gap: 12px;">
<div style="display: flex; flex-direction: column; gap: 4px;">
<span style="font-size: 0.58rem; letter-spacing: 0.08em; color: var(--text-primary);">CHANGE WINDOW SIZE EACH LAUNCH</span>
<span style="font-size: 0.55rem; letter-spacing: 0.03em; color: var(--text-secondary);">
{autoChangeWindowSize
? 'Randomizes window size and position every launch.'
: 'Keeps window size and position deterministic for the selected profile.'}
</span>
</div>
<button
class="btn {autoChangeWindowSize ? 'btn-active' : ''}"
style="font-size: 0.58rem; padding: 4px 10px; min-width: 50px; letter-spacing: 0.05em; {autoChangeWindowSize ? `background: ${accentGreen}; color: #000; border-color: ${accentGreen};` : ''}"
on:click={() => { autoChangeWindowSize = !autoChangeWindowSize; }}
>
{autoChangeWindowSize ? 'ON' : 'OFF'}
</button>
</div>
<div style="margin-top: 10px; display: flex; flex-direction: column; gap: 6px; opacity: {autoChangeWindowSize ? 0.6 : 1};">
<label for="auto-window-size-preset" style="font-size: 0.58rem; letter-spacing: 0.08em; color: var(--text-primary);">DEFAULT WINDOW SIZE PRESET</label>
<select
id="auto-window-size-preset"
class="input-field"
style="font-size: 0.65rem;"
bind:value={autoWindowPresetIndex}
disabled={autoChangeWindowSize}
>
<option value={-1}>AUTO DEFAULT</option>
{#each WINDOW_PRESETS as p, i}
<option value={i}>{p.label}</option>
{/each}
</select>
<span style="font-size: 0.54rem; letter-spacing: 0.03em; color: var(--text-secondary);">
Applies when window-size changing is OFF.
</span>
</div>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This section contains a lot of inline styles. For better maintainability, readability, and separation of concerns, it's recommended to move these styles into the InstanceSettingsModal.css file and use CSS classes instead. This also allows for easier reuse of styles and keeps the HTML markup cleaner. For example, you could create classes like .auto-mode-option and .auto-mode-description for the styled elements.

@theguy000 theguy000 merged commit 42c75a4 into master Mar 18, 2026
2 checks passed
@theguy000 theguy000 deleted the refactor/instance-settings-flow branch March 18, 2026 02:03
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