Skip to content

Fix Linux compatibility: Replace hardcoded macOS paths in Observability#497

Open
christauff wants to merge 1 commit intodanielmiessler:mainfrom
christauff:fix/linux-observability-paths
Open

Fix Linux compatibility: Replace hardcoded macOS paths in Observability#497
christauff wants to merge 1 commit intodanielmiessler:mainfrom
christauff:fix/linux-observability-paths

Conversation

@christauff
Copy link

Problem

PAI v2.4's Observability dashboard fails on Linux systems due to hardcoded macOS path encoding.

Both task-watcher.ts and file-ingest.ts use -Users- prefix which only works for macOS paths like /Users/username. Linux systems use /home/username, causing the dashboard to show empty even when agents are running.

Solution

Replace hardcoded path construction with dynamic HOME environment variable encoding:

// Before (macOS only)
const TASKS_DIR = \`/tmp/claude/-Users-\${process.env.USER}--claude/tasks\`;

// After (cross-platform)
const homePathEncoded = (process.env.HOME || homedir()).replace(/\//g, '-');
const TASKS_DIR = \`/tmp/claude/\${homePathEncoded}--claude/tasks\`;

Impact

  • Remote tab: Now displays background task timeline on Linux
  • Local tab: Now displays PAI hook events on Linux
  • Backward compatible: macOS paths unchanged

Testing

Tested on:

  • ✅ Ubuntu 24.04 (Linux 6.14.0-37-generic)
  • ✅ Confirmed both dashboard tabs functional

Files Changed

  • `Packs/pai-observability-server/src/Observability/apps/server/src/task-watcher.ts`
  • `Packs/pai-observability-server/src/Observability/apps/server/src/file-ingest.ts`

Both task-watcher.ts and file-ingest.ts used hardcoded -Users- prefix
for path construction, which only works on macOS (/Users/username).
Linux systems use /home/username, causing the dashboard to show empty
even when agents are running.

Fixed by encoding HOME environment variable dynamically, replacing
forward slashes with hyphens. Now generates correct paths for both:
- macOS:  /tmp/claude/-Users-username--claude/tasks
- Linux:  /tmp/claude/-home-username--claude/tasks

Impact:
- Remote tab: Now displays background task timeline on Linux
- Local tab: Now displays PAI hook events on Linux
- Backward compatible: macOS paths unchanged

Tested on Ubuntu 24.04 (Linux 6.14.0-37-generic).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Copy link

@realGregorVucajnk realGregorVucajnk left a comment

Choose a reason for hiding this comment

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

Nice, thank you!

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.

2 participants