TownieuseChatLogic.ts4 matches
7branchId: string | undefined;
8selectedFiles: string[];
9images: (string | null)[];
10soundEnabled: boolean;
11}
17// bearerToken,
18selectedFiles,
19images,
20soundEnabled,
21}: UseChatLogicProps) {
40branchId,
41selectedFiles,
42images: images
43.filter((img): img is string => {
44const isValid = typeof img === "string" && img.startsWith("data:");
45if (!isValid && img !== null) {
46console.warn(
47"Invalid image format:",
48img?.substring(0, 50) + "..."
49);
29- [x] File write as a code embed
30- [x] str_replace as a diff view
31- [x] make image drop area invisible and bigger
32- [x] Give it all the code (except maybe .txt files) as initial context (like cursor sonnet max)
33- [x] I seem to have lost the delete file tool and instructions, try to find them back in history or re-create?
55- [x] Create branch
56- [x] URL input + pathname
57- [x] Image upload controls
58- [x] Preview refresh button
59- [x] Audio controls
Towniesystem_prompt.txt2 matches
172173- **Redirects:** Use `return new Response(null, { status: 302, headers: { Location: "/place/to/redirect" }})` instead of `Response.redirect` which is broken
174- **Images:** Avoid external images or base64 images. Use emojis, unicode symbols, or icon fonts/libraries instead
175- **AI Image:** To inline generate an AI image use: `<img src="https://maxm-imggenurl.web.val.run/the-description-of-your-image" />`
176- **Storage:** DO NOT use the Deno KV module for storage
177- **Browser APIs:** DO NOT use the `alert()`, `prompt()`, or `confirm()` methods
Towniestyles.css11 matches
747background-color: var(--highlight);
748}
749.card-image {
750display: flex;
751align-items: center;
774}
775776.image-placeholder,
777.image-thumbnail {
778flex-shrink: 0;
779width: 40px;
782object-fit: cover;
783}
784.image-placeholder {
785background-color: var(--muted);
786}
793}
794795.image-row {
796display: flex;
797gap: var(--space-1);
798}
799.input-image {
800position: relative;
801border: 1px solid var(--muted);
802border-radius: 6px;
803}
804.remove-image-button {
805position: absolute;
806top: 0;
815opacity: 0;
816}
817.input-image:hover .remove-image-button {
818opacity: 1;
819}
820821.image-drop-overlay {
822position: fixed;
823top: 0;
832justify-content: center;
833}
834.image-drop-inner {
835padding: var(--space-2);
836background-color: var(--background);
837}
838839.transition, .input-box, .icon-button, .button, .remove-image-button {
840transition-property: color, background-color, border-color, opacity;
841transition-duration: 200ms;
Towniesend-message.ts11 matches
26}
2728const { messages, project, branchId, anthropicApiKey, selectedFiles, images } = await c.req.json();
2930// do we want to allow user-provided tokens still
48branch_id: branchId,
49val_id: project.id,
50num_images: images?.length || 0,
51model: "claude-3-7-sonnet-20250219",
52});
58let coreMessages = convertToCoreMessages(messages);
5960// If there are images, we need to add them to the last user message
61if (images && Array.isArray(images) && images.length > 0) {
62// Find the last user message
63const lastUserMessageIndex = coreMessages.findIndex(
81};
8283// Add each image to the content array using the correct ImagePart format
84for (const image of images) {
85if (image && image.url) {
86// Extract mime type from data URL if available
87let mimeType = undefined;
88if (image.url.startsWith("data:")) {
89const matches = image.url.match(/^data:([^;]+);/);
90if (matches && matches.length > 1) {
91mimeType = matches[1];
9495newUserMessage.content.push({
96type: "image",
97image: image.url,
98mimeType,
99});
Townieschema.tsx2 matches
18price?: number;
19finish_reason?: string;
20num_images?: number;
21our_api_token: boolean;
22}
43price REAL,
44finish_reason TEXT,
45num_images INTEGER,
46our_api_token INTEGER NOT NULL,
47finish_timestamp INTEGER
Townierequests.ts3 matches
16price: number | null;
17finish_reason: string | null;
18num_images: number | null;
19our_api_token: number;
20}
191<th>Price</th>
192<th>Finish</th>
193<th>Images</th>
194<th>Our API</th>
195</tr>
215<td class="price">${formatPrice(row.price)}</td>
216<td>${row.finish_reason || '-'}</td>
217<td>${formatNumber(row.num_images)}</td>
218<td>${formatBoolean(row.our_api_token)}</td>
219</tr>
Towniequeries.tsx4 matches
109model,
110our_api_token,
111num_images,
112}: {
113bearerToken: string;
116model: string;
117our_api_token: boolean;
118num_images: number;
119}) {
120const user = await getUser(bearerToken);
128model,
129our_api_token,
130num_images
131) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
132`,
139model,
140our_api_token ? 1 : 0,
141num_images,
142],
143);
TownieProjectsRoute.tsx7 matches
42user: {
43username: string;
44profileImageUrl: string | null;
45};
46project: any;
48return (
49<div className="card">
50{project.imageUrl ? (
51<img src={project.imageUrl} className="card-image" />
52) : user.profileImageUrl ? (
53<div className="card-image">
54<img
55src={user.profileImageUrl}
56width="48"
57height="48"
60</div>
61) : (
62<div className="card-image placeholder" />
63)}
64<div className="card-body">
TownieInputBox.tsx46 matches
2import { useRef, useState, useEffect } from "react";
3import { PlusIcon, ArrowUpIcon, Square, XIcon } from "./icons.tsx";
4import { processFiles } from "../utils/images.ts";
56export function InputBox ({
11running,
12error,
13images,
14setImages,
15} : {
16value: string;
20running: boolean;
21error: any;
22images: (string|null)[];
23setImages: (images: (string|null)[]) => void;
24}) {
25const form = useRef(null);
57autoFocus={true}
58/>
59<ImageRow images={images} setImages={setImages} />
60<div className="toolbar">
61<UploadButton
62disabled={running}
63images={images}
64setImages={setImages}
65/>
66<div className="spacer" />
88}
8990export function ImageDropContainer ({
91images,
92setImages,
93running,
94children,
95}: {
96images: (string|null)[];
97setImages: (images: (string|null)[]) => void;
98running: boolean;
99children: React.ReactNode;
100}) {
101const dragging = useImageDrop({ images, setImages, running });
102103return (
105{children}
106{dragging && (
107<div className="image-drop-overlay">
108<div className="image-drop-inner">
109Drop images here to upload
110</div>
111</div>
115}
116117export function useImageDrop ({ images, setImages, running }: {
118images: (string|null)[];
119setImages(images: (string|null)[]) => void;
120running: boolean;
121}) {
143setDragging(false);
144if (e.dataTransfer?.files && !running) {
145processFiles(Array.from(e.dataTransfer.files), images, setImages);
146}
147}
164}
165166function ImageRow ({ images, setImages }: {
167images: (string|null)[];
168setImages: (images: (string|null)[]) => void;
169}) {
170return (
171<div className="image-row">
172{images.map((image, i) => (
173<Thumbnail
174key={i}
175image={image}
176onRemove={() => {
177setImages([
178...images.slice(0, i),
179...images.slice(i + 1),
180]);
181}}
186}
187188function Thumbnail ({ image, onRemove }: {
189image: string|null;
190onRemove: () => void;
191}) {
192if (!image) return null;
193194return (
195<div className="input-image">
196<img
197src={image}
198alt="User uploaded image"
199className="image-thumbnail"
200/>
201<button
202type="button"
203title="Remove image"
204className="remove-image-button"
205onClick={onRemove}
206>
212213function UploadButton ({
214images,
215setImages,
216disabled,
217}: {
218images: (string|null)[];
219setImages: (images: (string|null)[]) => void;
220disabled: boolean;
221}) {
226<button
227type="button"
228title="Upload image"
229disabled={disabled}
230onClick={e => {
234<PlusIcon />
235<div className="sr-only">
236Upload image
237</div>
238</button>
243onChange={e => {
244if (e.target.files) {
245processFiles(Array.from(e.target.files), images, setImages);
246}
247}}