Skip to content

Harden view bootstrap setup#18

Open
slideep wants to merge 11 commits into
mainfrom
codex/view-bootstrap-hardening
Open

Harden view bootstrap setup#18
slideep wants to merge 11 commits into
mainfrom
codex/view-bootstrap-hardening

Conversation

@slideep
Copy link
Copy Markdown
Contributor

@slideep slideep commented May 18, 2026

Summary

  • add view-setup / view setup and view-doctor --fix to turn view prerequisites into executable setup checks
  • validate helper APK resolution with size/SHA-256, install it, and verify installed MediaProjection activity/service components
  • emit view_startup_phase JSONL events during helper resolution/install/verify, adb forward, MediaProjection activity launch, and consent approval
  • add source wrappers for Windows and POSIX shells to avoid stale direct DLL runs

Validation

  • dotnet test Luotsi.Cli.Tests\Luotsi.Cli.Tests.csproj (214/214 before final callback API refinement, 215/215 after)
  • dotnet build -c Release
  • view-setup --device 192.168.0.134:5555 --fix returned ready: true with helper install/verify succeeding
  • headless MediaProjection view started and streamed frames from the hardening worktree

Copilot AI review requested due to automatic review settings May 18, 2026 14:48
Comment thread Luotsi.Cli.Tests/ViewSessionLifecycleTests.cs Fixed
Comment thread Luotsi.Cli/View/Diagnostics/ViewSetup.cs Fixed
Comment thread Luotsi.Cli/View/Diagnostics/ViewSetup.cs Fixed
Comment thread Luotsi.Cli/View/Diagnostics/ViewSetup.cs Fixed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens the Android live view bootstrap flow by making prerequisites executable (view-setup / view setup, view-doctor --fix), validating/installing/verifying the helper APK, and emitting structured view_startup_phase JSONL events during startup to improve diagnosability.

Changes:

  • Added view-setup (and view setup alias) plus view-doctor --fix to run fixable setup checks and helper install/verification.
  • Hardened helper APK resolution with file fingerprinting (size + SHA-256) and added device-side verification of required MediaProjection components.
  • Added view startup phase reporting (JSONL events) and propagated ADB command timeout into view transport bootstrap.

Reviewed changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
scripts/luotsi.sh POSIX wrapper to run Luotsi CLI from source via dotnet run.
scripts/luotsi.ps1 PowerShell wrapper to run Luotsi CLI from source via dotnet run.
Luotsi.Cli/View/ViewHostPathResolver.cs Refactors repository-relative candidate resolution into a shared helper for file/dir probing.
Luotsi.Cli/View/Transport/NullViewTransport.cs Updates transport bootstrap interface to accept optional startup phase reporting callback.
Luotsi.Cli/View/Session/ViewSession.cs Emits view_startup_phase JSONL events and improves MediaProjection consent failure handling + fallback behavior.
Luotsi.Cli/View/Diagnostics/ViewSetup.cs Introduces view setup runner that can resolve/build helper, install/verify it, and return structured setup results.
Luotsi.Cli/View/Diagnostics/ViewDoctor.cs Enhances helper package check detail to include resolution source and fingerprint info.
Luotsi.Cli/View/Contracts/ViewAbstractions.cs Adds CommandTimeout propagation, startup phase abstractions, and bootstrap callback API.
Luotsi.Cli/Models/SessionEventTypes.cs Adds view_startup_phase inspect/view event type constant.
Luotsi.Cli/Hosts/Android/View/MediaProjectionConsentException.cs Adds a dedicated exception type for MediaProjection consent failures.
Luotsi.Cli/Hosts/Android/View/AndroidViewBootstrap.cs Hardens helper resolution (size/SHA-256), installs/verifies helper, adds phased startup reporting, and refines consent approval logic.
Luotsi.Cli/Cli/ViewSessionCommandPreparer.cs Resolves ADB command timeout from CLI/env and passes it into view options for transport startup.
Luotsi.Cli/Cli/ViewProfileCoordinator.cs Extends --profile applicability to view-setup.
Luotsi.Cli/Cli/ViewCommandOptionsFactory.cs Threads resolved command timeout into constructed ViewOptions.
Luotsi.Cli/Cli/Help.cs Documents new source wrappers and adds view setup / view-setup + view-doctor --fix usage text.
Luotsi.Cli/Cli/DeviceHostLauncher.cs Replaces inline timeout parsing with shared AdbCommandTimeoutResolver.
Luotsi.Cli/Cli/CliOptions.cs Registers view-setup command and --fix flag as known tokens.
Luotsi.Cli/Cli/AppDependencies.cs Adds optional IViewSetupFactory dependency injection slot.
Luotsi.Cli/Cli/AppCommandHost.cs Implements view-setup execution and view-doctor --fix behavior.
Luotsi.Cli/Cli/AppCommandFamilyRouter.cs Routes view-setup and view setup alias to the setup runner.
Luotsi.Cli/Cli/App.cs Wires default ViewSetupFactory and passes environment into view session preparation for timeout resolution.
Luotsi.Cli/Cli/AdbCommandTimeoutResolver.cs Centralizes parsing of --adb-timeout-sec / LUOTSI_ADB_TIMEOUT_SEC.
Luotsi.Cli.Tests/ViewTransportTests.cs Updates/extends transport tests to assert startup phase reporting and MediaProjection verification steps.
Luotsi.Cli.Tests/ViewSessionOptionsTests.cs Adds coverage ensuring view sessions receive resolved ADB command timeout (default and env override).
Luotsi.Cli.Tests/ViewSessionLifecycleTests.cs Adds coverage for streaming startup phases and explicit MediaProjection consent failures returning usage errors.
Luotsi.Cli.Tests/ViewDoctorTests.cs Adds coverage for injected setup factory usage and view-doctor --fix invoking setup.
Luotsi.Cli.Tests/TestSupport.cs Extends fakes to support setup and startup phase callback behavior in tests.

Comment thread Luotsi.Cli/Cli/AppCommandHost.cs Outdated
Comment thread Luotsi.Cli/View/Diagnostics/ViewSetup.cs
Comment thread Luotsi.Cli/Hosts/Android/View/AndroidViewBootstrap.cs
Comment thread Luotsi.Cli/Hosts/Android/View/AndroidViewHelperPackageLocator.cs Fixed
@slideep
Copy link
Copy Markdown
Contributor Author

slideep commented May 18, 2026

Addressed the Copilot/github-code-quality review threads in e1279b7.

Changes:

  • normalized the view setup alias envelope command to view-setup and added coverage
  • disposed the test MemoryStream explicitly
  • converted helper path lookups to explicit LINQ first-match filters
  • narrowed expected setup exception handling and avoided duplicate helper install failure steps
  • reused shared helper APK package-detail formatting for startup diagnostics

Validation:

  • dotnet test Luotsi.Cli.Tests\Luotsi.Cli.Tests.csproj
  • dotnet build -c Release

private readonly IDeviceHost _deviceHost = deviceHost ?? throw new ArgumentNullException(nameof(deviceHost));
private readonly IAndroidViewHelperPackageLocator _helperPackageLocator = helperPackageLocator ?? throw new ArgumentNullException(nameof(helperPackageLocator));
private readonly AndroidViewHelperSetupProvisioner _helperProvisioner = new(
helperPackageLocator ?? throw new ArgumentNullException(nameof(helperPackageLocator)),
fileSystem ?? throw new ArgumentNullException(nameof(fileSystem)),
processRunner ?? throw new ArgumentNullException(nameof(processRunner)));
private readonly IViewDoctorFactory _viewDoctorFactory = viewDoctorFactory ?? throw new ArgumentNullException(nameof(viewDoctorFactory));
private readonly IProcessRunner _processRunner = processRunner ?? throw new ArgumentNullException(nameof(processRunner));
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