opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Text and Boxes need flexShrink=0 where they should not shrink

Open ravshansbox opened this issue 2 months ago • 6 comments

Description

Sometimes it incorrectly chooses start column when rendering (or rerendering) tasks list

Image

OpenCode version

1.0.12

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

macOS 26.0.1

Terminal

No response

ravshansbox avatar Nov 02 '25 20:11 ravshansbox

This issue might be a duplicate of existing issues. Please check:

  • #3423: Also relates to todo/task list display problems in OpenTUI
  • #3650: Similar spacing/padding glitches that affect element positioning in TUI sessions
  • #3697: Display positioning issues that occur after window resizing in OpenTUI

Feel free to ignore if none of these address your specific case.

github-actions[bot] avatar Nov 02 '25 20:11 github-actions[bot]

lots of artifacts there but not sure what's going on

thdxr avatar Nov 02 '25 21:11 thdxr

@thdxr @kommander When there's not enough space to go around, it seems that flex gaps, margins etc are not honored, and some elements (like <text>) get collapsed. This o here is actually part of Todo which got hidden due to lack of vertical space. But I'm guessing the renderer didn't issue the correct ANSI sequence to explicitly delete that o, and since no other text (or background color) took its place it just remained displayed.

Image

veracioux avatar Nov 02 '25 22:11 veracioux

What terminal is this? Looks like a grapheme width issue, the checkmark is just one cell, in many other terminals/fonts the checkmark is two cells, so the width calculation for the grapheme is off. What is the Unicode/raw by sequence for that checkmark?

Edit: Is there a message before this one that has any emojis/CJK chars?

kommander avatar Nov 02 '25 23:11 kommander

@kommander Don't think this has anything to do with grapheme width necessarily. Check this out (pay attention to the Context text):

https://github.com/user-attachments/assets/7f51f1ea-2f29-40be-a744-bc2ae18f7429

After I modfiy the code to set a background color on the XX,XXX tokens text, it doesn't show up anymore:

https://github.com/user-attachments/assets/97cec708-d9fd-47d8-9e0b-8b690cca8e16

I don't see any special characters being rendered there: https://github.com/veracioux/opencode/blob/9fd672a1cb735eb7f8ec80ffbe9d7540e4687759/packages/opencode/src/cli/cmd/tui/routes/session/sidebar.tsx#L52

This further confirms https://github.com/sst/opencode/issues/3775#issuecomment-3478404067 I think.

veracioux avatar Nov 02 '25 23:11 veracioux

Ahh now I see what you mean. Okay that is curious. So by default all renderable yoga nodes are flexShrink = 1, so to avoid text nodes getting smashed into each other we can set flexShrink = 0 on the containers for the nodes. Then the container does not shrink and the text nodes do not overlap.

kommander avatar Nov 03 '25 00:11 kommander

@kommander Hello, I am looking at this issue, is there any point where we would want the sidebar to be scrollable, if the window is a bit small to contain it all?

OpeOginni avatar Nov 05 '25 16:11 OpeOginni

My 2 cents: I think the Modified Files and Todo sections would benefit from a scrollbox because their contents can get large for long sessions

veracioux avatar Nov 05 '25 16:11 veracioux

@veracioux For that I think they should have a fixed height, I can add that, but what I currently have made the whole sidebar scrollable if the window gets small.

https://github.com/user-attachments/assets/9b9feabc-44dd-46d5-9dd4-32b6167411bb

OpeOginni avatar Nov 05 '25 16:11 OpeOginni

I kinda like that, that's cool

rekram1-node avatar Nov 05 '25 16:11 rekram1-node

Scrollbox makes sense and would solve the shrinking issue as well

kommander avatar Nov 05 '25 16:11 kommander

Cool, Just doing some testing, then Ill get this PR out 🫡

OpeOginni avatar Nov 05 '25 16:11 OpeOginni

nice

thdxr avatar Nov 05 '25 17:11 thdxr

Want to get feedback on this. Was thinking of collapsable items in the sidebar, is it needed?

https://github.com/user-attachments/assets/36dc39b9-1946-480c-a58b-369f65cfa6c5

More of design decision

OpeOginni avatar Nov 09 '25 15:11 OpeOginni

i like it would want to play with some of the styling/icon but i'd take a PR

thdxr avatar Nov 12 '25 02:11 thdxr

i like it would want to play with some of the styling/icon but i'd take a PR

Yeah, was thinking of making use of some icons from the opencode/ui package making it similar to the Desktop one.

OpeOginni avatar Nov 12 '25 12:11 OpeOginni