WIP: feature: threads'n'forums #74

Draft
Guzio wants to merge 109 commits from Guzio/out-of-your-element:mergable-fr-fr into main

109 commits

Author SHA1 Message Date
1b9f99c4fd fix regression in Ellie Mode; add the announcement to it
Apparently, the context["m.relates_to"] = {"m.in_reply_to": {event_id: event.event_id}} has always been there... The more you know!

I forgot I didn't, apparently, add it myself.

Also, while fixing the regression, I may as well introduce the note to EM, too.
2026-04-22 14:11:06 +00:00
b007822174 Okey, let's be real: Those tests were an embarrassment. 2026-04-22 13:54:49 +00:00
7943f33dbb What were those imports for, anyway? 2026-04-22 13:50:27 +00:00
cd2b5ebb13 Yep! It does exactly what I thought it would. 2026-04-22 12:41:19 +00:00
a54809155f wait, I wanna test 1 more thing on mobile... 2026-04-22 12:31:02 +00:00
a7aad4281d Well, it DOES WORK, alright.....!
thanks, I hate it
2026-04-22 12:27:46 +00:00
cc906d5fb7 Does EM even work? 2026-04-22 12:18:38 +00:00
e92bda4a2a Credit where credit is due(TRUE)² 2026-04-17 22:39:32 +00:00
189ea7e769 text² 2026-04-17 22:30:14 +00:00
b6a68936ec text. 2026-04-17 22:10:50 +00:00
88b25e0482 imports. 2026-04-17 22:07:41 +00:00
5aa13a2a92 Somehow, it almost did!
2 caveats remain (and neither has anything to do with not passing ...channel):
* ugly-error with permissions (fixed)
* no auto-reset (maybe fixed??? - it's either because I DID pass channel (ironic) or because of no await, testing option 1 now)

Also, improved comment consistency
2026-04-17 21:27:14 +00:00
804a6ecb74 This isn't gonna work, is it?
I'm 99% sure I need to do {...channel, flags:(channel.flags^DiscordTypes.ChannelFlags.RequireTag)} but TypeScript won't let me
2026-04-17 20:04:10 +00:00
ab482a82fe actually, GIMME DA OBJECT! 2026-04-17 19:43:31 +00:00
81758529ba Debugging tags-breaking 2026-04-17 18:46:57 +00:00
e95df09c5d heyyyyy~~~~~~~~ 2026-04-17 17:59:02 +00:00
2d82734a06 just appreciated how useful these links are after getting an error and having to go all the way to the Command Handler for links 2026-04-17 17:48:42 +00:00
d52794e22c ACTUALLY handle forums
turns out my handling of it from yesterday was still broken
2026-04-17 17:00:16 +00:00
86c58f169e stupid emigrants...
The code is always greener in the other file, or something
2026-04-17 14:21:33 +00:00
10b6cf5bdb Undone some of the „quality improvements” from yesterday because I noticed they'd break auto-removing for already existing threads. 2026-04-17 13:27:46 +00:00
b1513a6fd1 idea acquired 2026-04-17 11:30:54 +00:00
3a74dfb78f Make sure it's actually possible to create a /thread in a Forum channel without guard()'s interference.
Also, while at it, let the users know that /thread usage is a possibility in Forums.
2026-04-16 21:27:01 +00:00
f17c070175 Account for the hypothetical „/thread ” command 2026-04-16 21:10:54 +00:00
81bf0b935f Extra changes for compat with previous commit 2026-04-16 20:26:20 +00:00
369370d0ad 🎶 the unenlightened masses, they cannot make a judgement call🎵
🎵Give up free will forever - their voices won't be heard at all!🎶
🎶Display obedience...🎵

Where was I, again? Ah, right. I'm supposed to make the judgment call (I am the unenlightened masses) ((Someone tries to link their, fkin, smart-bidet smart-home-controller-room to a Stage or something and imma be cooked))
2026-04-16 00:01:43 +00:00
f6b9614277 Only 2 things are eternal: Doom, and temporary solutions 2026-04-15 23:42:51 +00:00
0c6a5008e3 MOAR channels!!!1!1!!!11!!!!!
also, switched to working on this branch for now; I think that's the easiest option for the time being
2026-04-15 22:52:11 +00:00
f62468511b unfuck my mess
Why did I make it this way???

Guzio/out-of-your-element#13
2026-04-15 20:05:00 +00:00
1cc86b52fd these changes were promised to me 3000 years ago 2026-04-15 19:53:48 +00:00
b7e398a068 Handle errors; general code-quality improvements 2026-04-15 19:07:18 +00:00
bd80d562c7 t e s t i n g c o m p l e t e
I also noticed that my previous wiping code wasn't even doing anything at all. lmfao
2026-04-15 17:08:16 +00:00
9871ed8930 consistency. 2026-04-15 16:35:36 +00:00
5db585a525 I just noticed something silly...
I was stripping the ping before because I thought it just pings the thread-author (which I found kinda pointless). But I didn't actually remove the code that figures out who to ping (because I happened to reuse the „if” around it, and didn't remove the setting itself because I didn't pay enough attention to it and just assumed it has some side-effects). I just tried to remove it finally (because my thought was „Wait, WHY are we setting m.mentions only to remove it?”), only to realize that the code does something entirely different (it pings the one under whose message a thread is about to be created, which makes a lot of sense tbh), and actually shouldn't be removed at all and - on the contrary - I should stop removing m.mentions (and also fix Ellie-Mode so that it won't prevent m.mentions from being set even if it's enabled).
2026-04-15 16:24:32 +00:00
ff8e571950 Changes to thread announcements, especially:
* use "" instead of „” to comply with English Language Standards Recommendations On Quotation Marks [TM], as per Cadence's request
* reflect current bot behavior (ie. it no longer bridges-as-replies, but mercilessly rips the message away from your caring arms)
* add Ellie-Mode
2026-04-15 15:24:01 +00:00
7eeff2faf3 ...So I might as well take care of this mess with commands.
Notably:
* Don't do the unmarshalling and switch-cases, as Cadence asked
* Revert command handler returns to how they were before, now that we're not using the returned-command-name anymore.
2026-04-14 22:49:59 +00:00
b869b432b6 This looks better (I still don't remember what was I doing) 2026-04-14 20:52:29 +00:00
44fb3f9f64 Credit where credit is due 2026-04-03 13:08:13 +00:00
e47b5e3d2b I am SUCH a MASSIVE FUCKING MORON jesusfuckingCHRIST 2026-04-02 20:12:29 +00:00
50d09fd48f Async JS does *NOT* spark joy 2026-04-02 20:09:13 +00:00
85314818d2 WHAT? HOW? 2026-04-02 20:03:07 +00:00
b3badac452 i WILL cry 2026-04-02 19:55:10 +00:00
3df15c5efa WHY are you still defined? 2026-04-02 18:56:46 +00:00
c53b54bafc Fix Element being stupid 2026-04-02 18:24:30 +00:00
1ea9712086 Message redirection on Matrix side, too? 2026-04-02 17:42:36 +00:00
b924de2357 namegen; prevent commands from running in redirected messages 2026-04-02 16:26:20 +00:00
98240400a6 ThreadRoom auto-create
Both sides of creation (M2D and D2M) use ensureRoom() instead of syncRoom() because it's impossible to know which one will fire first, and we wouldn't want a double-sync. At the same time, calling ensureRoom() as a way to CREATE a thread-room is perfectly safe because „Naturally, the newly created room is already up to date, so we can always skip syncing here.” and also thread-rooms aren't subject to manual-mode restrictions, so we can skip all „Does a channel_room entry exists or guild autocreate = 1?” checks (actually, the comment probably should reflect that - so I updated the comments, too.

Also, bridgeThread() is a separate function to make guard clauses possible instead of nesting 3 more layers of IFs like we were fkin YandereDev.
2026-04-02 15:13:40 +00:00
e23d365913 this will likely be removed, but I might still fix it 2026-04-02 12:42:20 +00:00
6c2aeea8a6 This should, IN THEORY, *just work* for existing threads. 2026-04-01 21:20:54 +00:00
f3330826d9 Resolved merge conflicts 2026-04-01 20:47:56 +00:00
afa8ba2237 Emergency sync
I was not supposed to do more pulling, but I started seeing some instability and I want to see if it's me or main.
2026-03-14 07:10:09 +00:00
86cfbd21a9 I broke Git
of course I did
2026-03-02 15:27:54 +00:00
438ed2b4eb revert e807d1fbf2 2026-03-02 15:24:11 +00:00
56f7c4c09a Merge pull request 'sync-back' (#9) from main into fuckery
Reviewed-on: Guzio/out-of-your-element#9
2026-03-02 15:21:12 +00:00
e807d1fbf2 Merge branch 'fuckery' into main 2026-03-02 15:20:07 +00:00
748e851b39 Improve threads UX
/This is a squash-commit - the following is a rough summary of all sub-commits, written in style of commit messages (not necessarily those commits themselves), ie. short and in present tense./

* Document design choice to not bridge Discord threads as Matrix threads [by directly quoting Cadence]
* Alter thread-to-announcement, so that it replies in-thread [with this, Matrix users will get a list of almost all (exl. those that don't branch from anything) open threads on a given channel, whereas before it wasn't possible. Also features slight alterations to the text]
* Notify the user, whenever an in-thread message on Matrix is sent, that this isn't how they're supposed to do threads on OOYE
* Detect /thread being ran as a reply or in-thread to branch the thread from the relevant message
* Handle various /thread errors [notably being ran without args (infer the title if ran in the context above, simply show help if not)]
*  Whenever possible, direct the user to an already-existing thread-room [if /thread was ran as a reply or in-thread, or as part of the notification mentioned in point 3 (feat. a new utility method)]

AUXILIARY TYPE CHANGES (not always relevant to UX-improvement-related changes):
* Fix „boolean” being referred to as „bool” in types.d.ts
* Rename execute(event) in matrix-command-handler is now parseAndExecute(event) [and it is no longer of type CommandExecute, but has its own custom definition, because a) it has a different return now (returns what command was ran (needed for point 3 in section above) instead of always undefined and b) other params from CommandExecute (like ctx or words) weren't being used - quite the contrary, their values were only being created at that stage (as part of command parsing - hence the rename, too), so telling that they're values you pass into execute() was at least somewhat confusing]
* Further narrow-down the type of guard() in m2d event-dispatcher

TEST CHANGES:
* Create 7 new tests, all pass
* Update 4 existing threads, all pass
* Pass all other relevant tests [and almost all other tests, too - there are some issues with event2message for stickers, but given the fact that this commit does not touch the stickers subsystem in any way at all,  it does not seem like they are any way related to my changes and they must've been failing before]
* Do extensive manual testing and debugging
Co-authored-by: Guzio <guzekk@protonmail.com>
Co-committed-by: Guzio <guzekk@protonmail.com>
2026-03-02 15:17:08 +00:00
b38abe81a6 reworded the error
Turns out that auto-create is ALWAYS on for threads (which creates some hilarious situations, where the channel gets duplicated if it ever got unbridged). Also, manual bridging isn't even possible. Uhh... Sure! Let's just say, then, that it's the admin's problem to auto-create it (given the duplication - this is probably a better idea to leave it to them).

A proper fix for this (and also to limit (tho not fix) the dupe-by-autocreate problem) would probably be to allow for manual bridging on threads, but I really don't have time for this before The Merge (my ADHD is kicking-in on this update, and I have a feeling that if I don't PR soon, I'm gonna not do it for another 3 months).
2026-03-02 13:44:36 +00:00
b84b848d04 temporary change to VSC settings
So that I can squash-merge it all without leaving the trace of any extra unsolicited changes
2026-03-02 13:15:29 +00:00
20ce420303 copy-pasted Cadence's message as documentation 2026-03-02 13:12:17 +00:00
a877122ef6 fix one more final UX pet-peeve 2026-03-02 13:06:30 +00:00
de6ce38c2d Merge pull request 'bbbbbbb' (#8) from main into fuckery
Reviewed-on: Guzio/out-of-your-element#8
2026-03-02 13:00:11 +00:00
b90592cbe9 Prevent merge conflicts once again 2026-03-02 12:59:20 +00:00
8260396254 replace newlines instead of stripping them (what DC does by default) 2026-02-28 14:14:27 +00:00
c691274dd9 git pisses me off
just a little bit

I like it.

But it's just a little bit annoying.
2026-02-28 13:49:59 +00:00
5a0e7f6a66 Prevent more merge conflicts 2026-02-28 13:47:49 +00:00
69b128a598 debug done; turns out that I'm just stupid
I passed a completely wrong event ID and was confused as to why could it possibly be failing. (Btw, as part od fixing that - my new function from function is utils.js now supports blank values.)

Also - and that's unrelated to the bug I was debugging - I put a guard clause in my if (words.length < 2) backwards. If->return should canonically be above the logic, even if it technically doesn't break said logic in this case (all it was doing was creating an extra step that says „yea, name the newly-created thread /thread, even if this name is very stupid, and also pointless because no thread creation is about to take place”. And while fixing that, I also did some minor changes to error handling.
2026-02-28 13:37:16 +00:00
7895f89cc0 debug slop v2 2026-02-28 11:52:18 +00:00
10fbb9e696 improved consistency 2026-02-27 23:11:50 +00:00
edfbdc567f Used getThreadRoomFromThreadEvent in practice 2026-02-27 23:07:43 +00:00
c9509bb938 figured out how tests work, yaaayyyy
As a part of that:
* rewrote the tests to support my changed behaviors
* added a missing case
* Made my „threads get attached to” wording more consistent with the test cases („threads branch from”), as I always felt that there was something off about my phrasing, but I couldn't quite tell what was it. OOYE's „branch” term seems much more fitting there
* slightly cooked the testing data (changed the „Hey.” thread from „floating” to being a branch of a message, to accommodate...)
* 3 NEW TESTS: of the function created in my previous commit (I'm not sure if this *REALLY* needed testing, given how braindead-simple that function is, but everything else in utils.js is covered, so I figured it's only fair to test this, too)

EXTRA CHANGE: fixed that function's name (we're getting the thread from a (Matrix) Event, not a (Discord) Message) and description (I totally didn't copy-paste the JSDoc from above........)
2026-02-27 20:42:16 +00:00
42c32ba749 explained my technical decisions; made a function that'll help me later 2026-02-27 13:06:52 +00:00
ffed434c6a rewrote the f#cker as a switch statement 2026-02-26 16:05:53 +00:00
0557c7b143 works yay 2026-02-26 16:00:22 +00:00
3e42616065 It just occurred to me that I have no way of testing the „fallback case” now 2026-02-26 15:55:18 +00:00
22ff10222c fixed error details showing up as [object Object] 2026-02-26 15:38:20 +00:00
3f7a7aa10f handled overyapping 2026-02-26 15:37:17 +00:00
266f46563b Possibly? fixed error handling???
and yea, ofc it was a string......
2026-02-26 12:49:21 +00:00
06962c217e unspecified horsing around 2026-02-26 12:23:09 +00:00
9424b5e517 Apparenly, what I completley missed, is that „code” is overriden by something later in the error stack. Trying out other keys...... 2026-02-25 11:04:55 +00:00
9bf6e50ae9 SO WHAT DO YOU WANT? TELL ME WHAT'S YOUR POINT, JS!
So the code-key DOES exist. HuuuHhhhhh???
2026-02-25 10:56:51 +00:00
fa916699a7 Nope, it's an object. But, like... A weird one. It doesn't seem to behave like objects normally do. It it a wrapper around stuff? 2026-02-25 10:48:12 +00:00
bea0b9370d Type of e is its own content. Apparently. What the fuck? 2026-02-25 10:39:56 +00:00
c283528d72 Is this LITERALLY just a String????? 2026-02-25 10:32:37 +00:00
0ad4b41ae9 Iiiiiii........... I have no idea what was I trying to accomplish here... 2026-02-25 10:28:09 +00:00
4a26001382 Debug-slop begins! 2026-02-25 10:23:13 +00:00
f0515ceecf UX testing revealed that og messages looked awkward 2026-02-25 10:11:18 +00:00
69d07c1a7b I lied, that's the final patch (my C# past got the better of me lol) 2026-02-25 09:48:22 +00:00
3aa5f1b7ce Synced my branches, again 2026-02-25 09:33:45 +00:00
e146faced1 Prevent merge conflicts 2026-02-25 09:31:41 +00:00
23cdf54982 AEUGH it turns out that replying was already handled.
In other news: Made /thread work without args (in SOME cases).

I'm pretty sure this is the final patch before we go PR.
2026-02-25 09:25:02 +00:00
b53b2f56b6 Improved error handling 2026-02-24 19:26:34 +00:00
d7aadc3079 AAAAAAAAAAAAAAAAAAAA 2026-02-20 04:02:01 +00:00
f9e303f018 stray whitespace 2026-02-20 03:52:03 +00:00
e44f1041b6 Turns out that creating a thread-in-thread (which is what the stuff I was doing in matrix-command-handler effectively amounted to) KINDA breaks Element. Whoops!
Also, that message in thread-to-announcement was misleading, as now there's no guarantee that a thread was newly created (it could be very old, but freshly /thread-ed). So I changed that, too.

Also, while updating messages, I decided to slightly alter the „may not have been bridged to Discord in the way you thought it was gonna be”-warning in event-dispatcher.
2026-02-20 03:50:06 +00:00
f734b0619f Don't warn the user that they should use /thread if they literally just did it. 2026-02-20 03:10:09 +00:00
b542a81ee1 first time actually interacting with the DB 2026-02-20 02:21:52 +00:00
ac421e6c74 this looks better 2026-02-20 00:00:42 +00:00
7afcbfaa06 I have no idea if this works; just throwing random ideas together.
It's 23:42; I'm going just purely based on vibes at this point.

vibecoding but no AI, just eepy
2026-02-19 22:44:20 +00:00
abe42aaa92 Updated the message to its final form.
At least final-until-we-make-it-so-that-new-rooms-are-autogenerated-when-a-thread-is-opened. Then we'd need to include the link to it instead of a command-help.
2026-02-19 21:26:15 +00:00
aaf8dea104 Reply-related metadata 2026-02-19 19:27:13 +00:00
486959be0b forgor 2026-02-19 19:05:25 +00:00
01b82e7b68 I think I got SOMETHING up and running! 2026-02-19 18:48:24 +00:00
dca53752bb Reverse-engineering the docs 2026-02-19 18:34:30 +00:00
8676a73620 Testing BEGINS! 2026-02-19 17:53:56 +00:00
10099142c2 Merge branch 'main' into fuckery 2026-02-19 17:53:10 +00:00
aedd30ab4a Update "m.relates_to" type definition @ types.d.ts
* To better reflect reality ("m.in_reply_to" will not always be present - it's not (always?) found on "rel_type":"m.replace" relation-events)

* To support "rel_type":"m.replace" relation-events (added "m.replace" option to existing key "rel_type" and a new "is_falling_back" key)

AFFECTED TYPES: M_Room_Message, M_Room_Message_File, M_Room_Message_Encrypted_File

BREAKS: Nothing, as .d.ts files don't affect buisness logic. In terms of lint errors: Marking "m.in_reply_to" as optional is indeed technically a "breaking change" (TypeScript may complain about „is probably undefined” in places where it didn't before), but from early "testing" (ie. looking at VSCode's errors tab), it doesn't seem like anything broke, as no file that imports any of those 3 types (Or their Outer_ counterparts) has „lit up” with errors (unless I missed something). There was one type error found in m2d/converters/event-to-message.js, at line 1009, but that seemed unrelated to types.d.ts - nevertheless, that error was also corrected in this commit, by adding proper type annotations somewhere else in the affected file.
2026-02-19 17:48:32 +00:00
a66b93ed26 Merged my branches 2026-02-19 16:25:03 +00:00
5a853249a2 I prefer 4 spaces 2026-02-19 16:21:27 +00:00
2c7831c587 Small TypeScript coverage expansion
* The guard() function in m2d/event-dispatcher.js no longer takes (any, any), but a string and a function.

* m2d/send-event.js no longer complains that res.body has some missing fields. It would appear as though those missing fields weren't revelant to the fromWeb() function (into which res.body is passed), given that this code worked before and still contunes to work, so I just @ts-ignore'd res.body

This commit's developer's off-topic personal comment, related to this commit: This has nothing to do with improving thread UX, even tho this is what I was supposed to work on. However, in my attempts to discover in what file should I start, I stumbled upon those errors from m2d/send-event.js, so I fixed them. And after establishing that m2d/event-dispatcher.js is the file that I'm looking for, I also noticed that guard()'s @parm definitions could be improved, so I did that. Now - back to thread work...
2026-02-19 16:19:39 +00:00
ae6b730c26 Update .gitignore 2026-02-19 13:03:16 +00:00