Skip to content

fix(terminal): normalize acode open paths so folder name isn’t "."#1864

Merged
bajrangCoder merged 1 commit intoAcode-Foundation:mainfrom
bajrangCoder:fix/acode-cli
Feb 9, 2026
Merged

fix(terminal): normalize acode open paths so folder name isn’t "."#1864
bajrangCoder merged 1 commit intoAcode-Foundation:mainfrom
bajrangCoder:fix/acode-cli

Conversation

@bajrangCoder
Copy link
Member

No description provided.

@bajrangCoder bajrangCoder merged commit 055c51a into Acode-Foundation:main Feb 9, 2026
5 checks passed
@bajrangCoder bajrangCoder deleted the fix/acode-cli branch February 9, 2026 07:04
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 9, 2026

Greptile Overview

Greptile Summary

Fixed folder name display when using acode . command by implementing path normalization that properly handles trailing . and .. segments.

Key changes:

  • Added getPathDisplayName() method in terminalManager.js that normalizes filesystem paths by skipping empty segments, removing . references, and resolving .. by popping from the path stack
  • Enhanced get_abs_path() function in init-alpine.sh to check for realpath availability before using it, with a robust fallback using cd and pwd -P for environments where realpath is not installed
  • The fix ensures that when opening the current directory with acode ., the folder shows its actual name instead of the generic "."

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • The changes are well-implemented defensive improvements that fix a UX bug and add proper fallback handling. The getPathDisplayName() method correctly normalizes paths using standard path manipulation logic, and the shell script improvements add defensive checks for command availability. Both changes are isolated, focused, and don't affect other functionality.
  • No files require special attention

Important Files Changed

Filename Overview
src/components/terminal/terminalManager.js Added getPathDisplayName() method to normalize paths and handle trailing . and .. segments correctly
src/plugins/terminal/scripts/init-alpine.sh Enhanced get_abs_path() with fallback implementation when realpath is unavailable

Sequence Diagram

sequenceDiagram
    participant User
    participant Terminal
    participant AcodeCLI as acode CLI
    participant GetAbsPath as get_abs_path()
    participant TermMgr as TerminalManager
    participant GetDisplay as getPathDisplayName()
    participant OpenFolder as openFolder()

    User->>Terminal: Run "acode ."
    Terminal->>AcodeCLI: Execute command
    AcodeCLI->>GetAbsPath: Resolve path "."
    
    alt realpath available
        GetAbsPath->>GetAbsPath: Use realpath command
    else realpath not available
        GetAbsPath->>GetAbsPath: Fallback: cd + pwd -P
    end
    
    GetAbsPath-->>AcodeCLI: Return "/path/to/current/dir"
    AcodeCLI->>Terminal: Send OSC 7777 escape sequence
    Terminal->>TermMgr: onOscOpen("folder", "/path/to/current/dir")
    TermMgr->>GetDisplay: getPathDisplayName("/path/to/current/dir")
    
    GetDisplay->>GetDisplay: Split by "/" and normalize
    GetDisplay->>GetDisplay: Skip empty and "." segments
    GetDisplay->>GetDisplay: Handle ".." by popping
    GetDisplay-->>TermMgr: Return "dir" (not ".")
    
    TermMgr->>OpenFolder: openFolder(fileUri, {name: "dir"})
    OpenFolder-->>User: Folder opened with correct name
Loading

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