📱

Read on Your E-Reader

Thousands of readers get articles like this delivered straight to their Kindle or Boox. New articles arrive automatically.

Learn More

This is a preview. The full article is published at news.ycombinator.com.

Visual Studio Code - The open source AI code editor

Visual Studio Code - The open source AI code editor

By michidkHacker News: Front Page

The open source AI code editor Web , Insiders edition , or other platforms By using VS Code, you agree to its license and privacy statement . import { For, createSignal, createMemo } from "solid-js"; import { useNavigate, useParams } from "@tanstack/solid-router"; import { getEmailsForMailbox } from "~/data/emails"; import { MailListItem } from "~/components/MailListItem"; export function MailList() { const params = useParams({ strict: false }) as { mailbox?: string; id?: string; }; const navigate = useNavigate(); const [query, setQuery] = createSignal(""); const mailbox = () => params.mailbox || "inbox"; const list = createMemo(() => { const q = query().toLowerCase(); return getEmailsForMailbox(mailbox()).filter( (e) => !q || e.subject.toLowerCase().includes(q) || e.snippet.toLowerCase().includes(q) ); }); function open(id: string) { navigate({ to: "/mail/$mailbox/$id", params: { mailbox: mailbox(), id }, search: (prev) => prev, }); } return ( <For each={list()}> {(e) => ( <div role="listitem" tabindex={0} onClick={() => open(e.id)} onKeyDown={(ev) => ev.key === "Enter" && open(e.id)} class="mail-item" data-selected={params.id === e.id ? "true" : undefined} aria-selected={params.id === e.id ? "true" : undefined} > <div> <div class="mail-item-subject truncate">{e.subject}</div> <div class="mail-item-snippet truncate">{e.snippet}</div> </div> <time class="text-xs muted" datetime={e.date} title={new Date(e.date).toLocaleString()} > {new Date(e.date).toLocaleDateString(undefined, { month: "short", day: "numeric", })} </time> </div> <MailListItem email={e} isSelected={params.id === e.id} onOpen={open} /> )} </For> ); } import type { Email } from "~/types"; interface MailListItemProps { email: Email; isSelected: boolean; onOpen: (id: string) => void; } export function MailListItem(props: MailListItemProps) { return ( <div role="listitem" tabindex={0} onClick={() => props.onOpen(props.email.id)} onKeyDown={(ev) => ev.key === "Enter" && props.onOpen(props.email.id)} class="mail-item" data-selected={props.isSelected ? "true" : undefined} aria-selected={props.isSelected ? "true" : undefined} > <div> <div class="mail-item-subject truncate">{props.email.subject}</div> <div class="mail-item-snippet truncate">{props.email.snippet}</div> </div> <time class="text-xs muted" datetime={props.email.date} title={new Date(props.email.date).toLocaleString()} > {new Date(props.email.date).toLocaleDateString(undefined, { month: "short", day: "numeric", })} </time> </div> ); Create new MailListItem component that handles individual mail list item rendering Extract mail item JSX and logic from MailList into the new MailListItem component Update MailList to use the new MailListItem component Build the project to verify changes compile correctly Test the application to ensure functionality remains intact Created a reusable component for rendering individual mail list items Accepts email , isSelected , and onSelect props Maintains all accessibility features (ARIA roles, keyboard navigation) Preserves styling and interaction behavior Simplified by removing inline mail item rendering logic Now uses the MailListItem component with clean prop passing Reduced component complexity and improved readability ✅ Build successful ✅ All functionality working correctly (filtering, selection, navigation) ✅ Keyboard accessibility preserved (Enter key navigation) ✅ Visual selection state working properly Any model for any team Choose from multiple out of the box models, or bring your own key to access models from your preferred model and hosting provider. An expert on your codebase Your codebase is indexed locally and remotely to understand what's relevant, enabling fast, context-aware interactions. AI that works the way your team does Personalize interactions using custom agents, custom instructions, and reusable prompt files tailored to your workflows and tools. --- description: 'Generate compact responses, focusing on brevity and clarity.' tools: ['search', 'fetch', 'githubRepo', 'usages', 'vscodeAPI', 'problems', 'changes', 'testFailure', 'todos'] --- You...

Preview: ~500 words

Continue reading at Hacker News

Read Full Article

More from Hacker News: Front Page

Subscribe to get new articles from this feed on your e-reader.

View feed

This preview is provided for discovery purposes. Read the full article at news.ycombinator.com. LibSpace is not affiliated with Hacker News.

Visual Studio Code - The open source AI code editor | Read on Kindle | LibSpace