Skip to content

Fix: Hidden links survive a window clear from any buffer - #1

Merged
jaypatrickhoward merged 2 commits into
jaypatrickhoward:fix/clearwindow-drops-tracked-osc8-linksfrom
Mudlet:fix/osc8-detached-view-adjustment
Sep 2, 2026
Merged

jaypatrickhoward merged 2 commits into
jaypatrickhoward:fix/clearwindow-drops-tracked-osc8-linksfrom
Mudlet:fix/osc8-detached-view-adjustment

Conversation

@vadi2

@vadi2 vadi2 commented Sep 1, 2026

Copy link
Copy Markdown

Brief overview of PR changes/additions

  • Route the tracked-link maintenance through the console model rather than the view. The main console's model outlives the TConsole built on it and keeps taking lines meanwhile, so stopping at mpConsole gave up adjusting line numbers while the buffer was still being trimmed - concealed links then pointed at the wrong lines and overwrote text on reveal, the very symptom clearWindow() leaves OSC 8 links pointing at lines that no longer exist Mudlet/Mudlet#10122 reports.
  • Check that the buffer actually is the one the manager tracks, on both paths. TBuffer(host, console) is a legal way to build a scratch buffer, and its constructor calls clear() - which reached through the back-pointer and dropped every tracked link on the live console. Every model also builds its buffer before a view attaches, so the model path needs the same identity check.
  • Drop a comment on test_aWholelineConcealmentMovesTheLinksBelowItOnlyOnce claiming a click is the only thing that conceals without a delay. concealLink() conceals unconditionally and the same test calls it four lines below.
  • Tests: a link on the first removed line (the >= lower bound had nothing covering it), the queued screen-reader announcement being cancelled by a clear, a delete with no view attached, another buffer's construction and deletion leaving the tracked links alone, and a miniconsole maintaining its own links off its own buffer. friend class TrackedLinkTrimTest reads the line numbers and the pending announcement count, which are otherwise only observable through a screen reader.

Motivation for adding to Mudlet

The fix in this PR is right, but it addresses the manager through the view. Two states break that: a model with no view yet or no longer, and a second buffer that happens to hold a console pointer. Each was reproduced with a failing test before the change.

Other info (issues closed, discussion etc)

  • TBuffer::shrinkBuffer() carries the identical if (mpConsole) gate, but it predates this PR (it came in with fix: hidden links still reveal once older text has scrolled away Mudlet/Mudlet#10119), so it is deliberately left alone here rather than growing the scope. Filed as A buffer trim corrupts tracked OSC 8 links when no view is attached Mudlet/Mudlet#10315 with a reproduction: a concealed link's commands get swept and its line number never moves.
  • test_aWholelineConcealmentMovesTheLinksBelowItOnlyOnce passes against pre-PR code, so it is a double-adjustment guard rather than proof of this PR's fix - worth knowing given the commit message describes the manual loop's removal as covered by it.
  • Two mutation survivors were judged not worth a test: stopping mpAnnouncementTimer in clear() and calling stopTimerIfNotNeeded() in adjustLineNumbers() are both timer hygiene with no observable behaviour to assert on.

Test case: cmake --build --preset linux-debug-nosan && QT_QPA_PLATFORM=offscreen ctest --preset linux-debug-nosan -R TrackedLinkTrimTest. Manually: open a game with OSC 8 links, conceal one, then have the game clear the window or push enough lines to trim the buffer - the concealed link must not reappear over unrelated text.

Assisted-by: Claude:claude-opus-5

The main console's model outlives the view built on it and keeps taking
lines meanwhile, so gating the tracked-link adjustment on mpConsole stops
maintaining it while the buffer is still being written to. Reach the
manager through the model instead, and cover the announcement reset and
the detached path that had no test.

Assisted-by: Claude:claude-opus-5
A scratch buffer built with a console back-pointer clears itself in its
constructor, which reached through to the live console's manager and
dropped every tracked link on it.

Assisted-by: Claude:claude-opus-5
@jaypatrickhoward
jaypatrickhoward merged commit 6dad86a into jaypatrickhoward:fix/clearwindow-drops-tracked-osc8-links Sep 2, 2026
3 checks passed
@jaypatrickhoward

Copy link
Copy Markdown
Owner

Merged, thanks - this is on Mudlet#10179 now, along with development merged in.

Both fixes check out. I reverted each in turn and confirmed the tests bite: test_deletingALineMovesTrackedLinksWithNoViewAttached fails without the model path, and test_anotherBuffersLifecycleLeavesTheTrackedLinksAlone fails without the identity checks. The three additions that pass against unfixed code have teeth too - the miniconsole case fails if the mpConsole branch is dropped, test_clearingTheWindowDropsAQueuedHiddenAnnouncement fails if the announcement reset is reverted, and the first-removed-line assertion fails if adjustLineNumbers()'s lower bound is loosened to >. That last pair covers gaps we left untested, which is the more useful half. 164/164 on the merged result.

You were also right about the comment on test_aWholelineConcealmentMovesTheLinksBelowItOnlyOnce - the test calls concealLink() five lines above the click, and concealLink() only bails on untracked-or-already-concealed, so what we wrote there was wrong.

One leftover: registerHyperlink() at TBuffer.cpp:3563 is the last mpConsole gate on the manager in that file. Different consequence - the link is never registered rather than corrupted - so it may be fine as is. Noted on Mudlet#10315 rather than here, since that is where shrinkBuffer() is being tracked.

Assisted-by: Claude:claude-opus-5

jaypatrickhoward pushed a commit that referenced this pull request Sep 17, 2026
…t#10807)

#### Brief overview of PR changes/additions

- The bad-argument errors from `feedTelnet()` and `feedTriggers()` are
one line again. Each was built from two adjacent string literals where
the first ended in `\n`, so the message arrived split in two.

#### Motivation for adding to Mudlet

`TLuaInterpreter::logError()` wraps an error as ` <message>`, so the
embedded newline ended the line early: the tail landed at column 0 with
no closing `>`, and anything reading the log a line at a time saw only
the first half.

#### Other info (issues closed, discussion etc)

Fixes Mudlet#10776.

Honest about the scope: this is presentation only. The message exists in
exactly those two places, nothing in `src/mudlet-lua/` or `test/`
matches on it, and the existing `assertArgError` calls match `"bad
argument #1 type"` — text before the break — so no spec was quietly
failing and no consumer changes behaviour.

One spec per feeder rather than one covering both, so a regression in
each is reported separately; sharing one `it` meant the first failure
aborted before the second was checked. Confirmed to bite by mutating the
expected string to the pre-fix split form, which turns the suite red at
exactly that assertion.

The same split-literal pattern survives in nine other places —
`deleteArea`, `getRoomAreaName`, `setAreaName`, `setRoomArea` (both
arguments), `raiseEvent`, `raiseGlobalEvent` and `getMudletVersion`
(twice). All nine were demonstrated from ordinary Lua and filed as
Mudlet#10806 rather than swept in here. Two of them are a wording decision
rather than a one-character change, since their break falls at the end
of a sentence before an indented list; the issue says so.

**Test case:**
1. In any profile run `feedTriggers()` with no argument.
2. The error appears on a single line, inside its `< >`. Before this
change it broke after `as string` and the rest appeared unindented on
the next line with no closing bracket.

---

⚠️ **DCO sign-off still owed.** `docs/CONTRIBUTING.md` requires a human
to build and manually test AI-assisted work before signing off, and asks
that Mudlet developers not be the first to test AI-generated code. This
branch was produced in an unattended session, so no `Signed-off-by`
trailer has been added — please build and test it, then add yours before
merging.

Assisted-by: Claude:claude-opus-5

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_016ndCZh8idD5CroHvBzqA8R

---
_Generated by [Claude
Code](https://claude.ai/code/session_016ndCZh8idD5CroHvBzqA8R)_

Co-authored-by: Claude <noreply@anthropic.com>
@vadi2
vadi2 deleted the fix/osc8-detached-view-adjustment branch October 29, 2026 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants