fix ai handle

This commit is contained in:
2025-06-15 23:21:15 +09:00
parent 27935324c7
commit 63b6fd5142
3 changed files with 22 additions and 7 deletions

View File

@ -1,3 +1,3 @@
<!-- OAuth Comment System - Load globally for session management -->
<script type="module" crossorigin src="/assets/comment-atproto-C1j-ohiH.js"></script>
<link rel="stylesheet" crossorigin href="/assets/comment-atproto-yJnR1H7g.css">
<script type="module" crossorigin src="/assets/comment-atproto-DiczI9bS.js"></script>
<link rel="stylesheet" crossorigin href="/assets/comment-atproto-CKS23RV6.css">

View File

@ -1,3 +1,3 @@
<!-- OAuth Comment System - Load globally for session management -->
<script type="module" crossorigin src="/assets/comment-atproto-C1j-ohiH.js"></script>
<link rel="stylesheet" crossorigin href="/assets/comment-atproto-yJnR1H7g.css">
<script type="module" crossorigin src="/assets/comment-atproto-DiczI9bS.js"></script>
<link rel="stylesheet" crossorigin href="/assets/comment-atproto-CKS23RV6.css">

View File

@ -28,6 +28,7 @@ function App() {
const [aiChatHistory, setAiChatHistory] = useState<any[]>([]);
const [langEnRecords, setLangEnRecords] = useState<any[]>([]);
const [aiCommentRecords, setAiCommentRecords] = useState<any[]>([]);
const [aiProfile, setAiProfile] = useState<any>(null);
useEffect(() => {
// Setup Jetstream WebSocket for real-time comments (optional)
@ -89,6 +90,20 @@ function App() {
// Load AI chat history (認証状態に関係なく、全ユーザーのチャット履歴を表示)
loadAiChatHistory();
// Load AI profile
const fetchAiProfile = async () => {
try {
const response = await fetch(`${appConfig.bskyPublicApi}/xrpc/app.bsky.actor.getProfile?actor=${encodeURIComponent(appConfig.aiDid)}`);
if (response.ok) {
const data = await response.json();
setAiProfile(data);
}
} catch (err) {
// Use default values if fetch fails
}
};
fetchAiProfile();
// Handle popstate events for mock OAuth flow
const handlePopState = () => {
const urlParams = new URLSearchParams(window.location.search);
@ -966,7 +981,7 @@ function App() {
{authorInfo?.displayName || 'AI'}
</span>
<span className="comment-handle">
@{authorInfo?.handle || 'ai'}
@{authorInfo?.handle || aiProfile?.handle || 'yui.syui.ai'}
</span>
</div>
<span className="comment-date">
@ -1312,7 +1327,7 @@ function App() {
// For AI responses, use AI DID; for user questions, use the actual author
const isAiResponse = record.value.type === 'answer';
const displayDid = isAiResponse ? appConfig.aiDid : record.value.author?.did;
const displayHandle = isAiResponse ? 'ai.syui' : record.value.author?.handle;
const displayHandle = isAiResponse ? (aiProfile?.handle || 'yui.syui.ai') : record.value.author?.handle;
const displayName = isAiResponse ? 'AI' : (record.value.author?.displayName || record.value.author?.handle);
return (
@ -1446,7 +1461,7 @@ function App() {
AI
</span>
<span className="comment-handle">
@ai
@{aiProfile?.handle || 'yui.syui.ai'}
</span>
</div>
<span className="comment-date">