Skip to content

feat: expand item types and improve API response handling #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
May 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
eb738b2
feat: expand item types and improve API response handling
cubxxw May 15, 2025
945e9d3
refactor: clean up exports and improve type definitions in client files
cubxxw May 15, 2025
24ec5dd
refactor: improve API response handling and type assertions in ItemsT…
cubxxw May 15, 2025
8597763
fix: enhance error handling and localization in dashboard and login c…
cubxxw May 15, 2025
db7a5f4
chore: update pnpm version and enhance error handling in components
cubxxw May 15, 2025
5b6d0ae
fix: update item description handling in DashboardPage component
cubxxw May 16, 2025
d1b77aa
chore: update environment configurations and enhance Google OAuth han…
cubxxw May 16, 2025
b19bebc
fix: enhance authentication flow and improve error handling in middle…
cubxxw May 16, 2025
30581cf
chore: add extension testing capabilities and update Makefile
cubxxw May 16, 2025
fcca09d
chore: update client generation workflow and enhance admin dependencies
cubxxw May 16, 2025
8632aa7
chore: remove deprecated files and update project structure
cubxxw May 16, 2025
c235c6d
chore: remove SECURITY.md and update popup components for better acce…
cubxxw May 16, 2025
292e23a
chore: update Jest configuration and enhance testing utilities
cubxxw May 16, 2025
8ed343e
chore: update Makefile and improve code formatting across components
cubxxw May 16, 2025
3e934dd
feat: enhance sidebar functionality and improve API interactions
cubxxw May 17, 2025
0aa50fa
feat: add diagnose functionality and enhance sidebar resources
cubxxw May 17, 2025
37d3779
feat: add resource links for independent developers in README_zh-CN
cubxxw May 17, 2025
e057865
fix: update favicon file types and replace icon assets
cubxxw May 17, 2025
15803ba
chore: update Makefile and enhance extension functionality
cubxxw May 17, 2025
904b9db
refactor: enhance extension build process and update documentation
cubxxw May 18, 2025
8184607
chore: update test setup and enhance database management
cubxxw May 18, 2025
326d986
feat: add social media integration and improve options page layout
cubxxw May 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Any operations involving issues and pulls on GitHub
globs:
alwaysApply: false
---
**Repository Resolution Logic:**
**Github Repository Resolution Logic:**

- If owner and repo are explicitly provided, use them.
- Otherwise, default to:
Expand All @@ -17,3 +17,7 @@ alwaysApply: false
- The language chosen for raising an issue: Chinese-
- Be careful not to be too AI in your tone.
- Pay attention to choosing the appropriate labels and types. And select the latest Milestone

**Postgres db operation Logic:**

- db name is `app`
27 changes: 27 additions & 0 deletions .cursor/rules/tdd-sequential-api-flow.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
description:
globs:
alwaysApply: false
---
Design with Test-Driven Development + sequential thinking + API documentation review.

## Process

1. **Write Tests First**
- Define expected behavior before implementation

2. **Think Sequentially**
- Number each thought step
- Revise or branch when needed
- Generate and verify hypothesis

3. **Check API Docs**
- Consult official documentation before API usage
- Validate understanding with test cases

4. **Implement Minimally**
- Write code that passes tests
- Follow your sequential thought chain
5. **Refactor & Validate**
- Clean up while maintaining passing tests
- Verify all requirements are met
5 changes: 2 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ DOMAIN=localhost.nip.io
# Used by the backend to generate links (e.g., in emails).
# Example for local development: http://localhost:8000
# Example for production: https://dashboard.yourdomain.com
FRONTEND_HOST=http://localhost:8000
FRONTEND_HOST=http://localhost:3000

# -- Backend Settings --

Expand All @@ -47,6 +47,7 @@ [email protected]

# First Superuser Password: Password for the initial administrator account.
# Choose a strong password.
# min_length=8
FIRST_SUPERUSER_PASSWORD='telepace'

# -- Email (SMTP) Settings --
Expand Down Expand Up @@ -220,5 +221,3 @@ OR_API_KEY="sk-or-api03-1234567890"
# Google OAuth client ID and secret for authentication
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_OAUTH_REDIRECT_URI=http://localhost:8000/api/v1/login/google/callback
FRONTEND_URL=http://localhost:3000
14 changes: 10 additions & 4 deletions .github/workflows/generate-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 8
version: 9.9.0

- name: Setup Node.js
uses: actions/setup-node@v4
Expand All @@ -56,6 +56,10 @@ jobs:
- name: Install Frontend Dependencies
run: pnpm install
working-directory: frontend

- name: Install Admin Dependencies
run: pnpm install
working-directory: admin

# 安装所有后端依赖项
- name: Install Backend Dependencies
Expand Down Expand Up @@ -94,7 +98,9 @@ jobs:

# 6. Stage Generated Files
- name: Stage Generated Client Files
run: git add frontend/src/client # Adjust path if needed
run: |
git add frontend/app/openapi-client
git add admin/src/client

# 7. Handle Changes for Same-Repo Events (Push/PR from same repo)
- name: Commit and Push Changes (Same Repo)
Expand All @@ -104,8 +110,8 @@ jobs:
# Check if there are staged changes
if ! git diff --staged --quiet; then
echo "✅ Changes detected in generated client. Committing and pushing..."
# Pull before pushing to avoid conflicts if possible (optional)
# git pull --ff-only origin ${{ github.head_ref || github.ref_name }}
# Pull before pushing to avoid conflicts
git pull --rebase origin ${{ github.head_ref || github.ref_name }}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Enable full history for git pull --rebase
The workflow’s comments note that a full history (fetch-depth: 0) is required for accurate diffs and successful rebases, but the checkout step isn’t configured accordingly. Without it, git pull --rebase may fail due to missing history.

Apply this diff at the checkout step (lines 21–23) to set fetch-depth: 0:

-      - name: Checkout Code
-        uses: actions/checkout@v4
+      - name: Checkout Code
+        uses: actions/checkout@v4
+        with:
+          fetch-depth: 0
🤖 Prompt for AI Agents
In .github/workflows/generate-client.yml at the checkout step around lines 21 to
23, the git checkout action is missing the fetch-depth: 0 setting, which is
necessary to enable full git history for accurate diffs and successful rebases.
Modify the checkout step to include fetch-depth: 0 so that the full repository
history is fetched, preventing git pull --rebase failures due to incomplete
history.

git commit -m "ci: ✨ Autogenerate frontend client"
git push origin HEAD:${{ github.head_ref || github.ref_name }}
else
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v3
with:
version: 8
version: 9.9.0
- uses: actions/setup-node@v4
with:
node-version: lts/*
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ jobs:
run: |
echo "## 🚀 Release Summary" >> $GITHUB_STEP_SUMMARY
echo "Release draft created for version ${{ github.event.inputs.version }}." >> $GITHUB_STEP_SUMMARY
echo "Visit the [Releases section](https://github.com/vintasoftware/nextjs-fastapi-template/releases) to review and publish the release." >> $GITHUB_STEP_SUMMARY
echo "Visit the [Releases section](https://github.com/https://github.com/telepace/releases) to review and publish the release." >> $GITHUB_STEP_SUMMARY
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix the malformed GitHub URL in the release summary.

The GitHub URL contains a duplication of "https://github.com/" which will result in a broken link.

-          echo "Visit the [Releases section](https://github.com/https://github.com/telepace/releases) to review and publish the release." >> $GITHUB_STEP_SUMMARY
+          echo "Visit the [Releases section](https://github.com/telepace/releases) to review and publish the release." >> $GITHUB_STEP_SUMMARY
📝 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
echo "Visit the [Releases section](https://github.com/https://github.com/telepace/releases) to review and publish the release." >> $GITHUB_STEP_SUMMARY
echo "Visit the [Releases section](https://github.com/telepace/releases) to review and publish the release." >> $GITHUB_STEP_SUMMARY
🤖 Prompt for AI Agents
In .github/workflows/release.yml at line 60, the GitHub URL in the release
summary is malformed due to a duplicated "https://github.com/". Remove the extra
"https://github.com/" so the URL correctly points to
"https://github.com/telepace/releases" to fix the broken link.

echo "Once the draft is published, another action will automatically be triggered to publish the packages." >> $GITHUB_STEP_SUMMARY
36 changes: 31 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ UV_EXISTS := $(shell command -v uv 2> /dev/null)

## all: Run all tests, linting, formatting and build all components
.PHONY: all
all: format lint test backend-build frontend-build admin-build
all: format lint generate-client backend-build frontend-build admin-build # test
@echo "===========> All checks and builds completed successfully"

## dev: Start development environment
Expand All @@ -81,7 +81,8 @@ lint: backend-lint frontend-lint admin-lint

## test: Run tests for all components
.PHONY: test
test: backend-test frontend-test website-test admin-test
test: backend-test frontend-test website-test admin-test extension-test-unit
@echo "===========> All tests completed successfully"

## format: Format code in all components
.PHONY: format
Expand Down Expand Up @@ -395,9 +396,15 @@ website-test: website-install
# EXTENSION TARGETS
# ==============================================================================

## extension-clean: Clean extension build artifacts and cache
.PHONY: extension-clean
extension-clean:
@echo "===========> Cleaning extension build artifacts and cache"
@cd $(EXTENSION_DIR) && rm -rf build .plasmo

## extension-all: Run all extension related tasks without starting services
.PHONY: extension-all
extension-all: extension-build extension-package
extension-all: extension-build extension-package extension-test
@echo "===========> Extension all checks completed successfully"

## extension: Start extension development
Expand All @@ -408,16 +415,35 @@ extension: check-pnpm

## extension-build: Build browser extension for production
.PHONY: extension-build
extension-build: check-pnpm
extension-build: check-pnpm extension-clean
@echo "===========> Building browser extension for production"
@cd $(EXTENSION_DIR) && $(PNPM) run build
@cd $(EXTENSION_DIR) && $(PNPM) run build:with-tailwind
@echo "===========> Running post-build fixes"
@cd $(EXTENSION_DIR) && ./scripts/fix-build.sh

## extension-package: Package browser extension for distribution
.PHONY: extension-package
extension-package: check-pnpm
@echo "===========> Packaging browser extension for distribution"
@cd $(EXTENSION_DIR) && $(PNPM) run package

## extension-test: Run all extension tests
.PHONY: extension-test
extension-test: extension-test-unit extension-test-e2e
@echo "===========> All extension tests completed"

## extension-test-unit: Run extension unit tests with Jest
.PHONY: extension-test-unit
extension-test-unit: check-pnpm
@echo "===========> Running extension unit tests"
@cd $(EXTENSION_DIR) && $(PNPM) test

## extension-test-e2e: Run extension E2E tests with Playwright
.PHONY: extension-test-e2e
extension-test-e2e: check-pnpm
@echo "===========> Running extension E2E tests"
@cd $(EXTENSION_DIR) && $(PNPM) exec playwright test

# ==============================================================================
# DOCKER TARGETS
# ==============================================================================
Expand Down
114 changes: 112 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ This project provides optimized scripts and Makefile targets for common developm
### Frontend Development

- `make frontend-install` - Install frontend dependencies
- `make frontend-dev` - Run frontend development server
- `make frontend` - Run frontend development server
- `make frontend-build` - Build frontend for production
- `make frontend-test` - Run frontend tests
- `make frontend-lint` - Run linters on frontend code
Expand All @@ -436,4 +436,114 @@ This project provides optimized scripts and Makefile targets for common developm
- `make generate-client` - Generate OpenAPI client for frontend
- `make format` - Format code in all components
- `make lint` - Run linters on all components
- `make clean` - Clean build artifacts
- `make clean` - Clean build artifacts

# Nexus 浏览器扩展重构计划

## 目标
- 优化扩展架构,减少冗余代码
- 重新设计UI,提高用户体验
- 将设置整合到options.html中
- 简化侧边栏功能,提高性能和可维护性
- 参考Sider等优秀扩展的设计模式

## 现状分析
目前扩展存在以下问题:
1. 多个重复或未使用的文件和模块
2. 侧边栏实现混合了原生DOM操作和React,不够统一
3. 设置功能分散在多个位置
4. UI组件结构复杂,维护困难
5. 缺乏统一的状态管理

## 架构重构计划

### 1. 核心架构优化
- **采用模块化设计**:清晰区分UI层、业务逻辑层和基础设施层
- **统一状态管理**:使用React Context或Redux管理全局状态
- **API抽象**:将所有浏览器API调用封装到单独的服务层

### 2. 组件结构调整
- **UI组件库精简**:保留必要的UI组件,移除未使用组件
- **功能组件化**:将每个主要功能(摘要、搜索等)封装为独立组件
- **采用React Hooks**:重构类组件为函数组件,使用hooks管理状态

### 3. 页面重组
- **侧边栏(SidePanel)**:专注于内容交互和AI对话功能
- **弹出窗口(Popup)**:提供快速访问和简要信息
- **选项页面(Options)**:集中所有设置管理功能

## 功能优化计划

### 1. 侧边栏优化
- 重新设计侧边栏UI,更简洁现代
- 实现类似Sider的AI对话界面
- 增强上下文感知能力,更好地理解当前页面内容
- 添加对话历史记录功能

### 2. 设置功能整合
- 将所有设置集中到options.html
- 按类别组织设置选项(一般设置、AI设置、剪藏设置等)
- 增加设置搜索功能
- 实现设置同步功能

### 3. 增强功能
- 实现多AI模型支持(类似Sider)
- 添加更丰富的上下文操作(翻译、解释、总结等)
- 改进内容提取算法,更准确识别页面主要内容
- 添加键盘快捷方式

## 技术实现计划

### 第一阶段:架构整理与基础重构
1. 清理未使用的代码和文件
2. 创建新的核心架构(服务层、状态管理)
3. 重构基础UI组件库

### 第二阶段:功能组件重构
1. 重构侧边栏核心组件
2. 重构弹出窗口UI
3. 重新设计Options页面

### 第三阶段:功能优化与扩展
1. 实现新的AI对话界面
2. 增强设置功能
3. 添加新功能

### 第四阶段:测试与性能优化
1. 全面测试各项功能
2. 性能优化
3. 兼容性测试

## 具体实施计划
每个阶段详细的任务清单和实现时间表将根据开发资源和优先级另行制定。

## 重构进度

### 已完成
1. 设计规划:制定了全面的重构计划
2. 侧边栏重构:
- 重新设计了侧边栏组件,使用React Hooks和函数组件
- 实现了类似Sider的对话界面
- 增加了对话历史管理
- 添加了暗色模式切换
3. 选项页面重构:
- 设计了全新的选项页面布局,采用侧边导航样式
- 将所有设置集中归类,包括一般设置、AI设置、剪藏设置和键盘快捷键等
- 实现了多AI模型支持和API密钥配置
- 添加了快捷提示管理功能

### 未完成
1. Popup页面重构
2. 背景服务优化
3. 内容脚本优化
4. 状态管理统一
5. API服务层抽象
6. Manifest.json更新

## 下一步计划
1. 更新manifest.json,添加必要的权限和配置
2. 重构Popup页面,实现快速访问功能
3. 创建服务层,统一API调用
4. 实现状态管理系统,使用React Context或Redux
5. 优化页面内容提取算法
6. 增强AI功能,添加更多模型支持
1 change: 1 addition & 0 deletions README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ QuickForge AI使集成各种AI服务变得简单:
+ [1000UserGuide:对独立开发者和创业者来说,找到前1000个早期用户太关键了。这里精心整理了300多个国内外渠道,适合独立开发者和创业者推广产品的渠道。](https://github.com/naxiaoduo/1000UserGuide)
+ [中国独立开发者项目列表](https://github.com/1c7/chinese-independent-developer)
+ [独立开发者必备技能及现代工具 & 分别的上手指导](https://nsddd.top/zh/posts/ai-projects/independent-developer/)
+ [发现最好的独立开发者技术栈](https://www.chuhai.tools/categories/chrome-extension-development-template)


## 📄 许可证
Expand Down
29 changes: 0 additions & 29 deletions SECURITY.md

This file was deleted.

Binary file added admin/public/assets/images/favicon.ico
Binary file not shown.
3 changes: 1 addition & 2 deletions admin/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ export { CancelablePromise, CancelError } from "./core/CancelablePromise"
export { OpenAPI, type OpenAPIConfig } from "./core/OpenAPI"
export * from "./sdk.gen"
export * from "./types.gen"
export { isApiResponse, extractApiResponseError } from "./utils"
export { type ItemPublic } from "./types"
export * from "./utils"
Loading
Loading