Repository navigation
Improve Seal Gate Tunnel sign-in and Mobile Bash - #55
Conversation
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3b0f08b73f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| val location = manager.getProviders(true) | ||
| .mapNotNull { provider -> | ||
| try { | ||
| manager.getLastKnownLocation(provider) |
There was a problem hiding this comment.
Enable location foreground access for the tunnel service
On Android 10+, location last cannot read the cached fix after the user backgrounds the activity or turns off the screen, even when sharing is enabled and approximate-location permission is granted. The manifest declares only dataSync|camera, and promoteToForeground() activates only those types; neither provides foreground location access, and the app does not request background-location permission. Android requires a location foreground-service type for this use case. Consequently, the normal background-tunnel scenario returns an error instead of an available fix. Declare the location service type and its required permission, and activate it when location sharing is enabled, including when sharing is toggled on during an existing tunnel.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
6 issues found across 24 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="app/src/main/AndroidManifest.xml">
<violation number="1" location="app/src/main/AndroidManifest.xml:15">
P1: `ACCESS_COARSE_LOCATION` only grants while-in-use access, but `location_last` runs from the persistent `TunnelService` after the activity is backgrounded. Declare and start the service as a location foreground service, or request `ACCESS_BACKGROUND_LOCATION`; otherwise Android 10+ can deny `getLastKnownLocation` and the new tool fails.</violation>
</file>
<file name="app/src/main/java/ai/sealgate/stdiod/TunnelService.kt">
<violation number="1" location="app/src/main/java/ai/sealgate/stdiod/TunnelService.kt:111">
P1: `FOREGROUND_SERVICE_TYPE_DATA_SYNC` is time-limited on Android 15+, but this service is designed to keep one WebSocket alive indefinitely. After six hours in a 24-hour period Android will time out the service and disrupt the tunnel; use a non-time-limited foreground-service strategy appropriate for this connection, or redesign around the platform transfer API and handle the timeout.</violation>
</file>
<file name="app/src/main/java/ai/sealgate/stdiod/tunnel/TunnelFrame.kt">
<violation number="1" location="app/src/main/java/ai/sealgate/stdiod/tunnel/TunnelFrame.kt:56">
P2: These fields make the Android codec accept gateway metadata, but `schema/tunnel-protocol.json` still rejects both fields as additional properties. Update the shared ServerHello schema and synchronized protocol fixtures/implementations with this change.</violation>
</file>
<file name="app/src/main/java/ai/sealgate/stdiod/ui/TunnelVisualView.kt">
<violation number="1" location="app/src/main/java/ai/sealgate/stdiod/ui/TunnelVisualView.kt:130">
P3: `TunnelState.Connecting -> Unit` leaves `paint.alpha` at 245 from the connection line, so the phone and labels render translucent while connecting. Reset `paint.alpha` to 255 in this branch.</violation>
</file>
<file name="app/src/main/java/ai/sealgate/stdiod/MainActivity.kt">
<violation number="1" location="app/src/main/java/ai/sealgate/stdiod/MainActivity.kt:404">
P2: The API-key dialog accepts uppercase WebSocket schemes but the service rejects them, so valid-looking input is saved and then immediately stops. Normalize the scheme or use one case-insensitive gateway validation consistently before starting the service.</violation>
<violation number="2" location="app/src/main/java/ai/sealgate/stdiod/MainActivity.kt:674">
P2: The sign-in can finish without starting the tunnel when the activity is backgrounded and the process dies before `withResumed` runs. Persist an auto-connect completion state or keep enough pending state to retry starting the service after the next launch.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| <!-- The wifi module reads radio state, link speed, and SSID. --> | ||
| <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | ||
| <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> | ||
| <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> |
There was a problem hiding this comment.
P1: ACCESS_COARSE_LOCATION only grants while-in-use access, but location_last runs from the persistent TunnelService after the activity is backgrounded. Declare and start the service as a location foreground service, or request ACCESS_BACKGROUND_LOCATION; otherwise Android 10+ can deny getLastKnownLocation and the new tool fails.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/src/main/AndroidManifest.xml, line 15:
<comment>`ACCESS_COARSE_LOCATION` only grants while-in-use access, but `location_last` runs from the persistent `TunnelService` after the activity is backgrounded. Declare and start the service as a location foreground service, or request `ACCESS_BACKGROUND_LOCATION`; otherwise Android 10+ can deny `getLastKnownLocation` and the new tool fails.</comment>
<file context>
@@ -11,6 +11,8 @@
<!-- The wifi module reads radio state, link speed, and SSID. -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
+ <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<!-- The bluetooth module reads adapter state and bonded devices and,
with the control tools, connects to / scans for devices:
</file context>
|
|
||
| private fun promoteToForeground(state: TunnelState) { | ||
| val notification = buildNotification(state) | ||
| val dataSync = ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC |
There was a problem hiding this comment.
P1: FOREGROUND_SERVICE_TYPE_DATA_SYNC is time-limited on Android 15+, but this service is designed to keep one WebSocket alive indefinitely. After six hours in a 24-hour period Android will time out the service and disrupt the tunnel; use a non-time-limited foreground-service strategy appropriate for this connection, or redesign around the platform transfer API and handle the timeout.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/src/main/java/ai/sealgate/stdiod/TunnelService.kt, line 111:
<comment>`FOREGROUND_SERVICE_TYPE_DATA_SYNC` is time-limited on Android 15+, but this service is designed to keep one WebSocket alive indefinitely. After six hours in a 24-hour period Android will time out the service and disrupt the tunnel; use a non-time-limited foreground-service strategy appropriate for this connection, or redesign around the platform transfer API and handle the timeout.</comment>
<file context>
@@ -100,6 +106,27 @@ class TunnelService : LifecycleService() {
+ private fun promoteToForeground(state: TunnelState) {
+ val notification = buildNotification(state)
+ val dataSync = ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R &&
+ CameraSettings.isEnabled(this) &&
</file context>
| @SerialName("protocol_version") val protocolVersion: Int, | ||
| val servers: List<DesiredServer> = emptyList(), | ||
| // The gateway may send metadata alongside the version and server list. | ||
| val update: JsonObject? = null, |
There was a problem hiding this comment.
P2: These fields make the Android codec accept gateway metadata, but schema/tunnel-protocol.json still rejects both fields as additional properties. Update the shared ServerHello schema and synchronized protocol fixtures/implementations with this change.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/src/main/java/ai/sealgate/stdiod/tunnel/TunnelFrame.kt, line 56:
<comment>These fields make the Android codec accept gateway metadata, but `schema/tunnel-protocol.json` still rejects both fields as additional properties. Update the shared ServerHello schema and synchronized protocol fixtures/implementations with this change.</comment>
<file context>
@@ -52,6 +52,9 @@ data class DesiredServer(
@SerialName("protocol_version") val protocolVersion: Int,
val servers: List<DesiredServer> = emptyList(),
+ // The gateway may send metadata alongside the version and server list.
+ val update: JsonObject? = null,
+ @SerialName("device_settings") val deviceSettings: JsonObject? = null,
) : TunnelFrame
</file context>
| if (!canChangeConnection()) return | ||
| val gatewayUrl = binding.gatewayUrlInput.text?.toString()?.trim().orEmpty() | ||
| binding.gatewayUrlLayout.error = null | ||
| if (GatewayUrls.apiBaseFromWs(gatewayUrl) == null) { |
There was a problem hiding this comment.
P2: The API-key dialog accepts uppercase WebSocket schemes but the service rejects them, so valid-looking input is saved and then immediately stops. Normalize the scheme or use one case-insensitive gateway validation consistently before starting the service.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/src/main/java/ai/sealgate/stdiod/MainActivity.kt, line 404:
<comment>The API-key dialog accepts uppercase WebSocket schemes but the service rejects them, so valid-looking input is saved and then immediately stops. Normalize the scheme or use one case-insensitive gateway validation consistently before starting the service.</comment>
<file context>
@@ -355,26 +385,195 @@ class MainActivity : AppCompatActivity() {
+ if (!canChangeConnection()) return
+ val gatewayUrl = binding.gatewayUrlInput.text?.toString()?.trim().orEmpty()
+ binding.gatewayUrlLayout.error = null
+ if (GatewayUrls.apiBaseFromWs(gatewayUrl) == null) {
+ binding.gatewayUrlLayout.error = getString(R.string.error_gateway_url)
+ binding.gatewayUrlInput.requestFocus()
</file context>
| PendingSignInStore.clear(this) | ||
| // Dashboard approval can finish while the browser is in front. | ||
| // Android only lets us start the foreground service from a visible activity. | ||
| lifecycle.withResumed { |
There was a problem hiding this comment.
P2: The sign-in can finish without starting the tunnel when the activity is backgrounded and the process dies before withResumed runs. Persist an auto-connect completion state or keep enough pending state to retry starting the service after the next launch.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/src/main/java/ai/sealgate/stdiod/MainActivity.kt, line 674:
<comment>The sign-in can finish without starting the tunnel when the activity is backgrounded and the process dies before `withResumed` runs. Persist an auto-connect completion state or keep enough pending state to retry starting the service after the next launch.</comment>
<file context>
@@ -463,14 +666,14 @@ class MainActivity : AppCompatActivity() {
PendingSignInStore.clear(this)
+ // Dashboard approval can finish while the browser is in front.
+ // Android only lets us start the foreground service from a visible activity.
+ lifecycle.withResumed {
+ TunnelService.start(this, TunnelConfig(gatewayUrl, result.accessToken, result.deviceId))
+ }
</file context>
| drawSecureLock(canvas, w / 2f, centerY, color) | ||
| when (state) { | ||
| TunnelState.Connected -> drawSecureLock(canvas, w / 2f, centerY, color) | ||
| TunnelState.Connecting -> Unit |
There was a problem hiding this comment.
P3: TunnelState.Connecting -> Unit leaves paint.alpha at 245 from the connection line, so the phone and labels render translucent while connecting. Reset paint.alpha to 255 in this branch.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/src/main/java/ai/sealgate/stdiod/ui/TunnelVisualView.kt, line 130:
<comment>`TunnelState.Connecting -> Unit` leaves `paint.alpha` at 245 from the connection line, so the phone and labels render translucent while connecting. Reset `paint.alpha` to 255 in this branch.</comment>
<file context>
@@ -113,10 +125,10 @@ class TunnelVisualView @JvmOverloads constructor(
- drawSecureLock(canvas, w / 2f, centerY, color)
+ when (state) {
+ TunnelState.Connected -> drawSecureLock(canvas, w / 2f, centerY, color)
+ TunnelState.Connecting -> Unit
+ else -> drawDisconnectedPlug(canvas, w / 2f, centerY, color)
}
</file context>
| TunnelState.Connecting -> Unit | |
| TunnelState.Connecting -> { paint.alpha = 255 } |
Summary
Verification
Summary by cubic
Adds named connection profiles for Demo, Main, and custom gateways so you can save sign-ins for different dashboards and switch between them, and moves API-key entry into Advanced settings. Also adds Mobile Bash controls for media volume and opt-in approximate location sharing, and fixes several tunnel reliability and compatibility issues.
audioreads and sets media volume;locationchecks sharing status and reads a cached approximate fix (expires after five minutes).Written for commit 3b0f08b. Summary will update on new commits.