Class: RubynCode::IDE::Handlers::SessionResetHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/rubyn_code/ide/handlers/session_reset_handler.rb

Overview

Handles the “session/reset” JSON-RPC request.

Called when the user clicks “New Session” in the chat UI. Delegates to PromptHandler#reset_session which cancels any in-flight agent thread for that sessionId and drops the cached Agent::Conversation, so the next prompt starts with empty message history — parity with the CLI REPL’s ‘/new` command.

Instance Method Summary collapse

Constructor Details

#initialize(server) ⇒ SessionResetHandler

Returns a new instance of SessionResetHandler.



14
15
16
# File 'lib/rubyn_code/ide/handlers/session_reset_handler.rb', line 14

def initialize(server)
  @server = server
end

Instance Method Details

#call(params) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/rubyn_code/ide/handlers/session_reset_handler.rb', line 18

def call(params)
  session_id = params['sessionId']
  return { 'reset' => false, 'error' => 'Missing sessionId' } unless session_id

  prompt = @server.handler_instance(:prompt)
  return { 'reset' => false, 'error' => 'Prompt handler not available' } unless prompt

  prompt.reset_session(session_id)
  { 'reset' => true, 'sessionId' => session_id }
end