stevensDemoApp.tsx17 matches
82const [cookieAndTeaMode, setCookieAndTeaMode] = useState(false);
8384// Fetch images from backend instead of blob storage directly
85useEffect(() => {
86// Set default background color in case image doesn't load
89}
9091// Fetch avatar image
92fetch("/api/images/stevens.jpg")
93.then((response) => {
94if (response.ok) return response.blob();
103});
104105// Fetch wood background
106fetch("/api/images/wood.jpg")
107.then((response) => {
108if (response.ok) return response.blob();
129}, []);
130131const fetchMemories = useCallback(async () => {
132setLoading(true);
133setError(null);
134try {
135const response = await fetch(API_BASE);
136if (!response.ok) {
137throw new Error(`HTTP error! status: ${response.status}`);
154}
155} catch (e) {
156console.error("Failed to fetch memories:", e);
157setError(e.message || "Failed to fetch memories.");
158} finally {
159setLoading(false);
162163useEffect(() => {
164fetchMemories();
165}, [fetchMemories]);
166167const handleAddMemory = async (e: React.FormEvent) => {
176177try {
178const response = await fetch(API_BASE, {
179method: "POST",
180headers: { "Content-Type": "application/json" },
188setNewMemoryTags("");
189setShowAddForm(false);
190await fetchMemories();
191} catch (e) {
192console.error("Failed to add memory:", e);
199200try {
201const response = await fetch(`${API_BASE}/${id}`, {
202method: "DELETE",
203});
205throw new Error(`HTTP error! status: ${response.status}`);
206}
207await fetchMemories();
208} catch (e) {
209console.error("Failed to delete memory:", e);
231232try {
233const response = await fetch(`${API_BASE}/${editingMemory.id}`, {
234method: "PUT",
235headers: { "Content-Type": "application/json" },
240}
241setEditingMemory(null);
242await fetchMemories();
243} catch (e) {
244console.error("Failed to update memory:", e);
65const { startDate, endDate } = getYesterdayDateRange();
6667const response = await fetch("https://api.linear.app/graphql", {
68method: "POST",
69headers: {
8081if (data.errors) {
82console.error("Error fetching data from Linear API:", data.errors);
83Deno.exit(1);
84}
86const issues = data.data.viewer.assignedIssues.nodes;
8788// Group issues by team and fetch issue history
89const issuesByTeam: { [teamName: string]: any[] } = {};
90for (const issue of issues) {
94}
9596const historyResponse = await fetch("https://api.linear.app/graphql", {
97method: "POST",
98headers: {
110if (historyData.errors) {
111console.error(
112`Error fetching history for issue ${issue.id}:`,
113historyData.errors,
114);
190}
191192const slackResponse = await fetch("https://slack.com/api/chat.postMessage", {
193method: "POST",
194headers: {
cerebras_coderindex.ts1 match
181182try {
183const response = await fetch("/", {
184method: "POST",
185body: JSON.stringify({
169170// Send the conversation history *before* the user's latest message was added
171const response = await fetch("/process", {
172method: "POST",
173headers: { "Content-Type": "application/json" },
343try {
344log("INFO", "Making tool request", { toolName: tool.schema.name, toolId: tool.id });
345const toolResponse = await fetch("/tool", {
346method: "POST",
347headers: { "Content-Type": "application/json" },
351352if (controller.signal.aborted) {
353log("INFO", "Tool request fetch aborted.");
354// Update the specific tool message to reflect cancellation
355setMessages(prev =>
1086}
10871088// fetchData function (handles streaming) - unchanged from previous version
1089let currentFetchController = null;
1090async function fetchData(path) {
1091const cleanPath = '/' + path.replace(/^\\/|\\/$/g, '');
1092if (cleanPath === '/') {
1094return;
1095}
1096if (currentFetchController) currentFetchController.abort();
1097currentFetchController = new AbortController();
1098const signal = currentFetchController.signal;
10991100resultContainer.classList.remove('hidden');
11111112try {
1113console.log("Fetching:", cleanPath); // Client-side log
1114const response = await fetch(cleanPath, { signal });
1115if (!response.ok) {
1116let errorText = \`Request failed: \${response.status}\`;
11261127while (true) {
1128if (signal.aborted) { console.log("Fetch aborted."); reader.releaseLock(); return; }
1129const { done, value } = await reader.read();
1130if (done) { console.log("Stream finished."); break; }
1172} catch (error) {
1173if (error.name !== 'AbortError') {
1174console.error("Fetch Error:", error); // Client-side log
1175errorDisplay.textContent = \`Error: \${error.message}\`;
1176resultData.innerHTML = '<p class="text-red-500 italic">Failed.</p>';
1181submitButton.disabled = false;
1182topicInput.disabled = false;
1183currentFetchController = null;
1184}
1185}
1191e.preventDefault();
1192const topicPath = topicInput.value.trim();
1193if (topicPath) { fetchData(topicPath); history.pushState({ path: topicPath }, '', '/' + topicPath.replace(/^\\/|\\/$/g, '')); }
1194else { errorDisplay.textContent = 'Please enter topic path.'; resultContainer.classList.add('hidden'); }
1195});
1199e.preventDefault();
1200const path = link.getAttribute('href');
1201if (path) { const pathValue = path.substring(1); topicInput.value = pathValue; fetchData(pathValue); history.pushState({ path: pathValue }, '', path); }
1202});
1203}
1206const pathFromLocation = window.location.pathname.substring(1).replace(/\\/$/, '');
1207topicInput.value = pathFromLocation;
1208if (pathFromLocation) { fetchData(pathFromLocation); }
1209else { resultContainer.classList.add('hidden'); errorDisplay.textContent = ''; topicInput.value = ''; if (currentFetchController) currentFetchController.abort(); }
1210});
1211const initialPath = window.location.pathname.substring(1).replace(/\\/$/, '');
1212if (initialPath && initialPath !== 'favicon.ico') { topicInput.value = initialPath; fetchData(initialPath); }
1213else { resultContainer.classList.add('hidden'); }
1214});
1274+ " \"actionType\": \"use_tool\",\n"
1275+ " \"reasoning\": \"Why a tool is needed and what info you need.\",\n"
1276+ " \"response\": \"Inform the user you're fetching data (e.g., 'Let me look that up...').\",\n"
1277+ " \"tool\": {\n"
1278+ " \"id\": null, \n"
76setInput("");
7778const response = await fetch("/chat", {
79method: "POST",
80headers: { "Content-Type": "application/json" },
93setInput("");
9495const response = await fetch("/generate-image", {
96method: "POST",
97headers: { "Content-Type": "application/json" },
stevensDemosendDailyBrief.ts1 match
135const lastSunday = today.startOf("week").minus({ days: 1 });
136137// Fetch relevant memories using the utility function
138const memories = await getRelevantMemories();
139
stevensDemoNotebookView.tsx12 matches
67const [currentPage, setCurrentPage] = useState(1);
6869const fetchMemories = useCallback(async () => {
70setLoading(true);
71setError(null);
72try {
73const response = await fetch(API_BASE);
74if (!response.ok) {
75throw new Error(`HTTP error! status: ${response.status}`);
78setMemories(data);
79} catch (e) {
80console.error("Failed to fetch memories:", e);
81setError(e.message || "Failed to fetch memories.");
82} finally {
83setLoading(false);
8687useEffect(() => {
88fetchMemories();
89}, [fetchMemories]);
9091const handleAddMemory = async (e: React.FormEvent) => {
100101try {
102const response = await fetch(API_BASE, {
103method: "POST",
104headers: { "Content-Type": "application/json" },
112setNewMemoryTags("");
113setShowAddForm(false);
114await fetchMemories();
115} catch (e) {
116console.error("Failed to add memory:", e);
123124try {
125const response = await fetch(`${API_BASE}/${id}`, {
126method: "DELETE",
127});
129throw new Error(`HTTP error! status: ${response.status}`);
130}
131await fetchMemories();
132} catch (e) {
133console.error("Failed to delete memory:", e);
155156try {
157const response = await fetch(`${API_BASE}/${editingMemory.id}`, {
158method: "PUT",
159headers: { "Content-Type": "application/json" },
164}
165setEditingMemory(null);
166await fetchMemories();
167} catch (e) {
168console.error("Failed to update memory:", e);
stevensDemoindex.ts2 matches
135));
136137// HTTP vals expect an exported "fetch handler"
138export default app.fetch;
stevensDemo.cursorrules5 matches
163```
1641655. **fetchTranspiledJavaScript** - Fetch and transpile TypeScript to JavaScript:
166```ts
167const jsCode = await fetchTranspiledJavaScript("https://esm.town/v/username/project/path/to/file.ts");
168```
169242243// Inject data to avoid extra round-trips
244const initialData = await fetchInitialData();
245const dataScript = `<script>
246window.__INITIAL_DATA__ = ${JSON.stringify(initialData)};
3003015. **API Design:**
302- `fetch` handler is the entry point for HTTP vals
303- Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`
304- Properly handle CORS if needed for external access
stevensDemoApp.tsx17 matches
82const [cookieAndTeaMode, setCookieAndTeaMode] = useState(false);
8384// Fetch images from backend instead of blob storage directly
85useEffect(() => {
86// Set default background color in case image doesn't load
89}
9091// Fetch avatar image
92fetch("/api/images/stevens.jpg")
93.then((response) => {
94if (response.ok) return response.blob();
103});
104105// Fetch wood background
106fetch("/api/images/wood.jpg")
107.then((response) => {
108if (response.ok) return response.blob();
129}, []);
130131const fetchMemories = useCallback(async () => {
132setLoading(true);
133setError(null);
134try {
135const response = await fetch(API_BASE);
136if (!response.ok) {
137throw new Error(`HTTP error! status: ${response.status}`);
154}
155} catch (e) {
156console.error("Failed to fetch memories:", e);
157setError(e.message || "Failed to fetch memories.");
158} finally {
159setLoading(false);
162163useEffect(() => {
164fetchMemories();
165}, [fetchMemories]);
166167const handleAddMemory = async (e: React.FormEvent) => {
176177try {
178const response = await fetch(API_BASE, {
179method: "POST",
180headers: { "Content-Type": "application/json" },
188setNewMemoryTags("");
189setShowAddForm(false);
190await fetchMemories();
191} catch (e) {
192console.error("Failed to add memory:", e);
199200try {
201const response = await fetch(`${API_BASE}/${id}`, {
202method: "DELETE",
203});
205throw new Error(`HTTP error! status: ${response.status}`);
206}
207await fetchMemories();
208} catch (e) {
209console.error("Failed to delete memory:", e);
231232try {
233const response = await fetch(`${API_BASE}/${editingMemory.id}`, {
234method: "PUT",
235headers: { "Content-Type": "application/json" },
240}
241setEditingMemory(null);
242await fetchMemories();
243} catch (e) {
244console.error("Failed to update memory:", e);