-
Notifications
You must be signed in to change notification settings - Fork 27
Optimize Swift app polling with lightweight session endpoint #232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
vanpelt
wants to merge
12
commits into
main
Choose a base branch
from
feat/session-polling-optimization
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,368
−379
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Use the /v1/sessions/workspace/{path} endpoint for active session polling
instead of fetching all workspaces. This significantly reduces backend load
during active Claude sessions.
- Add latestUserPrompt, latestMessage, latestThought, stats to FullSessionData
- Always populate session data fields (not just when full=true)
- Update WorkspacePoller to use session endpoint for active sessions
- Add effectiveLatestUserPrompt/Message computed properties in views
- Fix "You asked" section disappearing during active sessions
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Show the "Start Working" button instead of an empty gray box when a workspace is in completed phase but has no session content (no user prompt, no Claude message, no session title, no todos). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…ding Two issues fixed: 1. Backend: Return full FullSessionData object (not just SessionInfo) when full=false, so latestUserPrompt, latestMessage, latestThought, and stats are included in the response 2. Swift: Send full workspace path (e.g., "/worktrees/catnip/ruby") instead of just the last component, so backend can match against config 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
The workspace path (e.g., /worktrees/catnip/ruby) contains slashes which break URL routing when used as a path parameter. Changed to use query parameter instead: - Backend: Accept workspace via ?workspace= query param (with path param fallback for backward compatibility) - Swift: Use URLComponents with query items to properly encode the path - Added route without path param that must come before parameterized route Now the URL is: /v1/sessions/workspace?workspace=/worktrees/catnip/ruby 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Much simpler approach - the Swift app already has the workspace ID from
the worktrees list. Using the ID in the URL path is cleaner than trying
to encode paths with slashes.
- Backend: Accept workspace ID or path in the path param, resolve ID to
path using GitService.GetWorktree()
- Swift: Use workspaceId directly in URL path
- Remove unused workspacePath from WorkspacePoller
URL is now: /v1/sessions/workspace/{workspace-uuid}
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Use paths.FindBestSessionFile in ClaudeService instead of SessionService - This filters out agent-*.jsonl subagent sessions via UUID validation - Checks for conversation content (not just snapshots) - Filters out forked sessions (queue-operation) - Prioritizes most recently modified, then largest size Also adds latestClaudeMessage field to Swift WorkspaceInfo model for fallback display when session endpoint returns empty. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
populateLatestDataFromParser was returning cached/stale session data because it didn't call ReadIncremental() to refresh the parser. The user prompt was correct because it reads from ~/.claude/history.jsonl fresh each time, but latestMessage/thought/stats came from cached parser state. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
ParserService had its own findBestSessionInDir() that did NOT filter by UUID format, so it was selecting agent-*.jsonl files when they were larger than the main session file. Now uses paths.FindBestSessionFile which properly: - Validates UUID format (filters out agent-*.jsonl) - Checks for conversation content (not just snapshots) - Filters out forked sessions (queue-operation) - Prioritizes most recently modified, then largest size This ensures the session endpoint returns data from the same session file as `catnip reflect`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This fixes a bug where the PTY terminal was resuming a different session than what the parser was reading. All session file selection logic now uses the centralized paths.FindBestSessionFile which properly: - Validates UUID format (filters out agent-*.jsonl files) - Checks for conversation content (user/assistant messages) - Filters out forked sessions (queue-operation) - Prioritizes most recently modified, with size as tie-breaker Updated: - SessionService.findNewestClaudeSessionFile - SessionService.FindBestSessionFile - PTYHandler.findNewestClaudeSession - ClaudeSessionDetector.findClaudeSessionFromFiles Also added comprehensive tests for paths.FindBestSessionFile. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add Todos and LatestSessionTitle fields to FullSessionData model - Populate fields in populateLatestDataFromParser from parser cache and session service - Update Swift SessionData model to include the new fields - Add effectiveSessionTitle and effectiveTodos computed properties in WorkspaceDetailView to prefer session data over workspace data - Wrap session token logging in #if DEBUG directive - Update UITestingHelper with mock todos and session title This enables the iOS app to display session title and todos during active polling without needing to fetch from the heavier /git/worktrees endpoint. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Remove duplicate GetAllSessionsForWorkspace call (was called twice per request) - Only populate allSessions when full=true is requested - Always clear sessionInfo.allSessions to avoid duplication in response This reduces polling response size from ~5.7KB to ~1.2KB (79% smaller) for the iOS app which never uses allSessions data. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Shows Claude's token consumption as a circular progress indicator around the terminal/dashboard toggle button. Ring color changes based on usage: - Gray: < 40K tokens - Green: 40K - 80K tokens - Orange: 80K - 120K tokens - Red: > 120K tokens (approaching 155K compaction limit) Also removes verbose session data logging. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Use the /v1/sessions/workspace/{path} endpoint for active session polling instead of fetching all workspaces. This significantly reduces backend load during active Claude sessions.
🤖 Generated with Claude Code