Skip to content

feat: add ai terminal settings#12208

Closed
ssongliu wants to merge 1 commit into
dev-v2from
feat/ai-terminal-settings
Closed

feat: add ai terminal settings#12208
ssongliu wants to merge 1 commit into
dev-v2from
feat/ai-terminal-settings

Conversation

@ssongliu
Copy link
Copy Markdown
Member

No description provided.

@f2c-ci-robot
Copy link
Copy Markdown

f2c-ci-robot Bot commented Mar 18, 2026

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@f2c-ci-robot
Copy link
Copy Markdown

f2c-ci-robot Bot commented Mar 18, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign zhengkunwang223 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 965da167fe

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +240 to +243
func normalizeModelID(model string) string {
model = strings.TrimSpace(model)
if parts := strings.SplitN(model, "/", 2); len(parts) == 2 {
return parts[1]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve slash-containing custom model IDs

Custom/vLLM accounts keep the user-entered model name verbatim except for an optional leading custom/ (agent/app/service/agents.go:2299), so IDs like meta-llama/Llama-3.1-8B-Instruct are valid. This helper strips everything before the first slash for every provider, which turns those common repo-style model IDs into Llama-3.1-8B-Instruct and makes the terminal feature send a model name the backend does not recognize.

Useful? React with 👍 / 👎.

Comment on lines +138 to +142
httpReq, err := http.NewRequestWithContext(ctx, http.MethodPost, buildChatCompletionsURL(c.config.BaseURL), bytes.NewReader(body))
if err != nil {
return nil, fmt.Errorf("create request: %w", err)
}
httpReq.Header.Set("Authorization", "Bearer "+strings.TrimSpace(c.config.APIKey))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Limit terminal AI to OpenAI-compatible providers

The terminal client always posts an OpenAI Chat Completions request to /v1/chat/completions and authenticates with Authorization: Bearer ..., but the settings UI accepts every saved agent account. Supported providers like anthropic and gemini use different verified APIs in agent/app/provider/verify.go (x-api-key/anthropic-version and :generateContent respectively), so selecting those accounts saves successfully but every AI terminal request will fail at runtime.

Useful? React with 👍 / 👎.

Comment on lines +177 to +181
if (!value) {
callback(new Error(i18n.global.t('commons.rule.requiredSelect')));
return;
}
callback();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject unverified agent accounts here

This validator only checks that an account ID is present. However, agent/utils/terminal/ai/config_runtime.go:138-146 rejects any selected account with Verified == false unless the provider skips verification, so choosing one of the N/A entries in this list leaves the UI in an “enabled” state while new terminals silently disable the interceptor instead of generating commands.

Useful? React with 👍 / 👎.

Comment on lines +156 to +160
if isEnterInput(decodeBytes) {
if generated, ok := sws.aiInterceptor.HandleEnter(); ok {
sws.sendWebsocketInputCommandToSshSessionStdinPipe(append([]byte{lineClearControl}, []byte(generated)...))
continue
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Consume AI-triggered Enter when generation fails

This branch falls back to sending the original Enter to the shell whenever HandleEnter() returns ok == false, but that method also returns false for AI-side failures (refresh errors, generator creation errors, request timeouts, empty prompts). Because the prefix field accepts any visible ASCII token, a failed //ai ... request becomes an attempted /ai execution on Unix instead of being safely swallowed; the same issue exists in ws_local_session.go.

Useful? React with 👍 / 👎.

@ssongliu ssongliu closed this Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants