91

UPDATE: Some new features and bug fixes based on your feedback!

  • PRs now render HTML that matches exactly with GitHub
  • Links to the GitHub username now go to the user profile
  • See the updates in the oneboxes for this post

User Acceptance Testing Opportunity

Stack Overflow for Teams feature

We are excited to be this close to shipping public GitHub oneboxes on Stack Overflow for Teams. This was a highly requested feature from our Teams users and will be included in our upcoming release for our Enterprise tier customers.

We built the feature with Stack Overflow in mind so that we could (with minimal effort) roll it out more broadly. We don’t have an exact timeline yet for Stack Overflow or the network, but will share them when we do.

At this stage, the feature has already gone through our internal QA process and is ready to ship for our Stack Overflow for Teams users, but we wanted to squeeze in a quick round of user acceptance testing with you before the upcoming release.

If you have a chance to kick the tires a bit, we'd like to know if you discover any bugs or edge cases we may have missed.

I’ll respond to your questions, feedback, bugs, or any suggestions you have related to your experience with the feature the best. Feedback and feature requests will be considered for future iterations.

As for the feature itself, you'll be able to paste links to gists, commits, blobs and PRs and they should be automatically oneboxed. The link you use must be by itself and on its own line. Below are examples of what you should see.

Gists:

https://gist.github.com/gdalgas/f93e05fa83b6badf37bd41b3bf33a7b6

https://gist.github.com/gdalgas/f93e05fa83b6badf37bd41b3bf33a7b6

Commits:

https://github.com/StackExchange/Dapper/pull/1400/commits/4f595a82d82317a1726c7cf8d9cf64eb28faf361

https://github.com/StackExchange/Dapper/pull/1400/commits/4f595a82d82317a1726c7cf8d9cf64eb28faf361

Blobs:

https://github.com/StackExchange/Dapper/blob/master/Dapper.SqlBuilder/SqlBuilder.cs

https://github.com/StackExchange/Dapper/blob/master/Dapper.SqlBuilder/SqlBuilder.cs

PRs:

https://github.com/StackExchange/Dapper/pull/1392

https://github.com/StackExchange/Dapper/pull/1392

Give it a try and please provide any bugs or edge cases you might have by adding it as an answer below.

Thanks for your help!

21
  • 34
    I only realized at the third box that these were not screenshots. Wow, that’s nice! Commented Feb 18, 2020 at 23:43
  • 23
    Ooooh, it even accepts line numbers, colour me moderately impressed. Commented Feb 18, 2020 at 23:54
  • 4
    These render as plain links on mobile, but you know that probably already. Might be worth to point that out somewhere and ideally provide some fallback on mobile if you cannot actually one-box them there.
    – poke
    Commented Feb 18, 2020 at 23:58
  • 11
    I think @poke means the Mobile theme (instead of responsive "full site") - indeed they don't work there and would continue to be links (so: no change from today). That's current status - let's see what kind of feedback we get :) Doing all the styling and maintenance work for older mobile would be non-trivial, work probably better spent getting everything towards responsive.
    – Nick Craver Mod
    Commented Feb 19, 2020 at 0:06
  • 66
    I’d be concerned about enabling this on the public site. If the gist changes or is deleted , the underlying context of the question could change. Same reasoning why we don’t like link only answers/links to code in questions. I do like the general idea. Commented Feb 19, 2020 at 0:18
  • 5
    @DanielA.White if the oneboxes are dynamic I agree. Snapshotting would seem to avoid any abuse cases though. Commented Feb 19, 2020 at 0:23
  • 6
    You can always permalink. I'm wondering how this feature could eventually apply to private repos, since if the question is in Teams to begin with, it may not be about public source code. Basically need a read-only GitHub API key plus the ability to replace it if/when the key is revoked, yes?
    – Andrew
    Commented Feb 19, 2020 at 0:26
  • 2
    @danis I don’t think these are snapshot. They are just transformed dynamically like into an iframe I think Commented Feb 19, 2020 at 0:26
  • 3
    @andrew external permalinks aren’t permalinks Commented Feb 19, 2020 at 0:27
  • 1
    @Andrew what happens if nick deleted that? Commented Feb 19, 2020 at 0:29
  • 5
    @Andrew I’m voicing my concerns now for the public site Commented Feb 19, 2020 at 0:32
  • 10
    We are working on the timing of the onebox refreshes. Right now they are tied to editing the post only after an initial fetch window. We have a service working in the background that can do the work of fetching an updated version as soon as we look at how these GitHub oneboxes are actually used in production. Commented Feb 19, 2020 at 0:37
  • 5
    What people probably would like to have would be a frozen version of the code at the time of the artifact creation, independent of any existing Gist and the actual code from the Gist and a way to toggle between the two. At least for the public Q&A. Can the boxes do that? Commented Feb 19, 2020 at 15:12
  • 4
    @Cœur you will not experience any slowness if GitHub is blocked in your country Commented Feb 19, 2020 at 18:40
  • 3
    @trilarion yes, the Oneboxes are a snapshot and captured the moment they are rendered. Toggling the live version is possible by editing the original question or answer, which captures another snapshot. Commented Feb 21, 2020 at 15:50

6 Answers 6

96

I'll address the guidance with the community team

This is amazing, for teams! Actually, it's probably good for Stack Overflow but conflicts with guidance we provide the community. When we close questions we provide a link to How do I ask a good question?

In there we offer this advice (links removed, emphasis is NOT mine):

  • Include just enough code to allow others to reproduce the problem. For help with this, read How to create a Minimal, Complete, and Verifiable example.
  • If it is possible to create a live example of the problem that you can link to (for example, on http://sqlfiddle.com/ or http://jsbin.com/) then do so - but also copy the code into the question itself. Not everyone can access external sites, and the links may break over time. Use Stack Snippets to make a live demo of inline JavaScript / HTML / CSS.

If we are going to start providing just links to GitHub, how do we ensure a question and answers stay relevant if code is updated?

8
  • 1
    You can define the commit so in theory that should be the same version for ever
    – rekire
    Commented Feb 19, 2020 at 10:03
  • 47
    @rekire as long as that stays available on GitHub's servers though. It's still a dependency. Commented Feb 19, 2020 at 10:25
  • 1
    I don't think that we're just going to be using GitHub. Maybe add https://github.com to those links?
    – S.S. Anne
    Commented Feb 19, 2020 at 12:36
  • 10
    One nice thing about this feature is that copy / pasting of code may not be required in some cases. The onebox snippet is cached so it is captured and persisted to give a clear reference at the time the question or answer is given. Edits to the question or answer will trigger a refresh to give an opportunity to use the most up to date version from the source. As far as guidance, that may be added to as additional onebox providers are created. Commented Feb 19, 2020 at 16:46
  • 2
    We can also imagine that all the GitHub URL get redirected one day to some github.microsoft.com... or similar. It happened for instance when msdn became docs.microsoft.com.
    – Cœur
    Commented Feb 19, 2020 at 18:01
  • 6
    Before launching the feature, I would suggest to clarify the guidelines to explicitly highlight that we should copy the whole code into the question itself. Truncated pieces of code aren't a real question/answer.
    – Cœur
    Commented Feb 19, 2020 at 18:09
  • 5
    @rekire Links can still break if a GitHub repository is deleted.
    – Stevoisiak
    Commented Feb 20, 2020 at 14:21
  • 2
    @GeoffDalgas So I ask a question with a oneboxed gist. Someone answers. Being the help vampire I am, I edit the gist to reflect the answer's code and edit my question to ask a different question. The edited question's onebox is now updated to the new gist, the answer is void. Is there any way for someone to roll the question back to the previous snapshot of the onebox to preserve the integrity of the original question and answer? Commented Feb 23, 2020 at 14:29
52

Markdown

Truncation

1. Markdown

What's the likelihood of supporting (at least to some extent) markup in the snippets? Compare the readability of these two:

Two different versions of a pull request. The top one's text is unformatted and the backticks are visible. The bottom one shows the text with code formatting and line breaks.

I understand fully supporting markdown would be a tremendous amount of work unlikely to be worthwhile, but the wall-of-text rendered in the snippet, and the lack of in-line code blocks significantly reduces the readability of the snippet.

I really like having the meta-data pulled in automatically (Link to the issue, date of closure, title, author, repository, etc), but I suspect I'll find myself simply clicking through to GitHub without reading the snippets presented.

2. Truncation

Any chance the 'truncated' link could be changed to 'load more', and have additional lines pulled into the snippet? I suspect there may only be very few situations where a couple of lines would be sufficient - in which case it may be better to simply copy it here and provide a link back to GitHub as attribution.

2
  • 1
    With regards to the truncation link: There's also a different styling for truncated posts between blobs and gists. (once: "This file was truncated", once "(truncated)"). This should be merged, too. Commented Feb 19, 2020 at 15:35
  • 3
    I'll look into the possibility of supporting markdown inside of the PR body. The only risk is that we are using a slightly different flavor of markdown so the render output wouldn't be a perfect 100% match, but it would be good enough. I'll look into dynamic truncation as well - that's a good idea! Commented Feb 19, 2020 at 16:48
41

Line Range

When posting a specific line range (as the one below), which I think is very useful, it would be nice to have something saying that this is a specific range (e.g., showing the line numbers). Moreover, as a line range was specified, I am not sure that displaying (truncated) is the best choice. If displaying the line number is beyond the scope, perhaps changing (truncated) to (L12-L17) would be easier and would work too.

https://github.com/StackExchange/Dapper/blob/61fa083ca3b711067b6b2a0448b156836d696794/Dapper.SqlBuilder/SqlBuilder.cs#L12-L17

For reference, GitHub renders the same line range like this:

Line Range from GitHub

3
  • 19
    Ah yes, we could easily support showing the line numbers somewhere in the snippet body. I'll add this to the list. Commented Feb 19, 2020 at 16:49
  • @Berriel where would you expect to see the line numbers?
    – Ted Goas Staff
    Commented Feb 19, 2020 at 16:58
  • 9
    @TedGoas left side, where it is usually displayed in snippets. I added an image to the answer showing how GitHub renders it, and I kind of like it. Glad to know you might be working on it :)
    – Berriel
    Commented Feb 19, 2020 at 19:36
26

I can see how this is useful in SO for Teams. And I can see how these "one-boxes" (I'm a known fan of these, specially in chat) might evolve to other 3rd party services that offer similar API's to pull this off.

One UX thingy:

The username links to my avatar. Which leaves me blurred. I rather have that link go to my gist profile.

enter image description here

1
  • 6
    Good catch - I will modify the links for the username to reference the user profile. Commented Feb 19, 2020 at 16:50
9

for now

Backwards-compatibility?

Will currently existing links to Gists, Pull Requests, Commits, and Blobs become oneboxed after this change? Is there some way to disable the oneboxing in case this is undesired?

4
  • 4
    Unlikely. The HTML of posts is generated once after post creation or each edit. One-boxing can be disabled by creating a link that isn’t on its own line or with alternative link text. Commented Feb 19, 2020 at 12:59
  • 1
    There may be plans to backfill existing posts. I'll be looking at the numbers here and representitve samples to see if they make the experience better or worse. Since they weren't there when the original post was created it might be odd at times. Commented Feb 20, 2020 at 21:53
  • 4
    @Geoff I would rather not have existing posts backfilled. Perhaps there should be an option to enable this instead of having it be automatic?
    – S.S. Anne
    Commented Feb 20, 2020 at 21:56
  • I concur with @S.S.Anne. If there's a post that someone viewing feels should be changed, the "edit" link is right there, and presumably the new behavior will kick in. Commented Feb 21, 2020 at 17:26
4

Add scrollbar arrows, these will allow me to quickly move to the right or left, without grabbing a scrollbar and moving the mouse pixel perfect. Not sure why it was decided to remove the scrollbar arrows, considering they show up normally on pages when scrolling on the page itself

Google Chrome Version 79.0.3945.130 - Windows

Not the answer you're looking for? Browse other questions tagged .