Skip to content

add add app to top of list user pref.#696

Merged
tavdog merged 6 commits intomainfrom
feature/user_pref_add_apps_to_top
Jan 23, 2026
Merged

add add app to top of list user pref.#696
tavdog merged 6 commits intomainfrom
feature/user_pref_add_apps_to_top

Conversation

@tavdog
Copy link
Member

@tavdog tavdog commented Jan 21, 2026

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @tavdog, 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 user preference that allows individuals to customize the default placement of newly added applications within their device's app list. This enhancement provides users with greater control over their app organization, enabling them to choose whether new apps appear at the top or bottom of their list. The change includes updates to the user data model, backend API for preference management, and the front-end user interface for configuration.

Highlights

  • New User Preference: Introduced a new user preference, AddAppsToTop, allowing users to control where newly added applications appear in their list.
  • User Interface for Preference: Added a checkbox to the user's profile edit page (web/templates/auth/edit.html) for enabling or disabling the AddAppsToTop preference, complete with descriptive text.
  • Backend Logic for Preference: Implemented backend logic in internal/server/auth.go to handle the saving and updating of the AddAppsToTop preference when a user's profile is edited.
  • Application Placement Logic: Modified the application addition logic in internal/server/handlers_app.go to respect the AddAppsToTop preference. If enabled, new apps are inserted at position Prettify app image just like Tidbyt's Apps page #1, shifting existing apps down; otherwise, they are appended to the end of the list.
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
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 a user preference to add new apps to the top of the list instead of the bottom. The changes are well-implemented across the data model, UI template, and server-side handlers. However, I've identified a critical issue in internal/server/handlers_app.go where the database operations for reordering and adding an app are not atomic, which could lead to data inconsistency. I've provided a detailed comment with a code suggestion to resolve this.

@tavdog tavdog requested a review from IngmarStein January 21, 2026 20:51
newApp.Order = 1
} else {
var maxOrder int64
if err := tx.Model(&data.App{}).Where("device_id = ?", device.ID).Select("COALESCE(MAX(`order`), -1)").Scan(&maxOrder).Error; err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

This should use getMaxAppOrder().
This query does not work across database dialects because order is a SQL keyword which must be escaped specially.
Same for the code above.

@tavdog
Copy link
Member Author

tavdog commented Jan 22, 2026

/gemini codereview

@gemini-code-assist
Copy link
Contributor

It looks like you tried to invoke the codereview command. The correct command to perform a code review is /gemini review. Please use that command if you'd like me to perform a code review.

@tavdog
Copy link
Member Author

tavdog commented Jan 22, 2026

/gemini review

Copy link
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 a user preference to add new applications to the top of the list. The implementation involves changes to the data model, the user settings page, and the application creation logic. My review found a high-severity issue in the app ordering logic that could lead to data inconsistency, and a medium-severity issue regarding the use of inline styles in the HTML template which affects maintainability. These comments align with the provided rules or are not covered by them, and no modifications or drops were necessary.

Comment on lines +273 to +292
<div style="margin-bottom: 15px;">
<div style="display: flex; align-items: center; gap: 10px;">
<input type="checkbox"
name="add_apps_to_top"
id="add_apps_to_top"
value="1"
{{ if .User.AddAppsToTop }}
checked
{{ end }}
style="width: 18px;
height: 18px">
<label for="add_apps_to_top" style="margin: 0;">{{ t .Localizer "Add new apps to top of list" }}</label>
</div>
<p style="color: #888;
font-size: 0.8em;
margin-top: 5px;
margin-bottom: 0">
{{ t .Localizer "When enabled, newly added apps will appear at position #1 instead of at the end." }}
</p>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This new section adds a number of inline styles. While this works, it's generally better for maintainability to use CSS classes and define the styles in a separate stylesheet. This keeps the HTML cleaner and makes it easier to apply consistent styling across the application. Consider creating a few utility classes for this component and adding them to your site's stylesheet.

if user.AddAppsToTop {
if _, err := gorm.G[data.App](tx).
Where("device_id = ?", device.ID).
Update(r.Context(), "order", gorm.Expr("`order` + 1")); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

`order` + 1 has the same escaping issue. GORM can only correctly escape it (SQL dialect dependent) if it's specified as a column name alone, like in clause.Column{Name: "order"}

tavdog and others added 3 commits January 21, 2026 23:04
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@tavdog
Copy link
Member Author

tavdog commented Jan 22, 2026

/gemini review

@tavdog tavdog merged commit b802bd5 into main Jan 23, 2026
11 checks passed
@tavdog tavdog deleted the feature/user_pref_add_apps_to_top branch February 24, 2026 03:34
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