Skip to content

Use the file and line from an editor plugin as lastFile - #491

Open
hollesse wants to merge 3 commits into
mainfrom
claude/jolly-cannon-stbfv3
Open

hollesse wants to merge 3 commits into
mainfrom
claude/jolly-cannon-stbfv3

Conversation

@hollesse

Copy link
Copy Markdown
Member

What

mob next can now remember the file and line you were last looking at in your editor, not only the file you modified last. Editor plugins provide this information through a small, documented state file, e.g. the new IntelliJ mob last file plugin.

  • Editor state file: mob next reads <git dir>/mob/last-file.json. It uses the file only if all of these hold:

    • the format version is known
    • updatedAt is newer than the last commit
    • the referenced file exists inside the repository

    Otherwise it falls back to the last modified file as before. There is no configuration; mob --debug shows which source was used and why.

  • Commit message: lastFile: is unchanged. A new lastLine: line is added below it, only when a line is known:

    mob next [ci-skip] [ci skip] [skip ci]
    
    lastFile:src/main/java/Foo.java
    lastLine:42
    
  • Open command: MOB_OPEN_COMMAND supports the named placeholders %{file} and %{line}, e.g. code -g %{file}:%{line} or idea --line %{line} %{file}. %{line} is 1 when the commit has no line. %s and commands without placeholders work as before.

  • Code structure: The logic lives in lastfile.go behind a small source abstraction (editor state file → last modified file), so more sources can be added later.

  • Docs and version: The README documents the open command placeholders and the state file format for other editor plugins. CHANGELOG is updated, and the version is bumped to 5.5.0.

Backwards compatibility / mixed teams

Situation Result
No editor plugin unchanged behavior
mob < 5.5.0 reads a new commit opens lastFile as before, ignores lastLine
mob 5.5.0 reads an old commit opens file, %{line} = 1
IntelliJ typist → VS Code typist (and vice versa) works, line via %{line}
State file stale (crash, clock skew) falls back to last modified file

Tests

  • 16 new tests:
    • state file valid, stale, invalid, pointing to missing or outside files
    • paths with spaces
    • commit message with and without lastLine
    • all placeholder combinations
    • parsing the exact JSON the IntelliJ plugin writes
  • The full existing suite passes.
  • Manual end-to-end check with real binaries: a commit written by this version is opened correctly by unmodified mob 5.4.4 and, with %{file}-L%{line}, at the right line by this version.

Generated by Claude Code

- mob next reads <git dir>/mob/last-file.json written by editor plugins
  (e.g. the IntelliJ mob last file plugin) and uses its file and line if
  it is valid, newer than the last commit and the file exists; otherwise
  it falls back to the last modified file
- The line is stored as lastLine: below lastFile: in the wip commit
  message, which older mob versions ignore
- MOB_OPEN_COMMAND supports the named placeholders %{file} and %{line};
  %s and commands without placeholders keep working
- Document the editor state file format for other editor plugins
- Bump version to 5.5.0

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XSv7vC67mr1W5WkDX3L96F
The editor state file may contain the optional, informational fields
plugin and pluginVersion; mob --debug shows them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XSv7vC67mr1W5WkDX3L96F
- lastfile.go: lastFile, the lastFileSource interface, source order,
  commit message writing and parsing
- lastfile_editorstate.go: editor state file source
- lastfile_modified.go: last modified file source, including the
  helpers moved from mob.go
- Tests split accordingly; no behavior change

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

This branch has not been deployed

No deployments
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