Skip to content

Improve Seal Gate Tunnel sign-in and Mobile Bash - #55

Merged
Miyamura80 merged 1 commit into
mainfrom
codex/seal-gate-tunnel-updates
Nov 30, 2026
Merged

Miyamura80 merged 1 commit into
mainfrom
codex/seal-gate-tunnel-updates

Conversation

@Miyamura80

@Miyamura80 Miyamura80 commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add named connection profiles for Demo, Release, and custom gateways. Keep API-key entry under Advanced settings.
  • Update the connection diagram and app branding, and fix Android foreground service startup and gateway handshake compatibility.
  • Add Mobile Bash controls for media volume and opt-in approximate location.

Verification

  • Built and installed the debug APK on a Pixel 9.
  • Ran 141 Android unit tests successfully.
  • Verified a live Demo tunnel and used Mobile Bash over MCP to change and restore the Pixel's media volume.

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.

  • Fixed Android foreground service startup when the camera permission is granted, and made the gateway handshake tolerate extra metadata from the gateway.
  • Rebranched the app, notifications, and accessibility services to Seal Gate Tunnel.
  • audio reads and sets media volume; location checks sharing status and reads a cached approximate fix (expires after five minutes).
  • Each connection profile keeps its own sign-in and credential; switching requires disconnecting first.

Written for commit 3b0f08b. Summary will update on new commits.

View guided diff Turn on auto-fix

@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-30T07:55:34.275836Z 3b0f08b PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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" />

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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>
Suggested change
TunnelState.Connecting -> Unit
TunnelState.Connecting -> { paint.alpha = 255 }

@Miyamura80
Miyamura80 merged commit 76f38ec into main Nov 30, 2026
3 checks passed
@github-actions
github-actions Bot deleted the codex/seal-gate-tunnel-updates branch November 30, 2026 07:59
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.

1 participant