fix config

This commit is contained in:
2026-01-20 20:03:36 +09:00
parent 49f4b71866
commit 20b515313a
4 changed files with 44 additions and 21 deletions

View File

@@ -2,6 +2,10 @@
"title": "syui.ai", "title": "syui.ai",
"did": "did:plc:vzsvtbtbnwn22xjqhcu3vd6y", "did": "did:plc:vzsvtbtbnwn22xjqhcu3vd6y",
"handle": "syui.syui.ai", "handle": "syui.syui.ai",
"bot": {
"did": "did:plc:6qyecktefllvenje24fcxnie",
"handle": "ai.syui.ai"
},
"collection": "ai.syui.log.post", "collection": "ai.syui.log.post",
"network": "syu.is", "network": "syu.is",
"color": "#EF454A", "color": "#EF454A",

View File

@@ -223,14 +223,16 @@ fn handle_chat_save(params: ChatSaveParams) -> Result<String> {
}); });
// Get user DID from token.json // Get user DID from token.json
let user_did = token::load_session() let user_did = match token::load_session() {
.map(|s| s.did) Ok(s) => s.did,
.unwrap_or_else(|_| "did:plc:unknown".to_string()); Err(_) => return Err(anyhow::anyhow!("User not logged in. Run: ailog login <handle> -p <password>")),
};
// Get bot DID from bot.json // Get bot DID from bot.json
let bot_did = token::load_bot_session() let bot_did = match token::load_bot_session() {
.map(|s| s.did) Ok(s) => s.did,
.unwrap_or_else(|_| "did:plc:6qyecktefllvenje24fcxnie".to_string()); Err(_) => return Err(anyhow::anyhow!("Bot not logged in. Run: ailog login <handle> -p <password> --bot")),
};
// Reset session if new_thread requested // Reset session if new_thread requested
if params.new_thread { if params.new_thread {
@@ -278,9 +280,10 @@ fn handle_chat_list() -> Result<String> {
.to_string() .to_string()
}); });
let user_did = token::load_session() let user_did = match token::load_session() {
.map(|s| s.did) Ok(s) => s.did,
.unwrap_or_else(|_| "did:plc:unknown".to_string()); Err(_) => return Err(anyhow::anyhow!("User not logged in. Run: ailog login <handle> -p <password>")),
};
let collection_dir = std::path::Path::new(&output_dir) let collection_dir = std::path::Path::new(&output_dir)
.join(&user_did) .join(&user_did)

View File

@@ -230,13 +230,17 @@ async function render(route: Route): Promise<void> {
} else if (route.type === 'chat') { } else if (route.type === 'chat') {
// Chat list page - show threads started by this user // Chat list page - show threads started by this user
const aiDid = 'did:plc:6qyecktefllvenje24fcxnie' // ai.syui.ai if (!config.bot) {
const aiHandle = 'ai.syui.ai' html += `<div id="content" class="error">Bot not configured in config.json</div>`
html += `<nav class="back-nav"><a href="/@${handle}">${handle}</a></nav>`
} else {
const botDid = config.bot.did
const botHandle = config.bot.handle
// Load messages and profiles in parallel // Load messages and profiles in parallel
const [chatMessages, aiProfile, pds] = await Promise.all([ const [chatMessages, botProfile, pds] = await Promise.all([
getChatMessages(did, aiDid, 'ai.syui.log.chat'), getChatMessages(did, botDid, 'ai.syui.log.chat'),
getProfile(aiDid, false), getProfile(botDid, false),
getPds(did) getPds(did)
]) ])
@@ -254,18 +258,23 @@ async function render(route: Route): Promise<void> {
langList = Array.from(chatLangs) langList = Array.from(chatLangs)
html += renderLangSelector(langList) html += renderLangSelector(langList)
html += `<div id="content">${renderChatListPage(chatMessages, did, handle, aiDid, aiHandle, profile, aiProfile, pds || undefined)}</div>` html += `<div id="content">${renderChatListPage(chatMessages, did, handle, botDid, botHandle, profile, botProfile, pds || undefined)}</div>`
html += `<nav class="back-nav"><a href="/@${handle}">${handle}</a></nav>` html += `<nav class="back-nav"><a href="/@${handle}">${handle}</a></nav>`
}
} else if (route.type === 'chat-thread' && route.rkey) { } else if (route.type === 'chat-thread' && route.rkey) {
// Chat thread page - show full conversation // Chat thread page - show full conversation
const aiDid = 'did:plc:6qyecktefllvenje24fcxnie' // ai.syui.ai if (!config.bot) {
const aiHandle = 'ai.syui.ai' html += `<div id="content" class="error">Bot not configured in config.json</div>`
html += `<nav class="back-nav"><a href="/@${handle}">${handle}</a></nav>`
} else {
const botDid = config.bot.did
const botHandle = config.bot.handle
// Load messages and profiles in parallel // Load messages and profiles in parallel
const [chatMessages, aiProfile, pds] = await Promise.all([ const [chatMessages, botProfile, pds] = await Promise.all([
getChatMessages(did, aiDid, 'ai.syui.log.chat'), getChatMessages(did, botDid, 'ai.syui.log.chat'),
getProfile(aiDid, false), getProfile(botDid, false),
getPds(did) getPds(did)
]) ])
@@ -283,8 +292,9 @@ async function render(route: Route): Promise<void> {
langList = Array.from(chatLangs) langList = Array.from(chatLangs)
html += renderLangSelector(langList) html += renderLangSelector(langList)
html += `<div id="content">${renderChatThreadPage(chatMessages, route.rkey, did, handle, aiDid, aiHandle, profile, aiProfile, pds || undefined)}</div>` html += `<div id="content">${renderChatThreadPage(chatMessages, route.rkey, did, handle, botDid, botHandle, profile, botProfile, pds || undefined)}</div>`
html += `<nav class="back-nav"><a href="/@${handle}/at/chat">chat</a></nav>` html += `<nav class="back-nav"><a href="/@${handle}/at/chat">chat</a></nav>`
}
} else { } else {
// User page: compact collection buttons + posts // User page: compact collection buttons + posts

View File

@@ -1,8 +1,14 @@
// Config types // Config types
export interface BotConfig {
did: string
handle: string
}
export interface AppConfig { export interface AppConfig {
title: string title: string
did?: string did?: string
handle: string handle: string
bot?: BotConfig
collection: string collection: string
network: string network: string
color: string color: string