Skip to content

Conversation

@lollipopkit
Copy link
Owner

@lollipopkit lollipopkit commented Aug 11, 2025

Fixes #822

Summary by Sourcery

Improve Linux terminal launching logic by broadening supported terminals and streamlining the shell script, and update the release CI pipeline with updated Flutter version, dependencies, and artifact naming conventions

Bug Fixes:

  • Fix Linux emulator launch script to include xterm and gnome-console in terminal detection and streamline execution logic

Enhancements:

  • Simplify and consolidate shell case statements for launching various terminals
  • Update CI workflow to bump Flutter version to 3.32.8 and adjust Linux dependencies to include mesa-utils and libsecret-1-dev
  • Remove manual AppImage download and renaming steps and standardize artifact naming with .AppImage extension

@sourcery-ai
Copy link

sourcery-ai bot commented Aug 11, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR refactors the Linux terminal launch script to improve auto-detection by expanding the supported terminal list, preferring xterm as a fallback, and consolidating case logic, and also updates the CI release workflow by bumping the Flutter version, adjusting apt dependencies, removing manual AppImage tool download, and standardizing AppImage artifact naming.

Sequence diagram for improved Linux terminal auto-detection and launch

sequenceDiagram
    participant App as Application
    participant Script as launch_terminal.sh
    participant Terminal as Terminal Emulator
    App->>Script: Request to launch terminal
    Script->>Script: Check provided terminal argument
    alt Terminal not provided or is x-terminal-emulator
        Script->>Script: Iterate through preferred terminal list
        Script->>Script: Select first available terminal (incl. xterm fallback)
    end
    Script->>Terminal: Launch terminal with appropriate arguments
    Terminal-->>App: Terminal window opens
Loading

Class diagram for updated terminal launch handling in shell script

classDiagram
    class TerminalLauncher {
        +terminal: String
        +launch(args)
        +autoDetectTerminal()
        +supportedTerminals: [kitty, alacritty, gnome-terminal, gnome-console, konsole, xfce4-terminal, terminator, tilix, wezterm, foot, xterm]
    }
    TerminalLauncher : autoDetectTerminal() selects first available terminal
    TerminalLauncher : launch(args) executes terminal with correct flags
Loading

File-Level Changes

Change Details Files
Refactor terminal auto-detection and launch logic in shell script
  • Expanded priority list to include gnome-console and xterm before fallback
  • Simplified detection loop with inline command-exists check
  • Streamlined case patterns, grouping similar terminals and inlining alacritty version check
lib/view/widget/server_func_btns.dart
Update CI release workflow for dependencies and packaging
  • Bumped Flutter version from 3.32.2 to 3.32.8
  • Added mesa-utils and libsecret-1-dev to apt install list, removed manual AppImage download
  • Standardized AppImage artifact naming to use uppercase .AppImage
.github/workflows/release.yml

Assessment against linked issues

Issue Objective Addressed Explanation
#822 Fix the bug where clicking the 'Terminal' button in the server window on Linux does not open a terminal window.
#822 Ensure that the application can auto-detect and launch a supported terminal emulator on Linux, including fallback options.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @lollipopkit - I've reviewed your changes - here's some feedback:

  • Make sure the invocation flags for the newly added terminals (mate-terminal, qterminal, lxterminal, deepin-terminal) are correct, as some of these may not support the "-e" syntax and could require different options.
  • Consider consolidating the repeated exec logic for terminals with the same flag patterns (e.g. all those using "-e") to simplify and reduce duplication in the case statement.
  • Double-check that the CI pipeline still produces and uploads the correctly named AppImage, since the separate rename step was removed and the extension was changed to ".AppImage".
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Make sure the invocation flags for the newly added terminals (mate-terminal, qterminal, lxterminal, deepin-terminal) are correct, as some of these may not support the "-e" syntax and could require different options.
- Consider consolidating the repeated exec logic for terminals with the same flag patterns (e.g. all those using "-e") to simplify and reduce duplication in the case statement.
- Double-check that the CI pipeline still produces and uploads the correctly named AppImage, since the separate rename step was removed and the extension was changed to ".AppImage".

## Individual Comments

### Comment 1
<location> `lib/view/widget/server_func_btns.dart:342` </location>
<code_context>
         exec "\$TERMINAL" "\$@"
         ;;
-    urxvt|rxvt-unicode)
+    urxvt|rxvt-unicode|xterm|mate-terminal|qterminal|lxterminal|deepin-terminal)
         exec "\$TERMINAL" -e "\$@"
         ;;
</code_context>

<issue_to_address>
Grouping many terminals under the same exec pattern may miss terminal-specific options.

Some terminals in this group may support unique options or behave differently. Please confirm that '-e' is compatible with each, or note any exceptions.
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
    urxvt|rxvt-unicode|xterm|mate-terminal|qterminal|lxterminal|deepin-terminal)
        exec "\$TERMINAL" -e "\$@"
        ;;
=======
    urxvt|rxvt-unicode)
        exec "\$TERMINAL" -e "\$@"
        ;;
    xterm)
        exec "\$TERMINAL" -e "\$@"
        ;;
    mate-terminal)
        # mate-terminal supports -- but not -e for custom commands
        exec "\$TERMINAL" -- "\$@"
        ;;
    qterminal)
        exec "\$TERMINAL" -e "\$@"
        ;;
    lxterminal)
        exec "\$TERMINAL" -e "\$@"
        ;;
    deepin-terminal)
        # deepin-terminal supports -e, but may require quotes around the command
        exec "\$TERMINAL" -e "\$@"
        ;;
>>>>>>> REPLACE

</suggested_fix>

### Comment 2
<location> `.github/workflows/release.yml:61` </location>
<code_context>
           sudo apt update
           # Basic
-          sudo apt install -y clang cmake ninja-build pkg-config libgtk-3-dev libvulkan-dev desktop-file-utils wget
+          sudo apt install -y clang cmake ninja-build pkg-config libgtk-3-dev mesa-utils libvulkan-dev desktop-file-utils wget
           # App Specific
-          sudo apt install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libunwind-dev
</code_context>

<issue_to_address>
Adding mesa-utils may be unnecessary for build environments.

mesa-utils is mainly for runtime diagnostics, not building. If it's not needed for the build, please remove it to streamline dependencies.
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
          sudo apt install -y clang cmake ninja-build pkg-config libgtk-3-dev mesa-utils libvulkan-dev desktop-file-utils wget
=======
          sudo apt install -y clang cmake ninja-build pkg-config libgtk-3-dev libvulkan-dev desktop-file-utils wget
>>>>>>> REPLACE

</suggested_fix>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines 342 to 344
urxvt|rxvt-unicode|xterm|mate-terminal|qterminal|lxterminal|deepin-terminal)
exec "\$TERMINAL" -e "\$@"
;;
Copy link

Choose a reason for hiding this comment

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

suggestion: Grouping many terminals under the same exec pattern may miss terminal-specific options.

Some terminals in this group may support unique options or behave differently. Please confirm that '-e' is compatible with each, or note any exceptions.

Suggested change
urxvt|rxvt-unicode|xterm|mate-terminal|qterminal|lxterminal|deepin-terminal)
exec "\$TERMINAL" -e "\$@"
;;
urxvt|rxvt-unicode)
exec "\$TERMINAL" -e "\$@"
;;
xterm)
exec "\$TERMINAL" -e "\$@"
;;
mate-terminal)
# mate-terminal supports -- but not -e for custom commands
exec "\$TERMINAL" -- "\$@"
;;
qterminal)
exec "\$TERMINAL" -e "\$@"
;;
lxterminal)
exec "\$TERMINAL" -e "\$@"
;;
deepin-terminal)
# deepin-terminal supports -e, but may require quotes around the command
exec "\$TERMINAL" -e "\$@"
;;

@lollipopkit
Copy link
Owner Author

@sourcery-ai review

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @lollipopkit - I've reviewed your changes - here's some feedback:

  • To keep the shell launch script maintainable as you add more terminals, consider extracting the repeated exec patterns into helper functions or a small lookup table instead of large inline case arms.
  • After removing the manual AppImage tool download in your CI, make sure appimagetool is still installed on the runner (for example via apt install appimagetool) so the build step won’t fail.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- To keep the shell launch script maintainable as you add more terminals, consider extracting the repeated `exec` patterns into helper functions or a small lookup table instead of large inline case arms.
- After removing the manual AppImage tool download in your CI, make sure `appimagetool` is still installed on the runner (for example via `apt install appimagetool`) so the build step won’t fail.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@lollipopkit lollipopkit merged commit 8c0e0f8 into main Aug 12, 2025
1 check passed
@lollipopkit lollipopkit deleted the lollipopkit/issue822 branch August 12, 2025 15:55
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.

On Linux, when you click on the "Terminal" button in the server window, the terminal does not open.

2 participants