The next ripe housing site in San Francisco is a bus yard at 17th and Bryant streets, where busy lines like the 5-Fulton and the 14-Mission park for the night.

By 2026, the Potrero bus yard project could be a triple-decker facility topped with apartments, an example of city officials getting creative as they strain to build more homes. Empty turf is scarce, and developers have already laid claim to gas stations, parking lots, shuttered fast-food restaurants and laundromats. Apartments stacked on a bus yard seem to fit the trend.

When the new mega bus garage is built, “it will have a 4½-acre flat roof,” said Licinia Iberri, campus planning manager for the San Francisco Municipal Transportation Agency. “Our city, the neighbors, and all the public stakeholders said that housing would be the best use for that lid,” she said.

The idea has been gestating for a while, and it’s not unique to San Francisco. Transit agencies in Boston, New York and Los Angeles are also contemplating housing development, though San Francisco’s project, if built, would be the first atop an active bus maintenance building. Once the Potrero edifice is complete, the transit agency may replicate the concept at two other bus yards — one on Presidio Avenue, the other near North Beach.

“I think it’s a great idea,” said Supervisor Hillary Ronen, who represents the surrounding Mission District. She and Municipal Transportation Agency Director Ed Reiskin began discussing the possibility of building affordable housing on a bus lot last year, hoping to curb displacement in the rapidly gentrifying Mission District. Ronen said she would champion the project so long as a large share of the homes are reserved for low- or middle-income households.

In October, the transit agency convened a working group to advance the discussions. Officials held two last month at a Sports Basement on Bryant Street.

For maintenance workers, the retrofit is essential. Built a century ago for trolleys, the garage is seismically unsound and too small to accommodate Muni’s expanding fleet. Its ceiling is too low for bus lifts, so workers have to squat or lie beneath the vehicles and repair bus rooftops outside. Often, the mechanics toil in 5-foot pits below the bus floors, bending uncomfortably to change fluids or fix an engine.

“Having to work like this cuts our productivity in half,” said Michael Henry, the Potrero shop maintenance superintendent. He pointed to a mechanic who was crouched over a machine on a recent morning, fixing brake pads.

“In a more modern shop, he would be able to stand up,” Henry said.

The new Potrero bus facility would be cavernous, crisscrossed with ramps and equipped with new battery-charging infrastructure, in time for Muni’s fleet to go all electric by 2035. Its roof would be a blank lot — a precious commodity in San Francisco.

So far, residents seem to welcome the housing proposal, said Scott Feeney, a member of the working group who lives about a half mile from the yard. The debate has largely centered on how much to charge for each unit.

“You’re in my barrio now, and I want to see 100 percent affordable housing,” said Roberto Hernandez, another working group participant who is also the artistic director of the Mission’s annual Carnaval festival. He’s watched tech-fueled gentrification reshape the neighborhood: streets once lined with scruffy apartments, tamale stands and produce markets are now speckled with wine bars and Michelin-starred restaurants.

The area around the bus yard is a patchwork quilt, with coffee shops and sports bars wedged among warehouses and artists’ lofts. Franklin Square Park sits on a hill across the street from the bus yard, a sloping mound of grass and blacktop with a soccer field and playground.

Hernandez said he wants the new housing to be reserved for families, teachers, firefighters and nurses. Others, such as pro-density housing activist Sonja Trauss, fear that a purely affordable project would require subsidies on top of the $400 million needed to construct the new transit facility. Agency officials envision the development as a revenue source to pay for the bus portion downstairs.

Affordability isn’t the only thing complicating the project. Some people worry that rumbling from the buses could annoy the residents upstairs, though transit officials say the new battery-powered vehicles are fairly quiet. Their electric motors burble and purr and they won’t release any fumes.

Others stress the need to preserve the historic 1915 facade of the bus garage when the rest of the yard is demolished in 2023. And bus drivers have raised concerns about parking: a few of them commute from as far away as Lodi or Sacramento to start shifts at 3 a.m.

“They can’t be circling the block looking for parking when their bus is supposed to be pulling out,” said Roger Marenco, president of the Transit Workers Union.

Most of these details will have to be worked out as the project evolves, Iberri said. At some point, the transit agency will conduct environmental studies to look at parking, building design and economic viability.

The one thing everyone seems to agree on is the need for a new three-story bus garage and maintenance shop.

“I think it’s long overdue,” Hernandez said. “I’ve been complaining about Muni being late and overcrowded for three decades now, and if this helps, I’m for it.”

The next set of Potrero bus yard workshops will take place in February.

Rachel Swan is a San Francisco Chronicle staff writer. Email: rswan@sfchronicle.com Twitter: @rachelswan