Skip to content

Commit 4d22771

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix(pi): preserve update PR BYOK after staging rebase
1 parent eef857f commit 4d22771

3 files changed

Lines changed: 23 additions & 9 deletions

File tree

apps/sim/blocks/blocks/pi.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,20 @@ describe('Pi cloud authoring surface', () => {
242242
babysitMode: true,
243243
})
244244
).toBe(false)
245+
expect(
246+
evaluateSubBlockCondition(prState?.condition, {
247+
mode: 'cloud_branch',
248+
babysitMode: 'true',
249+
})
250+
).toBe(false)
245251
expect(PiBlock.inputs.prState).toBeDefined()
246252
})
253+
254+
it.each(['cloud', 'cloud_branch'])(
255+
'always shows the model API key for sandbox authoring mode %s',
256+
(mode) => {
257+
const apiKey = PiBlock.subBlocks.find((subBlock) => subBlock.id === 'apiKey')
258+
expect(evaluateSubBlockCondition(apiKey?.condition, { mode })).toBe(true)
259+
}
260+
)
247261
})

apps/sim/blocks/blocks/pi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ const hostedModelApiKeyCondition = getApiKeyCondition()
153153
* rule and hide the field when Sim covers the key.
154154
*/
155155
const piApiKeyCondition = (values?: Record<string, unknown>) =>
156-
isPiByokOnlyMode(values?.mode) ? CLOUD : hostedModelApiKeyCondition(values)
156+
isPiByokOnlyMode(values?.mode) ? CLOUD_AUTHORING : hostedModelApiKeyCondition(values)
157157

158158
export const PiBlock: BlockConfig<PiResponse> = {
159159
type: 'pi',

apps/sim/providers/pi-providers.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ export function isPiSupportedProvider(providerId: string): providerId is PiSuppo
2929

3030
/**
3131
* Whether a Pi block mode hands the model API key into the sandbox and
32-
* therefore always requires the user's own key. Create PR ('cloud') runs the
33-
* model client inside the sandbox, so Sim never supplies a hosted key for it:
34-
* the block always shows the API Key field, copilot validation never strips
35-
* it, and execution requires BYOK. Review Code and Local Dev keep the model
36-
* client in Sim and follow the normal hosted-key rules. All three enforcement
37-
* sites (block condition, edit-workflow validation, key resolution) consume
38-
* this predicate so they cannot drift.
32+
* therefore always requires the user's own key. Create PR ('cloud') and Update
33+
* PR ('cloud_branch') run the model client inside the sandbox, so Sim never
34+
* supplies a hosted key for them: the block always shows the API Key field,
35+
* copilot validation never strips it, and execution requires BYOK. Review Code
36+
* and Local Dev keep the model client in Sim and follow the normal hosted-key
37+
* rules. All three enforcement sites (block condition, edit-workflow
38+
* validation, key resolution) consume this predicate so they cannot drift.
3939
*/
4040
export function isPiByokOnlyMode(mode: unknown): boolean {
41-
return mode === 'cloud'
41+
return mode === 'cloud' || mode === 'cloud_branch'
4242
}
4343

4444
/** Returns Pi's provider ID for a supported Sim provider. */

0 commit comments

Comments
 (0)