Implementation:OpenHands OpenHands LinearView
| Knowledge Sources | |
|---|---|
| Domains | Platform_Integration, Linear_API, Conversation_Management |
| Last Updated | 2026-02-11 21:00 GMT |
Overview
Concrete tools for handling Linear issue events by creating or updating conversations and formatting response messages, provided by the OpenHands enterprise Linear integration layer.
Description
The linear_view module provides three classes that implement the view layer for the Linear integration.
LinearNewConversationView handles webhook events that correspond to new Linear issues requiring a fresh conversation. Its create_or_update_conversation method creates a new internal conversation record linked to the Linear issue, initializes the conversation context with issue metadata (title, description, labels, assignee), and triggers the resolver job. Its get_response_msg method formats the initial acknowledgement message posted back to the Linear issue as a comment.
LinearExistingConversationView handles webhook events that correspond to updates on Linear issues that already have an associated conversation. Its create_or_update_conversation method locates the existing conversation record and appends the new event data (new comments, status changes, label updates) to the conversation history. Its get_response_msg method formats a progress or completion update to be posted back to the Linear issue.
LinearFactory is the factory class that inspects an incoming Linear webhook payload and determines which view class to instantiate. It checks whether a conversation already exists for the referenced Linear issue and returns either a LinearNewConversationView or LinearExistingConversationView instance accordingly.
Usage
Use LinearFactory as the entry point when processing incoming Linear webhook events. The factory handles view selection automatically. The returned view object provides the create_or_update_conversation and get_response_msg methods needed to complete the webhook processing lifecycle.
Code Reference
Source Location
- Repository: OpenHands
- File: enterprise/integrations/linear/linear_view.py
- Lines: 1-226
Signature
class LinearNewConversationView:
async def create_or_update_conversation(
self,
message: Message,
) -> Conversation:
...
def get_response_msg(self) -> str:
...
class LinearExistingConversationView:
async def create_or_update_conversation(
self,
message: Message,
) -> Conversation:
...
def get_response_msg(self) -> str:
...
class LinearFactory:
@classmethod
async def create_view(
cls,
message: Message,
conversation_store,
) -> LinearNewConversationView | LinearExistingConversationView:
...
Import
from enterprise.integrations.linear.linear_view import LinearFactory
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| message | Message |
Yes | Pydantic model containing the Linear webhook payload with issue metadata, event type, and action details |
| conversation_store | conversation store | Yes | Data access layer for looking up and persisting conversation records (for LinearFactory.create_view) |
Outputs
| Name | Type | Description |
|---|---|---|
| view | LinearNewConversationView or LinearExistingConversationView |
The appropriate view instance for processing the webhook event (from LinearFactory.create_view) |
| conversation | Conversation |
The created or updated conversation record (from create_or_update_conversation) |
| response_msg | str |
Formatted message string to post back to the Linear issue as a comment (from get_response_msg) |
Usage Examples
from enterprise.integrations.linear.linear_view import LinearFactory
from enterprise.integrations.models import Message, SourceType
# Parse the incoming Linear webhook
message = Message(
source=SourceType.LINEAR,
message=linear_webhook_payload,
ephemeral=False,
)
# Use the factory to get the appropriate view
view = await LinearFactory.create_view(
message=message,
conversation_store=conversation_store,
)
# Create or update the conversation
conversation = await view.create_or_update_conversation(message)
# Get the response message to post back to Linear
response = view.get_response_msg()
await linear_client.post_comment(
issue_id=conversation.external_id,
body=response,
)