Skip to content

feat: init public resources - #180

Merged
qdaxb merged 3 commits into
mainfrom
update_public_resource
Jan 19, 2026
Merged

qdaxb merged 3 commits into
mainfrom
update_public_resource

Conversation

@qdaxb

@qdaxb qdaxb commented Jan 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Public resources expanded to include Ghost, Bot, and Team with new default entries (e.g., Wegent resources) available system-wide.
    • UI: Team badges (Personal / Group namespace) in quick-access cards and dropdown; mobile and desktop model selectors show a "personal" badge for user models.
  • Refactor

    • Initialization streamlined to a single public-resource workflow with ordered application to satisfy cross-resource references; removed legacy admin post-processing.
  • Chores

    • Default team config values updated to new Wegent defaults.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Jan 19, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Refactors public resource initialization to support multiple kinds (Shell, Ghost, Bot, Team). Renames apply_public_shells → apply_public_resources, adds kind filtering and unified public-resource processing (user_id=0), applies skills first, and updates config/defaults and public resource YAML entries.

Changes

Cohort / File(s) Summary
Core YAML initialization
backend/app/core/yaml_init.py
Renamed apply_public_shells → apply_public_resources; added kind filtering and dynamic kind handling; unified public-resource collection (user_id=0); apply skills first then resources in order (Shell, Ghost, Bot, Team); removed admin default-user post-processing; adjusted logs/results payload keys.
Public resources YAML
backend/init_data/02-public-resources.yaml
Header updated to "Public resources (Ghost, Bot, Team) - accessible by all users (user_id=0)"; added Ghost wegent-knowledge, Bot wegent-knowledge-bot, Team wegent-notebook; renamed chat-team → wegent-chat and added displayName.
Config & env defaults
backend/app/core/config.py, backend/.env.example
Updated default team keys: DEFAULT_TEAM_CHAT → wegent-chat#default, DEFAULT_TEAM_CODE → wegent-notebook#default; .env.example values changed accordingly.
Frontend — Quick access / team UI
frontend/src/features/tasks/components/chat/QuickAccessCards.tsx
Exclude defaultTeam from dropdown items; add isPersonalTeam/isGroupTeam helpers; render Personal vs Group badges in cards and dropdown; adjust dropdownTeams usage and search/reset behavior.
Frontend — Model selectors
frontend/src/features/tasks/components/selector/ModelSelector.tsx, frontend/src/features/tasks/components/selector/MobileModelSelector.tsx
Change tag logic: show "个人" (personal) tag for model.type === 'user'; removed public tag from default item; MobileModelSelector adds small personal badge for user-type models.

Sequence Diagram(s)

(Skipped — changes are primarily refactor/initialization and UI tweaks without a new multi-component sequential runtime flow warranting a diagram.)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • cc-yafei
  • feifei325

Poem

🐰
I hopped through YAML, tidy and spry,
Shells, Ghosts, Bots, Teams now under one sky.
Public resources gathered, ordered, and neat,
Cross-linked and ready — a rabbit's small feat. 🥕✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: init public resources' directly corresponds to the main objective of the PR, which initializes public resources (Ghost, Bot, Team) with updated handling in the YAML initialization system.
Docstring Coverage ✅ Passed Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing touches
  • 📝 Generate docstrings

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 and usage tips.

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
backend/app/core/yaml_init.py (1)

541-609: Resource totals can overcount when unsupported kinds are present.
public_resources includes all docs, but apply_public_resources skips unsupported kinds without emitting results, so resources_failed can be inflated. Consider basing totals on public_results (processed items) or emitting explicit “skipped” entries for unsupported kinds.

🔧 Proposed adjustment (counts based on processed resources)
-    total_resources = len(public_resources) + len(skill_results)
+    total_resources = len(public_results) + len(skill_results)
🤖 Fix all issues with AI agents
In `@backend/app/core/yaml_init.py`:
- Around line 205-219: Add tracing to the module by importing trace_sync from
shared.telemetry.decorators and decorating each top-level synchronous
initialization entrypoint with `@trace_sync`(span_name="...",
tracer_name="backend.yaml_init"); specifically add the import and apply the
decorator to the apply_public_resources function and to the two other public
sync init functions in this file (the remaining two top-level initialization
entrypoints), using descriptive span names for each (e.g.,
span_name="yaml_init.apply_public_resources") while keeping
tracer_name="backend.yaml_init".
🧹 Nitpick comments (2)
backend/app/core/yaml_init.py (2)

343-345: Prefer logger.exception to retain stack traces.
Line 344 is in an exception path; logger.exception(...) is the idiomatic way to include the traceback automatically.

🔧 Proposed change
-        except Exception as e:
-            logger.error(f"Failed to process public {kind}: {e}")
+        except Exception as e:
+            logger.exception(f"Failed to process public {kind}: {e}")

614-628: Document the intentionally-unused skip_lock parameter.
This keeps the backward-compatible signature while silencing lint noise.

🔧 Proposed change
 def run_yaml_initialization(db: Session, skip_lock: bool = False) -> Dict[str, Any]:
+    _ = skip_lock  # deprecated; kept for backward compatibility

Comment on lines +205 to 219
def apply_public_resources(
db: Session, resources: List[Dict[str, Any]], force: bool = False
) -> List[Dict[str, Any]]:
"""
Apply public shell resources to the kinds table (user_id=0).
Only creates new shells, skips existing ones (create-only mode).
Apply public resources (Shell, Ghost, Bot, Team) to the kinds table (user_id=0).
Only creates new resources, skips existing ones (create-only mode).

Args:
db: Database session
resources: List of Shell resource documents
force: If True, delete existing shells and recreate them
resources: List of resource documents (Shell, Ghost, Bot, Team)
force: If True, delete existing resources and recreate them

Returns:
List of operation results
"""

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.

🛠️ Refactor suggestion | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, let's see the file structure and examine the specified line ranges
wc -l backend/app/core/yaml_init.py

Repository: wecode-ai/Wegent

Length of output: 93


🏁 Script executed:

# View the functions at the specified lines
cat -n backend/app/core/yaml_init.py | sed -n '200,225p'

Repository: wecode-ai/Wegent

Length of output: 1016


🏁 Script executed:

# View lines 501-518
cat -n backend/app/core/yaml_init.py | sed -n '495,525p'

Repository: wecode-ai/Wegent

Length of output: 1404


🏁 Script executed:

# View lines 614-621
cat -n backend/app/core/yaml_init.py | sed -n '610,630p'

Repository: wecode-ai/Wegent

Length of output: 946


🏁 Script executed:

# Check for any existing `@trace_sync` or `@trace_async` decorators in the file
rg '@trace_sync|@trace_async' backend/app/core/yaml_init.py

Repository: wecode-ai/Wegent

Length of output: 42


🏁 Script executed:

# Check import statements to see if tracing is imported
head -50 backend/app/core/yaml_init.py | cat -n

Repository: wecode-ai/Wegent

Length of output: 1770


🏁 Script executed:

# Search for any tracing imports in the entire file
rg 'trace_sync|trace_async|from.*tracing|import.*tracing' backend/app/core/yaml_init.py

Repository: wecode-ai/Wegent

Length of output: 42


🏁 Script executed:

# Check if trace_sync decorator exists in the codebase
fd -t f '*.py' backend/app | xargs rg -l 'def trace_sync|trace_sync ='

Repository: wecode-ai/Wegent

Length of output: 391


🏁 Script executed:

# Look for where tracing decorators are defined/exported
fd -t f '*.py' backend | xargs rg -l '@trace_sync' | head -5

Repository: wecode-ai/Wegent

Length of output: 515


🏁 Script executed:

# Check the structure of trace_sync decorator
cat -n shared/telemetry/decorators.py | head -100

Repository: wecode-ai/Wegent

Length of output: 3827


🏁 Script executed:

# Look for examples of `@trace_sync` usage in backend code
rg -A 3 '@trace_sync' backend --glob '*.py' | head -30

Repository: wecode-ai/Wegent

Length of output: 803


🏁 Script executed:

# Check if tracing is imported in yaml_init.py
rg -n 'from.*telemetry|import.*telemetry' backend/app/core/yaml_init.py

Repository: wecode-ai/Wegent

Length of output: 42


🏁 Script executed:

# Look at how trace_sync is imported in the backend files that use it
rg -B 5 '@trace_sync' backend/app/services/chat/trigger/core.py | head -30

Repository: wecode-ai/Wegent

Length of output: 234


Add required tracing decorators for sync public functions in initialization module.

The sync functions at lines 205, 501, and 614 are missing @trace_sync() decorators as required by guidelines. These are initialization entrypoints and should include tracing. Add the import from shared.telemetry.decorators import trace_sync and decorate each function with @trace_sync(span_name="...", tracer_name="backend.yaml_init").

🤖 Prompt for AI Agents
In `@backend/app/core/yaml_init.py` around lines 205 - 219, Add tracing to the
module by importing trace_sync from shared.telemetry.decorators and decorating
each top-level synchronous initialization entrypoint with
`@trace_sync`(span_name="...", tracer_name="backend.yaml_init"); specifically add
the import and apply the decorator to the apply_public_resources function and to
the two other public sync init functions in this file (the remaining two
top-level initialization entrypoints), using descriptive span names for each
(e.g., span_name="yaml_init.apply_public_resources") while keeping
tracer_name="backend.yaml_init".

@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: 2

🤖 Fix all issues with AI agents
In `@backend/init_data/02-public-resources.yaml`:
- Line 593: The language instruction "(in chinese)" after the agent name is
ambiguous; update the Core Principles by removing that inline note and adding a
clear separate rule such as "Your responses should be in Chinese" (or "Your
responses must be in Chinese") as its own bullet or sentence alongside the
"Wegent Notebook Agent" identity to make the language requirement explicit and
unambiguous.
- Around line 564-566: Update the README files to reflect the team rename:
search for occurrences of the old team name "chat-team" in README.md and
README_zh.md and replace them with the new name "wegent-chat" so the team
reference tables and any mentions match the resource name (e.g., the manifest
entry named "wegent-chat" / displayName "Wegent Chat"); verify both English and
Chinese READMEs and update any captions, links or table rows that reference the
old identifier to the new one.
🧹 Nitpick comments (1)
frontend/src/features/tasks/components/chat/QuickAccessCards.tsx (1)

569-607: Consider reusing the helper functions for consistency.

The inline logic (isGroupTeamItem, isPublicTeam, isPersonalTeamItem) duplicates the isPersonalTeam and isGroupTeam helper functions defined at lines 316-325. Using the helpers would reduce code duplication and ensure consistent badge logic across card and dropdown views.

♻️ Suggested refactor
                     dropdownTeams.map(team => {
                       const isSelected = selectedTeam?.id === team.id
                       const isSharedTeam = team.share_status === 2 && team.user?.user_name
-                      const isGroupTeamItem = team.namespace && team.namespace !== 'default'
-                      const isPublicTeam = 'user_id' in team && team.user_id === 0
-                      const isPersonalTeamItem = !isPublicTeam && !isGroupTeamItem
+                      // Reuse helper functions for consistency
+                      const isPersonalTeamItem = isPersonalTeam(team as DisplayTeam)
+                      const isGroupTeamItem = isGroupTeam(team as DisplayTeam)

                       return (

Note: This requires casting team to DisplayTeam since the dropdown iterates over Team objects. Alternatively, make the helper functions accept Team type if DisplayTeam fields aren't needed.

Comment on lines +564 to 566
name: wegent-chat
displayName: Wegent Chat
namespace: default

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.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for references to the old team name "chat-team"
echo "=== Searching for 'chat-team' references ==="
rg "chat-team" --type-list | head -20
echo ""
echo "=== Searching across common file types ==="
rg "chat-team" -t yaml -t py -t ts -t js -t json 2>/dev/null || true
echo ""
echo "=== Searching all files (no type restriction) ==="
rg "chat-team" --no-heading -c 2>/dev/null || true

Repository: wecode-ai/Wegent

Length of output: 1023


🏁 Script executed:

#!/bin/bash
echo "=== README.md context for 'chat-team' ==="
rg "chat-team" -B 2 -A 2 README.md

echo ""
echo "=== README_zh.md context for 'chat-team' ==="
rg "chat-team" -B 2 -A 2 README_zh.md

echo ""
echo "=== Check test file content ==="
rg "chat-team" -B 2 -A 2 frontend/e2e/tests/tasks/chat-image-browser-e2e.spec.ts

Repository: wecode-ai/Wegent

Length of output: 692


Update documentation to reflect team name change.

The rename from chat-team to wegent-chat requires corresponding updates in the README files. Both README.md and README_zh.md document the old team name in their team reference tables and must be updated to wegent-chat to maintain consistency.

No code or configuration dependencies on the old name were found, so this is primarily a documentation update requirement.

🤖 Prompt for AI Agents
In `@backend/init_data/02-public-resources.yaml` around lines 564 - 566, Update
the README files to reflect the team rename: search for occurrences of the old
team name "chat-team" in README.md and README_zh.md and replace them with the
new name "wegent-chat" so the team reference tables and any mentions match the
resource name (e.g., the manifest entry named "wegent-chat" / displayName
"Wegent Chat"); verify both English and Chinese READMEs and update any captions,
links or table rows that reference the old identifier to the new one.

- mermaid-diagram
mcpServers: {}
systemPrompt: |
You are "Wegent Notebook Agent", a research and writing assistant whose knowledge is strictly limited to the materials provided by the user in the current conversation(in chinese). Your behavior and output style are inspired by Google NotebookLM: material-centric, evidence-first, and focused on helping users understand, organize, and reuse their own content.

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.

⚠️ Potential issue | 🟡 Minor

Minor: Clarify the language instruction.

The inline (in chinese) is ambiguous. Consider making the language requirement more explicit, e.g., "Your responses should be in Chinese" as a separate instruction in the Core Principles section.

🤖 Prompt for AI Agents
In `@backend/init_data/02-public-resources.yaml` at line 593, The language
instruction "(in chinese)" after the agent name is ambiguous; update the Core
Principles by removing that inline note and adding a clear separate rule such as
"Your responses should be in Chinese" (or "Your responses must be in Chinese")
as its own bullet or sentence alongside the "Wegent Notebook Agent" identity to
make the language requirement explicit and unambiguous.

@qdaxb
qdaxb merged commit af9d27d into main Jan 19, 2026
13 of 14 checks passed
maquan0927 pushed a commit to maquan0927/Wegent that referenced this pull request Jan 22, 2026
* feat: init public resources

* fix: fix wegent initial team
This was referenced Jan 30, 2026
@qdaxb
qdaxb deleted the update_public_resource branch February 4, 2026 09:29
fengkuizhi pushed a commit that referenced this pull request Mar 3, 2026
feat: init public resources (#180)

See merge request weibo_rd/common/wecode/wegent!1211
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