Skip to content

Conversation

@bajrangCoder
Copy link
Member

Closes: #1806

But only for terminal accessible folder like terminal home dir and public folder

@github-actions github-actions bot added enhancement New feature or request translations Anything related to Translations Whether a Issue or PR labels Jan 11, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @bajrangCoder, 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 feature that allows users to directly open a folder in the integrated terminal via the context menu. This functionality is intelligently restricted to only those folders that are recognized as terminal-accessible, enhancing workflow efficiency for users working within designated terminal environments.

Highlights

  • New Feature: Open in Terminal: Introduced a new 'Open in Terminal' option to the folder context menu, allowing users to quickly open a selected folder in the integrated terminal.
  • Restricted Access: The 'Open in Terminal' option is only available for folders that are identified as 'terminal accessible', such as the terminal's home directory and public folder, as specified in the PR description.
  • Terminal Path Utilities: Added new utility functions (getTerminalPaths, isTerminalAccessiblePath, convertToProotPath) to manage and validate terminal-related file paths, ensuring correct integration and security.
  • Localization Support: Added localization strings for the new 'Open in Terminal' feature across multiple language files to support international users.
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.

gemini-code-assist[bot]

This comment was marked as resolved.

@greptile-apps
Copy link

greptile-apps bot commented Jan 11, 2026

Greptile Overview

Greptile Summary

This PR adds an "Open in Terminal" context menu option for terminal-accessible folders in the file explorer. The feature allows users to right-click on folders within Alpine root or public directories and open a terminal session that automatically navigates to that folder.

Implementation Overview:

  • Added isTerminalAccessiblePath() to detect if a folder is within terminal-accessible locations (Alpine root /data/user/0/{package}/files/alpine or public folder /data/user/0/{package}/files/public)
  • Added convertToProotPath() to convert Android filesystem paths to proot environment paths (e.g., /data/user/0/com.foxdebug.acode/files/public/foo/public/foo)
  • The context menu shows "Open in Terminal" option only for accessible folders
  • When selected, creates a new terminal tab via TerminalManager.createTerminal() and sends a cd command
  • Includes a polling mechanism to wait for WebSocket connection before writing the command
  • Added translation string "open in terminal" to all 31 language files

Architecture Integration:
The feature integrates cleanly with the existing terminal infrastructure. It uses TerminalManager.createTerminal() which handles terminal session creation, WebSocket connection setup, and tab management. The path conversion logic correctly maps between Android's filesystem structure and the proot environment used by the terminal.

Issues Identified:

  1. Critical - Infinite Loop Risk: The waitForConnection() polling function has no timeout mechanism. If the WebSocket connection fails to establish (e.g., terminal service down, network issues), the polling loop will run indefinitely, potentially causing memory leaks and hanging the application.

  2. Internationalization Incomplete: All 30 non-English language files contain the untranslated English string "Open in Terminal" instead of proper translations. This impacts the user experience for international users.

  3. Error Handling Generic: When terminal creation fails, users see only "Error" toast message without context about what went wrong, making troubleshooting difficult.

  4. Path Conversion Edge Case: The convertToProotPath() function falls back to returning the raw path for unrecognized formats without validation or warning, which could cause issues if unexpected URL formats are encountered.

Positive Aspects:

  • The race condition between terminal creation and command writing was addressed with the polling mechanism
  • Path detection logic properly handles both file:// URLs and SAF content:// URIs
  • JSON.stringify is correctly used to escape the path for shell safety
  • Feature is appropriately restricted to terminal-accessible directories only
  • Code follows existing patterns in the codebase

Confidence Score: 3/5

  • This PR has a useful feature but contains a critical infinite loop bug that must be fixed before merging.
  • Score of 3 reflects one critical issue (infinite loop potential in waitForConnection) that could cause application hangs, plus several style/quality issues (missing translations, generic error handling). The core functionality is sound and the race condition has been addressed, but the timeout issue is a blocking concern that needs resolution before production deployment.
  • src/lib/openFolder.js requires immediate attention - the waitForConnection polling loop needs timeout protection to prevent infinite loops if terminal connection fails.

Important Files Changed

File Analysis

Filename Score Overview
src/lib/openFolder.js 3/5 Added "Open in Terminal" feature with path detection and conversion logic. Contains an infinite loop risk in waitForConnection polling and insufficient error handling.
src/lang/en-us.json 5/5 Added English translation string for "open in terminal" feature.
src/lang/ar-ye.json 2/5 Added untranslated English string instead of Arabic translation for "open in terminal".
src/lang/zh-cn.json 2/5 Added untranslated English string instead of Chinese translation for "open in terminal".
src/lang/fr-fr.json 2/5 Added untranslated English string instead of French translation for "open in terminal".

Sequence Diagram

sequenceDiagram
    participant User
    participant ContextMenu as Context Menu
    participant openFolder as openFolder.js
    participant TerminalMgr as TerminalManager
    participant Terminal as TerminalComponent
    participant WebSocket as WS Connection
    
    User->>ContextMenu: Right-click on folder
    ContextMenu->>openFolder: handleContextmenu(type, url, name)
    openFolder->>openFolder: isTerminalAccessiblePath(url)
    
    alt Path is terminal accessible
        openFolder->>ContextMenu: Add "Open in Terminal" option
        ContextMenu-->>User: Show menu with option
        User->>ContextMenu: Select "Open in Terminal"
        ContextMenu->>openFolder: execOperation("open-in-terminal")
        openFolder->>openFolder: convertToProotPath(url)
        openFolder->>TerminalMgr: createTerminal({name, render: true})
        
        TerminalMgr->>Terminal: new TerminalComponent()
        Terminal->>Terminal: init() and mount()
        Terminal->>WebSocket: connectToSession()
        WebSocket-->>Terminal: onopen event
        Terminal->>Terminal: isConnected = true
        Terminal-->>TerminalMgr: return terminal instance
        TerminalMgr-->>openFolder: return terminal
        
        openFolder->>openFolder: waitForConnection() polling
        loop Poll every 50ms
            openFolder->>Terminal: Check isConnected
            alt isConnected is true
                Terminal-->>openFolder: resolve()
            else Not connected yet
                openFolder->>openFolder: setTimeout(check, 50)
            end
        end
        
        openFolder->>Terminal: write(`cd ${prootPath}\n`)
        openFolder->>openFolder: Sidebar.hide()
        openFolder-->>User: Terminal opens with cd command
        
    else Path not accessible
        openFolder->>ContextMenu: Don't add option
        ContextMenu-->>User: Show menu without terminal option
    end
Loading

Copy link

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

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@bajrangCoder
Copy link
Member Author

@greptileai

if (isAcodeTerminalPublicSafUri(url)) return true;
const { alpineRoot, publicDir } = getTerminalPaths();
const cleanUrl = url.replace(/^file:\/\//, "");
if (cleanUrl.startsWith(alpineRoot) || cleanUrl.startsWith(publicDir)) {
Copy link
Member

Choose a reason for hiding this comment

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

You could just check if a file starts with file:// and if it’s readable, but this works too.

Copy link

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

4 files reviewed, 4 comments

Edit Code Review Agent Settings | Greptile

@bajrangCoder bajrangCoder merged commit 16a5e63 into Acode-Foundation:main Jan 11, 2026
6 checks passed
@bajrangCoder bajrangCoder deleted the feature/open-folder-in-terminal branch January 11, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request translations Anything related to Translations Whether a Issue or PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add open Folder in Terminal option

3 participants