Fix: Prevent AuthManager state pollution on connection verification (#348)
* Fix: Prevent AuthManager state pollution on connection verification Modified `ConnectViewModel.connect()` to construct a temporary OkHttpClient and Retrofit builder, isolated from the global `ApiClient` state. The connection verification is executed using this temporary service. Only upon a successful HTTP response does the system persist the configured `host`, `port`, and `token` to the global `AuthManager` and triggers an `ApiClient.rebuild()`. This resolves the issue where a failed connection attempt would overwrite active and verified profiles. Extracted `createTempService` factory to `ApiClient` for robustness and clean tests. Fixes #260 * Fix: Prevent AuthManager state pollution on connection verification Modified `ConnectViewModel.connect()` to construct a temporary OkHttpClient and Retrofit builder, isolated from the global `ApiClient` state. The connection verification is executed using this temporary service. Only upon a successful HTTP response does the system persist the configured `host`, `port`, and `token` to the global `AuthManager` and triggers an `ApiClient.rebuild()`. This resolves the issue where a failed connection attempt would overwrite active and verified profiles. Extracted `createTempService` factory to `ApiClient` for robustness and clean tests. Fixes #260 --------- Co-authored-by: M57 <hy4ri@users.noreply.github.com>
This commit is contained in:
1 parent
c21e3e9ed0
commit
2c6e437a5b
42 files changed
+296
-667
No files matched your search
@@ -191,40 +191,7 @@ jobs:
|
||||
retention-days: 7
|
||||
|
||||
# ─────────────────────────────────────────────────────────────────────
|
||||
# Job 5: Release Compile — verifies release variant compiles.
|
||||
# Catches issues like debugImplementation-scoped dependencies that
|
||||
# main source code depends on (e.g. okhttp3.logging.HttpLoggingInterceptor).
|
||||
# debug-only CI jobs (ktlint, lint, tests) won't catch these.
|
||||
# ─────────────────────────────────────────────────────────────────────
|
||||
release-compile:
|
||||
name: Release Compile Check
|
||||
needs: [ktlint, android-lint, unit-tests]
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: '17'
|
||||
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v6
|
||||
with:
|
||||
validate-wrappers: true
|
||||
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTED_KEY }}
|
||||
|
||||
- name: Grant Execute Permission for Gradlew
|
||||
run: chmod +x gradlew
|
||||
|
||||
- name: Compile release Kotlin
|
||||
run: ./gradlew compileReleaseKotlin
|
||||
|
||||
# ─────────────────────────────────────────────────────────────────────
|
||||
# Job 6: Instrumented tests — runs on Android emulator.
|
||||
# Job 5: Instrumented tests — runs on Android emulator.
|
||||
# Required for Compose UI tests (TEST-09, TEST-14) and Navigation3 tests
|
||||
# that need a real Activity lifecycle. Cannot run on JVM.
|
||||
# ─────────────────────────────────────────────────────────────────────
|
||||
@@ -289,11 +256,11 @@ jobs:
|
||||
retention-days: 7
|
||||
|
||||
# ─────────────────────────────────────────────────────────────────────
|
||||
# Job 7: PR status summary — aggregates all checks.
|
||||
# Job 6: PR status summary — aggregates all checks.
|
||||
# ─────────────────────────────────────────────────────────────────────
|
||||
ci-summary:
|
||||
name: CI Summary
|
||||
needs: [ktlint, android-lint, unit-tests, build, release-compile]
|
||||
needs: [ktlint, android-lint, unit-tests, build]
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 2
|
||||
if: always()
|
||||
@@ -304,10 +271,9 @@ jobs:
|
||||
LINT_RESULT: ${{ needs.android-lint.result }}
|
||||
TEST_RESULT: ${{ needs.unit-tests.result }}
|
||||
BUILD_RESULT: ${{ needs.build.result }}
|
||||
RELEASE_COMPILE_RESULT: ${{ needs.release-compile.result }}
|
||||
run: |
|
||||
FAILED=0
|
||||
for entry in "ktlint:$KTLINT_RESULT" "android-lint:$LINT_RESULT" "unit-tests:$TEST_RESULT" "build:$BUILD_RESULT" "release-compile:$RELEASE_COMPILE_RESULT"; do
|
||||
for entry in "ktlint:$KTLINT_RESULT" "android-lint:$LINT_RESULT" "unit-tests:$TEST_RESULT" "build:$BUILD_RESULT"; do
|
||||
name="${entry%%:*}"
|
||||
result="${entry#*:}"
|
||||
echo "::notice::$name = $result"
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
name: Label PR merge conflicts
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened, ready_for_review]
|
||||
|
||||
jobs:
|
||||
label-conflict:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
pull-requests: write
|
||||
contents: read
|
||||
steps:
|
||||
- name: Get PR data and label conflicts
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const pr = context.payload.pull_request;
|
||||
const prNumber = pr.number;
|
||||
const repo = context.repo;
|
||||
|
||||
// Fetch PR details to get mergeable_state
|
||||
const { data: prData } = await github.rest.pulls.get({
|
||||
...repo,
|
||||
pull_number: prNumber
|
||||
});
|
||||
|
||||
const mergeableState = prData.mergeable_state; // clean, dirty, blocked, unstable
|
||||
const hasConflict = mergeableState === 'dirty';
|
||||
|
||||
const labelName = 'merge-conflict';
|
||||
|
||||
// Get current labels
|
||||
const { data: labels } = await github.rest.issues.listLabelsOnIssue({
|
||||
...repo,
|
||||
issue_number: prNumber
|
||||
});
|
||||
const hasLabel = labels.some(l => l.name === labelName);
|
||||
|
||||
if (hasConflict && !hasLabel) {
|
||||
console.log(`PR #${prNumber} has merge conflicts. Adding label '${labelName}'.`);
|
||||
await github.rest.issues.addLabels({
|
||||
...repo,
|
||||
issue_number: prNumber,
|
||||
labels: [labelName]
|
||||
});
|
||||
} else if (!hasConflict && hasLabel) {
|
||||
console.log(`PR #${prNumber} no longer has merge conflicts. Removing label '${labelName}'.`);
|
||||
await github.rest.issues.removeLabel({
|
||||
...repo,
|
||||
issue_number: prNumber,
|
||||
name: labelName
|
||||
});
|
||||
} else {
|
||||
console.log(`PR #${prNumber}: conflict=${hasConflict}, label=${hasLabel}. No change needed.`);
|
||||
}
|
||||
Reference in new issue
Block a user