examples/compose: build ttyd from our fork with autoreconnect patch - #126
Merged
Conversation
The ttyd web console previously consumed the upstream tsl0922/ttyd:1.7.7 image's embedded HTML directly. That HTML's WebSocket-client logic only reconnects on non-1000 close codes and bails entirely on a single socket error, so laptop sleep / VPN flap / brief network drops stick the in-browser terminal at "Press Enter to Reconnect" until the user notices. Switch the frontend build to clone our ttyd fork (https://github.com/hndrewaall/ttyd) and run yarn build + gulp inline against it, producing a single self-contained HTML file that ships an exponential-backoff auto-reconnect plus a visibilitychange handler (cancels the backoff + reconnects immediately when the tab becomes visible). The autodark CSS + theme-swap injection still runs on top of the fork-built HTML via inject-autodark.py. The upstream C binary is unchanged; we still copy it out of tsl0922/ttyd:1.7.7. Once the upstream PR (tsl0922/ttyd#1536) merges, the TTYD_FORK_REF pin can move back to tsl0922/ttyd:main (or a future tag). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
hndrewaall
added a commit
that referenced
this pull request
Aug 11, 2026
The ttyd web console previously consumed the upstream tsl0922/ttyd:1.7.7 image's embedded HTML directly. That HTML's WebSocket-client logic only reconnects on non-1000 close codes and bails entirely on a single socket error, so laptop sleep / VPN flap / brief network drops stick the in-browser terminal at "Press Enter to Reconnect" until the user notices. Switch the frontend build to clone our ttyd fork (https://github.com/hndrewaall/ttyd) and run yarn build + gulp inline against it, producing a single self-contained HTML file that ships an exponential-backoff auto-reconnect plus a visibilitychange handler (cancels the backoff + reconnects immediately when the tab becomes visible). The autodark CSS + theme-swap injection still runs on top of the fork-built HTML via inject-autodark.py. The upstream C binary is unchanged; we still copy it out of tsl0922/ttyd:1.7.7. Once the upstream PR (tsl0922/ttyd#1536) merges, the TTYD_FORK_REF pin can move back to tsl0922/ttyd:main (or a future tag). Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The ttyd web console in
examples/compose/previously served the upstreamtsl0922/ttyd:1.7.7image's embedded HTML directly. That HTML's WebSocketclient only reconnects on non-1000 close codes and bails entirely after a
single socket
errorevent, so laptop sleep / VPN flap / brief networkdrops park the in-browser terminal at "Press Enter to Reconnect" until
someone notices.
This PR adds a node-based frontend-builder stage that clones our ttyd
fork (https://github.com/hndrewaall/ttyd) and runs
yarn build+gulp inlineagainst it, producing a single self-contained HTML filethat ships:
reconnectis enabled, not just non-1000 codeserrorevents (the always-followingclosedrives the retry)visibilitychangehandler that cancels any pending backoff andreconnects immediately when the tab becomes visible
The autodark CSS + theme-swap inject-autodark.py pipeline still runs on
top of the fork-built HTML. The upstream ttyd C binary is unchanged —
we still copy it out of
tsl0922/ttyd:1.7.7.The fork pin is captured as
TTYD_FORK_REF(defaults to the squash-mergeSHA on the fork's main). Once the upstream PR
tsl0922/ttyd#1536 merges,
the pin can move back to a
tsl0922/ttydtag.Test plan
sudo docker build examples/compose/ttyd/succeeds end-to-end./usr/local/share/ttyd/index.html(visibilitychange,scheduleReconnect,reconnectDelay,reconnectMaxDelay,installVisibilityHandlerall present).prefers-color-scheme+autodark-injectedgrep matches preserved as build-time guards).
docker compose upstack; tab intohttp://localhost:7681 and verify reconnect overlay appears after a
forced socket close instead of "Press Enter to Reconnect".