Skip to content

sidebar

Class info

Classes

Name Children Inherits
FilterChanged
acptui.t3.sidebar
Sidebar filter query changed.
    ThreadSidebar
    acptui.t3.sidebar
    Left pane: filterable list of T3 threads with live status and previews.

      ๐Ÿ›ˆ DocStrings

      Telegram-like thread list sidebar for T3 Code environments.

      FilterChanged

      Bases: Message

      Sidebar filter query changed.

      Source code in src/acptui/t3/sidebar.py
      class FilterChanged(Message):
          """Sidebar filter query changed."""
      
          def __init__(self, query: str) -> None:
              super().__init__()
              self.query = query
      

      ThreadSidebar

      Bases: Vertical

      Left pane: filterable list of T3 threads with live status and previews.

      Source code in src/acptui/t3/sidebar.py
      class ThreadSidebar(Vertical):
          """Left pane: filterable list of T3 threads with live status and previews."""
      
          DEFAULT_CSS = """
          ThreadSidebar {
              width: 38;
              min-width: 28;
              max-width: 48;
              height: 1fr;
              border-right: solid $panel-lighten-2;
              background: $surface;
          }
          ThreadSidebar.-hidden {
              display: none;
          }
          #sidebar-header {
              height: 3;
              padding: 0 1;
              align: left middle;
              border-bottom: solid $panel;
          }
          #sidebar-title {
              width: 1fr;
              text-style: bold;
              color: $text;
          }
          #new-thread-btn {
              min-width: 5;
              height: 1;
              border: none;
              padding: 0 1;
          }
          #thread-filter {
              margin: 0 1 1 1;
              height: 3;
          }
          #thread-list {
              height: 1fr;
              border: none;
              background: $surface;
              padding: 0;
          }
          #thread-list > .option-list--option {
              padding: 0 1;
          }
          #sidebar-empty {
              padding: 1 2;
              color: $text-muted;
              display: none;
          }
          #sidebar-empty.-visible {
              display: block;
          }
          """
      
          class ThreadSelected(Message):
              """User selected a thread from the sidebar."""
      
              def __init__(self, thread_id: str) -> None:
                  super().__init__()
                  self.thread_id = thread_id
      
          class NewThreadRequested(Message):
              """User clicked the new-thread button."""
      
          def __init__(self, env_label: str = "T3 Code") -> None:
              super().__init__(id="thread-sidebar")
              self._env_label = env_label
              self._thread_ids: list[str] = []
              self._selected_id: str | None = None
              self._syncing = False
      
          def compose(self) -> ComposeResult:
              """Build the sidebar header, filter input, and thread list."""
              with Horizontal(id="sidebar-header"):
                  yield Static(f"T3 ยท {self._env_label}", id="sidebar-title")
                  yield Button("+ New", id="new-thread-btn", variant="primary")
              yield Input(placeholder="Filter threads (/)โ€ฆ", id="thread-filter")
              yield OptionList(id="thread-list")
              yield Static("No matching threads.", id="sidebar-empty")
      
          @property
          def filter_text(self) -> str:
              """Current filter query."""
              return self.query_one("#thread-filter", Input).value
      
          def focus_filter(self) -> None:
              """Focus the sidebar filter box."""
              self.query_one("#thread-filter", Input).focus()
      
          def focus_list(self) -> None:
              """Focus the thread list."""
              self.query_one("#thread-list", OptionList).focus()
      
          def refresh_from(self, state: WorkspaceState) -> None:
              """Re-render the thread list from `state` while preserving selection."""
              option_list = self.query_one("#thread-list", OptionList)
              empty = self.query_one("#sidebar-empty", Static)
              threads = state.sorted_threads(self.filter_text)
      
              self._syncing = True
              try:
                  self._thread_ids = [t.id for t in threads]
                  option_list.clear_options()
                  for thread in threads:
                      waiting = thread_needs_attention(thread)
                      running = thread_is_running(thread)
                      unread = thread.id in state.unread_ids
                      glyph, style = _status_badge(
                          thread.status,
                          waiting=waiting,
                          running=running,
                          unread=unread,
                          pinned=thread.pinned_at is not None,
                      )
                      proj = state.project_title(thread.project_id)
                      title_style = (
                          "bold" if (waiting or unread or thread.id == state.active_thread_id) else ""
                      )
                      preview_raw = (
                          thread.pending_runtime_request.prompt
                          if thread.pending_runtime_request and thread.pending_runtime_request.prompt
                          else (
                              thread.latest_visible_message.text
                              if thread.latest_visible_message and thread.latest_visible_message.text
                              else thread.status
                          )
                      )
                      line1 = Content.assemble(
                          Content(f"{glyph} ").stylize(style),
                          Content(_truncate(thread.title, 28)).stylize(title_style)
                          if title_style
                          else Content(_truncate(thread.title, 28)),
                      )
                      meta_parts = [proj]
                      if thread.branch:
                          meta_parts.append(thread.branch)
                      line2 = Content(f"  {' ยท '.join(meta_parts)}").stylize("$text-muted")
                      line3 = Content(f"  {_truncate(preview_raw, 34)}").stylize(
                          "$warning" if waiting else "$text-muted"
                      )
                      option_list.add_option(
                          Option(Content("\n").join([line1, line2, line3]), id=thread.id)
                      )
      
                  empty.set_class(not threads, "-visible")
                  target = state.active_thread_id or self._selected_id
                  if target and target in self._thread_ids:
                      option_list.highlighted = self._thread_ids.index(target)
                      self._selected_id = target
                  elif self._thread_ids:
                      option_list.highlighted = 0
              finally:
                  self._syncing = False
      
          def on_input_changed(self, event: Input.Changed) -> None:
              """Bubble filter updates to the app so it refreshes from workspace state."""
              if event.input.id == "thread-filter":
                  event.stop()
                  self.post_message(FilterChanged(event.value))
      
          def on_button_pressed(self, event: Button.Pressed) -> None:
              """Handle `+ New` button."""
              if event.button.id == "new-thread-btn":
                  event.stop()
                  self.post_message(self.NewThreadRequested())
      
          def on_option_list_option_selected(self, event: OptionList.OptionSelected) -> None:
              """Open the clicked / Enter-selected thread."""
              if self._syncing:
                  return
              idx = event.option_index
              if 0 <= idx < len(self._thread_ids):
                  tid = self._thread_ids[idx]
                  self._selected_id = tid
                  self.post_message(self.ThreadSelected(tid))
      

      filter_text property

      filter_text: str
      

      Current filter query.

      NewThreadRequested

      Bases: Message

      User clicked the new-thread button.

      Source code in src/acptui/t3/sidebar.py
      class NewThreadRequested(Message):
          """User clicked the new-thread button."""
      

      ThreadSelected

      Bases: Message

      User selected a thread from the sidebar.

      Source code in src/acptui/t3/sidebar.py
      class ThreadSelected(Message):
          """User selected a thread from the sidebar."""
      
          def __init__(self, thread_id: str) -> None:
              super().__init__()
              self.thread_id = thread_id
      

      compose

      compose() -> ComposeResult
      

      Build the sidebar header, filter input, and thread list.

      Source code in src/acptui/t3/sidebar.py
      def compose(self) -> ComposeResult:
          """Build the sidebar header, filter input, and thread list."""
          with Horizontal(id="sidebar-header"):
              yield Static(f"T3 ยท {self._env_label}", id="sidebar-title")
              yield Button("+ New", id="new-thread-btn", variant="primary")
          yield Input(placeholder="Filter threads (/)โ€ฆ", id="thread-filter")
          yield OptionList(id="thread-list")
          yield Static("No matching threads.", id="sidebar-empty")
      

      focus_filter

      focus_filter() -> None
      

      Focus the sidebar filter box.

      Source code in src/acptui/t3/sidebar.py
      def focus_filter(self) -> None:
          """Focus the sidebar filter box."""
          self.query_one("#thread-filter", Input).focus()
      

      focus_list

      focus_list() -> None
      

      Focus the thread list.

      Source code in src/acptui/t3/sidebar.py
      def focus_list(self) -> None:
          """Focus the thread list."""
          self.query_one("#thread-list", OptionList).focus()
      

      on_button_pressed

      on_button_pressed(event: Pressed) -> None
      

      Handle + New button.

      Source code in src/acptui/t3/sidebar.py
      def on_button_pressed(self, event: Button.Pressed) -> None:
          """Handle `+ New` button."""
          if event.button.id == "new-thread-btn":
              event.stop()
              self.post_message(self.NewThreadRequested())
      

      on_input_changed

      on_input_changed(event: Changed) -> None
      

      Bubble filter updates to the app so it refreshes from workspace state.

      Source code in src/acptui/t3/sidebar.py
      def on_input_changed(self, event: Input.Changed) -> None:
          """Bubble filter updates to the app so it refreshes from workspace state."""
          if event.input.id == "thread-filter":
              event.stop()
              self.post_message(FilterChanged(event.value))
      

      on_option_list_option_selected

      on_option_list_option_selected(event: OptionSelected) -> None
      

      Open the clicked / Enter-selected thread.

      Source code in src/acptui/t3/sidebar.py
      def on_option_list_option_selected(self, event: OptionList.OptionSelected) -> None:
          """Open the clicked / Enter-selected thread."""
          if self._syncing:
              return
          idx = event.option_index
          if 0 <= idx < len(self._thread_ids):
              tid = self._thread_ids[idx]
              self._selected_id = tid
              self.post_message(self.ThreadSelected(tid))
      

      refresh_from

      refresh_from(state: WorkspaceState) -> None
      

      Re-render the thread list from state while preserving selection.

      Source code in src/acptui/t3/sidebar.py
      def refresh_from(self, state: WorkspaceState) -> None:
          """Re-render the thread list from `state` while preserving selection."""
          option_list = self.query_one("#thread-list", OptionList)
          empty = self.query_one("#sidebar-empty", Static)
          threads = state.sorted_threads(self.filter_text)
      
          self._syncing = True
          try:
              self._thread_ids = [t.id for t in threads]
              option_list.clear_options()
              for thread in threads:
                  waiting = thread_needs_attention(thread)
                  running = thread_is_running(thread)
                  unread = thread.id in state.unread_ids
                  glyph, style = _status_badge(
                      thread.status,
                      waiting=waiting,
                      running=running,
                      unread=unread,
                      pinned=thread.pinned_at is not None,
                  )
                  proj = state.project_title(thread.project_id)
                  title_style = (
                      "bold" if (waiting or unread or thread.id == state.active_thread_id) else ""
                  )
                  preview_raw = (
                      thread.pending_runtime_request.prompt
                      if thread.pending_runtime_request and thread.pending_runtime_request.prompt
                      else (
                          thread.latest_visible_message.text
                          if thread.latest_visible_message and thread.latest_visible_message.text
                          else thread.status
                      )
                  )
                  line1 = Content.assemble(
                      Content(f"{glyph} ").stylize(style),
                      Content(_truncate(thread.title, 28)).stylize(title_style)
                      if title_style
                      else Content(_truncate(thread.title, 28)),
                  )
                  meta_parts = [proj]
                  if thread.branch:
                      meta_parts.append(thread.branch)
                  line2 = Content(f"  {' ยท '.join(meta_parts)}").stylize("$text-muted")
                  line3 = Content(f"  {_truncate(preview_raw, 34)}").stylize(
                      "$warning" if waiting else "$text-muted"
                  )
                  option_list.add_option(
                      Option(Content("\n").join([line1, line2, line3]), id=thread.id)
                  )
      
              empty.set_class(not threads, "-visible")
              target = state.active_thread_id or self._selected_id
              if target and target in self._thread_ids:
                  option_list.highlighted = self._thread_ids.index(target)
                  self._selected_id = target
              elif self._thread_ids:
                  option_list.highlighted = 0
          finally:
              self._syncing = False