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
@@ -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