feat(app-builder): add user-initiated new chat session#1720
Open
kilo-code-bot[bot] wants to merge 2 commits intomainfrom
Open
feat(app-builder): add user-initiated new chat session#1720kilo-code-bot[bot] wants to merge 2 commits intomainfrom
kilo-code-bot[bot] wants to merge 2 commits intomainfrom
Conversation
Contributor
Author
Code Review SummaryStatus: 4 Issues Found | Recommendation: Address before merge Fix these issues in Kilo Cloud Overview
Issue Details (click to expand)N/A Other Observations (not in diff)Issues found outside the current PR diff and therefore not eligible for inline comments:
Files Reviewed (56 files)
Reviewed by gpt-5.4-20260305 · 2,290,279 tokens |
- Adds a SquarePen toggle in the chat header to enter/cancel new-session mode - While pending, existing session history remains visible with a 'New chat session' placeholder appended below; history was previously replaced entirely - Sending a message in pending mode calls sendMessage with forceNewSession:true, which creates a new cloud-agent session via the existing handleSessionChanged machinery (zero changes to V1/V2 session/streaming code) - awaitingNewSession bridges the gap between pendingNewSession becoming false (on send) and the new session object arriving in state, preventing the placeholder from flickering away one render early; implemented with useState + useEffect instead of a render-time ref mutation - requestNewSession/cancelNewSession set session.info.ended_at to visually collapse the current session into a history block while pending - Layout heights updated from h-dvh to h-[calc(100dvh-3.5rem)] across AppBuilderPage, AppBuilderLanding, and ProjectLoader to account for the top navigation bar - FeedbackDialog no longer disabled during streaming - pendingNewSession added to ProjectState test fixtures
77ffe9e to
21f5ddd
Compare
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
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.
Summary
Adds a "New Chat" button to the app builder chat pane header, allowing users to start a fresh AI session within an existing project. The new session gets a clean LLM context while preserving the project's full codebase and previous session history.
User flow:
SquarePenicon in the chat header (disabled while streaming)forceNewSession: trueon the existingsendMessageendpoint; the old session collapses into an expandable history block via the existinghandleSessionChangedmachineryArchitecture: The
forceNewSessionflag is handled entirely at theProjectManagerlevel — it calls tRPC directly and then delegates to the existinghandleSessionChangedhandler. Zero changes to V1/V2 session or streaming code. No DB migration needed (thereasoncolumn is freeformtext).Key implementation details:
pendingNewSession(in ProjectManager store) tracks whether the user has clicked "New chat" but not yet sentawaitingNewSession(in AppBuilderChat) bridges the one-render gap betweenpendingNewSessionflipping tofalseon send and the new session object arriving in state — implemented withuseState+useEffectrather than a render-time ref mutationrequestNewSession/cancelNewSessionsetsession.info.ended_atoptimistically so the current session collapses into a history block while the user composes their messageh-dvhtoh-[calc(100dvh-3.5rem)]acrossAppBuilderPage,AppBuilderLanding, andProjectLoaderto account for the top navigation barVerification
forceNewSessionpath inapp-builder-service.tsbypassesshouldCreateNewSessionand uses the existingcreateV1Session/createV2Sessionhelpers with the newuser_initiatedreasonpendingNewSessionstate resets correctly on send, cancel, and session creationpnpm typecheckpasses;oxfmtformat check passesVisual Changes
Reviewer Notes
SquarePenbutton is a toggle: click to enter pending mode, click again to cancel. It is disabled whileisStreamingis true so users cannot trigger it mid-stream.sendMessageAsNewSessionfunction inProjectManager.tscalls tRPC directly (rather than going through the session layer) because the existing session must be ended server-side before the new one is created. The response triggershandleSessionChanged, which reuses all existing session-change UI logic.AppBuilderSessionReason.UserInitiated('user_initiated') is added to the schema constant but requires no migration since the column istext NOT NULLwith no DB-level constraint on values.pendingNewSessionwas true. This PR keeps session history visible and only appends the placeholder, which required theawaitingNewSessionstate to prevent a flicker whenpendingNewSessionclears on send.