Skip to content

Commit 9bbddda

Browse files
committed
fix(gateway): 对齐计划审批错误码
保留计划审批拒绝当前 revision 后隐藏的产品语义,并将 Web 文案调整为需要修改。
1 parent 5d69183 commit 9bbddda

4 files changed

Lines changed: 26 additions & 10 deletions

File tree

internal/gateway/protocol/jsonrpc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1544,7 +1544,7 @@ func decodeApprovePlanParams(raw json.RawMessage) (ApprovePlanParams, *JSONRPCEr
15441544
return NewJSONRPCError(JSONRPCCodeInvalidParams, "missing required field: params.plan_id", GatewayCodeMissingRequiredField)
15451545
}
15461546
if p.Revision <= 0 {
1547-
return NewJSONRPCError(JSONRPCCodeInvalidParams, "invalid field: params.revision", GatewayCodeInvalidFrame)
1547+
return NewJSONRPCError(JSONRPCCodeInvalidParams, "invalid field: params.revision", GatewayCodeInvalidAction)
15481548
}
15491549
return nil
15501550
})

internal/gateway/protocol/jsonrpc_test.go

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -343,12 +343,25 @@ func TestNormalizeJSONRPCRequestApprovePlan(t *testing.T) {
343343
})
344344

345345
tests := []struct {
346-
name string
347-
params string
346+
name string
347+
params string
348+
wantGatewayCode string
348349
}{
349-
{name: "missing session", params: `{"session_id":" ","plan_id":"plan-1","revision":1}`},
350-
{name: "missing plan", params: `{"session_id":"session-1","plan_id":" ","revision":1}`},
351-
{name: "invalid revision", params: `{"session_id":"session-1","plan_id":"plan-1","revision":0}`},
350+
{
351+
name: "missing session",
352+
params: `{"session_id":" ","plan_id":"plan-1","revision":1}`,
353+
wantGatewayCode: GatewayCodeMissingRequiredField,
354+
},
355+
{
356+
name: "missing plan",
357+
params: `{"session_id":"session-1","plan_id":" ","revision":1}`,
358+
wantGatewayCode: GatewayCodeMissingRequiredField,
359+
},
360+
{
361+
name: "invalid revision",
362+
params: `{"session_id":"session-1","plan_id":"plan-1","revision":0}`,
363+
wantGatewayCode: GatewayCodeInvalidAction,
364+
},
352365
}
353366
for _, tt := range tests {
354367
t.Run(tt.name, func(t *testing.T) {
@@ -361,6 +374,9 @@ func TestNormalizeJSONRPCRequestApprovePlan(t *testing.T) {
361374
if rpcErr == nil || rpcErr.Code != JSONRPCCodeInvalidParams {
362375
t.Fatalf("expected invalid params error, got %#v", rpcErr)
363376
}
377+
if gatewayCode := GatewayCodeFromJSONRPCError(rpcErr); gatewayCode != tt.wantGatewayCode {
378+
t.Fatalf("gateway_code = %q, want %q", gatewayCode, tt.wantGatewayCode)
379+
}
364380
})
365381
}
366382
}

web/src/components/chat/ChatPanel.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ describe('ChatPanel', () => {
341341
expect(screen.getByText('计划审批')).toBeInTheDocument()
342342
expect(screen.getByRole('button', { name: / bypass / })).toBeInTheDocument()
343343
expect(screen.getByRole('button', { name: / default / })).toBeInTheDocument()
344-
expect(screen.getByRole('button', { name: /\// })).toBeInTheDocument()
344+
expect(screen.getByRole('button', { name: // })).toBeInTheDocument()
345345
})
346346

347347
it('approves plan with bypass mode and starts build run', async () => {
@@ -398,13 +398,13 @@ describe('ChatPanel', () => {
398398
expect(useChatStore.getState().permissionMode).toBe('default')
399399
})
400400

401-
it('dismisses current plan revision and shows again for a new revision', async () => {
401+
it('rejects current plan revision and shows approval again for a new revision', async () => {
402402
useChatStore.setState({
403403
messages: [draftPlanMessage(1)],
404404
} as any)
405405

406406
render(<ChatPanel />)
407-
fireEvent.click(screen.getByRole('button', { name: /\// }))
407+
fireEvent.click(screen.getByRole('button', { name: // }))
408408

409409
await waitFor(() => {
410410
expect(screen.queryByText('计划审批')).not.toBeInTheDocument()

web/src/components/chat/ChatPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ export default function ChatPanel() {
684684
className="permission-btn reject"
685685
style={{ opacity: isApprovingPlan ? 0.6 : 1 }}
686686
>
687-
<X size={13} /> 拒绝/其它想法
687+
<X size={13} /> 需要修改
688688
</button>
689689
<button
690690
onClick={() => handleApprovePlan('default')}

0 commit comments

Comments
 (0)