1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
import {
CategorizationResponse,
userCategories,
} from "../../lib/categorization";
import { TwitterApiService, TwitterBookmark } from "../../lib/twitter-api";
export default function ({
bookmark,
categorization,
currentIndex,
totalCount,
}: {
bookmark: TwitterBookmark;
categorization: CategorizationResponse;
currentIndex: number;
totalCount: number;
}) {
async function processEntry() {
"use server";
const cookie = Bun.env.TWATTER_COKI;
const api = new TwitterApiService(cookie!);
await api.removeBookmark(bookmark.id);
}
return (
<div className="bg-white rounded-lg shadow-lg overflow-hidden">
{/* Bookmark Content */}
<div className="p-6 border-b">
<div className="flex items-start space-x-3 mb-4">
<img
src={bookmark.author.avatar}
alt={bookmark.author.name}
className="w-12 h-12 rounded-full"
/>
<div>
<h3 className="font-semibold text-gray-900">
{bookmark.author.name}
</h3>
<p className="text-gray-600">@{bookmark.author.username}</p>
<p className="text-sm text-gray-500">
{new Date(bookmark.createdAt).toLocaleDateString()}
</p>
</div>
</div>
<div className="prose max-w-none mb-4">
<p className="whitespace-pre-wrap">{bookmark.text}</p>
</div>
{bookmark.media.pics.length > 0 && (
<div className="mb-4">
<h4 className="text-sm font-semibold text-gray-700 mb-2">Images</h4>
<div className="grid grid-cols-3 gap-2">
{bookmark.media.pics.map((url, index) => (
<img
key={index}
src={url}
alt={`Bookmark image ${index + 1}`}
className="rounded-lg border"
/>
))}
</div>
</div>
)}
<div className="flex flex-wrap gap-2">
{bookmark.hashtags.map((tag) => (
<span
key={tag}
className="px-2 py-1 bg-gray-100 text-gray-700 rounded-full text-sm"
>
#{tag}
</span>
))}
</div>
</div>
{/* LLM Analysis */}
<div className="p-6 border-b bg-gray-50">
<h3 className="text-lg font-semibold mb-3">AI Analysis</h3>
<p className="text-sm text-gray-600 mb-3">{categorization.summary}</p>
<div className="mb-4">
<h4 className="text-sm font-semibold mb-2">Key Topics</h4>
<div className="flex flex-wrap gap-2">
{categorization.keyTopics.map((topic) => (
<span
key={topic}
className="px-2 py-1 bg-blue-100 text-blue-800 rounded text-sm"
>
{topic}
</span>
))}
</div>
</div>
<div>
<h4 className="text-sm font-semibold mb-2">Suggested Categories</h4>
{categorization.suggestedCategories.map((suggestion, index) => (
<div key={index} className="mb-2 p-2 bg-white rounded border">
<div className="flex items-center justify-between mb-1">
<span className="font-medium">
{suggestion.categories.join(", ")}
</span>
<span className="text-sm text-gray-600">
{(suggestion.confidence * 100).toFixed(0)}%
</span>
</div>
<p className="text-sm text-gray-600">{suggestion.reasoning}</p>
</div>
))}
</div>
</div>
{/* Category Selection */}
<form method="POST" action="/api/save-categorization">
<div className="p-6">
<h3 className="text-lg font-semibold mb-3">Select Categories</h3>
<div className="mb-4">
<h4 className="text-sm font-semibold mb-2">User Categories</h4>
<div className="flex flex-wrap gap-2">
{userCategories.map((category) => (
<label
key={category.name}
className="flex items-center cursor-pointer"
>
<input
type="checkbox"
name="categories"
value={category.name}
defaultChecked={categorization.suggestedCategories[0]?.categories.includes(
category.name,
)}
className="mr-2"
/>
<span className="px-3 py-1 bg-gray-200 text-gray-700 rounded-full text-sm">
{category.name}
</span>
</label>
))}
</div>
</div>
{categorization.newCategories.length > 0 && (
<div className="mb-4">
<h4 className="text-sm font-semibold mb-2">
New Category Suggestions
</h4>
<div className="flex flex-wrap gap-2">
{categorization.newCategories.map((category) => (
<label
key={category}
className="flex items-center cursor-pointer"
>
<input
type="checkbox"
name="categories"
value={category}
className="mr-2"
/>
<span className="px-3 py-1 bg-green-100 text-green-800 rounded-full text-sm">
{category}
</span>
</label>
))}
</div>
</div>
)}
<div className="mb-4">
<label className="block text-sm font-semibold mb-2">
Custom Categories
</label>
<input
type="text"
name="customCategories"
placeholder="Add custom categories, separated by commas"
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"
/>
</div>
<input type="hidden" name="bookmarkId" value={bookmark.id} />
<input type="hidden" name="nextIndex" value={currentIndex + 1} />
<div className="flex space-x-4">
{currentIndex > 0 && (
<a
href={`/categorize?idx=${currentIndex - 1}`}
className="px-4 py-2 border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50"
>
Previous
</a>
)}
<button
type="submit"
className="flex-1 bg-blue-600 text-white py-2 px-4 rounded-lg hover:bg-blue-700"
>
Save & Next
</button>
{currentIndex + 1 < totalCount && (
<a
href={`/categorize?idx=${currentIndex + 1}`}
className="px-4 py-2 border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50"
>
Skip
</a>
)}
</div>
</div>
</form>
</div>
);
}
|