Skip to content

Cache last opened file in log-viewer for persistence #221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
coderabbitai bot opened this issue Mar 31, 2025 · 5 comments
Open

Cache last opened file in log-viewer for persistence #221

coderabbitai bot opened this issue Mar 31, 2025 · 5 comments

Comments

@coderabbitai
Copy link

coderabbitai bot commented Mar 31, 2025

Background

Currently, the log-viewer doesn't cache the last opened file, so whenever a user refreshes the browser page, the last opened file is lost. This makes sharing links to local files impractical (e.g., http://localhost:3010/#logEventNum=12) as they are not accessible across sessions.

Feature Request

Implement functionality to cache and restore the last opened file when the log-viewer is refreshed or reopened.

Proposed Implementation

Utilize modern web standards to store file references persistently:

These APIs would allow storing the file reference and related viewing state (such as scroll position, filters, etc.) across browser sessions.

Related Discussion

This request originated from a discussion in #220.

cc @junhaoliao

@zzxthehappiest
Copy link
Contributor

Hi @junhaoliao , I find that this function in http.ts will be called when filePath parameter is provided in the URL. But it will raise error when pass the URL like file:///tmp/test.clp.zst, with error message: Not allowed to load local resource: file:///tmp/test.clp.zst.

So I think we can just modify this function to check if it starts with http (or https) or file, then we can handle it separately. I probably missed some code context, I am not sure if this quick solution works or can it induce any extra issues.

@jackluo923
Copy link
Member

We probably should only cache local file and leave remote file as-is or cache it with some expiration time, i.e. couple minutes. What do you think @junhaoliao

@junhaoliao
Copy link
Member

cc @zzxthehappiest @jackluo923

I believe the approach proposed by @zzxthehappiest could work; however, the HTTP utilities are used to handle HTTP requests only, so I'd probably avoid making the modification at the getUint8ArrayFrom level.


If I'm not mistaken, the concern raised by @jackluo923 relates to data retention and security compliance.

  1. For content caching, I believe we should limit caching to local files only.
  2. When loading from a remote source (filePath), we should cache only the last opened filePath URL, not the actual file content. This ensures that if the file is later removed from the remote location, it can no longer be accessed or retrieved on the user's device.
  3. While general users might find this caching feature helpful, in certain environments (e.g., corporate deployments), the maintainer may prefer it to be disabled by default to comply with data retention and security policies. To support this, we could introduce a configuration option.
    • Building on @jackluo923’s suggestion, instead of a simple Boolean flag, we could provide a numeric setting to specify the expiration time for cached content or URLs.

Let me know your thoughts on these

@jackluo923
Copy link
Member

@junhaoliao I encountered pain when adjusting LLM and other configs when working with local file. Whenever I adjust some configs, the log-viewer would reload, and I would need to drag and drop the local file back into the log-viewer again. This is the main issue that I wish it can be resolved.

For remote logs, the above behavior seems to be a non-issue.

@zzxthehappiest
Copy link
Contributor

@jackluo923 I can look into this after I finished my current PRs.

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

No branches or pull requests

3 participants