Skip to content

Link Mudlet folder: read and write back encoding, TLS, login, password and command history - #465

Merged
Delwing merged 4 commits into
masterfrom
claude/fix-issue-450
Oct 9, 2026
Merged

Delwing merged 4 commits into
masterfrom
claude/fix-issue-450

Conversation

@Delwing

@Delwing Delwing commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #450.

This builds on #461 (#455, now merged), reusing its Qt QString decoder.

Changes

  • Read when linking: "Link Mudlet folder…" now reads desktop's ssl_tsl, login and password files. The password goes into the encrypted vault once, at link time, and the folder's copy is never rewritten. ConnectionScreen shows any warnings, as an import does.
  • Read on every open: each time a linked profile opens, including a cold start once the folder has permission, it re-reads encoding, ssl_tsl and login from the folder, so changes made on desktop show up.
    • Desktop's encoding file wins over the web's saved value.
    • If that encoding can't be decoded, the profile reads as UTF-8 and nothing is written back.
  • Write-back: changes made in the web to the server encoding, TLS or character name are written back in desktop's format from ScriptingEngine.flushProfileData, and only for mudletLinked profiles.
    • Only files whose value changed are written, compared by canonical encoding name.
    • No file is created just to record a default.
    • A change to tls or charLoginAccount on the connection record now also triggers a save.
  • Command history: command_history_main is merged into the web's history, desktop's commands first, deduplicated and capped. This only happens when the file's modification time has changed, tracked in mudlet_history_<id>_desktop_mtime. It is never written back, so it can't race a running desktop Mudlet, which rewrites the file on exit.
  • One shared reader: the import and link paths now share readDesktopProfileFiles for these files.
  • Tests: tests/import/linkedDesktopFiles450.test.ts and tests/scripting/linkedDesktopFilesWriteback450.test.ts, using real desktop byte dumps.

Review fixes (15780ad)

  • Desktop's encoding overwritten: if desktop's encoding file named an encoding the web can't decode, the sidecar value was kept, and the next save overwrote desktop's choice with it. Fixed, with a regression test.
  • Stale comment: the comment next to LINKED_WRITEBACK_ENABLED still said "DISABLED". Replaced.

Known minor quirk

If a linked folder has no ssl_tsl file but its save has mSslTsl="yes", the first save writes ssl_tsl = 2. That matches the save, and it's rare, because desktop writes the file whenever the checkbox changes.

Testing

  • yarn typecheck passes.
  • yarn check:vendored passes.
  • yarn test, after merging master: 5,411 pass. The only failure is the GBK euro-sign test, which also fails locally on master and passes in CI.
  • The folder-link UI itself hasn't been tried in a real browser.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Um3ZSHRbGj1Rbf55rAQzdM

claude added 3 commits October 8, 2026 14:11
)

Desktop's MudletApp::writeProfileData/readProfileData keep `encoding`,
`ssl_tsl`, `login` and `password` as a QDataStream (Qt_5_12) QString: a
big-endian uint32 byte length (0xFFFFFFFF for null), then UTF-16BE. The
#436 readers took those bytes as UTF-8 text, so an imported desktop profile
lost its server encoding and TLS, and sent "\0\0\0\b\0H\0e\0r\0o" as the
character name with no password.

- New qtProfileData.ts decodes/encodes that format; anything that is not a
  whole QString is still read as plain text, for hand-written files.
- Import decodes the four files with it. An ssl_tsl that holds no check
  state now falls back to the save's mSslTsl instead of reading as off.
- Export writes them in the same format, so desktop can read an exported
  profile's TLS, login and encoding back.
- The #436 tests now use the bytes desktop really writes.

Fixes #455

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BiCGwimBDRdEXJa3hd9i7F
#450)

"Link Mudlet folder…" read none of the files desktop keeps a profile's
connection details in, so a linked profile read a non-UTF-8 game as UTF-8,
connected in plaintext, and lost its auto-login and command history.

- readDesktopProfileFiles (mudletProfileImport.ts) is now the one reader of
  `encoding`, `ssl_tsl`, `login`, `password` and `command_history_main`,
  shared by the import and the link.
- Linking reads TLS and the character name into the connection record and
  hands the password to the credential vault, as an import does; the
  folder's own password file is left alone.
- Every open of a linked profile (loadMudletLinkedProfile — cold start
  included, once the folder handle has permission) re-reads the encoding,
  TLS and character name, so a desktop change arrives. Desktop's history is
  merged in, desktop's commands first, whenever the file changed since it
  was last read.
- Linked write-back is already two-way for the save, so this client's
  encoding, TLS and character-name changes are written back to those files
  in desktop's QString format, only when they differ. Never the password;
  the history stays read-only, since a running desktop rewrites it on exit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BiCGwimBDRdEXJa3hd9i7F
When desktop's `encoding` file named an encoding Mudlet Web cannot decode,
loadMudletLinkedProfile kept the sidecar's older serverEncoding, and the next
save wrote that back over desktop's choice. The file now wins whenever it
exists; the profile reads as UTF-8 and nothing is written back. Also replace
the stale "write-back is DISABLED" comment in flushProfileData.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Um3ZSHRbGj1Rbf55rAQzdM
@Delwing
Delwing changed the base branch from claude/fix-issue-455 to master October 8, 2026 22:47
# Conflicts:
#	src/import/mudletProfileImport.ts
@Delwing
Delwing merged commit 8a9556d into master Oct 9, 2026
10 checks passed
@Delwing
Delwing deleted the claude/fix-issue-450 branch October 9, 2026 00:42
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.

"Link Mudlet folder…" doesn't read the profile's encoding, ssl_tsl, login or command history

2 participants