[t-014] Create workspace.py models — FileNode + FileContent #14

Open
opened 2026-07-05 08:31:01 +00:00 by david · 0 comments
Owner

Goal

Define the Strawberry GraphQL / Pydantic models for workspace files.

References

Reference

  • DESIGN.md §4 BFF models (workspace.py)
  • DOMAIN.md §2.5 File Row component taxonomy

Implementation Steps

Implementation Steps

1. Create src/models/workspace.py

Create workspace file model:

# src/models/workspace.py
import strawberry
from typing import Optional

class FileNode(BaseModel):
    id: str  # file path
    name: str
    is_directory: bool
    size: Optional[int] = None  # bytes, null for directories
    mime_type: Optional[str] = None
    modified_at: Optional[str] = None  # relative time string

class FileContent(BaseModel):
    path: str
    content: str
    mime_type: Optional[str] = None

2. Add FileRow to src/models/components.py (append)

Update the components.py file to include FileRow in the FeedComponent union:

# src/models/components.py (append)
@strawberry.type
class FileRow:
    id: str  # file path
    name: str
    is_directory: bool
    size: Optional[int] = None
    mime_type: Optional[str] = None
    modified_at: Optional[str] = None

# Update FeedComponent union to include FileRow
FeedComponent = strawberry.union(
    "FeedComponent",
    [SessionCard, MessageBubble, ThinkingBlock, ToolCallCard, CodeBlock, Divider, FileRow],
)

Verification Gate

Verification Gate

Run:

cd /home/david/Projects/keryx-bff && uv run python -c "
from src.models.workspace import FileNode
fn = FileNode(id='/src/main.py', name='main.py', is_directory=False, size=1024)
assert fn.name == 'main.py'
assert fn.size == 1024
print('OK')"
# Expected output: OK

And verify FileRow is in the union:

cd /home/david/Projects/keryx-bff && uv run python -c "
from src.models.components import FeedComponent, FileRow
assert FileRow is not None
print('FileRow defined')"
# Expected output: FileRow defined

STOP Conditions

STOP Conditions

  • If the FileNode model cannot be instantiated, stop and fix.

Depends on: t-008

## Goal Define the Strawberry GraphQL / Pydantic models for workspace files. ## References ## Reference - DESIGN.md §4 BFF models (workspace.py) - DOMAIN.md §2.5 File Row component taxonomy ## Implementation Steps ## Implementation Steps ### 1. Create `src/models/workspace.py` Create workspace file model: ```python # src/models/workspace.py import strawberry from typing import Optional class FileNode(BaseModel): id: str # file path name: str is_directory: bool size: Optional[int] = None # bytes, null for directories mime_type: Optional[str] = None modified_at: Optional[str] = None # relative time string class FileContent(BaseModel): path: str content: str mime_type: Optional[str] = None ``` ### 2. Add FileRow to `src/models/components.py` (append) Update the components.py file to include FileRow in the FeedComponent union: ```python # src/models/components.py (append) @strawberry.type class FileRow: id: str # file path name: str is_directory: bool size: Optional[int] = None mime_type: Optional[str] = None modified_at: Optional[str] = None # Update FeedComponent union to include FileRow FeedComponent = strawberry.union( "FeedComponent", [SessionCard, MessageBubble, ThinkingBlock, ToolCallCard, CodeBlock, Divider, FileRow], ) ``` ## Verification Gate ## Verification Gate Run: ```bash cd /home/david/Projects/keryx-bff && uv run python -c " from src.models.workspace import FileNode fn = FileNode(id='/src/main.py', name='main.py', is_directory=False, size=1024) assert fn.name == 'main.py' assert fn.size == 1024 print('OK')" # Expected output: OK ``` And verify FileRow is in the union: ```bash cd /home/david/Projects/keryx-bff && uv run python -c " from src.models.components import FeedComponent, FileRow assert FileRow is not None print('FileRow defined')" # Expected output: FileRow defined ``` ## STOP Conditions ## STOP Conditions - If the FileNode model cannot be instantiated, stop and fix. Depends on: t-008
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: david/keryx-bff#14
No description provided.