Skip to content

fix: prevent terminal hang in headless/SSH environments#142

Open
bwanswa wants to merge 4 commits intopermitio:mainfrom
bwanswa:main
Open

fix: prevent terminal hang in headless/SSH environments#142
bwanswa wants to merge 4 commits intopermitio:mainfrom
bwanswa:main

Conversation

@bwanswa
Copy link

@bwanswa bwanswa commented Jan 22, 2026

Description

This PR resolves the issue where the permit login command causes the terminal to hang indefinitely in headless environments (e.g., SSH, Docker, or Kali Linux without a GUI).

The hang occurred because the open package attempted to launch a browser even when a graphical display was unavailable or "ghosted" (e.g., DISPLAY=:0.0 being set without an active session). I have added a non-blocking check that verifies the environment and provides a fallback URL for manual login.
Type of Change

[x] Bug fix

[ ] New feature/command

[ ] Documentation update

[ ] Code refactoring

[ ] Performance improvement

[ ] Test addition/update

Checklist

[x] My code follows the project's coding style guidelines

[x] All tests pass locally (Verified with standalone Node.js proof-of-concept)

[x] I have reviewed my own code for potential issues

Additional Notes

Tested on Kali Linux (Headless).

Scenario A: DISPLAY is empty -> CLI prints the URL immediately.

Scenario B: DISPLAY is set to :0.0 but no browser is available -> The try/catch block prevents the terminal from locking up and provides the fallback link.

Screenshots/Recordings

I have verified the fix using a test script that replicates the logic in source/lib/auth.ts.

Environment: Kali Linux Terminal

Result: Responsive terminal with manual URL fallback.

UPDATE (Jan 23): Added dynamic column scaling to PolicyTables.tsx to fix border breakage and an @ts-ignore to RelationGenerator.ts for Node v22 compatibility.

@bwanswa
Copy link
Author

bwanswa commented Jan 23, 2026

Hi @gemanor, I've rebased this fix against the latest main branch. It's ready for review. This addresses the terminal hang when running in headless/SSH environments by checking for a display environment before attempting to open a browser. Thanks!

Implements dynamic width calculation in PolicyTables.tsx to prevent border breakage with long resource names
@bwanswa
Copy link
Author

bwanswa commented Jan 23, 2026

I have added the dynamic table scaling fix to this PR. Please review and process the bounty through Algora. Note: I am in Uganda, so please use Payoneer for the payout.

@gemanor
Copy link
Collaborator

gemanor commented Feb 3, 2026

The login shouldn't work in a headless env., you should use the --api-key in headless environments.
Can you share more on your usecase?

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