Class TerminalTab
java.lang.Object
uno.anahata.asi.agi.event.BasicPropertyChangeSource
uno.anahata.asi.agi.context.BasicContextProvider
uno.anahata.asi.nb.tools.terminal.TerminalTab
- All Implemented Interfaces:
ContextProvider, PropertyChangeSource, Rebindable
A hierarchical context provider representing an active terminal tab in NetBeans.
Each tab actively participates in the RAG pipeline by capturing its text scrollback
buffer thread-safely off the EDT and rendering it via a local, fully serializable
TextViewportSettings.- Author:
- anahata
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.netbeans.lib.terminalemulator.TermThe active rendering JComponent.private TextViewportIn-memory text viewport engine for line slicing, tailing, and grepping.private final TextViewportSettingsPersistent viewport configuration for this terminal tab.Fields inherited from class BasicContextProvider
children, parentFields inherited from class BasicPropertyChangeSource
propertyChangeSupport -
Constructor Summary
ConstructorsConstructorDescriptionTerminalTab(long tabId, String name, org.netbeans.lib.terminalemulator.Term term) Constructs a new TerminalTab context provider. -
Method Summary
Modifier and TypeMethodDescriptionlonggetTabId()Resolves the transient identity hash code of the Term component.Safely reads the terminal scrollback buffer completely off the EDT thread using raw line getters.private TextViewportvoidpopulateMessage(RagMessage ragMessage) Populates the givenRagMessagewith dynamic, just-in-time context parts.voidActivates theTerminalContainerTopComponentand selects this tab in its parent tabbed container.voidtypeCommand(String command) Types a command sequence into the terminal via reflection on the Term instance.Methods inherited from class BasicContextProvider
getAgi, getChildrenProviders, getParentProvider, setParentProviderMethods inherited from class BasicPropertyChangeSource
addPropertyChangeListener, addPropertyChangeListener, rebind, removePropertyChangeListener, removePropertyChangeListenerMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ContextProvider
getContextPosition, getDescription, getFlattenedHierarchy, getFullyQualifiedId, getHeader, getIconId, getId, getInstructionsTokenCount, getName, getRagTokenCount, getSystemInstructions, isEffectivelyProviding, isProviding, setProvidingMethods inherited from interface PropertyChangeSource
getPropertyChangeSupport
-
Field Details
-
viewportSettings
Persistent viewport configuration for this terminal tab. -
viewport
In-memory text viewport engine for line slicing, tailing, and grepping. -
term
private transient org.netbeans.lib.terminalemulator.Term termThe active rendering JComponent. Marked transient as Swing UI elements cannot be serialized directly.
-
-
Constructor Details
-
TerminalTab
Constructs a new TerminalTab context provider.- Parameters:
tabId- The transient identity hashcode of the Term component.name- The display title of the tab.term- The active Swing Term component.
-
-
Method Details
-
getViewport
-
getTabId
public long getTabId()Resolves the transient identity hash code of the Term component.- Returns:
- The identity hash code, or -1 if the Term is null.
-
populateMessage
Populates the givenRagMessagewith dynamic, just-in-time context parts. These parts are appended to the end of the user's prompt (RAG).Reconstructs the terminal's text buffer completely thread-safe and off the EDT, processes it via our local viewports, and injects a formatted Markdown code block directly into the RAG prompt.
- Parameters:
ragMessage- The message to be augmented with context.- Throws:
Exception- if an error occurs during context generation.
-
getTermContent
Safely reads the terminal scrollback buffer completely off the EDT thread using raw line getters.- Returns:
- The reconstructed terminal buffer as a String.
-
selectTab
public void selectTab()Activates theTerminalContainerTopComponentand selects this tab in its parent tabbed container. -
typeCommand
public void typeCommand(String command) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException Types a command sequence into the terminal via reflection on the Term instance.Automatically activates and selects this tab before sending the command, ensuring it is brought into focus in the IDE layout.
- Parameters:
command- The command sequence to execute.- Throws:
IllegalAccessException- If access to the fireChars method is denied.InvocationTargetException- If invoking the fireChars method throws an exception.NoSuchMethodException- If the fireChars method cannot be found on Term.
-

