| commit | 5477736d9678803a245764439df767bf0e7c561d | [log] [tgz] |
|---|---|---|
| author | banksean <banksean@gmail.com> | Thu Jun 19 16:38:30 2025 +0000 |
| committer | Autoformatter <bot@sketch.dev> | Thu Jun 19 23:08:56 2025 +0000 |
| tree | 887290d2e601739a4bfeae0b4e6638feb8bb393e | |
| parent | 65ff909493e8f27bcdc507ed27253e28c98eb5ec [diff] |
webui: implement explicit initial render detection using State.message_count Add explicit initial load completion detection to SketchTimeline component using State.message_count to determine when all existing messages have been loaded and the timeline is ready for initial render. Implementation Changes: 1. DataManager Enhancement (data.ts): - Add expectedMessageCount and isInitialLoadComplete state tracking - Add 'initialLoadComplete' event type to DataManagerEventType union - Add checkInitialLoadComplete() method to validate completion state - Add handleInitialLoadComplete() event emission with message counts - Handle empty conversation edge case (message_count: 0) with immediate completion - Reset initial load state on connection establishment to handle reconnection - Add getIsInitialLoadComplete() and getExpectedMessageCount() getters 2. Timeline Component Enhancement (sketch-timeline.ts): - Add isInitialLoadComplete state property for render control - Add dataManager property reference for event listener setup - Add handleInitialLoadComplete() event handler with console logging - Update render logic to show loading indicator until initial load complete - Apply 'view-initialized' CSS class when initial load completes - Only render messages and thinking indicator after initial load completion - Set up DataManager event listeners in updated() lifecycle hook - Clean up event listeners in disconnectedCallback() lifecycle hook 3. App Shell Integration (sketch-app-shell.ts): - Pass dataManager reference to sketch-timeline component property - Enable timeline component to receive initial load completion events - Maintain existing data flow while adding explicit completion detection 4. Demo Mock Enhancement (handlers.ts): - Initialize currentState with correct message_count based on initial messages - Ensure proper message_count synchronization in SSE stream simulation - Handle empty conversation demo scenario with accurate state 5. Enhanced CSS Styling (sketch-timeline.ts): - Add opacity-based transitions for message appearance - Show loading indicator before initial completion - Hide message content until view-initialized class is applied - Smooth transition from loading to content display Technical Benefits: - Eliminates reliance on implicit 'first message means streaming started' detection - Provides explicit completion signal when all existing messages are loaded - Handles edge cases like empty conversations (0 messages) immediately - Prevents flash of incomplete content during initial load - Enables proper loading states and smooth transitions - Supports reconnection scenarios with state reset User Experience Improvements: - Clear loading indicator until conversation is fully loaded - Smooth transition from loading to content display - No flash of partial message lists during initial load - Consistent behavior across different conversation sizes - Better feedback during network delays or large conversation loads Edge Case Handling: - Empty conversations (message_count: 0) marked complete immediately - Messages arriving before state handled gracefully - Reconnection scenarios reset initial load detection - Race conditions between state and message delivery resolved This replaces the implicit initial load detection with explicit State.message_count based completion detection, providing more reliable initial render timing and better user experience during conversation loading. Co-Authored-By: sketch <hello@sketch.dev> Change-ID: s5126c2705d6ad6bak
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!)