What it does
text_editor_window
Desktop Text Editor window — a multi-file code editor with an integrated
coding agent. Owns its own in-memory virtual file set (defined in
INITIAL_FILES) and registers a suite of file tools
(file_create/file_delete/file_edit/file_read/file_list/file_search)
against tools.registry so the agent can mutate the editor's files.
Exports
M.createState() -> EditorApp— build a fresh app state with the default initial files and register the file tools (idempotent across the process).M.update(app: EditorApp?) -> any— per-frame agent poll; truthy when the agent UI requested a re-render.M.buildScreen(app: EditorApp, desktopState: DesktopState?) -> any— build the editor window widget tree.desktopState.text_editor_maximizedcontrols full-screen layout.M.handleCallback(app: EditorApp?, callbackId: string, data: any) -> boolean— dispatch a UI callback. Returnstruewhen consumed.
Types:
EditorFile = { path, language, text }EditorApp = { files, file_buffers, file_languages, selected_file_path, file_query, language_index, line_numbers, folding, editor_text, agent_state }DesktopState = { text_editor_maximized? }
Usage
local TextEditorWindow = require("@builtin::modules.text_editor_window")
local app = TextEditorWindow.createState()
-- Per frame:
TextEditorWindow.update(app)
local widget = TextEditorWindow.buildScreen(app, desktopState)
-- In your router:
TextEditorWindow.handleCallback(app, callbackId, data)
Notes
- The agent's file tools target a single live app at a time, tracked via
the module-local
ACTIVE_APPupvalue. The most recentcreateStatecall wins — open the text editor once per desktop session. LANGUAGE_OPTIONSis fixed at{"lua","yaml","json"}.zuiemits a 1-based dropdown index; storage stays 0-based and the callback bridge converts at the boundary.- File-buffer / file-languages dictionaries shadow the per-file text so unsaved edits aren't lost when switching files in the explorer.
- The agent panel is built from
editor_agent_uiwith a fixedagent_id_prefix = "editor-agent"; the callback handler forwards any callback id starting witheditor-agent-to the agent UI.
Discussion
Scoped to this part · feeds back into the world's score.
Sign in to post.sign in
No comments yet. Be the first.