Skip to content

Automatically detect v1 endpoint on base URL input#1167

Merged
GT-610 merged 1 commit into
mainfrom
fix-ask-ai-endpoint-normalization
May 11, 2026
Merged

Automatically detect v1 endpoint on base URL input#1167
GT-610 merged 1 commit into
mainfrom
fix-ask-ai-endpoint-normalization

Conversation

@GT-610
Copy link
Copy Markdown
Collaborator

@GT-610 GT-610 commented May 11, 2026

Related to #1165.

Summary by CodeRabbit

  • Improvements

    • Redesigned AI settings UI with clearer "API Endpoint" labeling and helper instructions explaining endpoint configuration options.
    • Added multilingual support for AI endpoint setup guidance in English, Chinese, and Traditional Chinese.
  • Configuration

    • Updated default AI model to gpt-5.4-mini.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 11, 2026

📝 Walkthrough

Walkthrough

This PR adds flexible AI endpoint configuration by introducing a URI normalization method that automatically completes Chat Completions endpoint URLs. The new composeChatCompletionsUri() method handles three cases: appending /v1/chat/completions for service root URLs, appending /chat/completions for existing /v1 endpoints, and leaving complete endpoints unchanged. The default AI model is updated to gpt-5.4-mini, localization strings are added to explain the endpoint behavior, and the settings UI is enhanced to display contextual help text. Tool-call description extraction is refined to prefer explicit description fields, and exception handling is reformatted for clarity.

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: implementing automatic detection and handling of the v1 endpoint when users provide a base URL, which is the core functionality added via the composeChatCompletionsUri helper across all modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-ask-ai-endpoint-normalization

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
test/ask_ai_repository_test.dart (1)

4-36: 💤 Low value

LGTM!

Good test coverage for the three main endpoint scenarios. The tests verify the core functionality of composeChatCompletionsUri.

Consider adding edge case tests for trailing slashes (e.g., https://api.openai.com/v1/) and URLs with ports to increase confidence in the implementation.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/ask_ai_repository_test.dart` around lines 4 - 36, Add tests covering
edge cases for trailing slashes and URLs with ports to ensure
AskAiRepository.composeChatCompletionsUri handles them correctly; specifically,
add one test that passes a base URL ending with a trailing slash (e.g.,
'https://api.openai.com/v1/') and asserts the result is
'.../v1/chat/completions', and another test that passes a URL with an explicit
port (e.g., 'https://localhost:8080') and asserts the port is preserved in the
composed URI; locate the tests alongside the existing group that references
AskAiRepository.composeChatCompletionsUri and follow the same test structure and
expectations.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@test/ask_ai_repository_test.dart`:
- Around line 4-36: Add tests covering edge cases for trailing slashes and URLs
with ports to ensure AskAiRepository.composeChatCompletionsUri handles them
correctly; specifically, add one test that passes a base URL ending with a
trailing slash (e.g., 'https://api.openai.com/v1/') and asserts the result is
'.../v1/chat/completions', and another test that passes a URL with an explicit
port (e.g., 'https://localhost:8080') and asserts the port is preserved in the
composed URI; locate the tests alongside the existing group that references
AskAiRepository.composeChatCompletionsUri and follow the same test structure and
expectations.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 3a687081-22bb-4dab-adc2-eafa42e3b5a8

📥 Commits

Reviewing files that changed from the base of the PR and between bf03933 and ba0ee1f.

⛔ Files ignored due to path filters (15)
  • lib/generated/l10n/l10n.dart is excluded by !**/generated/**
  • lib/generated/l10n/l10n_de.dart is excluded by !**/generated/**
  • lib/generated/l10n/l10n_en.dart is excluded by !**/generated/**
  • lib/generated/l10n/l10n_es.dart is excluded by !**/generated/**
  • lib/generated/l10n/l10n_fr.dart is excluded by !**/generated/**
  • lib/generated/l10n/l10n_id.dart is excluded by !**/generated/**
  • lib/generated/l10n/l10n_it.dart is excluded by !**/generated/**
  • lib/generated/l10n/l10n_ja.dart is excluded by !**/generated/**
  • lib/generated/l10n/l10n_ko.dart is excluded by !**/generated/**
  • lib/generated/l10n/l10n_nl.dart is excluded by !**/generated/**
  • lib/generated/l10n/l10n_pt.dart is excluded by !**/generated/**
  • lib/generated/l10n/l10n_ru.dart is excluded by !**/generated/**
  • lib/generated/l10n/l10n_tr.dart is excluded by !**/generated/**
  • lib/generated/l10n/l10n_uk.dart is excluded by !**/generated/**
  • lib/generated/l10n/l10n_zh.dart is excluded by !**/generated/**
📒 Files selected for processing (7)
  • lib/data/provider/ai/ask_ai.dart
  • lib/data/store/setting.dart
  • lib/l10n/app_en.arb
  • lib/l10n/app_zh.arb
  • lib/l10n/app_zh_tw.arb
  • lib/view/page/setting/entries/ai.dart
  • test/ask_ai_repository_test.dart

@GT-610 GT-610 merged commit 1e759c2 into main May 11, 2026
3 checks passed
@GT-610 GT-610 deleted the fix-ask-ai-endpoint-normalization branch May 11, 2026 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant