Class: Protege::ThreadsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/protege/threads_controller.rb

Overview

Manages email threads — the inbox list, individual thread views, and composing new conversations from the dashboard console.

Instance Method Summary collapse

Instance Method Details

#createvoid

This method returns an undefined value.

Compose and dispatch a new conversation through the Gateway. Serves POST /threads.

Uses the same host-facing seam application code would — Gateway.message — passing any uploaded files straight through as attachments. Redirects to the thread created for the resulting message.



37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/controllers/protege/threads_controller.rb', line 37

def create
  persona = Persona.find(compose_params[:persona_id])

  message = Gateway.message(
    to:          persona.email_address,
    subject:     compose_params[:subject],
    body:        compose_params[:body],
    attachments: compose_params[:files] || []
  )

  redirect_to thread_path(message.email_thread)
end

#destroyvoid

This method returns an undefined value.

Delete a thread and all its messages. Serves DELETE /threads/:id.



53
54
55
56
57
# File 'app/controllers/protege/threads_controller.rb', line 53

def destroy
  @thread.destroy!

  redirect_to threads_path
end

#indexvoid

This method returns an undefined value.

List the inbox threads. Serves GET /threads.



12
13
14
# File 'app/controllers/protege/threads_controller.rb', line 12

def index
  @threads = EmailThread.for_inbox
end

#newvoid

This method returns an undefined value.

Render the compose form for a new conversation. Serves GET /threads/new.



29
# File 'app/controllers/protege/threads_controller.rb', line 29

def new; end

#showvoid

This method returns an undefined value.

Show a thread with its messages newest-first. Serves GET /threads/:id.

Liveness (the agent's reasoning and tool use) streams into the introspection panel, so the thread view itself is static — no per-message processing indicator to compute here.



22
23
24
# File 'app/controllers/protege/threads_controller.rb', line 22

def show
  @messages = @thread.messages.order(sent_at: :desc)
end