diff --git a/.claude/settings.local.json b/.claude/settings.local.json
index 3fce09c..6654e42 100644
--- a/.claude/settings.local.json
+++ b/.claude/settings.local.json
@@ -33,7 +33,8 @@
"Bash(./scripts/test-oauth.sh:*)",
"Bash(./run.zsh:*)",
"Bash(npm run dev:*)",
- "Bash(./target/release/ailog:*)"
+ "Bash(./target/release/ailog:*)",
+ "Bash(rg:*)"
],
"deny": []
}
diff --git a/aicard-web-oauth/.env.production b/aicard-web-oauth/.env.production
index cdee24b..c471f07 100644
--- a/aicard-web-oauth/.env.production
+++ b/aicard-web-oauth/.env.production
@@ -6,4 +6,6 @@ VITE_ADMIN_DID=did:plc:uqzpqmrjnptsxezjx4xuh2mn
# Optional: Override collection names (if not set, auto-generated from host)
# VITE_COLLECTION_COMMENT=ai.syui.log
-# VITE_COLLECTION_USER=ai.syui.log.user
\ No newline at end of file
+# VITE_COLLECTION_USER=ai.syui.log.user
+AILOG_COLLECTION_COMMENT=ai.syui.log
+AILOG_COLLECTION_USER=ai.syui.log.user
diff --git a/aicard-web-oauth/src/App.tsx b/aicard-web-oauth/src/App.tsx
index 98c6404..4f009b5 100644
--- a/aicard-web-oauth/src/App.tsx
+++ b/aicard-web-oauth/src/App.tsx
@@ -402,8 +402,28 @@ function App() {
}
const data = await response.json();
- const userComments = data.records || [];
- console.log(`Found ${userComments.length} comments from ${user.handle}`);
+ const userRecords = data.records || [];
+ console.log(`Found ${userRecords.length} comment records from ${user.handle}`);
+
+ // Flatten comments from new array format
+ const userComments = [];
+ for (const record of userRecords) {
+ if (record.value.comments && Array.isArray(record.value.comments)) {
+ // New format: array of comments
+ for (const comment of record.value.comments) {
+ userComments.push({
+ ...record,
+ value: comment,
+ originalRecord: record // Keep reference to original record
+ });
+ }
+ } else if (record.value.text) {
+ // Old format: single comment
+ userComments.push(record);
+ }
+ }
+
+ console.log(`Flattened to ${userComments.length} individual comments from ${user.handle}`);
// ページURLでフィルタリング(指定された場合)
const filteredComments = pageUrl
@@ -496,8 +516,7 @@ function App() {
// Use post rkey if on post page, otherwise use timestamp-based rkey
const rkey = appConfig.rkey || now.toISOString().replace(/[:.]/g, '-');
- const record = {
- $type: appConfig.collections.comment,
+ const newComment = {
text: commentText,
url: window.location.href,
createdAt: now.toISOString(),
@@ -509,6 +528,44 @@ function App() {
},
};
+ // Check if record with this rkey already exists
+ let existingComments = [];
+ try {
+ const existingResponse = await agent.api.com.atproto.repo.getRecord({
+ repo: user.did,
+ collection: appConfig.collections.comment,
+ rkey: rkey,
+ });
+
+ // Handle both old single comment format and new array format
+ if (existingResponse.data.value.comments) {
+ // New format: array of comments
+ existingComments = existingResponse.data.value.comments;
+ } else if (existingResponse.data.value.text) {
+ // Old format: single comment, convert to array
+ existingComments = [{
+ text: existingResponse.data.value.text,
+ url: existingResponse.data.value.url,
+ createdAt: existingResponse.data.value.createdAt,
+ author: existingResponse.data.value.author,
+ }];
+ }
+ } catch (err) {
+ // Record doesn't exist yet, that's fine
+ console.log('No existing record found, creating new one');
+ }
+
+ // Add new comment to the array
+ existingComments.push(newComment);
+
+ // Create the record with comments array
+ const record = {
+ $type: appConfig.collections.comment,
+ comments: existingComments,
+ url: window.location.href,
+ createdAt: now.toISOString(), // Latest update time
+ };
+
// Post to ATProto with rkey
const response = await agent.api.com.atproto.repo.putRecord({
repo: user.did,
@@ -811,7 +868,7 @@ function App() {
{user.displayName || user.handle}
@{user.handle}
-
DID: {user.did}
+
{user.did}