YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
small fix on reddit pipe
Louis Beaumontc838b83b55f7
diff --git a/examples/typescript/pipe-post-questions-on-reddit/pipe.ts b/examples/typescript/pipe-post-questions-on-reddit/pipe.tsindex 8171ddb0e..4d5c9e8fa 100644--- a/examples/typescript/pipe-post-questions-on-reddit/pipe.ts+++ b/examples/typescript/pipe-post-questions-on-reddit/pipe.ts@@ -108,15 +108,32 @@ function generateRedditLinks(content: string): string {if (titleMatch && bodyMatch && subredditsMatch) {const title = titleMatch[1].trim();const body = bodyMatch[1].trim();- const encodedTitle = encodeURIComponent(title);- const encodedBody = encodeURIComponent(`${title}\n\n${body}`);++ // Truncate title and body if they're too long+ const maxTitleLength = 300; // Reddit's title limit+ const maxBodyLength = 40000; // Reddit's body limit+ const truncatedTitle = title.length > maxTitleLength+ ? title.slice(0, maxTitleLength - 3) + "..."+ : title;+ const truncatedBody = body.length > maxBodyLength+ ? body.slice(0, maxBodyLength - 3) + "..."+ : body;++ const encodedTitle = encodeURIComponent(truncatedTitle);+ const encodedBody = encodeURIComponent(`${truncatedTitle}\n\n${truncatedBody}`);result += `### ${index + 1}. ${title}\n\n${body}\n\n`;subredditsMatch.forEach((subreddit) => {const subredditName = subreddit.slice(2, -1);- const link = `https://www.reddit.com/r/${subredditName}/submit?title=${encodedTitle}&text=${encodedBody}`;- result += `- ${subreddit} [SEND](${link})\n`;+ // Use a shorter URL format and handle potential URL length issues+ try {+ const link = `https://www.reddit.com/r/${subredditName}/submit?title=${encodedTitle}&text=${encodedBody}`;+ result += `- ${subreddit} [SEND](${link})\n`;+ } catch (error) {+ console.warn(`failed to generate link for post ${index + 1} in r/${subredditName}:`, error);+ result += `- ${subreddit} [POST TOO LONG - COPY MANUALLY]\n`;+ }});result += "\n";