Skip to content

25755 Show logs around specific line#53

Open
Jonstal wants to merge 2 commits into
mainfrom
feature/25755-show-logs-around-specific-line
Open

25755 Show logs around specific line#53
Jonstal wants to merge 2 commits into
mainfrom
feature/25755-show-logs-around-specific-line

Conversation

@Jonstal

@Jonstal Jonstal commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

TICKET-25755

Add byte offset navigation to explore logs around search results

  • Click expand button on search results to view surrounding context
image image
  • Manual byte offset input to jump to specific file positions
image
  • Feature hidden when ripgrep unavailable (grep doesn't support byte offsets)
  • Three modes: live, search, explore

@Jonstal Jonstal self-assigned this Jun 2, 2026
@Jonstal Jonstal changed the base branch from main to feature/25754-persist-filter-options-url June 2, 2026 16:02
@Jonstal Jonstal marked this pull request as ready for review June 2, 2026 16:16
@Jonstal Jonstal requested review from coorasse and edmunteanu June 2, 2026 16:16

@coorasse coorasse left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some points in this PR that are important, please have a look, maybe we can check them together as well. I want especially to ensure performance.

Comment thread app/channels/onlylogs/logs_channel.rb Outdated
Comment thread app/channels/onlylogs/logs_channel.rb Outdated
%(<pre data-byte-offset="#{byte_offset}">#{parsed}</pre>)
else
%(<pre>#{parsed}</pre>)
end

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a bit worried about performance here. This seems like a lot of work server-side, but maybe we have to. I don't know if it would be possible to delegate this client side.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to move it to client side now, is this what you meant?

Comment thread app/controllers/onlylogs/logs_controller.rb Outdated
@cursor_position = [byte_offset - 10000, 0].max
@end_position = byte_offset + 10000
@filter = nil
@mode = "explore"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah! We have a new mode...that's why it got mixed in the channel with the "live" mode. Can we handle it via "search" mode in the logs_channel instead? Feels more appropriate, no?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have now introduced a new search type instead so that we stay on search mode but we have either filer or byte_offset. Let me know what you think 😄

this.#updateWebsocketStatus('disconnected');

// Set up event delegation for expand button clicks
this.logLinesTarget.addEventListener('click', e => this.#handleExpandClick(e));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be done via stimulus as data-action attribute

Comment thread app/models/onlylogs/grep.rb Outdated
byte_offset = nil
content = line

if line.match?(/^\d+:/)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but this should always be true if we are using ripgrep, right? So instead of checking the line format on each line, we can know this already and avoid a if for each line

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea, i check ripgrep_enabled? now

@Jonstal Jonstal requested a review from coorasse June 4, 2026 13:56
@Jonstal Jonstal changed the base branch from feature/25754-persist-filter-options-url to main June 4, 2026 14:14
@Jonstal Jonstal changed the base branch from main to feature/25754-persist-filter-options-url June 4, 2026 14:14
@Jonstal Jonstal changed the base branch from feature/25754-persist-filter-options-url to main June 4, 2026 14:16
@Jonstal Jonstal force-pushed the feature/25755-show-logs-around-specific-line branch from 69249e5 to 353ecc4 Compare June 4, 2026 14:31
Introduce byte-offset navigation: track byte offsets while reading logs,
include them in ripgrep output and parse them in grep, and add an explore
mode that displays logs around a specific offset with an input field and
expand button on search results. Always allow switching to live mode
visually, build the pre element client-side, and adjust tests to the new
ripgrep output format.
@coorasse coorasse force-pushed the feature/25755-show-logs-around-specific-line branch from 305d4ce to 83e2aed Compare June 12, 2026 13:11
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