Class: RubynCode::CLI::Commands::NewSession

Inherits:
Base
  • Object
show all
Defined in:
lib/rubyn_code/cli/commands/new_session.rb

Overview

Saves the current session and starts a fresh conversation. Like pressing Escape in Claude Code — clears context without quitting.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

all_names, hidden?

Class Method Details

.aliasesObject



11
# File 'lib/rubyn_code/cli/commands/new_session.rb', line 11

def self.aliases = ['/reset'].freeze

.command_nameObject



9
# File 'lib/rubyn_code/cli/commands/new_session.rb', line 9

def self.command_name = '/new'

.descriptionObject



10
# File 'lib/rubyn_code/cli/commands/new_session.rb', line 10

def self.description = 'Save current session and start a fresh conversation'

Instance Method Details

#execute(_args, ctx) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/rubyn_code/cli/commands/new_session.rb', line 13

def execute(_args, ctx)
  save_current_session(ctx)
  clear_conversation(ctx)
  new_session_id = generate_session_id

  ctx.renderer.info('Session saved. Starting fresh.')
  ctx.renderer.info("New session: #{new_session_id[0..7]}")

  { action: :new_session, session_id: new_session_id }
end