February 20254:25:064.1k views

Open source work

About

A livestream hunting a weird rendering bug in Solo. I capture ngrok's raw output, boil the whole thing down to a two-line reproduction, and go deep on cursor movement and graphemes with a lot of help from chat.

Transcript

Everything I said

00:07

All right. Let's check. Okay. All right. We've already got people here. Hello, Joel.

00:29

Am I coming through okay? You can hear me all right? Hello, hello, hello. Hello, friends. Let's see if this mute button works before I take a sip.

00:58

There we go. Here come the people. How we doing? Hey. Loud and clear, that's what I like. I set up a new...

01:21

I'm listening to Paris Paloma. Look at this overlay, though. Look how good this is. I'm so freaking pumped by this. And watch this, I can hit a button. Uh, it's kinda hard to tell, but I can hit a button on the Stream Deck and boom, perfect size.

01:47

Got a Postgres fan. That's what I like to hear. Uh, I think I can also do left. Did I do that? Hmm, that one's not quite right. That one's not tall enough. But I can do left and right. I didn't adjust... I gotta adjust the sizes on those. Emmett, who did you get an email from?

02:09

Is that real or is that a bit? Man, 15-second delay. That sucks. I'm, uh, I gotta go back to working on, I gotta go back to working on my stream setup.

02:32

'Cause with my stream setup, there's only, like, a two-second delay. But with Restream, I don't know what they're doing, but they take forever. Okay, here's what we're gonna do. I got a really, I've got a few really weird bugs in Solo.

02:54

So if we open this up, uh... I wanna move this. So here's what I'm trying to do. If I move this to the right, and then I resize it like that, boom. Now you can't see the file tree, which is not important, but I can, and we have a lot of space.

03:27

I don't know. I've never used Streamlabs. Is it better? Let's see. Streamlabs. Yeah, I don't know.

03:54

I have no idea. Is this better? I don't wanna use anything, I don't wanna use their desktop app. I'm very happy with OBS, as happy as one can be, which is not that happy, but... Yeah, I don't know. I think the real answer, the real answer to the question is, uh, I've got my own SMTP.

04:17

No, is that? That's not right. RTMP. Not email. I've got my own RTMP server set up, um, and I should just be using that to do my own restreaming. The problem is, I just can't get, I just can't get, um, I can't get all the chats in.

04:38

I need-- Here's what I need. Here's what I need y'all to figure out. How do I get multiple chat streams into one as a service? That's what I want. I just wanna get all the chats into one, like I have here, but this is Restream. Um, that, that's why this is working.

05:01

Install... The only setback which has nothing to do with this is the Arabic UTF-8. Hmm, interesting. I'd be curious, Hassan, uh, if that's something I can fix. So open, open an issue if you can. Um, my scene setup for OBS is very basic.

05:26

So if we, uh, drag this over here, you'll see I have an everything, a recording monitor, and the overhead, and the overhead cam is disconnected. Um, but that's it. And in here I've got... You can blur it, um, so it just blurs the desktop.

05:48

Um, but that's about it. I mean, I can turn off the camera and you'll see the file tree behind it. Uh, there's the Restream chat. So if I turn that off, you'll see the file tree again. Uh, Krisp is cool. Krisp is my microphone, and it's like one of those AI things, so it takes out, like, if I take a sip without, you know, muting, it takes that out, so that's nice.

06:16

Um, and then down here is just my actual screen. That's it. Yeah, I think most of them are, uh, IRC or whatever the protocol is. But, like, Twitter's, for example, I don't think is. Twitch is easy to get. I think, um, I think YouTube has a live IRC-type thing, but Twitter's, Twitter's real

06:46

tough. All right, let's do some work. Here's what I'm trying to... Here's what I need to do. Um, so we're gonna work in Solo. If you're not aware of Solo, let me show you what it is, and then I'll describe the problem that we're dealing with. Um, do love these buttons.

07:10

Uh, Solo. Yeah, we're gonna do some fusion after this. Thank you, Nuno. This is Solo. Um, oh, man, somebody already... Hmm, that's not good. Mac user.

07:40

This is interesting. This would actually be good to look through. Well, that would actually be very interesting to see if that works. Um, okay. So, sure, run the workflows, that's fine. Um, oh, thanks, Derek. This is Solo. This is what we're dealing with right here.

08:02

Um, and one thing, so it's got all these tabs across the top. One thing is, that I'm constantly fighting against is, um, rendering bugs. Um, ngrok is one. So here's a rendering bug, and this is, I mean, I feel like this is gonna be a never-ending, uh, never-ending pursuit here.

08:28

Um, but because I am, because I'm running all of the underlying process through my screen implementation, uh, I am kind of responsible for these. So we're gonna start small because I have a very strange one. Uh, do I need this? Sure, let's leave it open.

08:50

Here's the one that, um, is very surprising to me. So if we come, we need to look for... I think I named this test WTF. So if we search for WTF. Yeah. Single zero doesn't work. What the hell? Um, okay. Let's talk about this assert terminal match, but first, let's just run this test and fit this.

09:18

Oh, how do we enable screenshot? I think it's enable screenshot testing. Cool. Hswad, that's very kind of you. Um, all right. So here's the test we're gonna run. God, that looks so clean. I am so happy with that setup. That looks great.

09:40

All right, let's run the test. Single zero doesn't work. Shows zero, zero goes away. Shows zero, zero goes away. And it failed. Um, failed asserting that screenshots are identical. Diff available here. So one nice thing that I wrote for Solo is screenshot testing, um, because I need to assert, more than anything, I need to assert that it looks right, and I don't really care if the underlying,

10:11

like, ANSI codes are the same. As long as it looks the same, I'm happy. So let's run a different one that actually passes. Um, so like, for example, capturing prompts didn't work. It does now, but it didn't. So if we clear this, and then we run this test.

10:36

So you see it kind of blinks, and that was, let's run it, uh, let's run it manually, and then let's run it through Aaron's implementation, and let's assert that the output looks the same. In fact, we can just do all the screen test. Why not? Screen test. So you'll see everything, everything renders twice, and if the renderings match, then I'm happy, even if the code is a little bit...

11:07

The, like, the underlying ANSI codes are different. So all of these work except for if you try to render a single zero, just a single character zero, it doesn't work. So all of these work just fine. It's taking, I'll show, I'll show it to you in a second.

11:29

It's actually taking screenshots and comparing them pixel by pixel, just to make sure that they end up looking the same. It's kind of fun to watch, actually. Boy, there are a lot of them, huh? It's very nice to have a testing setup that you, like, can trust.

12:00

Because now, like, when I found this zero bug, I can just come into my testing setup and I don't have to, like, manually configure anything. I just know Great. I am in this nice testing harness. I can just test everything I need to. Boy, there are a lot of tests here. This is great. All right, we're getting close to the end.

12:21

Let's see. This is five hundred lines of tests. Well, six hundred lines of tests. Uh, yo, what's good? Hey, this is bad. Yo, what's good? Hey, how's it going? And here's the final one. Zero. Boom.

12:42

Doesn't work. Zero doesn't work. So if we do this now, you'll see that this is the screenshot of the diff, and you'll see that there is a red zero, meaning the diff or the zero was present in one but not in the other. And so now I can look and see, like, oh, yeah. Well, that's the part that's missing.

13:02

So my question is: where's the zero go? Why is there no zero here? That makes no sense to me. Um, where in my process am I eating a zero? 'Cause if I, if I just change this to, uh... In fact, here's an open question.

13:24

If I change that to a one, does it eat the one? Single zero doesn't work. One. It's so interesting that it doesn't. It works on a one but not on a zero. This is some sort of regex thing, I'm sure of it. Single zero doesn't work, WTF.

13:45

That is a great question. WTF. All right, let's come into assert terminal match. Um, screenshot testing is true. Assert visual match. So let's go down here. Probably 'cause it's falsy. He might be onto something. Um, screenshot path, capture clean output, emulated.

14:11

So here's how we do it. Uh, the first time, we just pass the content out to the terminal, not using, not using Aaron's screen implementation. We pass it out to the terminal, take a screenshot. Then we emulate it by running it through my, uh, screen class, which is where the problem will lie. And then we write that content out, and we capture a screenshot.

14:37

Yeah, for sure. Yes, use them by all means. Um, here's, here's, here's something, Ezer, um, if that's correct. Um, feel free to use them. I would love credit, but here's the story. It's open source, and the license states you don't have to give credit.

14:58

So you can do a hundred percent whatever you want. If you find something in there that I've done that's silly, um, let me know. But yes, please use it. I find these to be very helpful, um, and gives me great confidence. That's a good question. If I pass two zeros. This is kinda, this is kind of like a, it's kind of a mystery, isn't it?

15:22

Single zero doesn't work. Double zero works. Oh, one will definitely work. Um, what about zero... I don't think it matters if it's a, I don't think it matters if it's a string or an integer. I think fundamentally, everything becomes a string at the end of the day. Um, okay.

15:44

So here's where I wanna break in. Um, so what I do is I create the screen, which the screen class is over here. This is the screen class. It is robust. Um, I make the screen, I just make it to match the width and height of the terminal that is currently running the tests so that, um, everything will line up internally,

16:15

and then I write the content in. So let's just start by asserting, um... I don't know if it would render Booleans at all. Um, okay. So yep, we got all the way there. We actually don't need to capture the clean output while we're doing this. It'll be faster. 'Cause it truly does take a screenshot.

16:36

So capture clean output. Um, this is interesting. I think all of this is interesting. I don't know if it is, but I certainly think it is. So when we capture the clean output, uh, what we do is we send a reset code, then we go home, we clear the screen, and we hide the cursor.

16:58

And then we echo the content out, sleep for a second, and then look at this. We're using, um, AppleScript, but in... We're using the shell exec, so we're, like, running it as, uh, just as a command. And we're finding the, uh, iTerm window. And then we are, uh, taking a screenshot using screen capture down here.

17:25

So we take a screenshot, and then we chop the top bar off um, because it'll, like, uh, the title of the terminal window changes, and then we write the screenshot to, uh, to the right spot. So very, very interesting. All right. Why? All right, so we get here, DD content.

17:47

That's fine. We get there. Yep. All right. Let's go check write. Did we make it all the way here? We sure did. Um, in fact, let's come back out here, and let's see what this output actually is. Let's see if it gets eaten before.

18:11

All right. So we wrote a zero in, and it didn't get- Output back out, which is interesting to me. Um, so if we come in here, I don't think we should... Here's an interesting question. I don't think... So what I do here is this ANSI matcher.

18:38

Um, so watch this. For example, if I change content to equal, let's do this, backslash e, uh, open. Hey, cool. Yeah, I'll take that. So I'm gonna change the content to be that, and then we'll dump the parts and see. Look, so this is called an ANSI code right here.

18:59

It controls, uh, I think this is like an SGI or something, standard graphic something something. Um, but I've got a class that does all the matching and, like, looks for this in the regex, and then it splits it up into parts 'cause each part is kinda handled a little differently. And so here is what you'll get.

19:20

You get one ANSI match. The command is M, the params are zero and thirty-two, and then you get just a pure string. And then there's the second ANSI match. So it seems as if we've breezed past... All right, so we're down here to a string. That is correct. Th- I guarantee you that there's a, um, type, a type juggle going on somewhere.

19:45

So we're not gonna do handle ANSI code because it's not an instance of match, so we should make it down here just fine. Yes, we do. Handle printable characters. Empty. That's interesting. Is it empty? It's empty.

20:10

It's empty. Yeah, that does, that does juggling. It sure does. So here's the question. Why did I do empty? I probably just wasn't thinking.

20:33

Is there a valid reason I did empty? Boy, I can't think of a reason why I would've done empty. Um, so what is, um, trim an empty string?

20:56

What does that give you? Empty string? Okay. I actually don't wanna trim it, in fact. Um, so if we do, if text is that or... I mean, it's type hinted as string, so I don't even think it could be null at that point. Blank.

21:24

Null if it's a string. See, but I need the spaces, because if somebody writes a space, I need to respect that. I think it's just that. I think that's the fix, which will let us move on to the ngrok stuff, which is gonna be a lot harder. I think that's it. I think that was the test.

21:49

I think that was it. That might be right, uh, Gert- Gertjan. That might be right. All right. Hey, you know what? We call that a freaking win. Um, all right, so if we clear this, enable screenshot testing.

22:13

Here's another nice thing about, um... Oh, that's interesting. What did I do wrong here? Oh, I didn't run the first one. Um, here's another nice thing about this screenshot testing is obviously, well, maybe not obviously, but, um, r- realistically, I can't run screenshot testing in CI.

22:38

And so what happens is, um, if the terminals are identical, um, if the terminals are identical, so we do this, uh, compare. We make sure that compare is installed, and then we do, um, and then we do a comparison, and we say, "All right, I'm gonna give you two, I'm gonna give you two screenshots, and you need to tell me if they're the same." And if it returns a zero, then it says, "There were no pixels different whatsoever.

23:09

Those screenshots are the same." That's great. However, once I determine that those terminals are identical, um, we'll actually run it twice because it's kind of flaky. Um, if they are identical, then I write a fixture file with the, um, identical content.

23:29

So I write a file that says like, "Hey, this content that you emulated matched the real content. Therefore, I trust that this content you emulated is correct. Let me write that into a text file, and next time I will just compare the text file." So if we look at, um, where would that be? Fixtures.

23:50

I know you can't see this, but that's fine. Fixtures, screen test, WTF. Where's WTF? There you go. So next time I run this, it's gonna say, "Hey, the width was one twenty-eight, the height was one twenty-six, so set the terminal to that, and here's the output that came out of the emulator." Um, and here's like...

24:14

Let's find a better one. Um, what was it? Prompts? That was kind of a big one. Capturing prompts didn't work. So this is a great example of, um, captured output. So I ran the screenshot tests, asserted that visually it was exactly what I was after, and then after that I can say, "Hey, as long as this doesn't change, as long as this stays the same, we're good.

24:41

I imagine it's gonna work." So, I do love a good test setup. That took a long time, truly. That took a long time to get that test set up right. So let's open GitHub, and let's fit it. And all of the fixtures changed. I actually don't want all of them to change, so we're going to discard those.

25:03

Let's just make sure I only selected fixtures. Yep. Discard those, discard those, and I just want the one fixture to change. So we're gonna retest that again. Writing tests truly, uh, well, let me say this. Getting a proper test set up is truly almost as difficult or more as writing the actual library.

25:30

Um, all right, so now we have the fix, and we have the fixture, the fix and the fixture. Um, do I wanna make a branch? Do I feel like being a good boy? Um, do I care? I don't care.

25:53

Um, fix zero bug. I do not care. Okay. Now we gotta fix, we gotta fix the ngrok bug, which is gonna be a lot more complicated. Hmm.

26:14

Oh, fifteen second delay, Lan, you missed it. I was a bad boy. I just pushed straight to main. Fix zero bug is on main. Um, tests are running. This test, however, has been running for far too long, so I don't know what the story with that is.

26:41

We might have to look at that in a second. It's possible-- Well, we'll find that out later. Maybe GitHub is, uh, GitHub's chilling. All right, we ran it. We know that it works. Let's fix this bug.

27:02

Let's fix this ngrok bug. This right here. Can I zoom? Hell yeah. Look at that, man. Look how clean that is. Doesn't break the whole UI. Yeah, that's so freaking good.

27:24

I can zoom in and out. It's awesome. Um, okay, so something wonky is going on here. Um, it looks like... It looks like ngrok is, uh, what is it doing?

27:54

Ngrok is using ANSI codes to jump around and rewrite stuff, and somewhere along the way, I have mucked it up by not respecting some ANSI code, which I knew was gonna happen. I'm, I'm not, um, I actually don't care. I think it's totally fine. But I gotta figure out which ANSI code it's not respecting.

28:20

Uh, when the remainder is falsey. Oh. Do I use empty somewhere else? Wow. Handle printable characters.

28:45

What is the remainder? Ooh, this is good. Eagle-eye Daniel. Eagle-eye Daniel just caught if the remainder is not empty... So here's, here's how we can test that. Let's go back to, um, screen test.

29:11

Um, yeah, apparently. Apparently, Daniel. Where, where were you when I wrote the code? I didn't know this. Um, empty remainder will break. All right, so what we need to do is we need to figure out how big our terminal is.

29:34

Uh, so that doesn't give me-- Sometimes that gives me, like, an overlay of how big it is. Actually, you know what we can do, is we can go check the fixture. All right, so the width is one twenty-eight. Here's how I'm gonna test this. Um, let's do, um, line equals str repeat.

29:57

Um, doesn't matter. Let's repeat A a hundred and twenty-eight times. Did I get those orders right? String and times. And then let's do line. This is gonna be off by one or, or many. First shot.

30:19

Look at that. This is... What's your last name? Weaver. The Daniel Weaver test. Bless you, Daniel. All right, done. Hey, look at that. All right, so it didn't work, um, because of exactly what Daniel said.

30:42

And here's something cool. So it grays out... This is the, this is the diff. Um, this is the screenshot diff, and so it grays out all the parts that match, and then it highlights in red parts that are missing. And I think it highlights... Yeah, it may just highlight in red the diffs. That may be it. Um, I don't know if it highlights in green additions between one or the other.

31:07

Uh, you know what? We can find out just for giggles. Why not? We're just here for the lols after all. Um, compares visually. If we go to assert visual match. Uh, if we just add a little foobar in here, what happens?

31:33

Did I mess something up? Oh, I named it the Daniel Weaver test. Do we get a little extra foobar? No, it's just red. So it just highlights red for differences. Um, I am using convert, which I think is an ImageMagick provided...

32:01

So if we search which compare, I'm using compare. The compare tool ImageMagick is not installed or not in path, so it is compare. So compare metric. Don't know what AE means, and then you pass in, uh, the terminal, the emulation, and where you wanna put the diff file, and that's it. All right.

32:21

So we fixed... Actually, we didn't. We asserted that there is a Daniel Weaver test that fails. Uh, now we go back to screen. And if remainder does not equal equals an empty string, I wonder if int is gonna convert that to single charac- single quotes.

32:47

Probably. Boom. Good freaking catch. Good catch, Daniel. Um, GitHub desktop. Where'd you go? We'll just type hub and get it back. Yes, yes, yes, yes, yes.

33:10

Remainder. Should've opened a branch, eh? Remainder fix. Too late now. YOLO. All right. We need to run ngrok. So here's, here's the plan of attack. Um, what's Yoda style?

33:35

Is that when you like swap around the order of the comparisons? Oh, I bet I know what that is. I bet that's if you do... I bet it's if you do it that way. That's weird. No, I'm with you. I hate that. Um, okay.

34:02

Let's, um... So I need to open, I just need to make sure I don't leak my, uh, ngrok key real quick. Nope, it's not there, which is good. I need to go find it real quick. Bear with me. I don't...

34:31

Hey, it's the PHP view guy. I like being that guy. All right. Um, ngrok. If I leak this key, it's fine. Um, no, I haven't leaked it yet. If I leak it, it's fine.

34:52

Just y'all don't use it. All right, so let me close this out so I don't leak it. Clear this out so I don't leak it, and then I'm gonna just see if this actually will leak. It's totally gonna leak. Um, let me... Oh, goodness.

35:14

How do I do this? Um, hang on, y'all. I'm trying to figure out, I'm trying to figure out how to not leak this. Give me one second. Um, uh, I'll show you the issue in one second. Oh, how can I do this? Um, I can do it like this.

35:35

How can I do this? I can do it like this. I can go to... Oh my goodness. Uh, let me get to a place where I can unblur. Okay. We can do it like this. Um, let me unblur. Oh, goodness. Um, if I open that file right there, I'm gonna leak it, so I'm not gonna open that file.

36:00

Let's go to the dashboard and... Oh, goodness. Where would this be? Silly Aaron. Where would this be? Um, is it like name? I need...

36:24

It's not in dashboard, you doofus. It's in, uh, renderer Render tabs. I think I'm just gonna... No, it's not tabs.

36:47

Sorry, y'all. I'm just trying to make sure I don't render out my key. Box top? Render content pane. Oh my goodness. Oh, I think it's marquee. There we go. Render process state.

37:08

Marquee, current Kick Command, command. Here's what we're gonna do. We're gonna say temp command equals that, and then we'll just say temp command equals str after. Nope, that would be only the key. Before, uh, we'll take that for now. What is the order on these? It is subject and search.

37:30

So subject before auth token. So that should split it. That should split it to make sure that it don't... Ugh, I'm sorry, I don't trust myself. Let me check real fast. Hey, look at that. Okay. Whew.

37:51

All that work. All that work just to make sure that right here used to say auth token, and then it was my auth token, but it doesn't anymore. Hey, Mark. Um, yeah, I just like light mode. Adam Wathan the other day said that dark mode is for children.

38:16

And it made me laugh. I don't necessarily agree, but it made me laugh. Um, what keyboard do I use? Y'all, I'm the most basic person in the world. This is an Apple keyboard. What mouse do I use? This is an Apple mouse. That's it. Um, this chair, I don't know what this chair is.

38:39

I have no idea. See, look, look, look. We can already see the bug starting to happen. You see this? It should not be doing that. And look, look, look. Look at all this. Somewhere, somewhere I am eating or improperly, improperly, uh, matching

39:10

some sort of text, and it's mucking the whole thing up. Um, I use a Canon R6 Mark II for streaming. It is, uh, it is a DSLR. And it is very expensive, but, uh, this is my full-time job. This is how I make a living, so I am well aware that it is, uh, an expensive camera, but it's very good.

39:33

All right, so here's how we're gonna test... This is always the question. All right, um, here's what we can do. We're gonna come in here, um, and any time, write.

39:59

Add output? All right. Any time the underlying process, um, any time the underlying process emits new content, we capture it here in add output. Um, and we add it to the screen buffer. So what we're gonna do is we're gonna do file, uh, put contents.

40:28

What's the mode? I want append. File append is a flag. So we're gonna put the contents to debug.txt, and then we'll do file append. So now we're gonna sit in, we're gonna sit in the middle, and we're gonna write it all to, we're gonna write it all to a file.

40:53

Um, do I already have this? This is called ngrok1.txt. I might have already done the capturing part. Let's go look for a test. Do I have a test anywhere that says ngrok that is being skipped?

41:23

Huh? Does that work? If so, then that test doesn't really matter, 'cause we know that it doesn't actually work. Ngrok test, basic ngrok. Well, there's definitely something not working there, but it's not the thing.

41:47

Uh. Um, I don't, I don't know. I don't think it's related to ngrok at all. I just know that ngrok expresses the bug. Um, so I don't really care. I don't really care if it's ngrok or not. I just know that ngrok is a, uh, repeatable way to get it to happen.

42:12

So you can see that diff is way off. Um, but that just looks... I don't know. I don't feel like that's the bug we're working with. I do need to fix that. I also need to find out why is this test not causing CI to fail if it like... Oh, I bet 'cause I don't have a fixture there.

42:33

That's fine. All right, here we go. We have modified command. We're gonna write all the content to- This debug. Now we can run the command and wait for it to fail. So if we run Artisan Solo again, we shouldn't see any secrets.

42:59

We're just gonna wait for it to fail. Everything... You know what? Um, I bet that's writing output for every, every command that's running. So I need to open Solo without showing it to you turkeys and comment those out.

43:22

Close it, delete it out of there. Deblur. Let's find debug.txt. Okay. Yep. There's all the stuff. All right, now we're good. We're, we're running one single tab. It is ngrok. That already looks like a bug, but I'm not entirely certain if it is.

43:45

That question mark looks like a multi-byte splice. That's what it looks like to me. Um, but I don't know if I want that to start with that. 22, 22R, home, clear, clear, turn off cursor, clear, set the color.

44:14

Uh... See, that feels wrong. That part feels wrong. We're gonna try it again. Let me see what your console output is set to. Is your console output on your base prompt...

44:38

Hey, SaltyMcGoat. Is your con... On your base prompt, the standard output that ships, or have you rolled your own using a non-blocking output? I can show you around in a second. I'm not full... I'm not sure I fully understand the question, um, but I can show you around in a second. Um, boy, we're just not getting any, uh, we're not getting any errors here, are we?

45:04

There we go. Stop. We got one. All right, we got one. Surely that's not it. Is that it? Is that the whole output? Surely not. What the heck?

45:25

What the heck? Okay. Um, the camera setup is, uh, a Canon R6 Mark II with some lens on it.

45:49

Um, let's take a look. It's a 35-millimeter prime lens, so it has no zoom. Um, the real thing that is, that is helping me the most are the lights. Um, so I've got, if I can, I can just hit this button and the background lights come on, the key light comes on, and this

46:19

light back here comes on. Um, I don't need fake sunlight 'cause I don't have windows in here. The windows are actually behind the wall. Um, Steve is the fake sunlight guy. Um, I don't feel like we captured, I don't feel like we captured the actual... This is not enough information.

46:47

We didn't capture everything. Let's try this again. Hey, Ivan, I'm not gonna do dark mode. I'm so sorry. Um, all right, let's try this again. Let's do this. Let's run ngrok, and then let's hit it. We're gonna see some errors, 'cause I, I don't actually have it set up.

47:11

Um, boy, yeah. See that, see how bad that looks? You see all that? All right, let's see if we captured that. That feels better.

47:32

That feels like enough to work with. This is what I do all day. Look at this. This is insane. But I can actually, I feel like the guy in The Matrix, maybe, um... Which one is it that says he can see stuff? Is it Tank, or is it the, is it the traitor? Um, or is it Neo that's like, "I, I can, I can see this.

47:54

Like I, I know what this, I can read through this, and I know exactly what all this stuff means." There's one character in here. There's one character in here that is wrong. Rather, that's a judgment call, and that's incorrect. There's one character in here that I am not handling correctly.

48:17

Tank. Um, so it's not their fault. It's my fault. We're gonna take all of this debug.txt, and we're gonna write it to, um, tests, fixtures. I'll resize this so you can see what I'm doing over here.

48:38

So let's write a new one in here called ngrok2.txt, and this is, this is now I'm confident that there's something in here that I'm not handling well. So we can go back to full screen, and we can go back to the ngrok test, and let's do, let's dupe that and do, um, ngrok two.

49:12

Uh, okay. Favorite ex-user? There's so many. That's so nice of you to say that. Cypher. Cypher's the bad guy, you're right. Um, okay, I'm not feeling... I'll be honest, I'm not feeling the Paris Paloma right now. Um, I think we-- Do we want Angels and Airwaves?

49:38

Do we want... We want John Bellion. That's possible. It's possible it's that. All right. Let's do a little bit of screenshot testing here and see.

50:02

Um, I need to enable, don't I? We need something with a little energy, y'all, come on. This ain't it, this ain't it, this ain't it. What do I need? You know what I need? This is what I need.

50:30

Uh, Bunky Pop, not my favorite so far. Here we go. Now we're talking. All right, enable ngrok two. Well, that'll do it. Those are certainly different.

51:03

All right, so we're in a good spot, um, because we've reproduced a bug, and we have a way to test it. Now, now I think we should start paring it down just a little bit. Um, I don't need you. You can be fit, and then I will actually hide you.

51:28

What we need to do is if we go to this ngrok two, my question is: how much of it can we get rid of and still see pretty nasty bug? So let's... Where are we? We're at a hundred and seven lines. Let's get rid of half of it. Let's do a manual, uh, a manual Git bisect here.

51:52

So we're gonna get rid of all of that and then run the test again. Still wonky as heck. That's good. So now we don't need to worry about that. Let's get rid of, um, all the way up to there. I feel-- It still, obviously still didn't work, but I feel like we lost some of the weird parts.

52:16

See, if we look really carefully... Uh, no, I don't play music on stream. One, copyright issues, and two, when I'm watching someone else's stream, uh, my music taste is very rarely the same as theirs. And I would much rather put the person on on, like, my second monitor and listen to my own music than have to listen to theirs.

52:43

So I don't know if that's good, bad, or indifferent, but that's how I prefer. Um, so if we watch this very carefully, up here in the left corner, you're gonna see, um, some numbers that have overwritten some text, and that's what I don't want to go away. So right here, two point oh gateway. You see that?

53:05

That's the, that's the part that I really need to figure out, and if we delete... Class animals. I love class animals. Oh, you're welcome. If we delete that, then we're just back to the issue where it's like, eh, I just feel like we're off by a few lines, which we definitely need to fix, but that issue is present in, um, ngrok one, the test.

53:32

And so I'm gonna leave all of that, and let's remove up to this favicon. Okay, so we're still getting a lot of wonky overwrites, which is good. Yeah, I don't want it to be heard on stream. That's the problem. 'Cause I like watching people on stream, but, um, I don't wanna listen to their music.

54:02

All right, so we're still getting the issue. I'm just trying to pare it down to the smallest reproducible. I feel like the word update isn't... Yeah, that's not doing any... Yeah, that's still super wonky, so that's good.

54:26

Let's get rid of version, region, web interface forwarding, connections. Let's get rid of all of that and see what happens. Okay, still awful, which is good. That's what we're after. Um, I like watching Nuno. I feel like Nuno's always doing some interesting stuff in, in languages that I understand.

54:51

I'll watch Prime and TJ, um, but they're always doing stuff in languages that I don't care about and They're always like, they're spending a lot more time interacting with chat, and I just kinda wanna watch somebody program. Um, and so I don't watch them terribly often, but I, I do like them a lot.

55:14

Um, I'm trying to fix this bug right here. That's what I'm trying to do. I'm working on a library called Solo for Laravel. It gives you this nice command line interface. I did the very foolish thing of deciding to write a terminal emulator myself, and now I am, um, living with the consequences.

55:36

Well, well, well, if it isn't my own actions coming back with consequences. I think I can get rid of account, version. I think I can get rid of all of those lines. Session, account, version, region, web, boarding, connections. Yep, still super wonky.

56:06

Okay, so that's good. We're still way off. Can I get rid of all of these lines? We'll see. Yep, still way, way wrong. Okay. Let's just ensure... Yeah, those business, those business bros aren't gonna know what hit some.

56:30

Log into LinkedIn and see a Degen. Uh, pray that I did not lose connection. Good, I did not. Um, let's check the... Just wanna make sure that if we swap the order that we're testing... So

57:02

if we just run just the emulated, is it still super wrong? Yes, it is. Good. Just making sure I'm not mucking up my terminal and then asserting that it's mucked up because it is. Uh, Len, here's the problem.

57:28

Um, if we run... So Len is asking, um, Len is asking why didn't I just take the output from the underlying process and hand it, like echo it out, basically. Um, because, um, if you notice... Well, now we actually are in a bad state.

57:54

If you notice here, um, we've got the Chrome going all the way around. So like we've got the tabs at the top, and we've got this outline, we've got this text, and we've got these, uh, hotkeys at the bottom. Um, you have to... Basically, you have to capture it and replay it because if inside of this terminal, if inside of this part right here, um, there are some ANSI codes that like move up

58:24

five lines, it is totally possible, and it one hundred percent did happen, um, that you would move up out of my Chrome and start erasing parts of my UI. And so I had to like constrain it and capture it and like, uh, virtualize all of those moves such that they are constrained to this scroll pane itself.

58:47

Um, so my emulator handles all of those move codes and basically like collapses them into a, uh, a friendly output buffer, but it leaves all the color codes to be output to the final terminal. Um, so somewhere in there, I'm not capturing some sort of code, 'cause look, I'm, I'm moving stuff the wrong way.

59:13

So, uh, the Fly.io driver for Sidecar is still a work in progress. Um, there's no updates on that yet, but it will. Now that Steve and I are focusing more on open source, um, it will come back to life. All right, so I've, I've managed to pare this down a little bit.

59:40

Um, it's, it is very fun and very difficult. So the question now is: how far can I pare this down? Still so wrong. If we do it in a new browser or a new terminal, still so wrong.

1:00:02

We're getting close. We're getting close to the minimum reproducible output, and then we can start trying to find the bug. So can I get rid of these lines? Hell yeah, that rules. That's great.

1:00:23

That's great. That's great. We're getting closer. So it's somewhere in these eight lines of code. There's some code in here. There's some code in here that is not right. Um, one thing that writing your own emulator allows you to do is you can then do stuff like this, where you have pop-ups.

1:00:48

'Cause like I have the full buffer. I know exactly, um, what should be rendered on the screen, and then I can... And like it's still, you see it's still working under the hood. It's like it's still updating underneath. Um- But because I have the full represented buffer in memory, I can, like, go in and overwrite some stuff, which is what I'm doing here.

1:01:14

Hey, we're, um, we're actually working on your bug. We are working on, we're working on your bug right here, Matteus. So thank you for joining. All right, back to work. All right, let's, um... I think we're super close to, to having the bug reproducible.

1:01:40

Um, all right. Can I get rid of this line and this line? Do we still have... Yes, big issues. Well, well, I don't know about that. I don't know about that.

1:02:02

This doesn't feel like my bug. This feels like a bug that exists. Can I get rid of you? Yes. Good. Hell yeah. This is great. So what are we seeing? Can we slow this down at all?

1:02:25

Capture clean output. Let's sleep for a little bit longer. So what are we actually seeing here? So it looks like... Look, look, look, look. Let's make this even longer. I'll show you what's happening.

1:02:45

Three seconds. So, uh, six point three oh nine and favicon are down here. This is what it should look like, and then boom, six point three oh nine and favicon are up there. So somewhere, somewhere there's an ANSI code that moves itself home. I bet, I bet I know what this is.

1:03:10

There's an ANSI code in here that is moving home, that I am-- as the emulator, I am moving home, but as the proper terminal, iTerm, it is not moving home. And I always defer to iTerm because I'm just a guy, and iTerm is, like, the real thing. I bet this has to do with something that I know very little about, which is setting scroll regions, setting

1:03:40

scroll regions in Tuis. Um, here's what we're gonna do. Um, we need to look up, um, ANSI code set scroll region.

1:04:01

Is it an ANSI code to make a terminal region scrollable? There we go. Look at that. I bet I do not respect this. Print F, escape character one comma twenty-four R. I'm 1000% sure that I don't handle that.

1:04:26

Um, uh, it's, it's just PHP. I use Laravel prompts in a few places, um, and I use Joe Tannenbaum's, uh, Tui in a few places. But if we look at the Chewy, I guess, um, I barely use Laravel prompts anymore.

1:04:51

This does extend prompt, but in fact, I, um, I took over their rendering altogether and left a big note as to why. Um, but I, I don't even use the base renderer. I just, I just do it myself. So I do use their stuff for, um, input handling, like keyboard handling, but that's about it.

1:05:21

Let's try this. Um, let's print F to Sequin. Here's what we're gonna try first. This is what I just took from Stack Overflow. Um, I'll tell you that in a second. This is what I just took from Stack Overflow, and we're gonna pipe it through to Sequin. Unhandled sequence text twenty-four R. So Sequin is supposed to be helpful.

1:05:44

I guess it's not. It's from, uh, this company Charm, and it's a way where you can pipe through all the ANSI codes, and then it'll tell you what they are. Clearly not that, not that great. Um, but let's take all of this. Let's open a, a plain text.

1:06:05

Let's take that and change those to... What did we change that to? Backslash O thirty-three, backslash O thirty-three. Um, and let's just take, let's yoink, uh, let's just yoink this. There's twenty-two R. That's it. That's the one. There, there's my problem, twenty-two R.

1:06:27

I guarantee you that is the problem. Print F, all of that through to Sequin. Well, why did that not work? Question mark three is where it failed. Uh, so Ivan asks, "What's your take

1:06:57

on using LLMs for coding?" Um, I am, I am very pro L- LLMs for coding. Here's my, here's my, here's my nuanced take on it. Um- I think you can't seed your brain. I can't, I think you can't seed your brain to the LLM.

1:07:19

So there was a good, there was a good tweet today. Um, let's do a fit here. Um, so I responded to somebody today. Here we go.

1:07:42

Um, and this is not, this is not a dig on Casey. Um, I asked ChatGPT for limitations and it said, "In high traffic, SQLite struggles and locks the entire database for writes, slowing things down." And my response was, "Haha, yeah, it's wrong." So, um, and I know, I know why ChatGPT said that. Like I, I understand what data it was pulling from.

1:08:06

Um, but this is what I'm talking about, like definitely use LLMs. Definitely, definitely, definitely. If you don't, you will get left behind. I hate that that is true, but it is true. So definitely use LLMs. Um, but do not, do not seed your ability to think to the LLM and continue to invest in your education.

1:08:28

Where I think it's viable, rather backup, where I think it's valuable to use an LLM is I've used it a ton with this ANSI code stuff. That's not something I've ever done and there's no good, like there's no good courses on like how to write a TUI. Joe has one that I watched and it was great, but then it was quickly like, good luck. Have fun. Um, so asking the LLM discrete questions I think is very, very helpful.

1:08:54

Like, hey, I have this piece of code. I need it to do this. It's currently doing this. Fix it for me. Or like, here's my test. Here's, uh, an example implementation. Write the real implementation. I think that's great. Expecting it to like, like vibe code, I'm, I'm less, I'm less sold on. Um, I wonder if some kind of test that checks the fixtures for all codes you handle and highlights unknowns, unknown ones.

1:09:22

Yeah. I mean, that's kind of what I'm doing, except I need like more input and so that's why we're doing this, is so that I can check to see that, um, I'm handling it correctly and then in the future it will continue to test against that fixture. There, Tizzy, no dark mode stream, sorry. Um, semi instead of a comma, maybe.

1:09:43

How often do you use LLMs yourself? Every single day. Um, I've got, you can't see it, but I've got, uh, here. I think these are all safe to share. Um, so let's make that fit.

1:10:06

Here's my ChatGPT history for today. Um, I'm on o3-mini right now. Um, here we go. I'm trying... Can you read this? I'm trying to use AppleScript ought position the window off-screen, but it won't go past the top of my screen. Is there any way to work around this?

1:10:28

And I pasted it my AppleScript, which sets up, like I was showing you guys earlier, the, the window automation that I have. It's all AppleScript. And so I was like, "Hey, here's my script. Is there a way to fix that?" It thought and said, "No, can't do it." All right, I'll do something else. Here's another one. This SVG has a part that is filled with color, yada yada.

1:10:49

How do I put an image there instead? Note the shape has cutouts, so I'd need those cutouts to exist. The image is at, and I gave it a made-up path. And so then I gave it the SVG, which is this, this SVG overlay that you're looking at right now. I gave it the SVG. It thought about it and said, "Hey, here's how you can do it." Boink. That's my code now. Thank you.

1:11:09

Um, so yeah, I use all day every day I'm asking ChatGPT questions. Um, I also ask Claude a lot of questions. I, I have Claude do some more like full-on implementations. Um, so I think what we have discovered is, um, Len, I don't know.

1:11:39

Maybe. I don't know. I just, it would require like, it would require iTerm. I don't know, I don't know if that would work. Um, so one, this is all I want. I want to find out what you do. What do you do, 22r? That's all I need to know.

1:12:00

So do you know what 22r is? No. See, even Sequin doesn't know what 22r is. You know what we do now? You guessed it, my friends. Okay, so let's form a question. Um, let's form a question.

1:12:23

In fact, watch this. I'm working with, uh, ANSI codes, and I'm trying to figure out what this, uh, escape sequence or ANSI code is, this one comma 22r. I think it has something to do with scrollable region, but I'm not entirely sure. Do you have any idea what this means?

1:12:46

Done. Done. There we go. That's how it works. Freaking knew it. Indicates the scroll region. The scrolling area.

1:13:10

It tells the terminal- All right, so now we have to ask another question. Okay, so if that ANSI sequence sets the scroll area, uh, let's assume that the scroll area has been set and then the ANSI code for

1:13:41

move home is passed, does the cursor go to the beginning of the scroll area or does the cursor go to the beginning of the terminal? Oh, F you. It didn't transcribe a single thing. Come on, man. Didn't transcribe a single thing.

1:14:09

Super Whisper. No, always use the shore. Come on, man. Okay, if somebody defines a scroll region and then passes the ANSI code to move home, does it move to the beginning of the scroll region or does it move to the beginning of the screen?

1:14:39

There we go. Oh, nice, Len. Look at that.

1:15:03

Funk yeah. Hell yeah. That freaking rules. Um, okay, so let me see if I understand this correctly. So

1:15:36

if I understand this correctly, uh, yeah, I don't need you. I don't like this song. If I understand this correctly, I think what it's saying is... Well, I think rather what is happening, let's start with that.

1:15:59

So it's setting, it's setting the scroll region one twenty-two, top and bottom margins to define the scrolling area. Only lines one to twenty-two should be scrollable. So is that zero-based? Is that zero-based?

1:16:28

Oh, you know what I need to do? In my test, in my test harness, I need to add this reset. That's part of the reason we were seeing a problem. Um, escape. Is it really just escape, open bracket, space, R? Come on, man. Um. All right, so no space.

1:16:57

All right, so I was not properly cleaning up after myself in the compares visually. Need to go to restore terminal. Um, before I move home, I need to lowercase R, I think is what we decided. Is that right? Lowercase R resets the scroll region.

1:17:20

Reset the scroll region. So now, I was having some sort of like residual hangover effect from all of this testing, and it's because I didn't know about scroll regions and therefore I wasn't resetting them. So now we'll have a better test. Um, should still be wrong, but we'll have a better test.

1:17:47

Yeah, that's better. Okay. Now we gotta figure out how the F are we gonna handle scroll regions. Good lord, that's an entire new, like an entirely new concept. Let's continue to narrow down the test first. Um, so I feel relatively confident that I can get rid of...

1:18:21

I think I can get rid of that. I still don't understand what the one twenty-two is, I don't think. I think I'm still a little bit, I'm still a little wonky on that. Um. What if we, what if we stash this?

1:18:53

What if we stash this and we try to write our own test here? Um, so if we did this, escape one to twenty-two. Two J I think is clear. If we go to screen test, screen two.

1:19:16

Yeah, two J, erase entire screen. And I think that that is a lie. F, I think that is a lie if the scroll region is active Boy, this is gonna be hard. This is gonna be very, very difficult. Um, so this is saying erase the whole screen, move home.

1:19:38

It does it twice, which I don't understand. So move home, erase the whole screen. Move home, erase the whole screen. Change the cursor, move home, erase the whole screen. Change the color of the text. Change the background, I think. Um, and then change the boldness, I think, and then reset everything.

1:20:04

Set the color, set the background. Okay, so I don't think I need any of that. We'll do, we'll do move home and clear screen, and then we'll just jump all the way down to bold, I think. So bold, yep, still wrong.

1:20:25

Bold, still wrong. Okay. I think backgrounds, I think that's 40. Yep. We don't need you. We don't need a background. Um, I don't think we need to hop all the way over to the end.

1:20:47

Still wrong. Still wrong. Okay. We're getting closer to a reproducible test. Hey, see ya, Ivan. Thanks for hanging. I know we're deep in the weeds now. Uh, where is a...

1:21:08

Where's the next move code? That's what I'm after, the next move code. Thirty-nine. Thirty-nine and forty-nine are colors. Thirty-seven and forty are colors. I don't know what C is. Dang it.

1:21:28

I don't know what most of these are. Um, cursor right one. Okay, so that's something. I already handled that. Cursor forward, yeah, I already handled that. Twenty-six C, which means move forward twenty-six characters, which is quite a few.

1:22:04

Here, I think this is the problem. Fourteen, fourteen thirty-one H1, what do you do? Yeah, that's gotta be the one. Set cursor position. I bet that's relative to the scroll region.

1:22:26

F. Let's ask. Um, so is an ANSI code like, um, whatever, E1431H. Is that what it was? Fourteen thirty-one H relative to the scroll region?

1:23:05

I'll look into that. Thanks, chat. Uh, FUBARNA, it's an old habit. Dang. Every sh-oot F.

1:23:34

Man. Man. Oh my gosh. Ah, what have I gotten myself into? Um, here's the, here's the struggle. Um, I've got all of this code and this logic, move cursor, um, to like in my screen emulator to move the cursor to where

1:24:04

it should go. Um, and all of it assumes you're moving around, you're moving around the window, um, like the full screen. And now, now I am learning that you might be moving around a scrollable region instead of the window.

1:24:29

So this is going to be very difficult. Um, but you know what? We can do hard things. Um, so in the scenario where a program declares the scrollable area to be...

1:24:55

What did we decide one of them was? Top one, bottom twenty-two. Um... Oh, that's very nice. Oh, thank you.

1:25:16

That's very nice of you, iPwnPancakes. I bet you do. I love pancakes. Um, I love meeting, uh, friends in person. Uh, scroll bar area be one twenty-two. Does that mean that There is one row above the scrollable area and potentially many

1:25:47

rows below the scrollable area. And does the numbering start at one or zero? We'll ask, but then I think we also, we might just have to figure this out ourselves. Um. Let's just go ahead and eliminate all...

1:26:21

Let's try to just eliminate all color codes. That'll be a good start. Um, let's look at the ANSI tracker. All right, so here we go. Uh, 30 through 39. So we can say 30 through, 30 through 49 are color codes.

1:26:51

And, ah, that's fine. We can get-- Ah, let's leave the resets. So 30 through 49 are color codes. We're gonna get rid of all of those just because we don't need them. 30 through 39, so you can all go. We're just, we're just trying to get down to the minimum reproducible.

1:27:17

30. Zero's a reset. We can leave the reset. That's fine. We're getting a lot closer. What does it say? Okay.

1:27:42

All right, cool. We're getting somewhere. So then the question is, um, in the scenario where the scrollable region is 122, how does a program right below that region, say, to row 30?

1:28:14

Good question, Aaron. I have no freaking clue. Um. So something happens right before 6.309. 6.309 ends up at the very top when it shouldn't. So what is issued?

1:28:36

Yeah, there you go. I think that's literally the only code we need to keep. Yep, look. There you go. We're getting a, we're getting a lot closer. I know it feels like this is an exercise in futility, and to some extent it is. But we dare to do great things, don't we?

1:29:03

All right. We have a pretty good reproducible... We can change this 'cause that's a little confusing. Hey there. Okay. Um, we don't need bold.

1:29:26

That serves no purpose here. We don't need a reset. That serves no purpose. There we go. That's the reproduction.

1:29:50

All that ngrok work comes down to these two lines of code. Two. There you go. So what did we learn? Uh, I use Restream. I use OBS, and it streams to Restream.

1:30:22

We're gonna see... to row 19, column eight, and then say, "Hey there." Boy, is that right?

1:30:47

'Cause it sure looks like it actually goes to row 19 and column eight. Let's make that timeline a little longer. I know that I've lost every viewer, but hey, we're still figuring it out. Um, where's 10,000?

1:31:09

Let's do 22.5 million. Oof, thank goodness, we still got some. Um, so what I'm confused about is it does seem like... See you, Nabil.

1:31:44

It does, ugh. I don't understand. That should be fine. Yeah, 2J clears the screen. Okay, good.

1:32:06

As long as, as long as you all are still here. We're co-working. I love this content. We're deep. I, like-- We're super deep in it. Um, let's take all of this. What does Sequin want? Sequin wants 033, so... Good. Thank goodness. Um, we'll do O33, and then we'll do printf U to Sequin.

1:32:47

Yeah, this is, this is confusing to me. Because truly, it seems like the thing that I'm not respecting is move to row 19, column 8. That seems like the thing I'm not respecting.

1:33:12

Um. No, it, it's cl- it's clearing the screen. It's clearing the screen. So if I were to write, um, that in there... Oh, I changed the escape codes.

1:33:34

Um, change those back to real escapes. Whoops, too many. You should never see the ASDF. Yeah, in both cases, you don't see the ASDF, so the screen is being cleared. It-- Boy, it feels like I'm not respecting that 19/8, and it honestly has nothing to do with the scroll region.

1:34:00

So you know what, Aaron? Why don't you be a smart boy and just take away the scroll region? Boy. Even when you take away the gosh dang scroll region... Well, that makes everything a lot easier, at least.

1:34:24

I mean, maybe I need to respect scroll regions. Maybe I don't. I definitely need to respect a cursor move. Um, all right. Think with your brain. You need to check if you handle the H command at all because 19;8H.

1:34:53

Do I... There's J. There's H. Holy moly. You s- son of a gun. You silly, silly boy.

1:35:17

You know what? Here's a good lesson. This is okay. How was I supposed to know this? I wasn't. Be thee kind to oneself. I didn't know that this was possible. Um, I thought, incorrectly, um, I thought H, so we're looking at code H here.

1:35:41

Um, so you see 19;8. Those are parameters, and the actual command is H. So if we go back, I'll answer that question in a second. That's a perfectly valid question. Um, um, so if we go back here, um, and we can just get all the way...

1:36:08

So you see this. Set cursor position, uh, 19/8. I assumed, which is fine, maybe it was silly, but it was appropriate at the time. I assumed H was absolute. It is absolute, I'm sorry. I assumed it was parameter-less, and so there was no...

1:36:32

If you just passed H, you get 1/1, but in fact, you can receive arguments. So, you know, the bug is we had a lack of knowledge, and that is o-freaking-kay. Um, so let's look at, let's just DD the param and the command. It's just gonna be...

1:36:55

It's just gonna be the params I'm after, TBH with you. Oh, I've entered into this weird alt screen universe. There we go. So I don't even parse the params, so there you go. There you freaking go.

1:37:16

Um, all right. Fu-- What does that say? Fubarna? Fubarna. I know this is more of a personal question. I don't know how you handle having four kids. We have four. She's a bit-- We have a four-year-old, and she's a bit sick, and we are so tired. Oh, this, you know, the answer's in the question. I am so tired.

1:37:37

Um, so I have four kids. Two of them are one years year. Two of them are one year old. Two of them are three years old. We have two sets of twins. Um- I too am very tired. I think the most fair answer to that is I work at work during the day, and my wife works as a mom during the day, and so that's a huge, like, she's a stay-at-home mom.

1:38:05

She does a freaking ton of work. Um, so that already frees up my nine to five. Truly, it's more like eight to six is how much I work. Um, and then, yeah, then I go home, and I help with bedtime, sometimes dinner, um, but I always put the big kids to bed and then eat dinner with my wife, and then it's probably seven thirty or eight, eight thirty, and I go back and

1:38:35

do some more work. Um, it is not, it is not sustainable, but I've been doing it for a while, so maybe it is. Um, it's not the recommended way of living, but I work all the time. Like, I don't have hobbies. I do see friends. I have several scheduled events where I see friends.

1:38:58

But I don't have hobbies. I don't watch sports. I don't play video games. I barely watch TV. I would love to watch "Severance," but I've... don't have time. So it's just what, like, what I wanna do with my life is make it. Like, I want to succeed. I want to make it, and so I work a lot, and it's hard. Um, I am not capturing those params at all.

1:39:22

So you'll see that they are, in fact, totally blank, which is a problem. Um. That part I've already accounted for, John, so I should be okay on that part. Uh, I d- I go to great pains to make sure that the underlying process thinks that its size is the size of the content pane

1:39:52

in which it will be rendered. So the underlying process thinks, "Oh, my terminal is four columns smaller and four rows shorter," and so all the movements in there I can trust to be absolute without having to translate. So fortunately, I'm good there. Um, all right. Let's do ANSI tracker test.

1:40:21

This is not... This is better called... This is not a good place to do this. ANSI match test might be. Cursor home.

1:40:44

So I have a test for cursor home, but I bet I don't have one that tests... There's H again. I bet I don't have one that tests cursor home with parameters, 'cause I didn't think that was legal. See, look, H, H with no params, H with no params.

1:41:14

Yeah, that's why, that's why we didn't catch this, 'cause I don't have a test for it. So the first thing we need to do, uh... Made some migration to PSQL, kept watching your videos.

1:41:42

Oh, that's nice. Thank you. I do like databases. Um, so we need to test... Well, where was the one with semicolon H? Let's just jump in here. It's a lot, isn't it, Len? Um, so if we did, let's just say, uh, five and ten so that we make them different.

1:42:06

Move cursor to, uh... So the first one is row. The second one is column. So move cursor to, first one is row, row five. The second one is column, call ten. Okay. M- most of the time, yes.

1:42:31

Most of the time, that left bracket is, denotes, like, the beginning of a code. You'll see that there are some wonky ones that aren't, um, but most of the ones... See, this weird stuff, I don't do anything with this weird stuff. Um. See, and I don't even, I don't even know how many people support that.

1:42:56

These are actually useful. But look, like, those, those typically have the left bracket on them as well. This is a very old archive of codes, and so I just, woomp, plopped them all in there. Um, if we run the ANSI match test, hopefully we'll see a failure now. We didn't.

1:43:20

So did it match? Okay. So it matched, but we didn't capture the params. That's good. So let's go check this. ANSI, uh, ANSI matcher. Nah, here we go. This is the thing.

1:43:52

What-- You know what? If If I was rich, I would, I would show, or show got in my brain 'cause I read Len's comment. Um, if I was rich, I would work on a, um, like an actual ANSI AST, like a parser, a tokenizer maybe.

1:44:15

But right now I'm just kinda kludgeing it together. Um, kludgeing it together with regexes. So let's write a test that, um, I think ANSI matcher test is actually probably ANSI match test. That's fine. This is probably a fine place to do it, but I need to make a better assertion.

1:44:38

Function Mitchell Hashimoto, link to a tweet. Um, that test didn't work. It doesn't need to, so, um, what do we say? Um, lexer, ANSI lexer, that's probably what I need to do. Yeah. It would be great fun.

1:44:59

It's just like, is it worth it? I don't think so. Um, let's see. Home command accepts params. So the sequence is... What is the sequence? Let's do five semicolon 10H, and let's DD that result.

1:45:34

Well, that's curious, isn't it? So I got the params there as five, 10, but over in, uh, over in the actual part where it matters, I didn't get the params. Um, that sure is curious, isn't it?

1:45:58

DD result zero params. I wonder if somebody's catching it before I get to it. This assert equals, it is, it should be five, 10, and that should be the params. We'll just leave this here just 'cause it, whatever. Um, but now my question is, dear Aaron, why?

1:46:27

Who, who, who, who, who is taking those params away in this scenario? What's incorrect two? F. Big old goofus. There's already one there.

1:46:50

Uh, we should dump it, not dump and die. And that's not gonna work. Um, why is that not gonna work? Because we've entered-- We're capturing the output buffer and... Oh, silly boy.

1:47:12

Let's do this. Um... So I think I actually do get them. I just, I just throw them away. If ANSI param not equal to this guy, DD ANSI. Boy, lots of, uh, lots of false starts, eh?

1:47:37

There we go. You ol', you ol' son of a gun, there you go. All right, here's what we're gonna do. We need to figure out, um, should we... We should factor this out.

1:48:00

Um, this move cursor absolute params. We'll factor this out so we have a little space to work. Move cursor absolute. Where should we put move cursor absolute? Let's put it next to move cursor call. Yeah, that's fine.

1:48:25

You know, if I use Solo, I could put the dumps over there. Um, but it's hard to do that when I'm working on Solo. What did I call it? Move cursor... Who, who can even remember what I called it? Is it move cursor absolute? I just wanna paste that into the buffer. That's, that's move cursor absolute.

1:48:46

Yeah, with the params. String params. Feel like this should be protected, TBH. Nope, wrong one. Focus up. Focus up, focus up. And actually, it shouldn't be called move.

1:49:12

That's poor behavior. It should be called handle absolute move. That's a better pattern. And it should go here. Um, handle absolute move. That's more appropriate. Handle absolute move, yeah.

1:49:38

Oh, my brain imploded many times when I was writing this. If we look at the ANSI tracker, the ANSI tracker uses bitwise comparisons, uh, and bitwise operators to make sure that we're keeping track of everything in the most compressed possible state.

1:50:00

And so we end up with all sorts of like- Um, we keep, we keep a buffer of every ANSI code that is applied to every single character. We keep that in memory. Those are typically integers. Um, and then as we're outputting it, we're compressing the ANSI buffer.

1:50:24

We compress down to the minimum representable, minimum required ANSI codes, um, needed to represent. That's why I'm talking about I compare everything visually, 'cause I don't think the ANSI codes will match under the hood, because we're doing so much, uh, mucking about with the actual ANSI codes. ANSI codes from bits, ANSI string from codes, ANSI string from bits.

1:50:51

It's just like... I mean, it's, it is, it is mind-bending. It's a lot of fun, I will admit. Like, when you get to do and equals and then the little tilde unset, it's like, wait, hang on. What the hell am I doing here?

1:51:12

What's going on? Um, but it's great. It's great. We have a great time, don't we? We really do. 64 bits, make sure we're doing all the right stuff. All right, let's keep going. Um, um, yeah, let's go back to Glass Animals.

1:51:36

That's fine. Is there a worse interface than Spotify? If so, I don't know what it is. There we go. That's what I wanted. All right. Handle absolute move. Um, if params... This is gonna be ugly to start, and then we'll clean it up.

1:51:58

Um, so we'll say, um, is that right? Is it call row? I keep forgetting. First one is row. So... I totally feel like a hacker.

1:52:23

Yes. Let's see if that does anything. Um, that's not the one. We need the ngrok test. 19 and eight.

1:52:45

Cool, cool, cool. Um, we're gonna need a couple of tests here, to be honest with you. Um, you know what we can do, though? We can do this. We don't need... Now, that's why we went through that entire exercise of paring it down, 'cause now we have the minimal representation, and we can just inline it just like that.

1:53:11

Yeah, cool. Which means, um, we need to do this. We'll do ngrok three. This is not really an ngrok test anymore, but it doesn't matter. We need to test with that, and we need to test with that. Um, and truly, we need to test with both of them gone as well, because I, I assume that's valid.

1:53:39

Um, oh yeah, I super consider myself as having not made it yet. 100%. You guys know, um, you guys know that every single night when I go to bed, I put my AirPods in and listen to an audiobook because otherwise I will just stress about my life.

1:54:00

I'll just stay up all night thinking about, uh, how am I gonna pay all these bills? How am I gonna send my kids to college? Yeah, I super don't think I've made it. I think I'm doing very well, and I'm on the right path, but I do not, I do not think that I have arrived. Can you just do an int in here? No. That'd be cool. Yeah, I think it's a, I think it's, it's pretty common.

1:54:27

I don't think a lot of people talk about it, but I think it's pretty common, especially, uh, when you're the sole breadwinner, man or woman. When you're the sole breadwinner, it's like, my whole team's counting on me. I think these are, these codes are one-based, and then they need to be zero-based, as, as evidenced here.

1:54:48

Um, so what we can do is we can make more things the same, and we're gonna do row equals one, call equals one, um, and then down here, we're just gonna do... What do I need to do? I probably need to do minus, minus row to decrement before it's passed.

1:55:10

I think that's right. The good news is, don't super care. We'll find out thanks to the test. Um, ups and downs, you'll be fine. I believe I will be fine. Um, and I believe in, that is in big part to having to keep working a lot. Oh, that's very nice of you, Andrew.

1:55:34

Um, I am co-MCing, uh, with the Primagen, the HTMX conference. Not HTMX conference, but the Big, Big Sky Conf right after Laracon. Um, yeah, being, being the sole breadwinner is tough. Which, of course, is to say, not to say that, um, being a stay-at-home parent is tough because, boy, that is pretty freaking tough, too.

1:56:03

Um, so if row is blank, then we need to say one Because it could be that you've got something like that, and then we'll handle the decrement down here. Um, ANSI codes are one-based, while our system is zero-based.

1:56:27

Good idea, bad idea, who knows? But it is true. Um, we'll probably need to do the same thing here. Ooh. F me.

1:56:49

Look at that. God freaking dang it. Look at that. Hell yeah, brother. Look at that. It worked. We fixed it. Cool. It's pretty good.

1:57:22

Um, cool. Let's test, let's test all of these. So we have, um... Actually, I'm not ready for you yet. Um, and why don't we just yoink those while we're here and go back to screen test?

1:57:44

Uh. Cursor home. Uh. Um, I'll tell you in one second, Daniel.

1:58:08

Cursor home both. Cursor home... Boy, if I had a memory, this would be a lot easier. The second one is column. Cursor home col only. Cursor home row only. Cursor home semicolon only. And so now let's test all of the cursor homes.

1:58:53

Cool. Freaking works. Feels good, man. Uh, yes, Len is correct. Also, John is correct. Aaron won. ANSI code zero. Um, the issue was, um, I was naively, which is different than stupidly, I was naively, um, anytime I encountered the H command, which is an absolute move, I was assuming that this always meant, uh, go home, when in fact

1:59:23

it just means absolutely move. And so now I am parsing the params so that the cursor will move to the correct position. Um, and if not, if it do- if it comes through with no params at all, it does do one one, which I don't think we, I don't think we added a test for that. I mean, functionally we did, but...

1:59:50

No params. I don't like this as a test because, um, my test runner actually goes home and clears the setup at the beginning anyway, so, um, if we run these again... Yes, the default is go home.

2:00:13

Um, the default is go to one one. I didn't know that you could pass params, and so I was just blindly sending it to one one when it should've been going to nine 18 or 18 nine or whatever. Oh, hello, Miro. Uh, we're mucking about with the terminal. We've been super deep into, um, ANSI codes and stuff, um, and we just finished kind of a gnarly bug.

2:00:42

Now, what I think is interesting is let's just run, um... Let's get a clean terminal just in case anything has been mucked up. Okay, so there's one issue already. This guy is an issue, and I know, I know probably why that's an issue, and that's because of this guy, which looks like a multi-byte splice.

2:01:13

So I don't know who's doing that, um, but I bet that is what's going on there. But let's open this up and see if we can... I mean, it's a lot better, but it's not great.

2:01:48

Thanks, John. Could be an emoji. I just don't know who's doing the splice, because I thought I was relatively careful about not splicing multi-byte characters. It got better.

2:02:17

Certainly got better. It's not great. If you look under the TTL part, you see that there's some over...

2:02:41

There's some bad overwriting. And every time a bad overwrite happens, we lose a l- uh, a column on the right. You'll see the white part on the right grows. I wonder if we can use our brains to figure out why that is.

2:03:10

Um, we can. We can absolutely do this. But first, what we need to do is open up some GitHub. Let's just make sure we haven't done anything stupid yet. Um, I don't wanna commit those two. I actually don't wanna commit that either.

2:03:38

This I do wanna commit. That is no longer necessary. Neither is that. Those are all the fixtures. Reset the scroll region, that's fine. That didn't, that, that didn't actually end up doing anything, but that's fine.

2:04:01

Uh, I don't need to commit that. Oh, man, there was my key. I'm gonna have to roll it. I actually didn't mean to discard those changes either. I meant to not stage them. I freaked out. Um, all right, I'll fix that later.

2:04:25

So I think these are ready. So let's do this. AF, uh, fix ngrok. Bring my changes. And first pass at fixing ngrok.

2:04:49

Poor ngrok, it's super not their fault that I keep naming this bug ngrok. Uh... Did

2:05:24

those actions ever run? Yeah, they did. Remainder fix. Cool. All right, so the questions. Todd, freaking Todd. Todd's definitely doing the splice, that freaking Todd guy. Um, catch unhandled params. I don't know if I understand the question.

2:05:47

Why use our brains? 'Cause the vibes don't understand anything that's going on here. Trim is not multi-byte safe. I have taken great... gone to great lengths to be multi-byte safe, but there's a 98% chance I missed one. Um, a mismatch between character length on your end and how it's written. Maybe. Um, nope, never used or heard of GitButler.

2:06:11

GitHub Desktop works fine for me. Um, why are you testing those specific strings? So the way that we got, the way that we got to those strings... Can I force those to run again? The way that we got to those strings was because adding ngrok breaks Solo, and we took all of that and distilled it down to that,

2:06:42

like, 15-character string. Um. You guys, look. My auth token is right there publicly on GitHub. And has been for days. Whatever. Who freaking cares?

2:07:03

Whatever. You wanna use my ngrok for the next hour, you can. You dum-dum. What a silly boy. All right. So we can-- I don't need to blur 'cause it's just gonna, it's already out there. Um, all right. That's what we're running, 'cause I freaked out and didn't wanna share my key.

2:07:25

I deleted the config. Um, so we're not working with any of those commands. What we are working with is we're working with ngrok, and that is what we're doing, key and all. That, that's what we call, that's what we call a whoopsie-doopsie.

2:07:46

Um, sometimes I call myself a developer, sometimes I'm just a working man. Um, all right. So we need to... Let's get rid of... We need to try, we need to try again. We need to try a-freaking-gain. Um, let's do this. Let's go to Command.

2:08:07

Where does output get called? I think it's manage process. Add output. Nope, not that one. Partial buffer. So here's where we're capturing the buffers. Um- Collect incremental output. Um, okay. Collect incremental output, where do you get called from?

2:08:50

Okay, every tick, every tick we collect the incremental output. Um, what we're working on, let's catch people up. We're working on sharing that secret key. Um, what we're working on is this. So, ugh, there's that multi-byte splice again, but again, look, I don't know if that's what ngrok is actually showing, right?

2:09:17

'Cause it's-- is it like, are they being cheeky and it's like, "Found a bug," including this multi-byte splice? That's kinda what it feels like, you know? Um, and it's frustrating because they don't... No, it's fully an emoji. I need the-- They switch the message every time, which is really frustrating, but they're always, "Found a bug." There's a heart.

2:09:49

Um, there's a shield. Goodbye tunnels, goodbye tunnels. Where's found a bug? There you go. We... When somewhere throughout our tool chain, I am cutting that emoji in half, and so what we end up with is the Unicode question mark box.

2:10:12

Not necessarily in half. I am definitely splicing it, though. Um, I'm definitely splicing it because when I run it, so when we run this... Sorry, everybody asked what are we doing, and I just, like, totally went on a tangent. Sorry, Lonnie. What we're doing, this.

2:10:34

Look. I am running, uh, ngrok inside of my little, uh, TUI here, inside of my little terminal emulator, and I'm doing something wrong. Um, I'm not respecting the emoji, and you have to respect the emoji.

2:10:55

So that should be an emoji, and instead it's a Unicode question mark with an E, which means there was probably a four-byte character, and I dorked up part of it, and then the E is left over. So that's something. Um, and see, then what happened there?

2:11:16

Like, why did you... What line are you on? You're on latency thirty-five, and we lost... We're losing spaces on latency. When it, when it updates the latency, the line is not being padded. We're losing some sort of F.

2:11:37

What could that possibly be? Um, the line is not long enough anymore, and so I am writing my border. I'm writing my border in where I think it should end, but in fact, the line is too short, which is why we're getting these multiple borders being written in.

2:12:02

Um, this is curious, isn't it? Every time the latency updates, the line gets shorter. Look at that. I'm everywhere, Mateus.

2:12:36

They definitely erase the, the latency and write again. This is a curious case, isn't it?

2:13:05

All right, so here's what we're gonna do. We're gonna hope that the debug captured some of that. Where's latency? Okay.

2:13:35

Yeah, fortunately, uh, Gert, I was still capturing it to the debug file, so I have all this information now. So we see, we only see latency twice, which is interesting. Um, that's ngrok that's dark mode. That's not me. I can't, I don't know how to force ngrok to be light mode, in fact.

2:13:57

Um, but if you look at the actual... See, the underlying command gets to decide some of its own stuff, and that underlying command decided it was gonna paint everything black.

2:14:19

Um, so I don't know. I don't know how to fix that. Um- Yeah, look, if it changed. You know what's interesting?

2:14:42

Um, let's in fact... We don't need you. We're just gonna-- You're all dead. Um, I wanna see, so it starts out-- Where's latency? Where are you, bud? Where are you, big guy? Come on, big guy. Where's my big guy? Come on. Where's latency? Latency, thirty MS.

2:15:04

Now let's watch it when it updates. So we got some forty MS, and it's still fine, but I think what happens... We got some wonkiness going on down there. That's fine. We haven't seen wonkiness on the latency.

2:15:26

Look, and it rendered the emoji that time. Um. It felt like to me at some point the MS went away, and that's when the line got shorter.

2:15:53

But of course, of course, no, we're not seeing it. And that TTL is wildly wrong, so we're getting a bunch of overwriting. Uh, the-- Everything, everything is coming down to the cursor movements in the buffer are not, uh, being appropriately replayed. And so it-- Ngrok says, "Hey, move the cursor here." And my screen says, "Sure, big guy." And I move it to the wrong spot and

2:16:23

then execute the writes, and that's why it gets all, like, wonky like this. Of course, I can get the goddamn latency to mess up now. Oh, guys, guys, guys, guys, what am I gonna do? Um. Well, there was a miswrite of the latency.

2:16:45

Did we capture that? Did we capture that? See, that's very interesting.

2:17:10

It only wrote milliseconds one time. Um, seventeen C. Oof, my friends, this is a tough one. We need a minimal... Okay, so let's stop.

2:17:30

We've got at least two issues here. One is sometimes the emoji gets spliced, sometimes it doesn't. Um, sometimes, sometimes the emoji gets spliced, sometimes it doesn't. We have to figure out, there are a few places it could be getting spliced.

2:17:54

Um, so the underlying process emits an emoji. Then the... So in fact, it's, it's kinda wild. We've got Solo, and then underneath Solo, um, we've got Screen.

2:18:15

And then underneath Screen, we've got Ngrok. And so when this emits something, it has to go up, and then it has to go through the screen, and then this has to go, uh, huh, Screen has to go up and into Solo.

2:18:41

Because when we start, um, you'll see we take the user's command, it manages processes. We take the user's command, and we actually pass it through Screen, because that buys us a bunch of stuff.

2:19:04

Um, four, two cares, six bytes, two cares, four bytes, two cares. Okay. So then once it's in Solo, then once it's in Solo, um, so the output has to get all the way up there. Um, inside of Solo itself, we've got the symphony process, which is, um, collect

2:19:36

incremental output. So when we start the process, we take all of the output from the underlying process, and we append it to partial buffer.

2:20:02

Then on collect incremental output, we capture what it was before, we execute one more. I don't know that we need to do that. We might not need to do that anymore. Uh, we do, we do, we do, we do.

2:20:25

Um, all right. So we have our partial buffer. We invoke running again, which makes the partial buffer get updated. If there's no more output Um, or if there's more output, we just, we defer back and we, we say try again. But if no more data came out, we're gonna flush the entire thing. So we write partial buffer. Um, there's a possibility.

2:20:50

So if no data came out, let's flush the whole thing. Now, if more data came out and we're over this threshold, then that's where we start looking for places to safely cut it. 'Cause we need to flush it, we need to flush it.

2:21:15

We can't just gather output forever and keep it in memory. We gotta flush it to the screen. Um, if there's a line break, we'll break on the line. If there is an ANSI escape, we'll break right before that. This is the only place I think we could ourselves slice the buffer incorrectly, is we slice at a UTF-8 boundary.

2:21:44

Um, and this is, like, such an outside case. I just don't think that that is possible. Um, four bytes. You're telling me there's one with six bytes, eh? That heart is six bytes long? So I'm only checking for...

2:22:18

All right. Let's go, let's go to chat. Um, all right, so let's do this. Is there such a thing as a six-byte emoji character? Because if I'm only checking for using MB string len...

2:22:48

Holy moly. That is the issue right there. No, no, no, no. No, no, no, no. No, no, no, no. Um, MB string len.

2:23:29

Is that not right? No, that's... Because this is not multi-byte safe. String offset length.

2:23:57

I think that's what we want, and there's our answer. It's six bytes long. Um, so chat better say yes. Zero-width joiners. Eight

2:24:36

bit. Um, all right. I don't think this is the case because it just feels like such an outside possibility.

2:25:01

Can you update this function to be safe for, um... Not be safe. Let's be more specific. Um, to not splice multi-character emojis.

2:25:25

Kinda out over my skis here. Um, let's see what it says about that. All right. Let's see what, let's see what you're on about here. Um... What did you say?

2:25:45

Eight bit? Oh, you said MB string. Six. I don't know what that tells me. That's cool. That's the same as string len at that point, but I don't know what that gets me. Oh, boy.

2:26:10

Grapheme extract international extension. Holy moly. Is the international extension pretty common? Does Laravel require extension- Is

2:26:42

this the right one? No, I want this one. Laravel needs it.

2:27:20

I just don't know if this is the actual issue, though. How safe is it? Ugh. Yeah, see.

2:27:44

Ugh. Man, these emojis are really dorking me up, aren't they? Um, does Laravel require ext international?

2:28:10

Um, I am starting to think that it's somewhere fur- I don't think it's the slicing part, but I do... I do wonder if I'm incorrectly handling, if I'm incorrectly handling a emoji somewhere else.

2:28:39

MB-STRWIDTH, huh? Whoops. Whoops. No, that one's two characters. I

2:29:10

think we just gotta wait for another splice and then capture it. Um. Ah, hell yeah. There it is right there. Did we get it? Did we get it?

2:29:34

Did we get it? Did we get it? I

2:30:05

don't see it. Ah. So this tells us, um...

2:30:35

This tells us because we captured it... So I think we, like, fully captured it before it ever hit the screen. Um, so let's take, let's go back to freaking ngrok2.txt. Let's take this godforsaken code, come over here.

2:31:03

Blah. Um, I think we're gonna see both representations. We're gonna see the byte splice in both. They, they might, they might actually just work. Like, it, the test might pass.

2:31:24

Um, ngrok2. Uh. The test might just pass. Ummm. Keep saying the test is gonna pass and then not successfully running the test.

2:31:46

Uh, the test is gonna pass. Okay, so what's the diff? Some weird stuff in there. Eh, I don't feel like that's actually a diff. Oh, Daniel, give me, um...

2:32:16

Daniel, do this. Go, go to this pull request and just leave a comment there. Ah. Oh, you know what? I c- I don't know how to click on that. Uh, let me see if Restream, I can go to the chat in Restream. There we go.

2:32:39

All right. Hey, Kyle. Daniel, did you write this? Yoink.

2:33:10

This is mine now. Daniel, the real MVP. Um, so I was on a train of thought. Um, all right. ChatGPT is still the real MVP. Um, this test passed, and I'll tell you why in a second. Um, slice at UTF-8 boundary.

2:33:36

Slice at UTF-8 boundary, better. Public function. So now... Sure, ngrok test. Why the hell not? Public function, um, slice at emoji. All right, let's give this a freaking go.

2:34:02

What do we need to make a command? Do we need anything? Do we need anything? Null, null, true. Boom. We don't need a freaking thing. Uh, command equals new, new command. All right. Command slice at, slice at UTF-8 boundary.

2:34:27

Um, hello. Oh, weird. Look at this. If I hit backspace, it turns into a little heart. Man, the things, the things that I don't know, they are many.

2:34:53

Um, what should this return? So this is the original one. Okay, so this is gonna return a string. I'll tell you why this test passed in a minute. Uh.

2:35:17

This is just a regular freaking test. I don't need a screenshot test. Get your head in the game. Um. Byte splice test. We've been down this road before. Safe bytes. I wonder if this class is used anywhere.

2:35:42

I don't think it is. Um, anyway, anyway, anyway, slice at emoji. Oh, there you go, the variation selector suffix. Um. Hey, look at that. That's great. That feels like it's totally broken, which is, you know, kinda what we're discovering.

2:36:07

Um, so then slice at UTF-8 boundary better. Hmm, still feels broken, doesn't it? I feel like I should have gotten back hello, or rather...

2:36:34

Yeah, I should have gotten back hello. Um, this is okay, Daniel. This was a good try. Let's try safe bytes. This is a class I wrote way long ago. Uh, have fun screening Laravel Agency Tuesday at noon.

2:37:04

Um, I'd be curious what the other people in chat think. Um, I would say, what's today? Thursday. You had the thing on Tuesday. I would send them an email tomorrow morning and just tell them how excited you were, how you're looking forward to the next round, and you hope they have a great weekend.

2:37:30

Um, that is my advice. Chat, please weigh in and tell me what y'all think. We got one vote for Monday. All right, so this should return... I mean, we're definitely splicing that emoji, so that, that-- this could very well be the, the case.

2:37:58

Um. This is kinda funky. What are we listening to? Hozier. Man, you know what? Hozier's kinda good. I don't know, I don't know if he's like, if people like him, but he's kinda good.

2:38:21

All right. So does safe bytes do this? I don't need all of that at the beginning. I mean, kind of, not really. Um. Why is it not parsing that at all Brother

2:39:08

man. Let's go back to Daniel's. I feel like his was kind of on the right track. Okay,

2:39:44

so it's 11 bytes long. It's 11 bytes long, and we moved backwards three, which is the, um, the first part of that two-character emoji. And so that's why we're getting the splice back because...

2:40:07

And that's what this part should handle right here. Um, so at this point, we've got-- What is the actual? It's hello. So H-E-L-L-O is five.

2:40:30

Then we have a, a three char, three char. I think we might have a three and a two with, like, a, a zero, zero-width join. Maybe.

2:40:50

What did chat say about... There you go. Tia Fu, thanks for the good luck.

2:41:17

I, uh, clearly need it. It seems like there's no joiner, no zero-width joiner in between.

2:41:50

Unless it's, like, truly... I guess it's zero-width is a... Rather, what's a zero-width joiner, and how is it represented in, I don't even know what that is, in Unicode? So that, uh, I guess it's possible that zero-width joiner is zero-width, and then so we'd have three, six, five, makes 11.

2:42:23

And we grabbed half of it, and we need to grab the other half. How can I convert an ASCII string in PHP to the bytes so I can inspect it?

2:42:51

Oh, hey, Duncan. What the hell is he doing? That's a great question, Eric. What indeed? What indeed? I actually do wanna see the hex representation. Um, I am trying to figure out, dear Eric, I'm trying to figure this out. When I run Artisan Solo, which is the library that I wrote, um, oftentimes we end up...

2:43:18

Yeah, restart. With goofy crap like that. Oftentimes we end up with a byte splice where we're splicing that right there. Trying to fix that. And so I'm walking a string, walking a string trying to figure out, um, how to make sure

2:43:49

we're not splicing a byte. Let's just take you over here. We're not s- rather, we're not splicing a multi-byte character, I suppose. Let's just be real. I'm trying to make sure this heart doesn't break in half. Um, X. Nope, wrong one.

2:44:15

Nope, wrong one. Guh. Uh, let's do this. We might have to use the extension.

2:44:49

The X matches any extended Unicode sequence, so that is why you want to split after. No,

2:45:32

there's no extra, there's no extra space. If I hit backspace, it takes away part of the emoji, if that's what you were saying. Does this tell anyone anything?

2:45:58

This doesn't tell me anything. I don't know what that means. So here's something. Let's do this. I ran this code and got this output.

2:46:40

Can you explain those bytes to me? 'Cause I certainly can't. Um, yeah, dinosaur game. Dinosaur game is definitely gonna be a lot of fun. I love when it gets excited.

2:47:04

It's a multi-byte encoded character. We found one. So, hey, Jesse. Boy, Jesse, we are deep in the weeds.

2:47:28

Um, we're deep in the weeds. We might be cutting a multi-character emoji in half, um, which is causing some issues. Um, we've been careful not to cut a multi-byte character, but now there's a multi-character emoji.

2:47:50

Um, and I think it's dorking up my, uh, UI here. If you don't know Jesse, who's joined the chat from the gym, Jesse runs Bento, which is the email service provider that we use at Try Hard Studios. In fact, get her out of here. Hey, there he is. That's what we're talking about.

2:48:10

There's a guy. Who's that person? Get that person out of here. There we go. That's better. So, if you're looking for an email service provider, call our friend Jesse. Tell him I sent you. Um, I just don't know how... So here's, here's my question for, uh, no, you weren't, but that's a good point.

2:48:36

I'll send you a bill. Um, here's my question for the chat. Um, I see nothing in here from, um, one two three to four five six. I see nothing, if I were working my way backwards, to indicate at two thirty-nine here that there could be potentially another emoji character before that.

2:49:02

Do you see, do you see what I mean? So like, I don't know, with zero knowledge, I don't know how I can work my way backwards. Yeah, this, this is actually a good reason. Um, let's try this. What does it look like to unpack a regular...

2:49:31

We might have to go about it a different way. What does it look like to unpack a regular... Yeah, so those are gonna be ninety-seven, ninety-eight, all the way up to who knows what. All the way down to 90. What do you know, Aaron? Very little about very little. Um, all right. Hey, Shane. Here's what I'm gonna do.

2:50:13

He said confidently. Um. Yeah, y- yeah, I will. Um, so if we run that, we get six ending in one six four is item number three, and then one six four is item number three.

2:50:40

Yeah. But they belong together. Here's what I think we're gonna do instead. Um, what's the range of bytes for A to Z, A to Z?

2:51:11

So I think it's like ninety-seven or sixty-five to ninety, ninety-seven to one twenty-two. Um, all right. So, we're just going to assume...

2:51:39

So we have several tests here that should absolutely pass. Um, we first break on a new line, and this is only if, this is only if we have so much in the buffer that we have to flush it. Um, so first we look for a new line, then we look for the beginnings of an ANSI code.

2:52:15

You know what? I think we can just do this. Um, we can do this. What about a space? Hello, hello, ardesio. So thirty-two. Thirty-two and...

2:52:46

So we are going to public function slice, slice at representable character. I don't wanna require ext intl, because I just don't know how common that is. Um, and then space is what?

2:53:10

So the only way that this will fail is if somebody strings together hundreds of emojis. Uh, which at that point, I don't know what to do. Um, all right. So, let's say that repri-- I mean, that's representable, so is like that, and so is that, and so is that.

2:53:35

Like, representable. Who knows? Um, we'll say that representable equals range of sixty-five to ninety. This is a little silly, so don't tell me that it's silly yet, because we'll get there. Um, so those are the representable ones with hand-waving representable a little bit.

2:54:02

I mean, they're, they're definitely representable, but that's a subset of representable characters. Okay. So then, let's do this. Um, I thought I commented out the unknown ANSI match thing.

2:54:30

Uh, Joseph, you're like the fourth person to say it. If you wanna be the first guy to say it, you gotta show up earlier. Uh, light mode. We love light mode. Yeah, I don't know, Len. That's the question. What-- Is everything below one twenty-seven, is that all good? Like, are those all, uh, single byte non...

2:54:53

Those won't appear in any other place? I think that's probably what we'll end up doing. Um, I don't know what that means. Oxo, oh, one hundred or oh, one million? I don't know what that means. Um, let's try this. String input.

2:55:18

Walk backwards to find a representable character. If... How do I turn... I don't want byte val, do I? I don't want ord. It's just binary one twenty-seven?

2:55:41

Oh, cool. What does ord even do? Ord A. Ninety-seven. That is what I want. Ord. Ord. Ord. Learn something new every freaking day.

2:56:07

Um, all right. Get out of here. If... Am I still online? Okay. Um, if byte val in array. We might end up just saying less than one twenty-seven. Oh, Daniel thinks he has it.

2:56:28

Daniel thinks he has it. Uh, in array. What's the order here? Needle haystack. Needle is, in fact, byte val representable. Uh, what was that third param there? Strict? Yeah. Hell yeah, brother. Let's do some strict. Um, all right.

2:56:50

So if it's a legit byte, well, rather, if it's representable, there are no ir-illegitimate bytes. If it is representable, then we wanna do that. And then what happens down here? I think that's the same as that. Yeah. Yeah, MB substring doesn't work Um, because these emojis are two characters long, and

2:57:20

that's what I'm trying to figure out. All right. Slice at representable character. Hey, are we having fun yet or what? This is the wackiest thing. We're not making cred apps over here. We're doing something even stupider. I bet Daniel's, I bet Daniel's, uh, implementation is way cleaner than mine.

2:57:45

Hello. So that worked. I think the thing is, if it's pure emoji... I think if it's-- So this, this is just such an outside case that I don't think it is possible.

2:58:15

You'd have to have over, you'd have to have over 10240 characters and the l-- no line breaks and no ANSI character, ANSI codes, and the last character would have to be an emoji for you to lose the emoji.

2:58:38

So you know what? Won't fix. All right. All right, so we did it. Now the question is, how much better is Daniel's? Let's open... Get real.

2:59:02

Get real. Uh, maybe John, I haven't seen one. What platform are you on? You're on YouTube? Let me see if I can go fix that. Um, oof, Ed. Oof, that's a good point. Um, how would I even...

2:59:32

Brother, I don't even know how to see if your, your links are being modded. Um, maybe we can go here? Um, I have moderation activity off. Okay.

2:59:58

Dunno. Don't know what to tell you. Um, boy, is that, is that it? Can you explain this function to me? Mm, that's a good point.

3:00:38

Grapheme clusters. Who knew that that was a word? I guess technically that's two words. A multi-code point

3:01:08

character, such as an emoji or a letter with combining marks. Man. This freaking rules. So today, um...

3:01:33

Where's my footrest? What am I supposed to do, put my feet on the floor like an idiot? Um, today I have learned grapheme. I've learned multi-code point, which I don't fully... What is code point? I don't understand what a multi-code point.

3:01:57

I understand, like, the concept, but I don't understand what a multi-code point is. Um, and it returns a single user-perceived character or grapheme. So grapheme and user-perceived character are synonyms. That is actually made up of a two or more unicor- unicorn, Unicode code points.

3:02:20

Still don't know what a code point is. Every distinct symbol in Unicode has a code point. Okay, so it's just, like, what they call their unique IDs in Unicode. Um, so a Unicode code point is the unique, this is me speaking now, is a unique representation, or rather a unique identifier of

3:02:51

a Unicode character. And so a multi-code point character, which would be a grapheme, is many Unicode characters, which is to say many Unicode code points put together into a single user-perceived character, so one logical representation, which we would also call a grapheme.

3:03:19

Hell yeah. Where else are you gonna learn stuff, you know? You just have to freaking learn it. This is great. Um, all right. I kinda like his, I kinda like his, like, 10 times more than I like mine, um, because it handles, it handles glyph characters better. Um, all right, so let's come back over here.

3:03:43

I still don't think this is the issue that we're... I, I don't think this is gonna fix our issue. Um, slice at UTF-8 boundary. Slice before... Slice

3:04:18

before grapheme. I'm not gonna remember. I will remember, but it's not very approachable. Slice before, um, user-perceived character. That doesn't make sense. Slice before logical character boundary.

3:04:49

Look for the complete visual unit. Went to high school with a guy who was a complete visual unit football player. Um, all right. Pattern X is a PCRE escape code that matches extended.

3:05:10

Okay. And then we are removing the last, um, return everything before the last grapheme cluster.

3:05:40

Slice before logical cal- character boundary. Func, yeah. Atta boy, Daniel. Freaking Daniel. Freaking Daniel guy. Um, assert equals hello sliced.

3:06:14

Soccer. Now, this guy was an actual football player. He was a big old mountain of a man. Super nice guy, but still a mountain of a man. Um, what happens if you do that? What happens if you do this?

3:06:48

Yeah, so if you have a giant string of, like, a million emojis, it ain't gonna work. Slice before grapheme, I think that's fine. I do wish, in this case, it returned one emoji.

3:07:17

I think we're probably, uh, tinkering at the margins a little too much. I bet if we added a space in between them. So yeah, we're just tinkering too much, because if you add a space here, yeah.

3:07:46

If you, uh, if you run a, if you run 5,000 emojis back to back, you're gonna get something wonky, and that's just not my problem. I feel super good about this. Cool. Nice job, Daniel.

3:08:08

All right, so let's implement this then. So we don't need slice at representable character, which, to be fair, was a good idea. We're actually after... Oh, man, we've been going for a while, haven't we?

3:08:30

For three hours now. Look at this. Nate Berkopec. Jesse, if you're still here, you'll appreciate this. Um, Nate Berkopec, big Rails guy, super smart Rails guy. Uh, something about code streams just doesn't click for me.

3:08:54

Dang it. Hey, Nate. Love your work. No, that's fine. I don't care. He's super smart. He does a lot of Rails, uh, speed work, so he's always going on about database performance, and so I really like him. Oh, he follows me. That's nice. I like him a lot. Yeah, code streams are weird.

3:09:19

Um, they are fun, like, at, at the very least, they're fun backgrounds It's a terrible song. Ooh, what do I wanna listen to now? Um, I don't know if we have a, I don't know if we have a Laravel

3:09:49

equivalent of Nate. I mean, Tobias and I both do the, both do the database stuff, but Nate is... He goes from, he goes from database all the way up through to application, as you well know, Jesse. Um, I don't think we have one.

3:10:11

It's a good, it'd be a good thing to fill, for sure. We're gonna go back to 2005 here, and we're gonna listen to Silent Alarm. Um, hey, Michael. Welcome. Oh, Nuno was just streaming?

3:10:34

Is he still working on Playwright, or is he working on his talk for Laracon India? I just think that this case is never, ever gonna be hit. That's, that's what I actually think. He's preparing for Laracon, yeah.

3:10:58

So now we're collecting the incremental output. We take a test before to see how long the buffer is. We invoke through a roundabout hand-wavy process. We invoke the collector again, make sure it picks up the newest output, and then we take a test to see how long it was after.

3:11:24

Which, do we use this variable anywhere else? Do we need to store that? Yes, we do. Um, if there was no output, we're done. We don't have anything to do. If there's no more data coming out of the underlying process, we are going to write the entire partial buffer.

3:11:45

That's interesting. That, that is a potential... We could potentially splice a multi-character grapheme. I sound so smart now, 'cause I've learned all these words. Did you hear me? God, I should've, I should've kept going.

3:12:07

I hung a lantern on it. You don't hang a lantern on it. You keep going. Um, I've just learned so many words. We could potentially splice a multi-character grapheme right here. If the partial buffer, if the underlying process has emitted the first character of a multi-character grapheme, and we blindly write it, I mean, it's a small...

3:12:35

But, you know, if you do something a million times, even edge cases become normal. Um, uh, 10,240 is just me just making stuff up, me deciding, "Eh, it's pretty big. Isn't that big? We should get rid of that. That's pretty big." Um, yeah, this is interesting to me.

3:13:05

I'm wondering if, I'm wondering if, um... So I'm assuming here, I'm assuming here that if the underlying process is not writing any more stuff to output, that it's, like, it's good.

3:13:31

It's solid. I don't need to do any of this introspection stuff. I don't know if that, I don't know if that is wise. I don't know if wisdom would dictate that I do that. Um, so if it's done, if it's still streaming tons and tons and tons of stuff, we have to cut it off at some point, otherwise it's gonna overflow.

3:13:55

And so we cut it off at 10,240. I don't know if that's good, bad, or otherwise, but we cut it off at 10,000 characters. Not characters, in fact, 10,000 bytes, 'cause we used strlen. Um, Ham, I don't know. That is a good question. Um, I don't know.

3:14:23

So here's what happens. If it's still streaming out, if it's still streaming output, and we haven't reached this boundary, we just bail. Otherwise, we figure out how much we're gonna write, which in this case is everything. How much we're gonna write, and then we leave the partial buffer behind so that we can save it for the next time.

3:14:45

So it's appended on, and then we add the output. So yep. Um, let's clear the debug. I bet immediately, I'm just gonna call my shot, immediately the first thing we're gonna get is, "Can you run the code?" Brother, I'm trying. I'm trying, man. I bet the first thing we're gonna get is a b- is a, is a grapheme splice.

3:15:10

That's just my guess. Uh, art isn't solo. Oh, called it. Got some wonkiness in that terminal there. Yep, there's a splice right there.

3:15:33

Bonk. All right, let's change tack just a little bit. Um, we've been, we've been writing it, um, file put contents.

3:15:54

We've been writing it up here. Let us in fact, um... Let's just write it cold. We're gonna do it right here. So coming directly out of, coming directly out of the underlying process, we're gonna write it to our, we're gonna write it to disk.

3:16:19

Um, we're gonna write it to disk so we can see. And this big old line right here will tell us where... This should tell us who's doing the splice.

3:16:39

'Cause I need the actual, I need the actual bytes, not the, not like the characters. Can you run the code? It's making me laugh.

3:16:59

You're making me laugh, Allen Corp official. Um, all right. Boom, got one. We got one. We got one, fellas. See, that looks like a splice to me right there.

3:17:26

So before we even touch it, coming, coming straight out of the underlying Symfony process, we're spliced. We have a grapheme splice. Why the heck?

3:17:50

Where did the other half of that emoji go? Everything is solvable, and so we have to think about how to solve this. Um, everything is solvable.

3:18:17

What can we do? What can we do? What can we do? What can we do? We can remove screen from the equation. Um, let's do this. We are simplifying. So, so far we have learned all that byte splice, all that grapheme splice was not the answer.

3:18:40

Um, it was appropriate. It was the pure and noble thing to do, but did not solve our problem. So what we're gonna do is we're gonna take screen... Yeah, here's the problem with screen. I know very little about it. So we're gonna take screen out of the equation here.

3:19:09

Yeah, that's the freaking problem. Look, did you see how it took over my whole screen? Like it killed... F, it killed the UI, and it killed my hotkeys. That's a bummer, brother. Yeah, and I don't even get to capture it.

3:19:34

I don't even get the opportunity to capture it. Yeah, the s- the standard in splicing, I guess it would technically be standard out, is what we're trying to accomplish.

3:19:57

We, we handle that via the buffer, the partial buffer. Um, that's why we do that, because at one point I was running into issues where after ten twenty-four characters, um... That time it was ten twenty-four or forty ninety-six.

3:20:17

After that many characters, it would overflow into standard error, and so went in circles and circles to make that viable, and that works now. So we're not, I don't think we have standard out, at least not from Symfony to me. We might have a standard out splice from ngrok to screen, and then screen reports it back to me as spliced.

3:20:45

That's very possible. But we might be reaching, we might be reaching the end of my endurance for this today. So I wasn't able... Oh, this is wrong. This should be screen width.

3:21:11

This should be screen height. So if I run it without screen... Oh, what? What does screen you do?

3:21:33

That is interesting. No way.

3:21:57

You old son of a gun. You old son of a gun. Uh, screen. Is this the right way to use it? PHP.

3:22:20

Or is it about... Whoa, if this... Yeah, suppresses informational messages.

3:22:46

That's what I want. That was a lie. I don't need that. Then yes. Okay, that is, that is sim- that is simply my goal, ChatGPT. If your goal is to run any command, that was just a stand-in, in a new UTF-8 enabled screen session with minimal startup messages, then yes, that is a valid way to do it.

3:23:16

Yeah, I don't care about detaching. You old salty dog. Damn it. Ah! Still

3:23:47

there. Boy, you know what's weird? You know what's weird is... This is a novel insight.

3:24:11

We're getting characters before, we're getting characters before the grapheme splice and after. So, like, this is our big, this is our big, hey, we're getting a new chunk of output, right? We did that over here.

3:24:34

So anytime we get a new chunk of output, callable output. Anytime we get a new chunk of output, we write it to debug, and then we write this, and then we move on. So it's not like... So what this tells me, this tells me that between me and screen, so between PHP and screen, so we're running it like this, which is insane.

3:25:03

Um, PHP screen users, uh, we can just call it what it is, ngrok. Um. So I know that when this comes up, when this comes up, I capture a chunk that is surrounded, like the grapheme splice is surrounded, which means I'm not,

3:25:33

like, if it were like this, I would say, well, obviously the prior half of that emoji is up here somewhere. But I'm not, I'm not, I'm not, that's not happening. Here's what we do. So I think what I, what I'm saying is I think right here it's getting, it's getting spliced somewhere.

3:25:56

Um, let's ask ChatGPT first, and then I have, I have a proposal for you. Um, okay. I'm writing a library that helps users run a bunch of commands in one command. And to do that, I'm using Symfony's process component and screen.

3:26:22

When I'm capturing the output from screen in Symfony, I'm getting a Unicode unknown character question mark box. I think a grapheme is being split. To be precise, I think an emoji, a two-character emoji is being split in half. I have verified that I'm accurately capturing the

3:26:53

output from screen, but I'm wondering if the underlying process is not sending the correct output to screen. Here's a capture of what I received in Symfony. You can see the question mark emoji box in there. Is there any way to make screen...

3:27:17

Is there any way to change the output buffering of screen to be either smaller or bigger or safer in some regard? Boy, that was... I don't know if we're gonna get there. Um, let's see what chat has to say about that. Yeah,

3:27:55

it's flushing output in chunks. Sheesh. Man. Okay, so that's interesting.

3:28:25

Let's see. So this is an interesting point that we might be receiving it correctly.

3:28:58

So what Daniel's saying is, we might be receiving it correctly. All right, let's try this first. Um, why don't you come over here?

3:29:25

We've already exposed this key a long time ago. And then what's the command we're actually running? It's screen UQ, then the command. So clear. Screen, big UQ, then the command. It's something between

3:29:56

ngrok and screen. Screen is terminating. It's something... F me, man. There's a good one.

3:30:20

And that's a six, that's a six-byte, two-character emoji. So it's random, which is not helpful. Oh, man. And have we confirmed that

3:30:51

this doesn't happen with just pure... It sure doesn't. What are all the flags you can pass to screen?

3:31:29

So, are y'all seeing this where... All right, I want you to watch super closely when I run this again. Um, we will see, you'll see the ngrok screen come up, and then you'll see the, um, the ad pop in.

3:31:56

Yeah, Kevin, the content is changing. You see the ad pop in, right? The ad that includes, like, the emoji. What does that tell me? Does that tell me anything? They're probably fetching the ad via API and then writing it into, writing it into the screen.

3:32:27

Or I'm sorry, uh, into the, into the output. But boy, we have just, we just, we've just captured it all. Also, we took PHP out of it altogether. And when we, when we took PHP out of it altogether, it still doesn't work.

3:32:53

See? It still doesn't freaking work. Hmm. This is a, this is a tricky one. This is starting to feel like it's not possible for me to fix this. Send commands.

3:33:13

What is that? Send a command to a running session.

3:33:48

Man, I think this is, I think this is out of my hands. Screen. How am I gonna search for screen? Is it new screen? No, not split, splice. Okay, well

3:34:18

that was useless. Um... Hey, Bradley. Lynn, that's interesting. No, Bradley, I'm, I'm using Restream.

3:34:46

I need to use my own because I don't, I still don't like Restream. Um, all right. How do I turn on deep research mode? Can't you do deep research with ChatGPT now?

3:35:17

Yeah. I'm running into an issue with GNU Screen, where if I run ngrok through Screen, I end up with a spliced grapheme character. Ngrok likes to show emojis, and when I run ngrok on its own, the emojis show up just fine, but when I run ngrok through Screen, the emojis often get spliced.

3:35:47

Is there any way around this, or is there anyone that has, um, written about this before? I don't want 4.0, I want, uh, 3 mini high deep research.

3:36:21

What locale settings are you using? Don't know. I'm using iTerm2. October of '06, is that the problem?

3:36:47

Is that the latest one? Maybe I shouldn't use Screen at all. Um... Man, it is a great question.

3:37:23

What's the latest version of GNU Screen? Maybe, maybe the problem is that I'm using a w- a 19-year-old version of Screen. Y'all,

3:38:01

I don't really know. To resolve the character buffer bug, updating to new Screen 4.2. I'm on 3.1. How do I... Oh, no, I'm not on 3.1, I'm on 4.0.

3:38:30

You're right, Len. What's the one I should be on? 4.2? That's good. I'm still, I'm still too low. I'm still too low. Um, I'm still too low. So this might be something I have to enforce. Um, install GNU Screen Mac, probably Homebrew.

3:39:03

Y'all, I'm just, I'm just a lowly web developer, and yet here we are. Isn't it crazy what you can do? Um, Homebrew, no auto-update. Brew, is it just... Yeah, install Screen. This would be mother freaking wild.

3:39:34

All right, so let's do a new one. Okay. Version five, ooh, fancy. Fancy, fancy, fancy. Okay, no splice, but no emoji.

3:39:58

No splice, no emoji. Ah, I don't know what that is. No splice. No splice. F you. No splice. You old salty dog. Sorry for the flashbangs.

3:40:21

Can't really control that. Hell yeah. Oh. Is there not a way to make ngrok be light mode? What

3:40:56

do you mean this project is no longer accepting... Wait, wait, wait. It's not ngrok? Oh, you might be right, Kevin. Who knows how anything works? I don't-- What, what do you mean it's not maintained? Is that not real? Maybe this is real.

3:41:27

All right. F that. Guys, this is great. Look, Len, released two thousand six.

3:41:49

It really was two thousand six. Due to an internal two-byte character buffer limitation. Somebody asked earlier, uh, about using LLMs in coding. Is this not maybe the best example you've ever seen?

3:42:12

Super esoteric, super esoteric question. Excuse my French. You just kinda shit out a question, and you're like, "Man, I don't know what this actually means." Like, "Hey, ah, good luck. Have fun." And then it comes back, it searches the web and comes back with the perfect answer. Release two thousand six has incomplete Unicode support.

3:42:38

Yep. They are replaced with a question mark. Good grief. Oh, it's well documented in the bug tracker. Okay. Well, I didn't know that. The emoji may appear cut in half.

3:43:10

It fails to interpret the four-byte sequence properly and splits it into invalid two-byte pieces, which is kind of... I mean, it's close. I think it split it into two three-character... And in fact, we don't actually know what it did. This is wild.

3:43:35

Commit from twenty thirteen added support. Twenty thirteen. Where were you on that one, Apple? I bought this computer, like, a year ago. Come on, man. Okay, so our learning here is that on behalf of the user, we need to at least check that screen is at four point two for sure.

3:44:04

Maybe four point two one. Yeah, I'll mention it in the docs, which no one will read, and so I'll also, I'll also check it for them on startup. Ian would be so bored by this.

3:44:25

Are you crazy? Ian, if I brought this up, if I brought this up on Mostly Technical, Ian would tell me how much of a dummy I am for spending so much time on it. You know, you know that's exactly what Ian would say. He'd be like, "Why are you doing, why are you doing this? You gotta, you gotta make courses." You know it's true.

3:44:45

Now I have to bring it up. Now I'm gonna tell him. Now I'm gonna tell him, so tune in. Tune in to Mostly Technical. Um, here's hard status. Xkul, Xkul, Xul, whatever your name is, Xul. Cool, maybe.

3:45:06

Uh, you mentioned hard status earlier. I don't know what that means. I'm gonna make, I'm gonna make Ian listen to this story. Still seeing issues in screen four point eight.

3:45:29

Honestly, should I just make people update to five? Not make them, but suggest that they update to five because, um, why, why not? I mean, why not? It works in tmux.

3:45:55

Okay. Okay, tmux guy. Tried tmux, but it crashed a lot. Developers, man. Developers are the worst. Um... Oh, that's interesting. Boy, I know so little about screen Yeah, I think I'm gonna suggest they go all the way to five, uh, based, based on this

3:46:25

reading here. UTF mode was a great call. That was, that should've been there from the beginning. So thanks, ex-Yule. Wait, wait, wait. What is this? Oh, alternat- so you can do those two things in your screen RC, or you can start the screen with U, which is what we've done.

3:46:54

Five, 12. Guys, I gotta go home at some point. Um, silently execute brew install. Yeah, and s- you know, bork their machine for the next three hours as it does the upgrades. Um, mm-hmm.

3:47:22

Lynn, this is what you were saying. Ensure your environment's locale is correctly set to UTF-8 before launching screen. Which I can definitely do. My,

3:47:54

my, my worry is, do I set it to en-US UTF-8? I can do it just for that command, so it's not like there's gonna be collateral damage. I just don't know, like, what if it's en-UK.UTF-8?

3:48:19

Can I do that? I don't know. Tmux. I just... I don't, I feel like Screen is way lighter than Tmux. And I, all, all, all, all I need it for...

3:48:48

Yeah, it has a config file. All I need it for is to, like, sit in the middle between me and the process so that it doesn't take over the entire screen, like we've seen. This is a great, great article. This is the freaking best.

3:49:08

Um, can I type in here? Like, w- w-what does this mean? Okay, I guess not. Create link. Um, copy link. What am I gonna do with this? Don't really know. Um, resources about Screen version needing to be 5.0.0.

3:49:41

At to-do, add a check on startup to see what version Screen they are using. At to-do, allow them to configure maybe the locale.

3:50:06

Um, okay. So let's take this. We're gonna take... Oh, make it fall back to plain text. I don't like that. Um, where's locale?

3:50:37

So here's what we're gonna do. Boy, that wasn't that a rabbit hole. We're gonna go back to ChatGPT and say, "I learned this," but we're not gonna say, "I learned it from you." Don't give them the credit. I learned that setting the locale to, uh, UTF-8 might help. Here's the passage that you wrote. Here's my, uh, here's how I'm launching Screen.

3:51:12

Can you add the locale as, ugh, variables? Yeah, we're going to, we're going to, we're going to, we're going to. Add the locale as variables affecting this script only.

3:51:44

Man, just push a fix, 254. God. Freaking Cam. Freaking Cam guy. Look at this guy.

3:52:06

Look at this guy. I owe this guy a phone call. Cam, if you're still here, I have not forgotten about you This is the good stuff, man.

3:52:29

This is the good stuff! Some days, some days it works, my friends. All right. You can ensure the, uh, is there extra look in the command string. Yeah, yeah, yeah, yeah, yeah. Um.

3:52:56

Yeah, I don't like that, 'cause that will affect their underlying command. Um. Um, what if the user i- the user's locale is en-FR?

3:53:19

Is that, is that real? Is this going to cause problems? I don't really want to change the language. I just need to ensure that it's UTF-8. Are there any, uh, what am I looking for?

3:53:42

Not consequences, um... Side effects, side effects of forcing it to be en-US UTF-8. Uh, going back to the LLM conversation, this is, I think, because I'm doing it, the way that you should use an L- LLM.

3:54:07

You should, like, have a good knowledge of what's going on and ask it more probing questions like this. Now, some of this knowledge I gained from the LLM, which is fine, but I think you need to keep pushing on it. Yeah, that's what I want.

3:54:29

Um, show me how to check if it's a UTF-8 locale of any language. I have not told ChatGPT about my language because, I don't know.

3:54:52

I usually tell it in the, in the chat, um, as I'm chatting. Um, hey, Kyle. Thanks for hanging out. I know this was a, this, this was a wild one, but thanks, thanks for hanging out. Um... Yeah, so es_ER has FR, FR.

3:55:20

Of course, it's not en-FR. Goofball. Uh, FR, FR, UTF-8. We're probably looping back to you. I'm gonna leave you, but it also said to set the locale. So

3:55:51

I think the U, the U flag sets def UT8 and def encoding, but then it says separately, locale must be UTF-8 before launching screen, if that makes sense. Hey, Mulos.

3:56:15

I don't know why, I don't wanna make Wi-Fi calls. I wish it would stop telling me that I can't. I don't want to. You can't tell me I can't. I don't want to. Um... Here's what I think I'm gonna do. If it's not a UTF-8, if it's not a UTF-8 encoding, I'm gonna force it to en-US UTF-8,

3:56:45

and then otherwise, I'm confident that it's a UTF-8 encoding. Yeah, ISO, whatever, whatever. We don't want those. Um, all right. Why don't we do this? Write me a PHP function to return the UTF-8 version of the user's locale.

3:57:16

So if, if it's, uh, what did you say there? If it's FR, FR.ISO8859-1, you should return FR, FR.UTF-8.

3:57:40

I want to preserve the user's, uh, desired language, but set the, I don't know what that's called, encoding, encoding to UTF-8. I gotta open the door. I've been, it's spewing carbon monoxide for a while. Do we spew monoxide or dioxide?

3:58:06

I think we spew carbon dioxide, don't we? Cool. That's fine with me. I like that. Oh, Ed has an official answer Um,

3:58:49

can you use... John, you're, you're probably absolutely right. Dioxide, there you go.

3:59:18

All right. We're getting close, we're getting close, we're getting close. Um, all right. So protected function, um, UTF-8 locale. Okay.

3:59:57

And then we need to ensure that that ends up in the string. Not in the ENV, but rather... Boy, it's just gonna end up in the ENV no matter what, isn't it? That's okay. Um, this is still, this is still fine.

4:00:22

This is much safer. UTF-8 locale. Um, all right, let's try this. Protected function, um, locale in environment variables.

4:00:48

Locale equals... Boy, shouldn't give away software for free. What the hell are you doing, man? You got stuff you gotta do. Why are you doing this? Locale, um. Oh, you freaking goober.

4:01:12

All right. Um. Oh, is this, is that why it's complaining? F, that is why it's complaining. Back to the drawing board we go. How's

4:01:46

that feel? No extension needed. Yeah, freaking E-X-T-I-N-T-L got me again. All right, I buy that.

4:02:12

We're here, we're here to do what we can. If function exists... So watch this. We're gonna use PhpStorm to do this. We're gonna do that, and then we're gonna come over here, and we're gonna say simplify if.

4:02:34

There we go. Is that better? Do we like that? I think that's better. Good idea. Yeah, I don't wanna put it in the Composer JSON, 'cause I don't actually wanna rely on it. If it's there, hey, we'll use it.

4:02:56

Let's have some fun. But if it's not there, I don't wanna rely on it. All right. Good idea, Ed. Thank you for that. Um, okay. Now finally, finally, um, I think we can just plop...

4:03:26

Does that kinda muck it up? Yeah, so this is how they say to do it. Just ram it all together there. Fine. Fine, fine, fine, fine. Fine, fine, fine, fine.

4:03:48

Um, locale. Boy, this command is really getting unruly, isn't it? Um, this is an experiment, so don't yell at me yet.

4:04:17

I don't know if I like it, so don't yell at me. Uh. We don't need the space. It's a little bit of a logical break.

4:04:40

And in fact, you can go there Oh no, he's yelling at me. Philippe, hello.

4:05:12

Um, built equals... Sure.

4:05:51

All right. How does that look? Export EN US UTF-8. Export EN US UTF-8. Calls, 124. Rows, 22. And screen. Why does that have a semicolon and that has an and and? Screen UTF-8, quiet mode, ngrok, HTTP, my super secret token.

4:06:18

Eh. Meh. Meh. Um, I wonder if, like... Should I just implode with and and? Is, like, that what I should do? Probably.

4:06:42

Does this command work, is the question. Like a freaking dream. Look at that. Look at that, my friends, my dear friends. Let's implode with an and and. Yeah.

4:07:03

Hey, we like it. We like it. Um, build the command by adding a few, um... Oh, I'm sorry, I did not see that question. Zul, why do I not need the and and? Should I just do semicolons?

4:07:25

Um, Milos, I'm sorry, I did not see that question. Um, Josh Siri named Fusion for me. Um, uh, Solo, Solo was, it came to me in a burst of inspiration. Um, it's one command, so single, one, Solo.

4:07:46

Pretty good so far. Um, and then Josh, nope, Joe's package is named Chewy. Um, Chewy spelled like Chewy. Star Wars. Uh, let's do this. Chewbacca, Star Wars, Han Solo, Solo.

4:08:11

Pretty good. Pretty good. Um, the namespaces are just a freaking nightmare. So Fusion is, on GitHub, it's Fusion PHP, Fusion-PHP, and on Packagist, it's Fusion PHP. And, uh, Solo is Solo Term because, uh, nothing else was available, so Solo Term, Solo.

4:08:34

And on Packagist, Solo Term was available. Um, so Solo Term. So, there you go. Yeah, I feel like that's what I want. Hey, Fracis, and and. Um, thanks, Chris. I take a lot of pride in my stream being quite clean.

4:09:00

Yeah, I kinda, I don't think these could ever fail because they're not really actually doing anything. But if they do, I, I definitely want everything to stop. So, that's good. We'll, we'll live with that. Um, allow them to configure the locale. I'm not gonna do that. I do need to do this. Funny, I left this for myself, but I'm not sure why.

4:09:24

There's double question marks, like, uh, uh, well, uh, good luck, man. Um, all right. Let's get a fresh little terminal going here. And let's just say, artisan Solo. Somehow it's worse.

4:09:51

Where did session go? Why is it, why does it not say... Why is it worse? Uh, get a byte splice, so that, that much is true. What is going on?

4:10:20

This is it. I'm done for today. Let's just see one more time. Yeah, that one worked, but it, like, the other ones didn't. Um, all right, quit. Give ngrok a second to shut down, restart. All right, so we get S-I-O-N, and then that...

4:10:45

We get S-I-O-N status. Let's go look for that Okay, this is good. This is fan-freaking-tastic. Praise be. Um, thank God.

4:11:09

My gosh. Okay, so the reason I'm so elated with this failure is we got the output. We got the output. Um, yeah, I can't control ngrok's UI, unfortunately. However, I guess I could sneak in there.

4:11:31

I guess I could sneak in there and muck it up. I'm not gonna do that. Um, but we got the output. We did it. So now the issue, which we're not gonna address today, we're, we're super not gonna address today. Um, we were noticing... We were and have been noticing issues with stuff going in the wrong place, right?

4:11:55

So we still have that issue, but at least now we are receiving the output from the underlying process correctly. Um, so that's fine. We can fix that. Like, that's, that's im- what we would like to call a mere matter of programming. We can fix it. We merely need to fix it.

4:12:17

Um, so if you see, like, let's look S-I-O-N... Actually, let's quit this. Let's clear the debug and then let me, uh, let me prove to you. I wish, I just wanna listen to the same thing over and over for the rest of my life. Don't go to a new album. Um, all right. So we've cleared, so the debug is clear.

4:12:41

Let's run Artisan solo. We get S-I-O-N status. Not great. However, if we come into the debug and we look for S-I-O-N status, we do not one time see that it has been spliced. So now, which is good, 'cause we're back in the realm of code that we have written, which is way better.

4:13:07

Um, so now what's happening is, um, so we've got PHP on the top, then we've got Screen in the middle, which we've updated to a version that is not literally 19 years old, and so things are going better there. And then we've got ngrok at the bottom. Ngrok is faithfully, um, emitting output, and Screen finally is faithfully emitting output to PHP.

4:13:34

And then in fact, it goes up one level, and it runs through Aaron's terminal emulator. Sad. This is where the error is, and then it goes up one level further, and it goes out to iTerm2. This is the problem right here. It's me. I'm the problem. The good news is we can fix that.

4:13:58

We can freaking fix that. We can absolutely, all things are fixable, and we can fix that. Um, okay. But I ain't doing that. Um, let's open up GitHub. Debug text. Um, we don't need you. Manage process. What did we change?

4:14:20

Um, this is an unrelated fix, but that's fine. Oh, we don't wanna do that. We don't wanna ship that. All right. Let's come back over here. Debug. Okay. That's a little nicety.

4:14:41

That's fine. We had a lot of fun with logical character boundaries. That's all fine. The renderer, uh, we can discard that change. That was to hide my auth token, which I promptly revealed. Ngrok two has a byte splice, or I'm sorry, a grapheme splice in it, so that is useless.

4:15:12

Byte splice test. Yeah, let's commit that. Ngrok test, spliced emoji. In fact, this test tests nothing. That tests nothing, so we can discard those changes.

4:15:34

Solo, we can keep those changes, but we don't need to commit them. All right. Praise be. All right. Um, did, what did, what did we, did we even do anything here? Um, set the locale for the commands to UTF-8.

4:15:56

And I think, um, doesn't matter, nobody's ever gonna read this. All right. Pull, push. Y'all, this, this was great. This was, this was the good stuff right here.

4:16:19

And while I'm doing that, freaking Cam is out there doing other stuff that's even better? What a dog. Good job, Cam. All right. Screen rendering issues. Let's see what we've actually done here.

4:16:44

Mm-hmm, mm-hmm, mm-hmm, mm-hmm, mm-hmm, mm-hmm, mm-hmm, mm-hmm. Grapheme, what a great word. What a great word. Daniel, you were massively helpful today as well. Thank you all. Thank you all.

4:17:04

Oh yeah, it, Pint did convert it to singles. Thank you all for helping. Oh, we fixed this one. This was a huge one. Absolute move with parameters. Boy, feels like, feels like years ago that we fixed that one. We added that to the test.

4:17:25

We actually still have not implemented any scroll, uh, scroll region stuff. Boy, we got some good stuff going here. All right, y'all. That was wild. Huh? How about that? Jules, Daniel, Len, Ed, Tam.

4:17:53

Amazing. Amazing work. Amazing work. This was it, huh? Steve, you just came at literally the end. It's over, my brother. But boy, we did, we did some good work. We did some good work.

4:18:17

Ah. Yeah, Ian's gonna tell me I need hobbies. What do you call this, Ian? Huh? What do you call this? Steve, listen, brother, there's, uh, four and a half hours of playback you can go watch. I dare you. Let's see. What does it show here? Oh, does it-- Am I not live anymore?

4:18:43

Oh, no, it, it's, I am live. It just doesn't show it on my profile. Oh, all right. Any questions, comments, concerns? We did, we did a lot of work here today. We did a lot of really esoteric, bizarre, super fun work. Somehow it's 5:45, so I gotta go home.

4:19:06

But y'all, this, this was good. This was good. How do I do that? How do I, how do I, uh, how do I add co-conspirators to this? I don't know how to do that. I, I'm telling you guys, I'm a normie through and through.

4:19:28

Reason of project? What? This project is cancer, should die. That doesn't sound very nice. What's your problem, man? The account doesn't exist. Oh, that's good. What about fellow normies?

4:19:50

Normies unite. What about your website? Does your website exist? No, that's good. Okay. I don't know who this guy is. I'm about to find out. Why are you leaving an issue saying this project is cancer, should die? That doesn't seem That's not, that's not very nice.

4:20:25

What? What? Um, uh... This project is cancer, should die.

4:20:52

That's what we call, uh, close as not planned. Close as not planned. Sorry, brother, I'm not, I'm not planning on doing that. Um, how do I block somebody?

4:21:13

Can you block anybody on GitHub? Can you block anybody? I don't, I don't, I don't want to cause him harm, but I don't ever want him to comment on anything I do ever again. Oh, tell me how to block somebody, Steve.

4:21:50

Block. Uh, block user. Block user. There we go. Perfect. Thanks, y'all. Silly, silly person.

4:22:11

What are you doing? Don't be a silly boy. Don't do this kind of thing. And you're, like, an active developer. Like, why would you, why would you do that to another person? That's not very nice. PHPteacher.com. Now you're fine.

4:22:34

PHPteacher.com, where, what is that? It's, like, a active PHP developer in the development space. Like, like, uh, I think that's European for February ninth of this year.

4:22:58

Come on, man, don't be a goofball. All right. Well, you know, we saw it live. That's how you handle a hater. You be a little silly boy, and then you block them, and now I never have to think about them again, so. Problem solved. All right. Weird ending.

4:23:20

Weird ending to a great stream. Um, I think next we need to, um, uh, uh, um, fix a lot of the issues, but still have a few cursor movement problems with ngrok.

4:23:47

We'll need to capture some ngrok output and try to make the emulator render it faithfully. Cool. Oh, that is a good thing to mention on the podcast.

4:24:09

I gotta write that one down. That is a good thing. What possible tests? I feel like I moved those. Eh, who knows?

4:24:32

Who knows, man? If we run the same test twice, will we call that good test coverage? Who can say for sure? Okay. Well, thanks for hanging out. This was awesome right up till the end. Although that was, that was a little bit silly too. Um, thanks for hanging out. Thank you for all of the help.

4:24:56

Many assists. I would not have gotten there by myself. 0% chance. I will see you all next time. Thanks again.

Laravel & PHP

More videos on Laravel & PHP

All videos

Get the next one by email

I’ll send you some more. Not too many.

Join 7,500+ other readers.

Read past issues