Skip to content

Conversation

@dapi
Copy link
Owner

@dapi dapi commented Jan 7, 2026

Summary

Improves the readability and compactness of the --list command output by implementing dynamic column formatting and intelligent path truncation that preserves path structure.

Changes

1. Dynamic Column Spacing

  • Calculates the maximum directory width from actual data in the current output
  • Uses this to determine minimal spacing between DIRECTORY and NAME columns
  • Caps maximum directory width at 40 characters

2. Intelligent Directory Path Truncation (Improved)

  • Truncates directory paths longer than 40 characters while preserving path structure
  • New algorithm:
    • Keeps the beginning (e.g., ~/) and compresses the middle with ...
    • Preserves parent directories (e.g., feature/, worktrees/)
    • Only truncates the filename/last part when necessary
  • Example: ~/code/worktrees/feature/103-manager-reply-from-dashboard~/.../feature/...r-reply-from-dashboard
  • Added truncateDirectoryPath() helper function

3. Always Show Name Column

  • Removed conditional logic that hid "main" names when no other names existed
  • Now always displays the NAME column for every allocation
  • Makes output more consistent and explicit

Example Output

Before (v0.9.0):

PORT  DIRECTORY                                                    NAME   STATUS  LOCKED  USER  PID  PROCESS       ASSIGNED
3000  ~/code/merchantly/main                                            free    yes     -     -    -             2026-01-03 20:53
3004  ~/code/worktrees/feature/103-manager-reply-from-dashboard           free            -     -    -             2026-01-03 23:30

After (This PR):

PORT  DIRECTORY                               NAME   STATUS  LOCKED  USER  PID  PROCESS       ASSIGNED
3000  ~/code/merchantly/main                  main   free    yes     -     -    -             2026-01-03 20:53
3004  ~/.../feature/...r-reply-from-dashboard main   free            -     -    -             2026-01-03 23:30
3006  ~/.../worktrees/...er-takeover-services main   free            -     -    -             2026-01-04 20:21

Note how parent directories (feature/, worktrees/) are preserved!

Very Long Path Example (New):

For paths with extremely long names:

# Path: ~/test-long-path/very-long-directory-name-that-exceeds-forty-character-limit/
#        another-nested-subdirectory/feature-branch-with-extremely-long-name

PORT  DIRECTORY                                NAME  STATUS  LOCKED  USER  PID  PROCESS  ASSIGNED
3000  .../...-branch-with-extremely-long-name  main  free            -     -    -        2026-01-07 19:16
3001  .../...-branch-with-extremely-long-name  web   free            -     -    -        2026-01-07 19:16
3002  .../...-branch-with-extremely-long-name  api   free            -     -    -        2026-01-07 19:16

Note: The truncation preserves the structure and shows .../...-branch-with-extremely-long-name to indicate there's a long path structure that's been compressed.

Testing

  • All existing tests pass
  • Manual testing with various directory lengths
  • Verified truncation preserves parent directories
  • Verified "main" name always appears
  • Verified dynamic column spacing works correctly
  • Tested with very long paths (> 40 chars)

Implementation Details

The implementation uses a two-pass approach:

  1. First pass: calculate max directory width (capped at 40 chars) from current data
  2. Second pass: format and output with proper alignment

The truncation algorithm intelligently:

  • For paths with many components (>3), shows ~/.../parent/filename
  • Prioritizes keeping parent directories over middle directories
  • Only truncates the filename part, preserving context

When a port is busy and has Docker container info, the directory is updated from live data, which is then reflected in the output.

Closes #68

🤖 Generated with Claude Code

@dapi dapi force-pushed the feature/list-formatting branch from bee0652 to b6bec77 Compare January 7, 2026 13:06
Implement dynamic column formatting and truncation for better readability:

1. Dynamic column spacing - minimum distance between DIRECTORY and NAME
   - Calculate max directory width from actual data
   - Cap at 40 characters maximum

2. Truncate long directory paths to 40 chars with ellipsis
   - Shows first half + "..." + second half for paths > 40 chars
   - Example: ~/code/worktrees/f...eply-from-dashboard

3. Always show name column (including "main")
   - Removed conditional hiding of "main" name
   - Now always displays name for every allocation

Added helper function:
- truncateDirectoryPath(path string, maxLen int) string

Fixes #68

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@dapi dapi force-pushed the feature/list-formatting branch from b6bec77 to 539592c Compare January 7, 2026 13:15
@dapi dapi force-pushed the feature/list-formatting branch from cf9b6ef to dcebe09 Compare January 7, 2026 15:51
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.

Улучшить форматирование вывода команды --list

1 participant