From b6476a386bab8b02d8eb5da25e7a4782e907fac8 Mon Sep 17 00:00:00 2001 From: syui Date: Tue, 20 Jan 2026 20:03:36 +0900 Subject: [PATCH] fix config --- public/config.json | 6 ++++ public/networks.json | 6 ++-- src/mcp/mod.rs | 21 +++++++------ src/web/components/chat.ts | 12 +++++--- src/web/components/footer.ts | 5 +-- src/web/main.ts | 60 +++++++++++++++++++++--------------- src/web/types.ts | 9 ++++++ 7 files changed, 77 insertions(+), 42 deletions(-) diff --git a/public/config.json b/public/config.json index 08ee20d..73eda31 100644 --- a/public/config.json +++ b/public/config.json @@ -2,9 +2,15 @@ "title": "syui.ai", "did": "did:plc:vzsvtbtbnwn22xjqhcu3vd6y", "handle": "syui.syui.ai", + "bot": { + "did": "did:plc:6qyecktefllvenje24fcxnie", + "handle": "ai.syui.ai" + }, "collection": "ai.syui.log.post", + "chatCollection": "ai.syui.log.chat", "network": "syu.is", "color": "#EF454A", "siteUrl": "https://syui.ai", + "repoUrl": "https://git.syui.ai/ai/log", "oauth": true } diff --git a/public/networks.json b/public/networks.json index 62de6a3..7c6c266 100644 --- a/public/networks.json +++ b/public/networks.json @@ -2,11 +2,13 @@ "bsky.social": { "plc": "https://plc.directory", "bsky": "https://public.api.bsky.app", - "web": "https://bsky.app" + "web": "https://bsky.app", + "handleDomains": ["bsky.social"] }, "syu.is": { "plc": "https://plc.syu.is", "bsky": "https://bsky.syu.is", - "web": "https://syu.is" + "web": "https://syu.is", + "handleDomains": ["syu.is", "syui.ai"] } } diff --git a/src/mcp/mod.rs b/src/mcp/mod.rs index e3b5ab7..d8382d7 100644 --- a/src/mcp/mod.rs +++ b/src/mcp/mod.rs @@ -223,14 +223,16 @@ fn handle_chat_save(params: ChatSaveParams) -> Result { }); // Get user DID from token.json - let user_did = token::load_session() - .map(|s| s.did) - .unwrap_or_else(|_| "did:plc:unknown".to_string()); + let user_did = match token::load_session() { + Ok(s) => s.did, + Err(_) => return Err(anyhow::anyhow!("User not logged in. Run: ailog login -p ")), + }; // Get bot DID from bot.json - let bot_did = token::load_bot_session() - .map(|s| s.did) - .unwrap_or_else(|_| "did:plc:6qyecktefllvenje24fcxnie".to_string()); + let bot_did = match token::load_bot_session() { + Ok(s) => s.did, + Err(_) => return Err(anyhow::anyhow!("Bot not logged in. Run: ailog login -p --bot")), + }; // Reset session if new_thread requested if params.new_thread { @@ -278,9 +280,10 @@ fn handle_chat_list() -> Result { .to_string() }); - let user_did = token::load_session() - .map(|s| s.did) - .unwrap_or_else(|_| "did:plc:unknown".to_string()); + let user_did = match token::load_session() { + Ok(s) => s.did, + Err(_) => return Err(anyhow::anyhow!("User not logged in. Run: ailog login -p ")), + }; let collection_dir = std::path::Path::new(&output_dir) .join(&user_did) diff --git a/src/web/components/chat.ts b/src/web/components/chat.ts index 7d35597..cddeac7 100644 --- a/src/web/components/chat.ts +++ b/src/web/components/chat.ts @@ -171,10 +171,11 @@ export function renderChatThread( botHandle: string, userProfile?: Profile | null, botProfile?: Profile | null, - pds?: string + pds?: string, + chatCollection: string = 'ai.syui.log.chat' ): string { // Find root message - const rootUri = `at://${userDid}/ai.syui.log.chat/${rootRkey}` + const rootUri = `at://${userDid}/${chatCollection}/${rootRkey}` const rootMsg = messages.find(m => m.uri === rootUri) if (!rootMsg) { @@ -222,7 +223,7 @@ export function renderChatThread( const displayContent = getTranslatedContent(msg) const content = renderMarkdown(displayContent) - const recordLink = `/@${author.handle}/at/collection/ai.syui.log.chat/${rkey}` + const recordLink = `/@${author.handle}/at/collection/${chatCollection}/${rkey}` return `
@@ -268,8 +269,9 @@ export function renderChatThreadPage( botHandle: string, userProfile?: Profile | null, botProfile?: Profile | null, - pds?: string + pds?: string, + chatCollection: string = 'ai.syui.log.chat' ): string { - const thread = renderChatThread(messages, rootRkey, userDid, userHandle, botDid, botHandle, userProfile, botProfile, pds) + const thread = renderChatThread(messages, rootRkey, userDid, userHandle, botDid, botHandle, userProfile, botProfile, pds, chatCollection) return `
${thread}
` } diff --git a/src/web/components/footer.ts b/src/web/components/footer.ts index 3b85534..021851a 100644 --- a/src/web/components/footer.ts +++ b/src/web/components/footer.ts @@ -1,11 +1,12 @@ -export function renderFooter(handle: string): string { +export function renderFooter(handle: string, repoUrl?: string): string { // Extract username from handle: {username}.{name}.{domain} -> username const username = handle.split('.')[0] || handle + const repo = repoUrl || '#' return `