Skip to content

Commit 96a3b20

Browse files
fix: address review feedback on Bitbucket credentials
- Key the credentials form by environment so drafts never carry over and get saved to a different environment. - Clear a saved token field on focus instead of stripping the mask prefix from typed input, which could truncate a real token. - Provide settings to BitbucketApi in the title evaluation script. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent b145016 commit 96a3b20

3 files changed

Lines changed: 10 additions & 13 deletions

File tree

‎apps/server/scripts/evaluate-thread-titles.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import * as GitLabCli from "../src/sourceControl/GitLabCli.ts";
2828
import * as ForgejoCli from "../src/sourceControl/ForgejoCli.ts";
2929
import * as AzureDevOpsCli from "../src/sourceControl/AzureDevOpsCli.ts";
3030
import * as BitbucketApi from "../src/sourceControl/BitbucketApi.ts";
31+
import * as ServerSettings from "../src/serverSettings.ts";
3132
import * as VcsProcess from "../src/vcs/VcsProcess.ts";
3233
import * as VcsDriverRegistry from "../src/vcs/VcsDriverRegistry.ts";
3334
import * as VcsProjectConfig from "../src/vcs/VcsProjectConfig.ts";
@@ -155,7 +156,8 @@ await Effect.runPromise(
155156
GitLabCli.layer,
156157
ForgejoCli.layer,
157158
AzureDevOpsCli.layer,
158-
BitbucketApi.layer,
159+
// No saved credentials here; Bitbucket falls back to T3CODE_BITBUCKET_* variables.
160+
BitbucketApi.layer.pipe(Layer.provide(ServerSettings.layerTest())),
159161
),
160162
),
161163
Layer.provide(VcsDriverRegistry.layer.pipe(Layer.provide(VcsProjectConfig.layer))),

‎apps/web/src/components/settings/BitbucketCredentialsSettings.tsx‎

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ function savedMethod(saved: BitbucketSettings): CredentialMethod | null {
4747
}
4848

4949
/**
50-
* A write-only token field. A saved token shows as a filled password field; typing replaces
51-
* it, and leaving the field empty restores the saved one. `draft` is null until edited.
50+
* A write-only token field. A saved token shows as a filled password field; focusing it starts
51+
* a fresh token, and leaving that empty restores the saved one. `draft` is null until edited.
5252
*/
5353
function TokenInput({
5454
id,
@@ -70,17 +70,10 @@ function TokenInput({
7070
size="sm"
7171
placeholder={isSaved ? undefined : "Not set"}
7272
value={masked ? SAVED_TOKEN_MASK : (draft ?? "")}
73-
onFocus={(event) => {
74-
if (masked) event.target.select();
75-
}}
76-
onChange={(event) => {
77-
const value = event.target.value;
78-
if (!masked) return onDraftChange(value);
79-
// Typing at the end of the mask, or deleting into it, starts a fresh token.
80-
if (value.startsWith(SAVED_TOKEN_MASK))
81-
return onDraftChange(value.slice(SAVED_TOKEN_MASK.length));
82-
onDraftChange(SAVED_TOKEN_MASK.startsWith(value) ? "" : value);
73+
onFocus={() => {
74+
if (masked) onDraftChange("");
8375
}}
76+
onChange={(event) => onDraftChange(event.target.value)}
8477
onBlur={() => {
8578
if (isSaved && draft === "") onDraftChange(null);
8679
}}

‎apps/web/src/components/settings/SourceControlSettings.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,8 @@ export function SourceControlSettingsPanel() {
597597
{item.kind === "bitbucket" ? (
598598
<SettingsSearchTarget id={searchableSetting("bitbucket-credentials").id}>
599599
<BitbucketCredentialsSettings
600+
// Drafts belong to one environment; switching must not carry them over.
601+
key={environmentId}
600602
environmentId={environmentId}
601603
onSaved={handleScan}
602604
/>

0 commit comments

Comments
 (0)