Implement Executable File Detection & Terminal Integration + i18n Improvements #252

Merged
ZacharyZcR merged 63 commits from main into main 2025-09-18 02:58:14 +00:00
ZacharyZcR commented 2025-09-16 17:35:02 +00:00 (Migrated from github.com)

Summary

This PR implements comprehensive executable file detection, terminal integration features, and optimizes internationalization support for core UI components.

🚀 New Features

1. Executable File Detection System

  • Smart Detection: Automatically identifies ELF binaries, script files (.sh, .py, .pl, etc.), and files with execute permissions
  • Backend API: Added /ssh/file_manager/ssh/executeFile execution endpoint
  • Frontend Integration: File list API returns executable field for visual indication

2. Enhanced Context Menu

  • Open Terminal: Support opening terminal at file/folder location or current directory
    • Files: Open terminal in file's parent directory
    • Folders: Open terminal inside the folder
    • Empty area: Open terminal in current directory
  • Run Function: Right-click executable files shows "Run" option, automatically executes in terminal

3. Terminal Integration Improvements

  • Initial Path Support: Terminal component supports initialPath parameter, auto-navigates after connection
  • Command Execution: Supports executeCommand parameter for automatic command execution
  • Window Management: Created TerminalWindow component with full draggable window experience

4. Internationalization Enhancements

  • Core UI Translation: Fixed hardcoded Chinese text in drag hints, context menus, error messages
  • Multi-language Support: Added complete Chinese and English translation entries
  • Consistency: Unified usage of t() function for text rendering

🔧 Technical Implementation

Backend Improvements

  • file-manager.ts: Added isExecutableFile() detection function and execution API
  • terminal.ts: Support for initial path and automatic command execution
  • Permission parsing: Unix permission bits and file extension analysis

Frontend Architecture

  • TerminalWindow.tsx: New terminal window component
  • FileManagerContextMenu.tsx: Extended context menu functionality
  • FileManagerModern.tsx: Integrated terminal and execution features
  • Type definitions: Extended FileItem interface with executable field

User Experience

  • Unified Interaction: Run functionality through terminal enables real-time output and interaction
  • Smart Hints: Context menu dynamically shows relevant options based on file type
  • Multi-language: Interface text supports Chinese/English switching

📋 Test Checklist

  • Executable files correctly detected (binaries, scripts, permissions)
  • Context menu shows "Open Terminal" and "Run" options appropriately
  • Terminal windows open correctly and navigate to specified directories
  • Executable files run properly in terminal
  • Multi-language switching works correctly
  • Drag hints use translation functions

🎯 Impact

  • Non-breaking: All new features are backward-compatible enhancements
  • Performance-friendly: Executable detection only occurs during file listing
  • Type-safe: Complete TypeScript type definitions

🤖 Generated with Claude Code

## Summary This PR implements comprehensive executable file detection, terminal integration features, and optimizes internationalization support for core UI components. ### 🚀 New Features #### 1. Executable File Detection System - **Smart Detection**: Automatically identifies ELF binaries, script files (.sh, .py, .pl, etc.), and files with execute permissions - **Backend API**: Added `/ssh/file_manager/ssh/executeFile` execution endpoint - **Frontend Integration**: File list API returns `executable` field for visual indication #### 2. Enhanced Context Menu - **Open Terminal**: Support opening terminal at file/folder location or current directory - Files: Open terminal in file's parent directory - Folders: Open terminal inside the folder - Empty area: Open terminal in current directory - **Run Function**: Right-click executable files shows "Run" option, automatically executes in terminal #### 3. Terminal Integration Improvements - **Initial Path Support**: Terminal component supports `initialPath` parameter, auto-navigates after connection - **Command Execution**: Supports `executeCommand` parameter for automatic command execution - **Window Management**: Created TerminalWindow component with full draggable window experience #### 4. Internationalization Enhancements - **Core UI Translation**: Fixed hardcoded Chinese text in drag hints, context menus, error messages - **Multi-language Support**: Added complete Chinese and English translation entries - **Consistency**: Unified usage of `t()` function for text rendering ### 🔧 Technical Implementation #### Backend Improvements - `file-manager.ts`: Added `isExecutableFile()` detection function and execution API - `terminal.ts`: Support for initial path and automatic command execution - Permission parsing: Unix permission bits and file extension analysis #### Frontend Architecture - `TerminalWindow.tsx`: New terminal window component - `FileManagerContextMenu.tsx`: Extended context menu functionality - `FileManagerModern.tsx`: Integrated terminal and execution features - Type definitions: Extended `FileItem` interface with `executable` field #### User Experience - **Unified Interaction**: Run functionality through terminal enables real-time output and interaction - **Smart Hints**: Context menu dynamically shows relevant options based on file type - **Multi-language**: Interface text supports Chinese/English switching ### 📋 Test Checklist - [x] Executable files correctly detected (binaries, scripts, permissions) - [x] Context menu shows "Open Terminal" and "Run" options appropriately - [x] Terminal windows open correctly and navigate to specified directories - [x] Executable files run properly in terminal - [x] Multi-language switching works correctly - [x] Drag hints use translation functions ### 🎯 Impact - **Non-breaking**: All new features are backward-compatible enhancements - **Performance-friendly**: Executable detection only occurs during file listing - **Type-safe**: Complete TypeScript type definitions 🤖 Generated with [Claude Code](https://claude.ai/code)
LukeGus (Migrated from github.com) reviewed 2025-09-16 17:35:02 +00:00
gemini-code-assist[bot] (Migrated from github.com) reviewed 2025-09-16 17:36:04 +00:00
gemini-code-assist[bot] (Migrated from github.com) left a comment

Summary of Changes

Hello @ZacharyZcR, 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 delivers a substantial upgrade to the application's core functionalities, focusing on secure and efficient file management. It introduces advanced executable handling and deep terminal integration, while simultaneously bolstering data security with enterprise-grade database encryption. The user experience is also significantly enhanced through a modernized file manager and improved internationalization.

Highlights

  • Executable File Detection & Terminal Integration: Implemented smart detection for executable files (ELF binaries, scripts, execute permissions) and integrated features to open terminals at specific file/folder locations, as well as directly run executables within a terminal window. The terminal component now supports initial paths and command execution.
  • Comprehensive Database Encryption: Introduced AES-256-GCM encryption for sensitive data stored in the database, including SSH credentials, passwords, and authentication tokens. This includes robust key management, migration tools for existing data, and device-bound master key protection (KEK).
  • Enhanced SSH Key Management: Added new API endpoints and UI features for detecting SSH key types (private and public), generating new SSH key pairs (RSA, Ed25519, ECDSA), generating public keys from private keys, and deploying public keys to remote hosts.
  • Modernized File Manager Experience: The file manager has been significantly upgraded with a new grid view, drag-and-drop functionality (for uploads, downloads, and internal moves), copy/cut/paste operations, symlink resolution, and an advanced file viewer/editor with syntax highlighting, search, and replace capabilities.
  • Internationalization Improvements: Fixed hardcoded Chinese text in core UI components and expanded multi-language support with complete Chinese and English translation entries, unifying the usage of the translation function.
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.


  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. ↩︎

## Summary of Changes Hello @ZacharyZcR, I'm Gemini Code Assist[^1]! 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 delivers a substantial upgrade to the application's core functionalities, focusing on secure and efficient file management. It introduces advanced executable handling and deep terminal integration, while simultaneously bolstering data security with enterprise-grade database encryption. The user experience is also significantly enhanced through a modernized file manager and improved internationalization. ### Highlights * **Executable File Detection & Terminal Integration**: Implemented smart detection for executable files (ELF binaries, scripts, execute permissions) and integrated features to open terminals at specific file/folder locations, as well as directly run executables within a terminal window. The terminal component now supports initial paths and command execution. * **Comprehensive Database Encryption**: Introduced AES-256-GCM encryption for sensitive data stored in the database, including SSH credentials, passwords, and authentication tokens. This includes robust key management, migration tools for existing data, and device-bound master key protection (KEK). * **Enhanced SSH Key Management**: Added new API endpoints and UI features for detecting SSH key types (private and public), generating new SSH key pairs (RSA, Ed25519, ECDSA), generating public keys from private keys, and deploying public keys to remote hosts. * **Modernized File Manager Experience**: The file manager has been significantly upgraded with a new grid view, drag-and-drop functionality (for uploads, downloads, and internal moves), copy/cut/paste operations, symlink resolution, and an advanced file viewer/editor with syntax highlighting, search, and replace capabilities. * **Internationalization Improvements**: Fixed hardcoded Chinese text in core UI components and expanded multi-language support with complete Chinese and English translation entries, unifying the usage of the translation function. <details> <summary><b>Using Gemini Code Assist</b></summary> <br> The full guide for Gemini Code Assist can be found on our [documentation page](https://developers.google.com/gemini-code-assist/docs/review-github-code), here are some quick tips. <b>Invoking Gemini</b> 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. <b>Customization</b> 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](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github). <b>Limitations & Feedback</b> Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with :thumbsup: and :thumbsdown: 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](https://google.qualtrics.com/jfe/form/SV_2cyuGuTWsEw84yG). <b>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](https://cloud.google.com/products/gemini/code-assist).</b> </details> [^1]: Review the [Privacy Notices](https://policies.google.com/privacy), [Generative AI Prohibited Use Policy](https://policies.google.com/terms/generative-ai/use-policy), [Terms of Service](https://policies.google.com/terms), and learn how to configure Gemini Code Assist in GitHub [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github). Gemini can make mistakes, so double check it and [use code with caution](https://support.google.com/legal/answer/13505487).
gemini-code-assist[bot] (Migrated from github.com) reviewed 2025-09-16 17:38:02 +00:00
gemini-code-assist[bot] (Migrated from github.com) left a comment

Code Review

This pull request introduces a significant set of new features, including a comprehensive database encryption system, executable file detection, and enhanced terminal integration. The implementation of database encryption using a KEK pattern and per-field keys is robust from a cryptographic standpoint. The file manager has been completely refactored to use a modern, windowed interface, which is a major UX improvement. My review has identified one critical security vulnerability related to unauthenticated API endpoints for encryption management that must be addressed. I've also pointed out a high-severity issue with the device fingerprinting logic that could lead to data inaccessibility, along with several medium-severity suggestions to improve robustness and code quality.

## Code Review This pull request introduces a significant set of new features, including a comprehensive database encryption system, executable file detection, and enhanced terminal integration. The implementation of database encryption using a KEK pattern and per-field keys is robust from a cryptographic standpoint. The file manager has been completely refactored to use a modern, windowed interface, which is a major UX improvement. My review has identified one critical security vulnerability related to unauthenticated API endpoints for encryption management that must be addressed. I've also pointed out a high-severity issue with the device fingerprinting logic that could lead to data inaccessibility, along with several medium-severity suggestions to improve robustness and code quality.
@@ -0,0 +34,4 @@
```
**⚠️ CRITICAL:** The encryption key must be:
- At least 16 characters long (32+ recommended)
gemini-code-assist[bot] (Migrated from github.com) commented 2025-09-16 17:38:01 +00:00

medium

The recommendation for the encryption key length could be clearer. For AES-256, a 32-byte (256-bit) key is required. Your example openssl rand -hex 32 correctly generates this (a 64-character hex string). However, the text "At least 16 characters long" is misleading as it suggests a 128-bit key would suffice, which is weaker than the AES-256 you've implemented. It would be better to consistently recommend a 32-byte key, for example, by specifying a 64-character hex string.

- 32 bytes (e.g., a 64-character hexadecimal string) is required for AES-256.
![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg) The recommendation for the encryption key length could be clearer. For AES-256, a 32-byte (256-bit) key is required. Your example `openssl rand -hex 32` correctly generates this (a 64-character hex string). However, the text "At least 16 characters long" is misleading as it suggests a 128-bit key would suffice, which is weaker than the AES-256 you've implemented. It would be better to consistently recommend a 32-byte key, for example, by specifying a 64-character hex string. ```suggestion - 32 bytes (e.g., a 64-character hexadecimal string) is required for AES-256. ```
gemini-code-assist[bot] (Migrated from github.com) commented 2025-09-16 17:38:01 +00:00

critical

These encryption management endpoints (/initialize, /migrate, /regenerate) are exposed without any authentication. This is a critical security vulnerability, as any unauthenticated user could potentially call these APIs to re-initialize encryption keys or trigger migrations, which could lead to data corruption or loss. These endpoints must be protected by an authentication middleware and restricted to administrative users.

![critical](https://www.gstatic.com/codereviewagent/critical.svg) These encryption management endpoints (`/initialize`, `/migrate`, `/regenerate`) are exposed without any authentication. This is a critical security vulnerability, as any unauthenticated user could potentially call these APIs to re-initialize encryption keys or trigger migrations, which could lead to data corruption or loss. These endpoints must be protected by an authentication middleware and restricted to administrative users.
@@ -664,0 +1010,4 @@
// Final attempt: Try using ssh2 as fallback
if (!privateKeyObj) {
console.log("Attempting fallback to parseSSHKey function...");
gemini-code-assist[bot] (Migrated from github.com) commented 2025-09-16 17:38:01 +00:00

medium

This file contains numerous console.log statements used for debugging. While useful during development, they should be removed or replaced with a proper logging utility (like the authLogger used elsewhere in this file) before merging to avoid leaking sensitive information and cluttering production logs.

![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg) This file contains numerous `console.log` statements used for debugging. While useful during development, they should be removed or replaced with a proper logging utility (like the `authLogger` used elsewhere in this file) before merging to avoid leaking sensitive information and cluttering production logs.
gemini-code-assist[bot] (Migrated from github.com) commented 2025-09-16 17:38:02 +00:00

medium

This comment contains a typo ( should likely be ). More importantly, the logic for parsing the date from ls -l output is fragile, as the date format can vary based on system locale and the age of the file (e.g., showing a year instead of a time). This could lead to incorrect date parsing.

          // 日期可能占3个部分(月 日 时间)或者是(月 日 年)
![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg) This comment contains a typo (`夨` should likely be `个`). More importantly, the logic for parsing the date from `ls -l` output is fragile, as the date format can vary based on system locale and the age of the file (e.g., showing a year instead of a time). This could lead to incorrect date parsing. ```suggestion // 日期可能占3个部分(月 日 时间)或者是(月 日 年) ```
gemini-code-assist[bot] (Migrated from github.com) commented 2025-09-16 17:38:02 +00:00

medium

Parsing the exit code from stdout using a simple string like "EXIT_CODE:" can be unreliable. If the executed program's output happens to contain this exact string, it will be incorrectly parsed. A more robust approach would be to use the code argument from the stream.on("close", (code) => { ... }) event, which directly provides the process's exit code. The current implementation of chaining commands with ; means the code will be from the last command (echo), so to get the exit code of the executed script, you should check $? immediately after it runs. To make this reliable, consider using a more unique separator.

![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg) Parsing the exit code from stdout using a simple string like `"EXIT_CODE:"` can be unreliable. If the executed program's output happens to contain this exact string, it will be incorrectly parsed. A more robust approach would be to use the `code` argument from the `stream.on("close", (code) => { ... })` event, which directly provides the process's exit code. The current implementation of chaining commands with `;` means the `code` will be from the last command (`echo`), so to get the exit code of the executed script, you should check `$?` immediately after it runs. To make this reliable, consider using a more unique separator.
Sign in to join this conversation.