Compare commits

..

13 Commits

Author SHA1 Message Date
dayuan.jiang
476a632d1b fix: update @ai-sdk/amazon-bedrock to 3.0.62 for tool streaming support 2025-11-30 16:32:40 +09:00
dayuan.jiang
0cba721d33 Merge branch 'main' into feat/tool-streaming 2025-11-30 16:17:40 +09:00
dayuan.jiang
de910bdf6c fix: correct anthropic beta header config for fine-grained tool streaming
- Use bedrock.anthropicBeta for Bedrock provider (not additionalModelRequestFields)
- Use top-level headers for direct Anthropic API
- Update @ai-sdk/amazon-bedrock to 3.0.62
- Add headers support to ModelConfig interface
2025-11-30 16:12:12 +09:00
Ming long Hu
6e6de1eba6 feat: add copy button to user messages in chat sidebar (#21)
* Initial plan

* Initial plan for adding copy button to user messages

Co-authored-by: huminglong <63436986+huminglong@users.noreply.github.com>

* Add copy button to user messages in chat sidebar

Co-authored-by: huminglong <63436986+huminglong@users.noreply.github.com>

* Refactor: extract userMessageText to avoid duplicate function calls

Co-authored-by: huminglong <63436986+huminglong@users.noreply.github.com>

* feat(ui): 增加消息复制功能支持非 HTTPS 环境

优化复制消息到剪贴板的逻辑,增加对非 HTTPS 环境的降级处理,提升用户体验。

* fix(package): 添加 peer 属性以支持依赖关系

* chore(.gitignore): 添加 next 和 next-ai-draw-io@0.2.0 相关条目

* fix: improve copy button implementation

- Fix copy button alignment (place left of user message)
- Remove unused React import
- Move getMessageTextContent outside component
- Add error state with X icon for copy failures
- Translate Chinese comments to English
- Simplify copy function
- Add missing semicolon
- Remove accidental .gitignore entries

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: dayuan.jiang <jdy.toh@gmail.com>
2025-11-29 13:39:35 +09:00
dayuan.jiang
00af87edbe fix: prevent duplicate PR review comments by tracking existing file:line 2025-11-29 12:55:53 +09:00
dayuan.jiang
468d6c0276 fix: require suggested fixes in PR review comments 2025-11-29 12:46:24 +09:00
dayuan.jiang
14f74b076f fix: remove gh pr comment from allowed tools to force inline comments only 2025-11-29 12:38:35 +09:00
dayuan.jiang
78d9229ca3 fix: remove gh pr comment from allowed tools to force inline comments only 2025-11-29 12:36:35 +09:00
dayuan.jiang
d8e0a1daad fix: enforce inline comments for all issues found
- Explicitly require mcp inline comment tool for each issue
- Clarify gh pr comment is only for final summary
- Forbid dismissing issues as minor/harmless
2025-11-29 12:31:46 +09:00
Dayuan Jiang
32e75ab556 feat: expand PR review scope to catch more issues (#25)
* feat: use pull_request_target to support fork PR reviews

* feat: expand PR review scope to catch more issues

- Add categories for scope creep, suspicious .gitignore additions, UI inconsistencies
- Change from 'be very selective' to 'report ALL issues found'
- Simplify DO NOT comment list to allow more actionable feedback
2025-11-29 12:22:21 +09:00
Dayuan Jiang
b87e3a2de9 feat: use pull_request_target to support fork PR reviews (#24) 2025-11-29 11:14:49 +09:00
Dayuan Jiang
b32d42d962 Merge pull request #23 from DayuanJiang/feature/claude-code-actions
Feature/claude code actions
2025-11-29 01:50:27 +09:00
Dayuan Jiang
b4d0c6c18b Merge pull request #22 from DayuanJiang/feature/claude-code-actions
Add Claude Code GitHub Actions with Bedrock and auto PR review
2025-11-29 01:32:06 +09:00
7 changed files with 4852 additions and 103 deletions

6
.eslintrc.json Normal file
View File

@@ -0,0 +1,6 @@
{
"extends": [
"next/core-web-vitals",
"next/typescript"
]
}

View File

@@ -77,14 +77,15 @@ jobs:
- Vercel AI SDK (streamText, useChat, tool calling) - Vercel AI SDK (streamText, useChat, tool calling)
- Multiple AI providers: Bedrock, Anthropic, OpenAI, Google, Azure, OpenRouter, Ollama - Multiple AI providers: Bedrock, Anthropic, OpenAI, Google, Azure, OpenRouter, Ollama
First, check previous review comments from github-actions bot using `gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/comments`. STEP 1: Check existing comments to avoid duplicates.
For each previous comment: Run: `gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/comments`
- If the issue is fixed in the current code, resolve the comment thread using:
`gh api graphql -f query='mutation { resolveReviewThread(input: {threadId: "THREAD_ID"}) { thread { isResolved } } }'`
Get the thread ID from the comment's node_id field.
- If the issue still exists, leave it alone
Then review the current diff for NEW issues only: Build a list of files and line numbers that already have comments. For each existing comment:
- If the issue is FIXED in current code, resolve the thread using:
`gh api graphql -f query='mutation { resolveReviewThread(input: {threadId: "THREAD_ID"}) { thread { isResolved } } }'`
- If the issue still exists, remember this file:line - DO NOT create a new comment for it
STEP 2: Review the diff for issues, but SKIP any file:line that already has a comment.
Review this PR for these issues (report ALL that apply): Review this PR for these issues (report ALL that apply):
1. Bugs that would cause runtime errors or broken functionality 1. Bugs that would cause runtime errors or broken functionality
@@ -108,7 +109,10 @@ jobs:
- Code style preferences (unless clearly wrong) - Code style preferences (unless clearly wrong)
- Type annotations that don't affect functionality - Type annotations that don't affect functionality
Use `mcp__github_inline_comment__create_inline_comment` for inline comments. IMPORTANT:
Report ALL issues found - create multiple inline comments if needed. Only say "LGTM" if there are truly no issues. - NEVER create a comment on a file:line that already has a comment - this causes duplicates
- For each NEW issue, use `mcp__github_inline_comment__create_inline_comment` to comment on the specific line
- ALWAYS include a suggested fix using GitHub's suggestion syntax: ```suggestion\n<fixed code>\n```
- Only say "LGTM" if there are truly ZERO new issues to report
claude_args: | claude_args: |
--allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh api:*),WebFetch(domain:ai-sdk.dev)" --allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh api:*),WebFetch(domain:ai-sdk.dev)"

View File

@@ -120,13 +120,14 @@ ${lastMessageText}
console.log("Enhanced messages:", enhancedMessages); console.log("Enhanced messages:", enhancedMessages);
// Get AI model from environment configuration // Get AI model from environment configuration
const { model, providerOptions } = getAIModel(); const { model, providerOptions, headers } = getAIModel();
const result = streamText({ const result = streamText({
model, model,
system: systemMessage, system: systemMessage,
messages: enhancedMessages, messages: enhancedMessages,
...(providerOptions && { providerOptions }), ...(providerOptions && { providerOptions }),
...(headers && { headers }),
tools: { tools: {
// Client-side tool that will be executed on the client // Client-side tool that will be executed on the client
display_diagram: { display_diagram: {

View File

@@ -1,15 +1,23 @@
"use client"; "use client";
import type React from "react";
import { useRef, useEffect, useState, useCallback } from "react"; import { useRef, useEffect, useState, useCallback } from "react";
import Image from "next/image"; import Image from "next/image";
import { ScrollArea } from "@/components/ui/scroll-area"; import { ScrollArea } from "@/components/ui/scroll-area";
import ExamplePanel from "./chat-example-panel"; import ExamplePanel from "./chat-example-panel";
import { UIMessage } from "ai"; import { UIMessage } from "ai";
import { convertToLegalXml, replaceNodes } from "@/lib/utils"; import { convertToLegalXml, replaceNodes } from "@/lib/utils";
import { Copy, Check, X } from "lucide-react";
import { useDiagram } from "@/contexts/diagram-context"; import { useDiagram } from "@/contexts/diagram-context";
const getMessageTextContent = (message: UIMessage): string => {
if (!message.parts) return "";
return message.parts
.filter((part: any) => part.type === "text")
.map((part: any) => part.text)
.join("\n");
};
interface ChatMessageDisplayProps { interface ChatMessageDisplayProps {
messages: UIMessage[]; messages: UIMessage[];
error?: Error | null; error?: Error | null;
@@ -30,6 +38,21 @@ export function ChatMessageDisplay({
const [expandedTools, setExpandedTools] = useState<Record<string, boolean>>( const [expandedTools, setExpandedTools] = useState<Record<string, boolean>>(
{} {}
); );
const [copiedMessageId, setCopiedMessageId] = useState<string | null>(null);
const [copyFailedMessageId, setCopyFailedMessageId] = useState<string | null>(null);
const copyMessageToClipboard = async (messageId: string, text: string) => {
try {
await navigator.clipboard.writeText(text);
setCopiedMessageId(messageId);
setTimeout(() => setCopiedMessageId(null), 2000);
} catch (err) {
console.error("Failed to copy message:", err);
setCopyFailedMessageId(messageId);
setTimeout(() => setCopyFailedMessageId(null), 2000);
}
};
const handleDisplayChart = useCallback( const handleDisplayChart = useCallback(
(xml: string) => { (xml: string) => {
const currentXml = xml || ""; const currentXml = xml || "";
@@ -160,16 +183,30 @@ export function ChatMessageDisplay({
{messages.length === 0 ? ( {messages.length === 0 ? (
<ExamplePanel setInput={setInput} setFiles={setFiles} /> <ExamplePanel setInput={setInput} setFiles={setFiles} />
) : ( ) : (
messages.map((message) => ( messages.map((message) => {
const userMessageText = message.role === "user" ? getMessageTextContent(message) : "";
return (
<div <div
key={message.id} key={message.id}
className={`mb-4 ${ className={`mb-4 flex ${message.role === "user" ? "justify-end" : "justify-start"}`}
message.role === "user" ? "text-right" : "text-left"
}`}
> >
{message.role === "user" && userMessageText && (
<button
onClick={() => copyMessageToClipboard(message.id, userMessageText)}
className="p-1 text-gray-400 hover:text-gray-600 transition-colors self-center mr-1"
title={copiedMessageId === message.id ? "Copied!" : copyFailedMessageId === message.id ? "Failed to copy" : "Copy message"}
>
{copiedMessageId === message.id ? (
<Check className="h-3.5 w-3.5 text-green-500" />
) : copyFailedMessageId === message.id ? (
<X className="h-3.5 w-3.5 text-red-500" />
) : (
<Copy className="h-3.5 w-3.5" />
)}
</button>
)}
<div <div
className={`inline-block px-4 py-2 whitespace-pre-wrap text-sm rounded-lg max-w-[85%] break-words ${ className={`px-4 py-2 whitespace-pre-wrap text-sm rounded-lg max-w-[85%] break-words ${message.role === "user"
message.role === "user"
? "bg-primary text-primary-foreground" ? "bg-primary text-primary-foreground"
: "bg-muted text-muted-foreground" : "bg-muted text-muted-foreground"
}`} }`}
@@ -204,7 +241,8 @@ export function ChatMessageDisplay({
})} })}
</div> </div>
</div> </div>
)) );
})
)} )}
{error && ( {error && (
<div className="text-red-500 text-sm mt-2"> <div className="text-red-500 text-sm mt-2">

View File

@@ -18,15 +18,19 @@ export type ProviderName =
interface ModelConfig { interface ModelConfig {
model: any; model: any;
providerOptions?: any; providerOptions?: any;
headers?: Record<string, string>;
} }
// Anthropic beta headers for fine-grained tool streaming // Bedrock provider options for Anthropic beta features
const ANTHROPIC_BETA_OPTIONS = { const BEDROCK_ANTHROPIC_BETA = {
anthropic: { bedrock: {
additionalModelRequestFields: { anthropicBeta: ['fine-grained-tool-streaming-2025-05-14'],
anthropic_beta: ['fine-grained-tool-streaming-2025-05-14'] },
} };
}
// Direct Anthropic API headers for beta features
const ANTHROPIC_BETA_HEADERS = {
'anthropic-beta': 'fine-grained-tool-streaming-2025-05-14',
}; };
/** /**
@@ -87,13 +91,14 @@ export function getAIModel(): ModelConfig {
let model: any; let model: any;
let providerOptions: any = undefined; let providerOptions: any = undefined;
let headers: Record<string, string> | undefined = undefined;
switch (provider) { switch (provider) {
case 'bedrock': case 'bedrock':
model = bedrock(modelId); model = bedrock(modelId);
// Add Anthropic beta headers if using Claude models via Bedrock // Add Anthropic beta options if using Claude models via Bedrock
if (modelId.includes('anthropic.claude')) { if (modelId.includes('anthropic.claude')) {
providerOptions = ANTHROPIC_BETA_OPTIONS; providerOptions = BEDROCK_ANTHROPIC_BETA;
} }
break; break;
@@ -112,7 +117,7 @@ export function getAIModel(): ModelConfig {
case 'anthropic': case 'anthropic':
model = anthropic(modelId); model = anthropic(modelId);
// Add beta headers for fine-grained tool streaming // Add beta headers for fine-grained tool streaming
providerOptions = ANTHROPIC_BETA_OPTIONS; headers = ANTHROPIC_BETA_HEADERS;
break; break;
case 'google': case 'google':
@@ -140,10 +145,10 @@ export function getAIModel(): ModelConfig {
); );
} }
// Log if provider options are being applied // Log if provider options or headers are being applied
if (providerOptions) { if (providerOptions || headers) {
console.log('[AI Provider] Applying provider-specific options'); console.log('[AI Provider] Applying provider-specific options/headers');
} }
return { model, providerOptions }; return { model, providerOptions, headers };
} }

4753
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -9,7 +9,7 @@
"lint": "next lint" "lint": "next lint"
}, },
"dependencies": { "dependencies": {
"@ai-sdk/amazon-bedrock": "^3.0.52", "@ai-sdk/amazon-bedrock": "^3.0.62",
"@ai-sdk/anthropic": "^2.0.44", "@ai-sdk/anthropic": "^2.0.44",
"@ai-sdk/azure": "^2.0.69", "@ai-sdk/azure": "^2.0.69",
"@ai-sdk/google": "^2.0.0", "@ai-sdk/google": "^2.0.0",
@@ -46,6 +46,8 @@
"@types/pako": "^2.0.3", "@types/pako": "^2.0.3",
"@types/react": "^19", "@types/react": "^19",
"@types/react-dom": "^19", "@types/react-dom": "^19",
"eslint": "9.39.1",
"eslint-config-next": "16.0.5",
"tailwindcss": "^4", "tailwindcss": "^4",
"typescript": "^5" "typescript": "^5"
} }