Editable code: how should files larger than the retained-text budget be edited?
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 12/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Active
- Tech stack
- typescript, zig
- Domain
- desktop
Research direction
This is an open design question, not a bounded change. Start with the 384 KiB cap in examples/code-editor/src/document.ts and the selection reconciliation in src/runtime/canvas_widget_runtime.zig, where the runtime clamps the retained selection when source is rebuilt. Done would mean an agreed approach for keeping the caret's document position across windowed source replacement, which maintainers have not yet decided on.
Written by the indexing model from the issue text.
Description
I am building a text editor on Native SDK 0.11.0. Documents can exceed the per-view retained-text budget, and the docs and examples only describe a read-only preview for that case. Files of any size need to stay editable, so I need to know how those files are supposed to be edited. All references are to v0.11.0.
Current limits
- Editable source is capped at 384 KiB in the official code-editor example (document.ts#L8). Larger files open read-only.
codeEditableis false when the source is truncated (view.ts#L73), and the status shows "preview limited to 384 KiB" (editor.ts#L166). - Whole-file reads stop at 1 MiB and return
truncatedbeyond that (files.mdx#L13).Cmd.readFileStreamhas no total-size ceiling (files.mdx#L44). - The per-view retained-text budget is 512 KiB (text.zig#L9).
What I tried
The native-ui skill recommends keeping a bounded window in the model and sliding it with on-scroll for large content (SKILL.md#L378). I applied that to an editable <code>:
<scroll value="{scrollTop}" on-scroll="scrolled">
<column>
<stack height="{topSpacerHeight}" />
<code source="{editorText}" editable="true" on-input="edit" height="{stageHeight}" />
<stack height="{bottomSpacerHeight}" />
</column>
</scroll>
The spacers keep the scrollbar over the full document. The scroll handler replaces the rendered slice:
// The runtime owns the selection. Replacing `text` changes the source.
function scrolled(model: Model, state: ScrollState): Model {
const firstLine = Math.floor(state.offsetY / LINE_HEIGHT);
const text = sliceLines(model.document, firstLine, model.windowLines);
return { ...model, scrollTop: firstLine * LINE_HEIGHT, editor: { ...model.editor, text } };
}
What I see
The window renders, but the caret does not follow the document. Click a line, then scroll until that line leaves the window. The automation snapshot reports the textbox selection collapsed at the edge of the new window, while the app's editor state still has the caret on the original line. Scrolling back restores the view, but the caret was painted at the window edge the whole time.
The runtime owns the selection and the app cannot provide one:
- The runtime applies input and writes the resulting selection back to the widget: view_widget_text.zig#L106-L118, #L1443-L1470.
- When the source is rebuilt, the runtime reconciles and clamps the retained selection: canvas_widget_runtime.zig#L750, #L956, #L995.
- The source entry comes from
node.widget.text_selection: view_widget_tree.zig#L189.
The runtime does not consult the app's TextEditState.selection. on-input carries selection changes only from the widget to the model (#213).
Questions
- Is the 384 KiB preview limit a runtime boundary, or can an editable
<code>go beyond it? - If a windowed source is the intended approach, how should the caret keep its document position across source replacement? #755 appears to target this and was closed without merging, as was #748.
- Should large files be read with
Cmd.readFileStreamand kept in an app-owned window, or is another reading path intended for the editor?
Related: #461 (same gap at the Zig tier), #755, #748, #213, #506, #514.
Environment: Native SDK 0.11.0 (scriptc 0.3.0), macOS 27.0.1 (26A434, arm64), TypeScript core + native markup.
- Dominant language
- Zig
- Stars
- 7.9k
- Forks
- 335
- Avg merge
- 10h 33m
- Merged PRs (30d)
- 147
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from vercel-labs/native
-
Per-view widget layout budget (1024 nodes) drops whole frames on real multi-pane app viewsPossibly taken @slicenferqin claimed this 100 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
vercel-labs/native#408 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
vercel-labs/native#387 ·
Maintainers usually reply within 1 day
-
macOS: the window frame event reports the frame size where everything else expects the content sizeOpen
Difficulty 1/5 Under an hour Newbie friendliness 84/100
vercel-labs/native#355 ·
Maintainers usually reply within 1 day
-
cef.zig: InstallResult.archive_path leaks on successPossibly taken @versecafe claimed this 206 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
vercel-labs/native#32 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
vercel-labs/native#957 ·
Maintainers usually reply within 1 day
All issues in vercel-labs/native
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
GUI: the space panel stays stale after a run stops with no spacePossibly taken @nikkexe0-del claimed this today. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
xevrion/hatchzip#237 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
flathub/org.ardour.Ardour#89 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Javis603/token-monitor#1861 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
Maintainers usually reply within 1 day