| commit | c514748e2bebc4c0d2955c3da15224f4a71aed19 | [log] [tgz] |
|---|---|---|
| author | banksean <banksean@gmail.com> | Sun Jun 29 00:41:58 2025 +0000 |
| committer | Autoformatter <bot@sketch.dev> | Tue Jul 01 03:51:08 2025 +0000 |
| tree | b849f32531dd8fad42060eb38127d018bb7fb131 | |
| parent | 26bc659f8f7e8864a6fb0a71dcbee7d3742d3763 [diff] |
webui: convert SketchTimelineMessage to TailwindElement with TypeScript demo module Convert SketchTimelineMessage component from Lit CSS-in-JS styles to TailwindElement inheritance with Tailwind utility classes, and replace standalone HTML test with comprehensive TypeScript demo module integrated with the demo runner framework. Problems Solved: CSS Inconsistency and Shadow DOM Isolation: - SketchTimelineMessage used shadow DOM with extensive CSS-in-JS styles while other components use TailwindElement - Component styling was isolated from global design system and Tailwind utilities - Over 400 lines of CSS-in-JS code created maintenance overhead and styling inconsistencies - No access to global Tailwind utility classes within shadow DOM environment Test Infrastructure Brittleness: - Tests relied on CSS class selectors that were implementation details - Complex CSS class selectors made tests fragile to styling changes - No standardized approach for testing UI elements across component library - Test selectors tightly coupled to internal CSS implementation Missing Development Infrastructure: - timeline-message-test.html was standalone and not integrated with demo runner - Required manual HTML file maintenance and Tailwind CDN loading - Component not discoverable through standardized demo system - No interactive controls for testing different component states - No integration with demo framework utilities and mock data Solution Implementation: TailwindElement Conversion: - Changed inheritance from LitElement to SketchTailwindElement to disable shadow DOM - Replaced all CSS-in-JS styles with equivalent Tailwind utility classes - Converted over 400 lines of CSS to responsive Tailwind class compositions - Maintained complete visual and functional parity while using global design system CSS Class Mapping and Styling: - .message → relative mb-1.5 flex flex-col w-full (base message layout) - .message-content → relative px-2.5 py-1.5 rounded-xl shadow-sm max-w-full w-fit (message bubble) - .user .message-content → bg-blue-500 text-white rounded-br-sm (user message styling) - .agent .message-content → bg-gray-100 text-black rounded-bl-sm (agent message styling) - .message-actions → absolute top-1 right-1 z-10 opacity-0 hover:opacity-100 (interaction buttons) - .commit-card → bg-gray-100 rounded-lg overflow-hidden mb-1.5 shadow-sm (commit display) - .commit-hash → text-blue-600 font-bold font-mono cursor-pointer bg-blue-600/10 (commit hash styling) - .commit-branch → text-green-600 font-medium cursor-pointer font-mono bg-green-600/10 (branch styling) Test Infrastructure Modernization: - Replaced CSS class selectors with Tailwind class selectors for reliable element targeting - Updated all test selectors to use new Tailwind class patterns for better maintainability - Converted .message-text to .overflow-x-auto for text content targeting - Converted .message-info-panel to .mt-2.p-2 for info panel targeting - Converted .commit-notification to .bg-green-100 for commit notification targeting - Maintained all existing test functionality while improving test reliability TypeScript Demo Module Creation: - Created sketch-timeline-message.demo.ts following established demo module pattern - Comprehensive component demonstration with multiple message types and features - Interactive controls for testing component behavior and state changes - Proper integration with demo framework types, utilities, and mock data system - Added component to knownComponents registry in demo-runner.ts for discoverability Demo Content Organization and Features: - Message Types section: User, agent, and error message examples with proper styling - Interactive Features section: Live component with control buttons for state testing - Advanced Examples section: Tool calls, commits, and complex markdown demonstrations - Interactive controls: Toggle info panel, change message type, toggle compact padding, cycle content examples - Event listeners for commit diff interactions and proper error handling Global Styling Architecture: - Added global CSS using document.head.appendChild for complex styling not easily replicated with Tailwind - Implemented floating message animations and transitions for user feedback - Created comprehensive markdown content styling for both user and agent messages - Added print media query support using Tailwind print: variants for proper printing - Used Tailwind @apply directive in global styles for complex component styling Implementation Details: Component Structure and Functionality: - Maintained all existing properties, methods, and component lifecycle hooks - Preserved scroll handling, markdown rendering, and interaction features completely - Added comprehensive Tailwind class composition for dynamic styling based on message type - Kept all existing functionality while changing only the styling implementation approach Visual Consistency and Behavior: - All colors, spacing, borders, and animations maintained complete visual parity - User message styling: blue background with white text and right alignment - Agent message styling: gray background with black text and left alignment - Commit cards: consistent styling with color-coded elements and proper interaction states - Info panels: conditional styling based on message type with proper contrast Interactive Features and Accessibility: - Copy buttons with proper hover states and transition animations - Info toggle functionality with slide-in panel animations and proper state management - Commit hash and branch click-to-copy functionality with user feedback - Floating success/error messages with proper positioning and accessibility - Keyboard navigation and screen reader compatibility maintained Demo Module Architecture: - Follows DemoModule interface with title, description, imports, and setup function - Includes Tailwind CSS styles for proper component rendering in demo environment - Cleanup function for demo-specific style removal to prevent memory leaks - Comprehensive error handling for malformed message data and edge cases - Uses existing demo fixture utilities and realistic mock state for consistency Mock Data Integration and Examples: - Realistic message examples with proper timestamps, IDs, and conversation threading - Tool call examples with proper structure, formatting, and result display - Git commit examples with hash, branch, subject, and GitHub integration - Usage information examples with token counts, costs, and performance metrics - Error message examples with proper error state styling and user guidance Files Modified: - sketch/webui/src/web-components/sketch-timeline-message.ts: TailwindElement inheritance and complete Tailwind class conversion - sketch/webui/src/web-components/sketch-timeline-message.test.ts: Updated test selectors to use new Tailwind class patterns Files Added: - sketch/webui/src/web-components/demo/sketch-timeline-message.demo.ts: Comprehensive TypeScript demo module Files Modified (Demo Integration): - sketch/webui/src/web-components/demo/demo-framework/demo-runner.ts: Added sketch-timeline-message to knownComponents Files Removed: - sketch/webui/src/web-components/demo/timeline-message-test.html: Replaced with TypeScript demo module The conversion maintains complete visual and functional parity while enabling consistent styling across the component library, improving test reliability through semantic Tailwind class targeting, and providing superior development capabilities through integrated TypeScript demo infrastructure. Co-Authored-By: sketch <hello@sketch.dev> Change-ID: s0efb435d3be1c182k
Sketch is an agentic coding tool. It draws the 🦉
Sketch runs in your terminal, has a web UI, understands your code, and helps you get work done. To keep your environment pristine, sketch starts a docker container and outputs its work onto a branch in your host git repository.
Sketch helps with most programming environments, but Sketch has extra goodies for Go.
go install sketch.dev/cmd/sketch@latest sketch
Currently, Sketch runs on MacOS and Linux. It uses Docker for containers.
| Platform | Installation |
|---|---|
| MacOS | brew install colima (or Docker Desktop/Orbstack) |
| Linux | apt install docker.io (or equivalent for your distro) |
| WSL2 | Install Docker Desktop for Windows (docker entirely inside WSL2 is tricky) |
The sketch.dev service is used to provide access to an LLM service and give you a way to access the web UI from anywhere.
Start Sketch by running sketch in a Git repository. It will open your browser to the Sketch chat interface, but you can also use the CLI interface. Use -open=false if you want to use just the CLI interface.
Ask Sketch about your codebase or ask it to implement a feature. It may take a little while for Sketch to do its work, so hit the bell (🔔) icon to enable browser notifications. We won't spam you or anything; it will notify you when the Sketch agent's turn is done, and there's something to look at.
When you start Sketch, it:
This design lets you run multiple sketches in parallel since they each have their own sandbox. It also lets Sketch work without worry: it can trash its own container, but it can't trash your machine.
Sketch's agentic loop uses tool calls (mostly shell commands, but also a handful of other important tools) to allow the LLM to interact with your codebase.
Sketch is trained to make Git commits. When those happen, they are automatically pushed to the git repository where you started sketch with branch names sketch/*.
Finding Sketch branches:
git branch -a --sort=creatordate | grep sketch/ | tail
The UI keeps track of the latest branch it pushed and displays it prominently. You can use standard Git workflows to pull those branches into your workspace:
git cherry-pick $(git merge-base origin/main sketch/foo)
or merge the branch
git merge sketch/foo
or reset to the branch
git reset --hard sketch/foo
Ie use the same workflows you would if you were pulling in a friend's Pull Request.
Advanced: You can ask Sketch to git fetch sketch-host and rebase onto another commit. This will also fetch where you started Sketch, and we do a bit of "git fetch refspec configuration" to make origin/main work as a git reference.
Don't be afraid of asking Sketch to help you rebase, merge/squash commits, rewrite commit messages, and so forth; it's good at it!
The diff view shows you changes since Sketch started. Leaving comments on lines adds them to the chat box, and, when you hit Send (at the bottom of the page), Sketch goes to work addressing your comments.
You can interact directly with the container in three ways:
ssh sketch-ilik-eske-tcha-lott. We have automatically configured your SSH configuration to make these special hostnames work.Using SSH (and/or VSCode) allows you to forward ports from the container to your machine. For example, if you want to start your development webserver, you can do something like this:
# Forward container port 8888 to local port 8000 ssh -L8000:localhost:8888 sketch-ilik-epor-tfor-ward go run ./cmd/server
This makes http://localhost:8000/ on your machine point to localhost:8888 inside the container.
You can ask Sketch to browse a web page and take screenshots. There are tools both for taking screenshots and "reading images", the latter of which sends the image to the LLM. This functionality is handy if you're working on a web page and want to see what the in-progress change looks like.
Docker images, containers, and so forth tend to pile up. Ask Docker to prune unused images and containers:
docker system prune -a
See CONTRIBUTING.md for development guidelines.
Sketch is open source. It is right here in this repository! Have a look around and mod away.
If you want to run Sketch entirely without the sketch.dev service, you can set the flag -skaband-addr="" and then provide an ANTHROPIC_API_KEY environment variable. (More LLM services coming soon!)