Skip to content

feat: add channel API address column#6079

Open
poneding wants to merge 1 commit into
QuantumNous:mainfrom
poneding:feat/channel-api-address-column
Open

feat: add channel API address column#6079
poneding wants to merge 1 commit into
QuantumNous:mainfrom
poneding:feat/channel-api-address-column

Conversation

@poneding

@poneding poneding commented Jul 10, 2026

Copy link
Copy Markdown

#6077

⚠️ 提交说明 / PR Notice

Important

  • 请提供人工撰写的简洁摘要,避免直接粘贴未经整理的 AI 输出。

📝 变更描述 / Description

本 PR 在渠道列表中新增可选的 API 地址 列,用于展示渠道配置的 base_url

实现上,新增列使用现有表格列配置接入,位置放在 类型 / Type状态 / Status 之间;同时在渠道表格的 initialColumnVisibility 中将 base_url 默认设为隐藏,因此它会先出现在“切换列”菜单中,用户勾选后才显示到列表里。

地址渲染逻辑单独抽到 formatChannelApiAddress:空地址显示为 -http/https 地址会作为链接在新标签页打开,非 http/https 地址仅按文本展示,避免把不安全协议写入可点击链接。敏感信息隐藏状态下,该列也会显示掩码,保持与渠道列表现有敏感信息展示逻辑一致。

本次实现由 AI 协助完成,并经过整理、验证后提交。

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix) - 请关联对应 Issue,避免将设计取舍、理解偏差或预期不一致直接归类为 bug
  • ✨ 新功能 (New feature) - 重大特性建议先通过 Issue 沟通
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

🔗 关联任务 / Related Issue

✅ 提交前检查项 / Checklist

  • 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • 非重复提交: 我已搜索现有的 IssuesPRs,确认不是重复提交。
  • Bug fix 说明: 若此 PR 标记为 Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。
  • 变更理解: 我已理解这些更改的工作原理及可能影响。
  • 范围聚焦: 本 PR 未包含任何与当前任务无关的代码改动。
  • 本地验证: 已在本地运行并通过测试或手动验证,维护者可以据此复核结果。
  • 安全合规: 代码中无敏感凭据,且符合项目代码规范。

📸 运行证明 / Proof of Work

$ npx --yes tsx --test src/features/channels/lib/channel-api-address.test.ts

✔ returns null for empty channel base URLs
✔ trims visible API addresses and uses the same value as the link target
✔ does not create link targets for non-http API addresses

tests 3
pass 3
fail 0

Summary by CodeRabbit

  • New Features

    • Added an API address column to the channels table.
    • API addresses are displayed with masking, truncation, tooltips, and clickable links when valid.
    • The column is hidden by default and can be enabled through table settings.
  • Bug Fixes

    • Invalid or unsafe API addresses are shown without clickable links.
    • Whitespace and empty API address values are handled consistently.
  • Tests

    • Added coverage for valid, empty, whitespace-only, and unsafe API addresses.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Adds an optional, hidden-by-default Base URL column to the channel table. API addresses are trimmed, validated for HTTP(S) links, displayed with sensitive-data handling, and tested for empty, valid, and non-HTTP inputs.

Changes

Channel API address column

Layer / File(s) Summary
API address formatting contract
web/default/src/features/channels/lib/channel-api-address.ts, web/default/src/features/channels/lib/channel-api-address.test.ts, web/default/src/features/channels/lib/index.ts
Defines and exports formatChannelApiAddress, which trims values, handles empty input, restricts link targets to HTTP(S), and tests these behaviors.
Channel table address column
web/default/src/features/channels/components/channels-columns.tsx, web/default/src/features/channels/components/channels-table.tsx
Adds the Base URL column with masking, tooltips, truncated external links, and row-click handling; the column is hidden by default.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Poem

I’m a bunny with URLs tucked neat,
Trimmed and tested, crisp and sweet.
Hidden at first, then shown on cue,
Safe little links hop into view.
Thump, thump—new columns grew!

🚥 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 clearly and concisely describes the main change: adding a channel API address column.
Linked Issues check ✅ Passed The PR adds the optional API address column between Type and Status, hides it by default, and makes HTTP(S) values clickable; empty values show '-'.
Out of Scope Changes check ✅ Passed The changes appear limited to the API address column, its formatting utility, tests, and table wiring.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@web/default/src/features/channels/lib/channel-api-address.test.ts`:
- Around line 1-2: Replace the node:test and node:assert/strict imports in
channel-api-address.test.ts with Vitest imports, using describe, test, and
appropriate expect assertions; update all assertions accordingly so the tests
run under the project’s standard Vitest runner.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d3466200-cd66-4dcd-8d50-fa85f7dd9f46

📥 Commits

Reviewing files that changed from the base of the PR and between 4e57038 and 0deb45e.

📒 Files selected for processing (5)
  • web/default/src/features/channels/components/channels-columns.tsx
  • web/default/src/features/channels/components/channels-table.tsx
  • web/default/src/features/channels/lib/channel-api-address.test.ts
  • web/default/src/features/channels/lib/channel-api-address.ts
  • web/default/src/features/channels/lib/index.ts

Comment on lines +1 to +2
import assert from 'node:assert/strict'
import { describe, test } from 'node:test'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Use Vitest instead of node:test per project conventions.

The coding guidelines for web/default/**/*.test.ts require unit tests to be written with Vitest. Using node:test and node:assert/strict means these tests won't run under the project's standard Vitest-based test runner and may be silently skipped in CI.

As per coding guidelines: web/default/**/*.test.ts: Write unit tests for utility functions and pure logic with Vitest.

♻️ Proposed fix: migrate to Vitest
-import assert from 'node:assert/strict'
-import { describe, test } from 'node:test'
+import { describe, it, expect } from 'vitest'

 import { formatChannelApiAddress } from './channel-api-address'

 describe('channel API address formatting', () => {
-  test('returns null for empty channel base URLs', () => {
-    assert.equal(formatChannelApiAddress(null), null)
-    assert.equal(formatChannelApiAddress(undefined), null)
-    assert.equal(formatChannelApiAddress('   '), null)
+  it('returns null for empty channel base URLs', () => {
+    expect(formatChannelApiAddress(null)).toBeNull()
+    expect(formatChannelApiAddress(undefined)).toBeNull()
+    expect(formatChannelApiAddress('   ')).toBeNull()
   })

-  test('trims visible API addresses and uses the same value as the link target', () => {
-    assert.deepEqual(formatChannelApiAddress('  https://api.example.com  '), {
+  it('trims visible API addresses and uses the same value as the link target', () => {
+    expect(formatChannelApiAddress('  https://api.example.com  ')).toEqual({
       displayText: 'https://api.example.com',
       href: 'https://api.example.com',
     })
   })

-  test('does not create link targets for non-http API addresses', () => {
-    assert.deepEqual(formatChannelApiAddress('javascript:alert(1)'), {
+  it('does not create link targets for non-http API addresses', () => {
+    expect(formatChannelApiAddress('javascript:alert(1)')).toEqual({
       displayText: 'javascript:alert(1)',
       href: null,
     })
   })
 })
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import assert from 'node:assert/strict'
import { describe, test } from 'node:test'
import { describe, it, expect } from 'vitest'
import { formatChannelApiAddress } from './channel-api-address'
describe('channel API address formatting', () => {
it('returns null for empty channel base URLs', () => {
expect(formatChannelApiAddress(null)).toBeNull()
expect(formatChannelApiAddress(undefined)).toBeNull()
expect(formatChannelApiAddress(' ')).toBeNull()
})
it('trims visible API addresses and uses the same value as the link target', () => {
expect(formatChannelApiAddress(' https://api.example.com ')).toEqual({
displayText: 'https://api.example.com',
href: 'https://api.example.com',
})
})
it('does not create link targets for non-http API addresses', () => {
expect(formatChannelApiAddress('javascript:alert(1)')).toEqual({
displayText: 'javascript:alert(1)',
href: null,
})
})
})
🤖 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 `@web/default/src/features/channels/lib/channel-api-address.test.ts` around
lines 1 - 2, Replace the node:test and node:assert/strict imports in
channel-api-address.test.ts with Vitest imports, using describe, test, and
appropriate expect assertions; update all assertions accordingly so the tests
run under the project’s standard Vitest runner.

Source: Coding guidelines

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.

Add optional API address column to channel list

1 participant