Connection status in the top bar, as SilverBullet does

- The top bar (and the phone's status bar) turns red when the server
  can't be reached: the device is offline, or a request failed (signal
  but no internet, or the proxy answering for the app). While red it
  checks /up every 15 seconds and turns back on its own.
- A ring fills while pages are saved for offline use or flights and
  squawks logged offline are sent, with the percentage in its middle,
  and hides when done. While some wait to send, it's amber with how many.

Checked on an Android 14 emulator: airplane mode on and off, saving for
offline, and a flight logged offline then sent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-15 13:15:50 -05:00
1 parent 66fa5f4423
commit d9de1be562
7 files changed
+220 -13

No files matched your search

@@ -0,0 +1,31 @@
require "test_helper"
# The top bar turns red when the server can't be reached and has a ring for
# saving for offline / sending (connection_controller.js); here, its markup,
# styles and strings.
class ConnectionStatusTest < ActionDispatch::IntegrationTest
test "the top bar carries the connection status, hidden ring and announcer" do
sign_in create_user
get root_path
assert_select "header[data-controller=connection]" do
assert_select ".sync-ring[hidden][role=img][data-connection-target=ring] [data-connection-target=label]"
assert_select "[role=status][data-connection-target=announce]"
end
strings = JSON.parse(css_select("script#i18n").first.text)
assert_equal %w[back_online offline saving sending waiting], strings["connection"].keys.sort
assert_match "%{percent}", strings["connection"]["saving"]
end
test "signed out pages have it too, for the sign-in page offline" do
create_user
get new_session_path
assert_response :success
assert_select "header[data-controller=connection] .sync-ring[hidden]"
end
test "the red top bar and the ring are styled" do
css = Rails.root.join("app/assets/tailwind/application.css").read
assert_match(/header\.is-offline \{ --color-header: var\(--color-header-offline\); \}/, css)
assert_match "conic-gradient", css
end
end